@aptos-labs/ts-sdk 5.0.0 → 5.1.1-side-effect-free.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 (547) hide show
  1. package/dist/common/{account-BDwBREvt.d.ts → account-Dr4y1uZG.d.ts} +8 -2
  2. package/dist/common/chunk-AWFAHZSB.js +4 -0
  3. package/dist/common/{chunk-6MMUUJHX.js.map → chunk-AWFAHZSB.js.map} +1 -1
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/cli/index.js.map +1 -1
  7. package/dist/common/index.d.ts +339 -10
  8. package/dist/common/index.js +33 -33
  9. package/dist/common/index.js.map +1 -1
  10. package/dist/esm/{Ed25519Account-8ETkcAk_.d.mts → Ed25519Account-CPwej6wB.d.mts} +1 -1
  11. package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
  12. package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
  13. package/dist/esm/account/AbstractKeylessAccount.mjs.map +1 -1
  14. package/dist/esm/account/AbstractedAccount.d.mts +2 -2
  15. package/dist/esm/account/AbstractedAccount.mjs +1 -1
  16. package/dist/esm/account/AbstractedAccount.mjs.map +1 -1
  17. package/dist/esm/account/Account.d.mts +2 -2
  18. package/dist/esm/account/Account.mjs +1 -1
  19. package/dist/esm/account/Account.mjs.map +1 -1
  20. package/dist/esm/account/AccountUtils.d.mts +3 -3
  21. package/dist/esm/account/AccountUtils.mjs +1 -1
  22. package/dist/esm/account/AccountUtils.mjs.map +1 -1
  23. package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
  24. package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
  25. package/dist/esm/account/DerivableAbstractedAccount.mjs.map +1 -1
  26. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  27. package/dist/esm/account/Ed25519Account.mjs +1 -1
  28. package/dist/esm/account/Ed25519Account.mjs.map +1 -1
  29. package/dist/esm/account/EphemeralKeyPair.d.mts +1 -1
  30. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  31. package/dist/esm/account/EphemeralKeyPair.mjs.map +1 -1
  32. package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
  33. package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
  34. package/dist/esm/account/FederatedKeylessAccount.mjs.map +1 -1
  35. package/dist/esm/account/KeylessAccount.d.mts +3 -3
  36. package/dist/esm/account/KeylessAccount.mjs +1 -1
  37. package/dist/esm/account/KeylessAccount.mjs.map +1 -1
  38. package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
  39. package/dist/esm/account/MultiEd25519Account.mjs +1 -1
  40. package/dist/esm/account/MultiEd25519Account.mjs.map +1 -1
  41. package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
  42. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  43. package/dist/esm/account/MultiKeyAccount.mjs.map +1 -1
  44. package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
  45. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  46. package/dist/esm/account/SingleKeyAccount.mjs.map +1 -1
  47. package/dist/esm/account/index.d.mts +3 -3
  48. package/dist/esm/account/index.mjs +1 -1
  49. package/dist/esm/account/index.mjs.map +1 -1
  50. package/dist/esm/account/utils.d.mts +1 -1
  51. package/dist/esm/account/utils.mjs +1 -1
  52. package/dist/esm/account/utils.mjs.map +1 -1
  53. package/dist/esm/{account-ClxOwjdh.d.mts → account-BortO8g2.d.mts} +6 -1
  54. package/dist/esm/api/account/abstraction.d.mts +1 -1
  55. package/dist/esm/api/account/abstraction.mjs +1 -1
  56. package/dist/esm/api/account/abstraction.mjs.map +1 -1
  57. package/dist/esm/api/account.d.mts +30 -9
  58. package/dist/esm/api/account.mjs +1 -1
  59. package/dist/esm/api/account.mjs.map +1 -1
  60. package/dist/esm/api/ans.d.mts +2 -2
  61. package/dist/esm/api/ans.mjs +1 -1
  62. package/dist/esm/api/ans.mjs.map +1 -1
  63. package/dist/esm/api/aptos.d.mts +3 -3
  64. package/dist/esm/api/aptos.mjs +1 -1
  65. package/dist/esm/api/aptos.mjs.map +1 -1
  66. package/dist/esm/api/aptosConfig.d.mts +1 -1
  67. package/dist/esm/api/aptosConfig.mjs +1 -1
  68. package/dist/esm/api/aptosConfig.mjs.map +1 -1
  69. package/dist/esm/api/coin.d.mts +1 -1
  70. package/dist/esm/api/coin.mjs +1 -1
  71. package/dist/esm/api/coin.mjs.map +1 -1
  72. package/dist/esm/api/digitalAsset.d.mts +2 -2
  73. package/dist/esm/api/digitalAsset.mjs +1 -1
  74. package/dist/esm/api/digitalAsset.mjs.map +1 -1
  75. package/dist/esm/api/faucet.d.mts +1 -1
  76. package/dist/esm/api/faucet.mjs +1 -1
  77. package/dist/esm/api/faucet.mjs.map +1 -1
  78. package/dist/esm/api/fungibleAsset.d.mts +2 -2
  79. package/dist/esm/api/fungibleAsset.mjs +1 -1
  80. package/dist/esm/api/fungibleAsset.mjs.map +1 -1
  81. package/dist/esm/api/general.d.mts +1 -1
  82. package/dist/esm/api/general.mjs +1 -1
  83. package/dist/esm/api/general.mjs.map +1 -1
  84. package/dist/esm/api/index.d.mts +3 -3
  85. package/dist/esm/api/index.mjs +1 -1
  86. package/dist/esm/api/index.mjs.map +1 -1
  87. package/dist/esm/api/keyless.d.mts +3 -3
  88. package/dist/esm/api/keyless.mjs +1 -1
  89. package/dist/esm/api/keyless.mjs.map +1 -1
  90. package/dist/esm/api/object.d.mts +1 -1
  91. package/dist/esm/api/object.mjs +1 -1
  92. package/dist/esm/api/object.mjs.map +1 -1
  93. package/dist/esm/api/staking.d.mts +1 -1
  94. package/dist/esm/api/staking.mjs +1 -1
  95. package/dist/esm/api/staking.mjs.map +1 -1
  96. package/dist/esm/api/table.d.mts +1 -1
  97. package/dist/esm/api/table.mjs +1 -1
  98. package/dist/esm/api/table.mjs.map +1 -1
  99. package/dist/esm/api/transaction.d.mts +2 -2
  100. package/dist/esm/api/transaction.mjs +1 -1
  101. package/dist/esm/api/transaction.mjs.map +1 -1
  102. package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
  103. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  104. package/dist/esm/api/transactionSubmission/build.mjs.map +1 -1
  105. package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
  106. package/dist/esm/api/transactionSubmission/helpers.mjs +1 -1
  107. package/dist/esm/api/transactionSubmission/helpers.mjs.map +1 -1
  108. package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
  109. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  110. package/dist/esm/api/transactionSubmission/management.mjs.map +1 -1
  111. package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
  112. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  113. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  114. package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
  115. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  116. package/dist/esm/api/transactionSubmission/simulate.mjs.map +1 -1
  117. package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
  118. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  119. package/dist/esm/api/transactionSubmission/submit.mjs.map +1 -1
  120. package/dist/esm/api/utils.d.mts +1 -1
  121. package/dist/esm/api/utils.mjs +1 -1
  122. package/dist/esm/api/utils.mjs.map +1 -1
  123. package/dist/esm/bcs/consts.d.mts +1 -1
  124. package/dist/esm/bcs/consts.mjs +1 -1
  125. package/dist/esm/bcs/consts.mjs.map +1 -1
  126. package/dist/esm/bcs/deserializer.d.mts +1 -1
  127. package/dist/esm/bcs/deserializer.mjs +1 -1
  128. package/dist/esm/bcs/deserializer.mjs.map +1 -1
  129. package/dist/esm/bcs/index.d.mts +1 -1
  130. package/dist/esm/bcs/index.mjs +1 -1
  131. package/dist/esm/bcs/index.mjs.map +1 -1
  132. package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
  133. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  134. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs.map +1 -1
  135. package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
  136. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  137. package/dist/esm/bcs/serializable/fixedBytes.mjs.map +1 -1
  138. package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
  139. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  140. package/dist/esm/bcs/serializable/movePrimitives.mjs.map +1 -1
  141. package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
  142. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  143. package/dist/esm/bcs/serializable/moveStructs.mjs.map +1 -1
  144. package/dist/esm/bcs/serializer.d.mts +1 -1
  145. package/dist/esm/bcs/serializer.mjs +1 -1
  146. package/dist/esm/bcs/serializer.mjs.map +1 -1
  147. package/dist/esm/cli/index.d.mts +1 -1
  148. package/dist/esm/cli/index.mjs +1 -1
  149. package/dist/esm/cli/index.mjs.map +1 -1
  150. package/dist/esm/cli/localNode.mjs +1 -1
  151. package/dist/esm/cli/localNode.mjs.map +1 -1
  152. package/dist/esm/cli/move.d.mts +1 -1
  153. package/dist/esm/cli/move.mjs +1 -1
  154. package/dist/esm/cli/move.mjs.map +1 -1
  155. package/dist/esm/client/core.d.mts +1 -1
  156. package/dist/esm/client/core.mjs +1 -1
  157. package/dist/esm/client/core.mjs.map +1 -1
  158. package/dist/esm/client/get.d.mts +1 -1
  159. package/dist/esm/client/get.mjs +1 -1
  160. package/dist/esm/client/get.mjs.map +1 -1
  161. package/dist/esm/client/index.d.mts +1 -1
  162. package/dist/esm/client/index.mjs +1 -1
  163. package/dist/esm/client/index.mjs.map +1 -1
  164. package/dist/esm/client/post.d.mts +1 -1
  165. package/dist/esm/client/post.mjs +1 -1
  166. package/dist/esm/client/post.mjs.map +1 -1
  167. package/dist/esm/core/account/index.d.mts +2 -2
  168. package/dist/esm/core/account/index.mjs +1 -1
  169. package/dist/esm/core/account/index.mjs.map +1 -1
  170. package/dist/esm/core/account/utils/address.d.mts +13 -2
  171. package/dist/esm/core/account/utils/address.mjs +1 -1
  172. package/dist/esm/core/account/utils/address.mjs.map +1 -1
  173. package/dist/esm/core/account/utils/index.d.mts +2 -2
  174. package/dist/esm/core/account/utils/index.mjs +1 -1
  175. package/dist/esm/core/account/utils/index.mjs.map +1 -1
  176. package/dist/esm/core/accountAddress.d.mts +1 -1
  177. package/dist/esm/core/accountAddress.mjs +3 -1
  178. package/dist/esm/core/accountAddress.mjs.map +1 -1
  179. package/dist/esm/core/authenticationKey.d.mts +1 -1
  180. package/dist/esm/core/authenticationKey.mjs +1 -1
  181. package/dist/esm/core/authenticationKey.mjs.map +1 -1
  182. package/dist/esm/core/common.mjs +1 -1
  183. package/dist/esm/core/common.mjs.map +1 -1
  184. package/dist/esm/core/crypto/abstraction.d.mts +1 -1
  185. package/dist/esm/core/crypto/abstraction.mjs +1 -1
  186. package/dist/esm/core/crypto/abstraction.mjs.map +1 -1
  187. package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
  188. package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
  189. package/dist/esm/core/crypto/deserializationUtils.mjs.map +1 -1
  190. package/dist/esm/core/crypto/ed25519.d.mts +1 -1
  191. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  192. package/dist/esm/core/crypto/ed25519.mjs.map +1 -1
  193. package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
  194. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  195. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -1
  196. package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
  197. package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
  198. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -1
  199. package/dist/esm/core/crypto/hdKey.mjs +1 -1
  200. package/dist/esm/core/crypto/hdKey.mjs.map +1 -1
  201. package/dist/esm/core/crypto/index.d.mts +3 -2
  202. package/dist/esm/core/crypto/index.mjs +1 -1
  203. package/dist/esm/core/crypto/index.mjs.map +1 -1
  204. package/dist/esm/core/crypto/keyless.d.mts +2 -2
  205. package/dist/esm/core/crypto/keyless.mjs +1 -1
  206. package/dist/esm/core/crypto/keyless.mjs.map +1 -1
  207. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  208. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  209. package/dist/esm/core/crypto/multiEd25519.mjs.map +1 -1
  210. package/dist/esm/core/crypto/multiKey.d.mts +1 -1
  211. package/dist/esm/core/crypto/multiKey.mjs +3 -1
  212. package/dist/esm/core/crypto/multiKey.mjs.map +1 -1
  213. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  214. package/dist/esm/core/crypto/poseidon.mjs.map +1 -1
  215. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  216. package/dist/esm/core/crypto/privateKey.mjs +1 -1
  217. package/dist/esm/core/crypto/privateKey.mjs.map +1 -1
  218. package/dist/esm/core/crypto/proof.d.mts +1 -1
  219. package/dist/esm/core/crypto/proof.mjs +1 -1
  220. package/dist/esm/core/crypto/proof.mjs.map +1 -1
  221. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  222. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  223. package/dist/esm/core/crypto/publicKey.mjs.map +1 -1
  224. package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
  225. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  226. package/dist/esm/core/crypto/secp256k1.mjs.map +1 -1
  227. package/dist/esm/core/crypto/secp256r1.d.mts +306 -0
  228. package/dist/esm/core/crypto/secp256r1.mjs +2 -0
  229. package/dist/esm/core/crypto/secp256r1.mjs.map +1 -0
  230. package/dist/esm/core/crypto/signature.d.mts +1 -1
  231. package/dist/esm/core/crypto/signature.mjs +1 -1
  232. package/dist/esm/core/crypto/signature.mjs.map +1 -1
  233. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  234. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  235. package/dist/esm/core/crypto/singleKey.mjs.map +1 -1
  236. package/dist/esm/core/crypto/types.d.mts +1 -1
  237. package/dist/esm/core/crypto/types.mjs +0 -1
  238. package/dist/esm/core/crypto/utils.d.mts +1 -1
  239. package/dist/esm/core/crypto/utils.mjs +1 -1
  240. package/dist/esm/core/crypto/utils.mjs.map +1 -1
  241. package/dist/esm/core/hex.d.mts +1 -1
  242. package/dist/esm/core/hex.mjs +1 -1
  243. package/dist/esm/core/hex.mjs.map +1 -1
  244. package/dist/esm/core/index.d.mts +4 -3
  245. package/dist/esm/core/index.mjs +1 -1
  246. package/dist/esm/core/index.mjs.map +1 -1
  247. package/dist/esm/errors/index.d.mts +1 -1
  248. package/dist/esm/errors/index.mjs +6 -1
  249. package/dist/esm/errors/index.mjs.map +1 -1
  250. package/dist/esm/{federatedKeyless-CUPEnP-W.d.mts → federatedKeyless-CTzDAQTu.d.mts} +1 -1
  251. package/dist/esm/index.d.mts +5 -4
  252. package/dist/esm/index.mjs +1 -1
  253. package/dist/esm/index.mjs.map +1 -1
  254. package/dist/esm/internal/abstraction.d.mts +1 -1
  255. package/dist/esm/internal/abstraction.mjs +1 -1
  256. package/dist/esm/internal/abstraction.mjs.map +1 -1
  257. package/dist/esm/internal/account.d.mts +21 -3
  258. package/dist/esm/internal/account.mjs +1 -1
  259. package/dist/esm/internal/account.mjs.map +1 -1
  260. package/dist/esm/internal/ans.d.mts +2 -2
  261. package/dist/esm/internal/ans.mjs +1 -1
  262. package/dist/esm/internal/ans.mjs.map +1 -1
  263. package/dist/esm/internal/coin.d.mts +1 -1
  264. package/dist/esm/internal/coin.mjs +1 -1
  265. package/dist/esm/internal/coin.mjs.map +1 -1
  266. package/dist/esm/internal/digitalAsset.d.mts +2 -2
  267. package/dist/esm/internal/digitalAsset.mjs +1 -1
  268. package/dist/esm/internal/digitalAsset.mjs.map +1 -1
  269. package/dist/esm/internal/faucet.d.mts +1 -1
  270. package/dist/esm/internal/faucet.mjs +1 -1
  271. package/dist/esm/internal/faucet.mjs.map +1 -1
  272. package/dist/esm/internal/fungibleAsset.d.mts +2 -2
  273. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  274. package/dist/esm/internal/fungibleAsset.mjs.map +1 -1
  275. package/dist/esm/internal/general.d.mts +1 -1
  276. package/dist/esm/internal/general.mjs +1 -1
  277. package/dist/esm/internal/general.mjs.map +1 -1
  278. package/dist/esm/internal/keyless.d.mts +3 -3
  279. package/dist/esm/internal/keyless.mjs +1 -1
  280. package/dist/esm/internal/keyless.mjs.map +1 -1
  281. package/dist/esm/internal/object.d.mts +1 -1
  282. package/dist/esm/internal/object.mjs +1 -1
  283. package/dist/esm/internal/object.mjs.map +1 -1
  284. package/dist/esm/internal/staking.d.mts +1 -1
  285. package/dist/esm/internal/staking.mjs +1 -1
  286. package/dist/esm/internal/staking.mjs.map +1 -1
  287. package/dist/esm/internal/table.d.mts +1 -1
  288. package/dist/esm/internal/table.mjs +1 -1
  289. package/dist/esm/internal/table.mjs.map +1 -1
  290. package/dist/esm/internal/transaction.d.mts +1 -1
  291. package/dist/esm/internal/transaction.mjs +1 -1
  292. package/dist/esm/internal/transaction.mjs.map +1 -1
  293. package/dist/esm/internal/transactionSubmission.d.mts +2 -2
  294. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  295. package/dist/esm/internal/transactionSubmission.mjs.map +1 -1
  296. package/dist/esm/internal/utils/index.d.mts +1 -1
  297. package/dist/esm/internal/utils/index.mjs +1 -1
  298. package/dist/esm/internal/utils/index.mjs.map +1 -1
  299. package/dist/esm/internal/utils/utils.d.mts +1 -1
  300. package/dist/esm/internal/utils/utils.mjs +1 -1
  301. package/dist/esm/internal/utils/utils.mjs.map +1 -1
  302. package/dist/esm/internal/view.d.mts +1 -1
  303. package/dist/esm/internal/view.mjs +1 -1
  304. package/dist/esm/internal/view.mjs.map +1 -1
  305. package/dist/esm/transactions/authenticator/account.d.mts +1 -1
  306. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  307. package/dist/esm/transactions/authenticator/account.mjs.map +1 -1
  308. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  309. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  310. package/dist/esm/transactions/authenticator/index.mjs.map +1 -1
  311. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  312. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  313. package/dist/esm/transactions/authenticator/transaction.mjs.map +1 -1
  314. package/dist/esm/transactions/index.d.mts +1 -1
  315. package/dist/esm/transactions/index.mjs +1 -1
  316. package/dist/esm/transactions/index.mjs.map +1 -1
  317. package/dist/esm/transactions/instances/chainId.d.mts +1 -1
  318. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  319. package/dist/esm/transactions/instances/chainId.mjs.map +1 -1
  320. package/dist/esm/transactions/instances/identifier.d.mts +1 -1
  321. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  322. package/dist/esm/transactions/instances/identifier.mjs.map +1 -1
  323. package/dist/esm/transactions/instances/index.d.mts +1 -1
  324. package/dist/esm/transactions/instances/index.mjs +1 -1
  325. package/dist/esm/transactions/instances/index.mjs.map +1 -1
  326. package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
  327. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  328. package/dist/esm/transactions/instances/moduleId.mjs.map +1 -1
  329. package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
  330. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  331. package/dist/esm/transactions/instances/multiAgentTransaction.mjs.map +1 -1
  332. package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
  333. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  334. package/dist/esm/transactions/instances/rawTransaction.mjs.map +1 -1
  335. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  336. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  337. package/dist/esm/transactions/instances/rotationProofChallenge.mjs.map +1 -1
  338. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  339. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  340. package/dist/esm/transactions/instances/signedTransaction.mjs.map +1 -1
  341. package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
  342. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  343. package/dist/esm/transactions/instances/simpleTransaction.mjs.map +1 -1
  344. package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
  345. package/dist/esm/transactions/instances/transactionArgument.mjs +0 -1
  346. package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
  347. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  348. package/dist/esm/transactions/instances/transactionPayload.mjs.map +1 -1
  349. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
  350. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  351. package/dist/esm/transactions/management/accountSequenceNumber.mjs.map +1 -1
  352. package/dist/esm/transactions/management/asyncQueue.mjs +1 -1
  353. package/dist/esm/transactions/management/asyncQueue.mjs.map +1 -1
  354. package/dist/esm/transactions/management/index.d.mts +2 -2
  355. package/dist/esm/transactions/management/index.mjs +1 -1
  356. package/dist/esm/transactions/management/index.mjs.map +1 -1
  357. package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
  358. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  359. package/dist/esm/transactions/management/transactionWorker.mjs.map +1 -1
  360. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
  361. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  362. package/dist/esm/transactions/transactionBuilder/helpers.mjs.map +1 -1
  363. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  364. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  365. package/dist/esm/transactions/transactionBuilder/index.mjs.map +1 -1
  366. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
  367. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  368. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs.map +1 -1
  369. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
  370. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  371. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -1
  372. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  373. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  374. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs.map +1 -1
  375. package/dist/esm/transactions/typeTag/index.d.mts +1 -1
  376. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  377. package/dist/esm/transactions/typeTag/index.mjs.map +1 -1
  378. package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
  379. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  380. package/dist/esm/transactions/typeTag/parser.mjs.map +1 -1
  381. package/dist/esm/transactions/types.d.mts +1 -1
  382. package/dist/esm/transactions/types.mjs +0 -1
  383. package/dist/esm/types/abstraction.mjs +1 -1
  384. package/dist/esm/types/abstraction.mjs.map +1 -1
  385. package/dist/esm/types/generated/queries.mjs +493 -1
  386. package/dist/esm/types/generated/queries.mjs.map +1 -1
  387. package/dist/esm/types/generated/types.mjs +1 -1
  388. package/dist/esm/types/generated/types.mjs.map +1 -1
  389. package/dist/esm/types/index.d.mts +1 -1
  390. package/dist/esm/types/index.mjs +1 -1
  391. package/dist/esm/types/index.mjs.map +1 -1
  392. package/dist/esm/types/indexer.mjs +0 -1
  393. package/dist/esm/types/types.d.mts +1 -1
  394. package/dist/esm/types/types.mjs +1 -1
  395. package/dist/esm/types/types.mjs.map +1 -1
  396. package/dist/esm/utils/apiEndpoints.d.mts +1 -0
  397. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  398. package/dist/esm/utils/apiEndpoints.mjs.map +1 -1
  399. package/dist/esm/utils/const.mjs +1 -1
  400. package/dist/esm/utils/const.mjs.map +1 -1
  401. package/dist/esm/utils/helpers.d.mts +1 -1
  402. package/dist/esm/utils/helpers.mjs +1 -1
  403. package/dist/esm/utils/helpers.mjs.map +1 -1
  404. package/dist/esm/utils/index.d.mts +1 -1
  405. package/dist/esm/utils/index.mjs +1 -1
  406. package/dist/esm/utils/index.mjs.map +1 -1
  407. package/dist/esm/utils/memoize.mjs +1 -1
  408. package/dist/esm/utils/memoize.mjs.map +1 -1
  409. package/dist/esm/utils/normalizeBundle.d.mts +1 -1
  410. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  411. package/dist/esm/utils/normalizeBundle.mjs.map +1 -1
  412. package/dist/esm/version.d.mts +1 -1
  413. package/dist/esm/version.mjs +1 -1
  414. package/dist/esm/version.mjs.map +1 -1
  415. package/package.json +40 -22
  416. package/src/api/account.ts +32 -7
  417. package/src/api/aptos.ts +25 -14
  418. package/src/core/account/utils/address.ts +22 -0
  419. package/src/core/crypto/index.ts +1 -0
  420. package/src/core/crypto/privateKey.ts +1 -0
  421. package/src/core/crypto/secp256k1.ts +9 -1
  422. package/src/core/crypto/secp256r1.ts +495 -0
  423. package/src/core/crypto/singleKey.ts +11 -0
  424. package/src/internal/account.ts +33 -0
  425. package/src/internal/ans.ts +1 -0
  426. package/src/types/types.ts +5 -0
  427. package/src/utils/apiEndpoints.ts +7 -0
  428. package/src/version.ts +1 -1
  429. package/dist/common/chunk-6MMUUJHX.js +0 -4
  430. package/dist/esm/chunk-35DKMW7Q.mjs +0 -2
  431. package/dist/esm/chunk-35DKMW7Q.mjs.map +0 -1
  432. package/dist/esm/chunk-4QMXOWHP.mjs +0 -1
  433. package/dist/esm/chunk-4QMXOWHP.mjs.map +0 -1
  434. package/dist/esm/chunk-4RXKALLC.mjs +0 -2
  435. package/dist/esm/chunk-4RXKALLC.mjs.map +0 -1
  436. package/dist/esm/chunk-4WPQQPUF.mjs +0 -1
  437. package/dist/esm/chunk-4WPQQPUF.mjs.map +0 -1
  438. package/dist/esm/chunk-56CNRT2K.mjs +0 -2
  439. package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
  440. package/dist/esm/chunk-5FI4545P.mjs +0 -2
  441. package/dist/esm/chunk-5FI4545P.mjs.map +0 -1
  442. package/dist/esm/chunk-5HXLZHDW.mjs +0 -1
  443. package/dist/esm/chunk-5HXLZHDW.mjs.map +0 -1
  444. package/dist/esm/chunk-6WDVDEQZ.mjs +0 -7
  445. package/dist/esm/chunk-6WDVDEQZ.mjs.map +0 -1
  446. package/dist/esm/chunk-7DQDJ2SA.mjs +0 -2
  447. package/dist/esm/chunk-7DQDJ2SA.mjs.map +0 -1
  448. package/dist/esm/chunk-7ECCT6PK.mjs +0 -1
  449. package/dist/esm/chunk-7ECCT6PK.mjs.map +0 -1
  450. package/dist/esm/chunk-A5L76YP7.mjs +0 -2
  451. package/dist/esm/chunk-A5L76YP7.mjs.map +0 -1
  452. package/dist/esm/chunk-B563XRSZ.mjs +0 -2
  453. package/dist/esm/chunk-B563XRSZ.mjs.map +0 -1
  454. package/dist/esm/chunk-C3Q23D22.mjs +0 -2
  455. package/dist/esm/chunk-C3Q23D22.mjs.map +0 -1
  456. package/dist/esm/chunk-CW35YAMN.mjs +0 -2
  457. package/dist/esm/chunk-CW35YAMN.mjs.map +0 -1
  458. package/dist/esm/chunk-DIGP2ALY.mjs +0 -4
  459. package/dist/esm/chunk-DIGP2ALY.mjs.map +0 -1
  460. package/dist/esm/chunk-DNRUDMMV.mjs +0 -2
  461. package/dist/esm/chunk-DNRUDMMV.mjs.map +0 -1
  462. package/dist/esm/chunk-EBMEXURY.mjs +0 -2
  463. package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
  464. package/dist/esm/chunk-EM52Z7T7.mjs +0 -2
  465. package/dist/esm/chunk-EM52Z7T7.mjs.map +0 -1
  466. package/dist/esm/chunk-ES2KP6BS.mjs +0 -2
  467. package/dist/esm/chunk-ES2KP6BS.mjs.map +0 -1
  468. package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
  469. package/dist/esm/chunk-FD6FGKYY.mjs.map +0 -1
  470. package/dist/esm/chunk-FGFLPH5K.mjs +0 -2
  471. package/dist/esm/chunk-FGFLPH5K.mjs.map +0 -1
  472. package/dist/esm/chunk-FLZPUYXQ.mjs +0 -2
  473. package/dist/esm/chunk-FLZPUYXQ.mjs.map +0 -1
  474. package/dist/esm/chunk-FZY4PMEE.mjs +0 -1
  475. package/dist/esm/chunk-FZY4PMEE.mjs.map +0 -1
  476. package/dist/esm/chunk-G3MHXDYA.mjs +0 -1
  477. package/dist/esm/chunk-G3MHXDYA.mjs.map +0 -1
  478. package/dist/esm/chunk-GFFKEZ56.mjs +0 -2
  479. package/dist/esm/chunk-GFFKEZ56.mjs.map +0 -1
  480. package/dist/esm/chunk-GMQCQDW4.mjs +0 -2
  481. package/dist/esm/chunk-GMQCQDW4.mjs.map +0 -1
  482. package/dist/esm/chunk-GOXRBEIJ.mjs +0 -2
  483. package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
  484. package/dist/esm/chunk-HGLO5LDS.mjs +0 -1
  485. package/dist/esm/chunk-HGLO5LDS.mjs.map +0 -1
  486. package/dist/esm/chunk-HNBKTJPN.mjs +0 -2
  487. package/dist/esm/chunk-HNBKTJPN.mjs.map +0 -1
  488. package/dist/esm/chunk-HNBVYE3N.mjs +0 -2
  489. package/dist/esm/chunk-HNBVYE3N.mjs.map +0 -1
  490. package/dist/esm/chunk-IF4UU2MT.mjs +0 -2
  491. package/dist/esm/chunk-IF4UU2MT.mjs.map +0 -1
  492. package/dist/esm/chunk-IJE2LVZG.mjs +0 -2
  493. package/dist/esm/chunk-IJE2LVZG.mjs.map +0 -1
  494. package/dist/esm/chunk-KDMSOCZY.mjs +0 -2
  495. package/dist/esm/chunk-KDMSOCZY.mjs.map +0 -1
  496. package/dist/esm/chunk-LWL57YFU.mjs +0 -2
  497. package/dist/esm/chunk-LWL57YFU.mjs.map +0 -1
  498. package/dist/esm/chunk-MT2RJ7H3.mjs +0 -2
  499. package/dist/esm/chunk-MT2RJ7H3.mjs.map +0 -1
  500. package/dist/esm/chunk-N3O3ULF7.mjs +0 -2
  501. package/dist/esm/chunk-N3O3ULF7.mjs.map +0 -1
  502. package/dist/esm/chunk-N6YTF76Q.mjs +0 -2
  503. package/dist/esm/chunk-N6YTF76Q.mjs.map +0 -1
  504. package/dist/esm/chunk-NECL5FCQ.mjs +0 -1
  505. package/dist/esm/chunk-NECL5FCQ.mjs.map +0 -1
  506. package/dist/esm/chunk-OLILO7VD.mjs +0 -2
  507. package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
  508. package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
  509. package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
  510. package/dist/esm/chunk-Q4W3WJ2U.mjs +0 -2
  511. package/dist/esm/chunk-Q4W3WJ2U.mjs.map +0 -1
  512. package/dist/esm/chunk-QREVMGQZ.mjs +0 -2
  513. package/dist/esm/chunk-QREVMGQZ.mjs.map +0 -1
  514. package/dist/esm/chunk-RCSJFTST.mjs +0 -2
  515. package/dist/esm/chunk-RCSJFTST.mjs.map +0 -1
  516. package/dist/esm/chunk-RGKRCZ36.mjs +0 -4
  517. package/dist/esm/chunk-RGKRCZ36.mjs.map +0 -1
  518. package/dist/esm/chunk-ROT6S6BM.mjs +0 -2
  519. package/dist/esm/chunk-ROT6S6BM.mjs.map +0 -1
  520. package/dist/esm/chunk-RQX6JOEN.mjs +0 -2
  521. package/dist/esm/chunk-RQX6JOEN.mjs.map +0 -1
  522. package/dist/esm/chunk-STY74NUA.mjs +0 -2
  523. package/dist/esm/chunk-STY74NUA.mjs.map +0 -1
  524. package/dist/esm/chunk-TGRLDWXV.mjs +0 -2
  525. package/dist/esm/chunk-TGRLDWXV.mjs.map +0 -1
  526. package/dist/esm/chunk-TOBQ5UE6.mjs +0 -2
  527. package/dist/esm/chunk-TOBQ5UE6.mjs.map +0 -1
  528. package/dist/esm/chunk-UL777LTI.mjs +0 -494
  529. package/dist/esm/chunk-UL777LTI.mjs.map +0 -1
  530. package/dist/esm/chunk-UYVPNUH3.mjs +0 -1
  531. package/dist/esm/chunk-UYVPNUH3.mjs.map +0 -1
  532. package/dist/esm/chunk-V3MBJJTL.mjs +0 -1
  533. package/dist/esm/chunk-V3MBJJTL.mjs.map +0 -1
  534. package/dist/esm/chunk-V74WPKSY.mjs +0 -2
  535. package/dist/esm/chunk-V74WPKSY.mjs.map +0 -1
  536. package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
  537. package/dist/esm/chunk-WCMW2L3P.mjs.map +0 -1
  538. package/dist/esm/chunk-WSR5EBJM.mjs +0 -2
  539. package/dist/esm/chunk-WSR5EBJM.mjs.map +0 -1
  540. package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
  541. package/dist/esm/chunk-XJJVJOX5.mjs.map +0 -1
  542. package/dist/esm/chunk-XKUIMGKU.mjs +0 -2
  543. package/dist/esm/chunk-XKUIMGKU.mjs.map +0 -1
  544. package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
  545. package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
  546. package/dist/esm/chunk-ZP4DWSQA.mjs +0 -2
  547. package/dist/esm/chunk-ZP4DWSQA.mjs.map +0 -1
@@ -1,2 +1,2 @@
1
- import{kc as o}from"../../chunk-DIGP2ALY.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-ROT6S6BM.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-RQX6JOEN.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-HNBKTJPN.mjs";import"../../chunk-V74WPKSY.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ES2KP6BS.mjs";import"../../chunk-EM52Z7T7.mjs";import"../../chunk-TGRLDWXV.mjs";import"../../chunk-N3O3ULF7.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-GMQCQDW4.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-DNRUDMMV.mjs";import"../../chunk-GFFKEZ56.mjs";import"../../chunk-LWL57YFU.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-5FI4545P.mjs";import"../../chunk-KDMSOCZY.mjs";var a=class{constructor(n){this.config=n}transaction(n){return o({...n})}transactionAsFeePayer(n){let{signer:r,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=r.accountAddress,o({signer:r,transaction:t})}};export{a as Sign};
1
+ import{signTransaction as r}from"../../internal/transactionSubmission";class m{constructor(n){this.config=n}transaction(n){return r({...n})}transactionAsFeePayer(n){const{signer:o,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=o.accountAddress,r({signer:o,transaction:t})}}export{m as Sign};
2
2
  //# sourceMappingURL=sign.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/api/transactionSubmission/sign.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"../../account\";\nimport { signTransaction } from \"../../internal/transactionSubmission\";\nimport { AccountAuthenticator, AnyRawTransaction } from \"../../transactions\";\nimport { AptosConfig } from \"../aptosConfig\";\n\n/**\n * A class to handle all `Sign` transaction operations.\n *\n * @param config - The configuration object for Aptos.\n * @group Implementation\n */\nexport class Sign {\n readonly config: AptosConfig;\n\n /**\n * Creates an instance of the Aptos client with the specified configuration.\n *\n * @param config - The configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with testnet configuration\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client created with config:\", config);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Signs a transaction using the provided account signer. This function is essential for ensuring that transactions are properly\n * authenticated before being sent to the network.\n *\n * @param args - The arguments for signing the transaction.\n * @param args.signer - The account that will sign the transaction.\n * @param args.transaction - The raw transaction data to be signed.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const sender = Account.generate(); // Generate a new account for signing\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [ \"0x1\", 100 ], // replace with a real account address and amount\n * },\n * });\n *\n * // Sign the transaction\n * const signedTransaction = await aptos.transaction.sign({\n * signer: sender,\n * transaction: transaction,\n * });\n *\n * console.log(\"Signed Transaction:\", signedTransaction);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n // eslint-disable-next-line class-methods-use-this\n transaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n return signTransaction({\n ...args,\n });\n }\n\n /**\n * Sets the fee payer address for a transaction and signs it with the provided account.\n * This function is essential for transactions that require a designated fee payer.\n *\n * @param args - The arguments for the function.\n * @param args.signer - The account that will sign the transaction.\n * @param args.transaction - The transaction object that requires a fee payer address.\n *\n * @throws Error if the transaction does not have a feePayerAddress property.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const sender = Account.generate(); // Generate a new account for signing\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [\"0x1\", 100], // replace with a real recipient address\n * },\n * });\n *\n * // Set the fee payer for the transaction\n * transaction.feePayerAddress = \"0x1\"; // replace with a real fee payer address\n *\n * const signedTransaction = await aptos.transactionAsFeePayer({ signer: sender, transaction });\n *\n * console.log(\"Signed Transaction:\", signedTransaction);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n // eslint-disable-next-line class-methods-use-this\n transactionAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n\n // if transaction doesn't hold a \"feePayerAddress\" prop it means\n // this is not a fee payer transaction\n if (!transaction.feePayerAddress) {\n throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);\n }\n\n // Set the feePayerAddress to the signer account address\n transaction.feePayerAddress = signer.accountAddress;\n\n return signTransaction({\n signer,\n transaction,\n });\n }\n}\n"],"mappings":"s2DAcO,IAAMA,EAAN,KAAW,CAuBhB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAwCA,YAAYC,EAAiF,CAC3F,OAAOC,EAAgB,CACrB,GAAGD,CACL,CAAC,CACH,CAyCA,sBAAsBA,EAAiF,CACrG,GAAM,CAAE,OAAAE,EAAQ,YAAAC,CAAY,EAAIH,EAIhC,GAAI,CAACG,EAAY,gBACf,MAAM,IAAI,MAAM,eAAeA,CAAW,iCAAiC,EAI7E,OAAAA,EAAY,gBAAkBD,EAAO,eAE9BD,EAAgB,CACrB,OAAAC,EACA,YAAAC,CACF,CAAC,CACH,CACF","names":["Sign","config","args","signTransaction","signer","transaction"]}
1
+ {"version":3,"sources":["../../../../src/api/transactionSubmission/sign.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"../../account\";\nimport { signTransaction } from \"../../internal/transactionSubmission\";\nimport { AccountAuthenticator, AnyRawTransaction } from \"../../transactions\";\nimport { AptosConfig } from \"../aptosConfig\";\n\n/**\n * A class to handle all `Sign` transaction operations.\n *\n * @param config - The configuration object for Aptos.\n * @group Implementation\n */\nexport class Sign {\n readonly config: AptosConfig;\n\n /**\n * Creates an instance of the Aptos client with the specified configuration.\n *\n * @param config - The configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with testnet configuration\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client created with config:\", config);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Signs a transaction using the provided account signer. This function is essential for ensuring that transactions are properly\n * authenticated before being sent to the network.\n *\n * @param args - The arguments for signing the transaction.\n * @param args.signer - The account that will sign the transaction.\n * @param args.transaction - The raw transaction data to be signed.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const sender = Account.generate(); // Generate a new account for signing\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [ \"0x1\", 100 ], // replace with a real account address and amount\n * },\n * });\n *\n * // Sign the transaction\n * const signedTransaction = await aptos.transaction.sign({\n * signer: sender,\n * transaction: transaction,\n * });\n *\n * console.log(\"Signed Transaction:\", signedTransaction);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n // eslint-disable-next-line class-methods-use-this\n transaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n return signTransaction({\n ...args,\n });\n }\n\n /**\n * Sets the fee payer address for a transaction and signs it with the provided account.\n * This function is essential for transactions that require a designated fee payer.\n *\n * @param args - The arguments for the function.\n * @param args.signer - The account that will sign the transaction.\n * @param args.transaction - The transaction object that requires a fee payer address.\n *\n * @throws Error if the transaction does not have a feePayerAddress property.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const sender = Account.generate(); // Generate a new account for signing\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [\"0x1\", 100], // replace with a real recipient address\n * },\n * });\n *\n * // Set the fee payer for the transaction\n * transaction.feePayerAddress = \"0x1\"; // replace with a real fee payer address\n *\n * const signedTransaction = await aptos.transactionAsFeePayer({ signer: sender, transaction });\n *\n * console.log(\"Signed Transaction:\", signedTransaction);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n // eslint-disable-next-line class-methods-use-this\n transactionAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n\n // if transaction doesn't hold a \"feePayerAddress\" prop it means\n // this is not a fee payer transaction\n if (!transaction.feePayerAddress) {\n throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);\n }\n\n // Set the feePayerAddress to the signer account address\n transaction.feePayerAddress = signer.accountAddress;\n\n return signTransaction({\n signer,\n transaction,\n });\n }\n}\n"],"mappings":"AAIA,OAAS,mBAAAA,MAAuB,uCAUzB,MAAMC,CAAK,CAuBhB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAwCA,YAAYC,EAAiF,CAC3F,OAAOH,EAAgB,CACrB,GAAGG,CACL,CAAC,CACH,CAyCA,sBAAsBA,EAAiF,CACrG,KAAM,CAAE,OAAAC,EAAQ,YAAAC,CAAY,EAAIF,EAIhC,GAAI,CAACE,EAAY,gBACf,MAAM,IAAI,MAAM,eAAeA,CAAW,iCAAiC,EAI7E,OAAAA,EAAY,gBAAkBD,EAAO,eAE9BJ,EAAgB,CACrB,OAAAI,EACA,YAAAC,CACF,CAAC,CACH,CACF","names":["signTransaction","Sign","config","args","signer","transaction"]}
@@ -1,4 +1,4 @@
1
- import { A as AptosConfig, C as PublicKey, bg as AnyRawTransaction, bi as InputSimulateTransactionOptions, cm as UserTransactionResponse } from '../../account-ClxOwjdh.mjs';
1
+ import { A as AptosConfig, C as PublicKey, bg as AnyRawTransaction, bi as InputSimulateTransactionOptions, cm as UserTransactionResponse } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{ce as a}from"../../chunk-DIGP2ALY.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-ROT6S6BM.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-RQX6JOEN.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-HNBKTJPN.mjs";import"../../chunk-V74WPKSY.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ES2KP6BS.mjs";import"../../chunk-EM52Z7T7.mjs";import"../../chunk-TGRLDWXV.mjs";import"../../chunk-N3O3ULF7.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-GMQCQDW4.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-DNRUDMMV.mjs";import"../../chunk-GFFKEZ56.mjs";import"../../chunk-LWL57YFU.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-5FI4545P.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as Simulate};
1
+ var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var e=(r,n,t,o)=>{for(var i=o>1?void 0:o?l(n,t):n,a=r.length-1,s;a>=0;a--)(s=r[a])&&(i=(o?s(n,t,i):s(i))||i);return o&&i&&u(n,t,i),i};import{simulateTransaction as c}from"../../internal/transactionSubmission";import{ValidateFeePayerDataOnSimulation as p}from"./helpers";class y{constructor(n){this.config=n}async simple(n){return c({aptosConfig:this.config,...n})}async multiAgent(n){return c({aptosConfig:this.config,...n})}}e([p],y.prototype,"simple",1),e([p],y.prototype,"multiAgent",1);export{y as Simulate};
2
2
  //# sourceMappingURL=simulate.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/api/transactionSubmission/simulate.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { PublicKey } from \"../../core\";\nimport { simulateTransaction } from \"../../internal/transactionSubmission\";\nimport { AnyRawTransaction, InputSimulateTransactionOptions } from \"../../transactions\";\nimport { UserTransactionResponse } from \"../../types\";\nimport { AptosConfig } from \"../aptosConfig\";\nimport { ValidateFeePayerDataOnSimulation } from \"./helpers\";\n\n/**\n * A class to handle all `Simulate` transaction operations.\n * @group Implementation\n */\nexport class Simulate {\n readonly config: AptosConfig;\n\n /**\n * Initializes a new instance of the Aptos client with the specified configuration.\n * This allows you to interact with the Aptos blockchain using the provided settings.\n *\n * @param config - The configuration settings for the Aptos client.\n * @param config.network - The network to connect to (e.g., TESTNET, MAINNET).\n * @param config.nodeUrl - The URL of the Aptos node to connect to.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for the Aptos client\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify your desired network\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Simulates a transaction based on the provided parameters and returns the result.\n * This function helps you understand the outcome of a transaction before executing it on the blockchain.\n *\n * @param args - The parameters for simulating the transaction.\n * @param args.signerPublicKey - The public key of the signer for the transaction (optional).\n * @param args.transaction - The raw transaction data to simulate.\n * @param args.feePayerPublicKey - The public key of the fee payer (optional).\n * @param args.options - Additional options for simulating the transaction (optional).\n *\n * @example\n * ```typescript\n * import {\n * Account,\n * Aptos,\n * AptosConfig,\n * Network,\n * } from \"@aptos-labs/ts-sdk\";\n *\n * async function example() {\n * let sender = Account.generate();\n * let receiver = Account.generate();\n *\n * // 0. Set up the client and test accounts\n * const config = new AptosConfig({ network: Network.DEVNET });\n * const aptos = new Aptos(config);\n *\n * await aptos.fundAccount({\n * accountAddress: sender.accountAddress,\n * amount: 100_000_000,\n * });\n *\n * // 1. Build the transaction to preview the impact of it\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * // All transactions on Aptos are implemented via smart contracts.\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [receiver.accountAddress, 100],\n * },\n * });\n *\n * // 2. Simulate to see what would happen if we execute this transaction\n * const [userTransactionResponse] = await aptos.transaction.simulate.simple({\n * signerPublicKey: sender.publicKey,\n * transaction,\n * });\n * console.log(userTransactionResponse);\n *\n * // If the fee looks ok, continue to signing!\n * // ...\n * }\n *\n * example();\n * ```\n * @group Implementation\n */\n @ValidateFeePayerDataOnSimulation\n async simple(args: {\n signerPublicKey?: PublicKey;\n transaction: AnyRawTransaction;\n feePayerPublicKey?: PublicKey;\n options?: InputSimulateTransactionOptions;\n }): Promise<Array<UserTransactionResponse>> {\n return simulateTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Simulates a multi-agent transaction by generating a signed transaction and posting it to the Aptos full node.\n * This function helps in understanding the outcome of a transaction involving multiple signers before it is executed.\n *\n * @param args - The parameters for simulating the transaction.\n * @param args.signerPublicKey - The public key of the primary signer (optional).\n * @param args.transaction - The raw transaction to be simulated.\n * @param args.secondarySignersPublicKeys - An array of public keys for secondary signers (optional).\n * Each element of the array can be optional, allowing the corresponding key check to be skipped.\n * @param args.feePayerPublicKey - The public key of the fee payer (optional).\n * @param args.options - Options for simulating the transaction (optional).\n *\n * @example\n * ```typescript\n * import {\n * Account,\n * Aptos,\n * AptosConfig,\n * Network,\n * } from \"@aptos-labs/ts-sdk\";\n *\n * async function example() {\n * let sender1 = Account.generate();\n * let sender2 = Account.generate();\n * let receiver = Account.generate();\n *\n * // 0. Set up the client and test accounts\n * const config = new AptosConfig({ network: Network.DEVNET });\n * const aptos = new Aptos(config);\n *\n * await aptos.fundAccount({\n * accountAddress: sender.accountAddress,\n * amount: 100_000_000,\n * });\n *\n * // 1. Build\n * console.log(\"\\n=== 1. Building the transaction ===\\n\");\n * const transaction = await aptos.transaction.build.multiAgent({\n * sender: sender1.accountAddress,\n * secondarySignerAddresses: [sender2.accountAddress],\n * data: {\n * // REPLACE WITH YOUR MULTI-AGENT FUNCTION HERE\n * function:\n * \"<REPLACE WITH YOUR MULTI AGENT MOVE ENTRY FUNCTION> (Syntax {address}::{module}::{function})\",\n * functionArguments: [],\n * },\n * });\n * console.log(\"Transaction:\", transaction);\n *\n * // 2. Simulate (Optional)\n * console.log(\"\\n === 2. Simulating Response (Optional) === \\n\");\n * const [userTransactionResponse] = await aptos.transaction.simulate.multiAgent(\n * {\n * signerPublicKey: sender1.publicKey,\n * secondarySignersPublicKeys: [sender2.publicKey],\n * transaction,\n * },\n * );\n * console.log(userTransactionResponse);\n *\n * // If the fee looks ok, continue to signing!\n * // ...\n * }\n *\n * example();\n * ```\n * @group Implementation\n */\n @ValidateFeePayerDataOnSimulation\n async multiAgent(args: {\n signerPublicKey?: PublicKey;\n transaction: AnyRawTransaction;\n secondarySignersPublicKeys?: Array<PublicKey | undefined>;\n feePayerPublicKey?: PublicKey;\n options?: InputSimulateTransactionOptions;\n }): Promise<Array<UserTransactionResponse>> {\n return simulateTransaction({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"wMAIA,OAAS,uBAAAA,MAA2B,uCAIpC,OAAS,oCAAAC,MAAwC,YAM1C,MAAMC,CAAS,CA4BpB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CA4DA,MAAM,OAAOC,EAK+B,CAC1C,OAAOJ,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGI,CAAK,CAAC,CAClE,CAuEA,MAAM,WAAWA,EAM2B,CAC1C,OAAOJ,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGI,CAAK,CAAC,CAClE,CACF,CAvFQC,EAAA,CADLJ,GAzFUC,EA0FL,sBA8EAG,EAAA,CADLJ,GAvKUC,EAwKL","names":["simulateTransaction","ValidateFeePayerDataOnSimulation","Simulate","config","args","__decorateClass"]}
@@ -1,4 +1,4 @@
1
- import { A as AptosConfig, bg as AnyRawTransaction, W as AccountAuthenticator, bm as InputTransactionPluginData, cl as PendingTransactionResponse } from '../../account-ClxOwjdh.mjs';
1
+ import { A as AptosConfig, bg as AnyRawTransaction, W as AccountAuthenticator, bm as InputTransactionPluginData, cl as PendingTransactionResponse } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{de as a}from"../../chunk-DIGP2ALY.mjs";import"../../chunk-5HXLZHDW.mjs";import"../../chunk-GOXRBEIJ.mjs";import"../../chunk-ROT6S6BM.mjs";import"../../chunk-XJJVJOX5.mjs";import"../../chunk-C3Q23D22.mjs";import"../../chunk-NECL5FCQ.mjs";import"../../chunk-4QMXOWHP.mjs";import"../../chunk-RQX6JOEN.mjs";import"../../chunk-WSR5EBJM.mjs";import"../../chunk-WCMW2L3P.mjs";import"../../chunk-G3MHXDYA.mjs";import"../../chunk-HNBKTJPN.mjs";import"../../chunk-V74WPKSY.mjs";import"../../chunk-UYVPNUH3.mjs";import"../../chunk-A5L76YP7.mjs";import"../../chunk-XKUIMGKU.mjs";import"../../chunk-N6YTF76Q.mjs";import"../../chunk-ZP4DWSQA.mjs";import"../../chunk-QREVMGQZ.mjs";import"../../chunk-FGFLPH5K.mjs";import"../../chunk-V3MBJJTL.mjs";import"../../chunk-ES2KP6BS.mjs";import"../../chunk-EM52Z7T7.mjs";import"../../chunk-TGRLDWXV.mjs";import"../../chunk-N3O3ULF7.mjs";import"../../chunk-YOZBVVKL.mjs";import"../../chunk-GMQCQDW4.mjs";import"../../chunk-UL777LTI.mjs";import"../../chunk-7ECCT6PK.mjs";import"../../chunk-DNRUDMMV.mjs";import"../../chunk-GFFKEZ56.mjs";import"../../chunk-LWL57YFU.mjs";import"../../chunk-HGLO5LDS.mjs";import"../../chunk-CW35YAMN.mjs";import"../../chunk-6WDVDEQZ.mjs";import"../../chunk-FZY4PMEE.mjs";import"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-7DQDJ2SA.mjs";import"../../chunk-HNBVYE3N.mjs";import"../../chunk-RGKRCZ36.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-RCSJFTST.mjs";import"../../chunk-4RXKALLC.mjs";import"../../chunk-OLILO7VD.mjs";import"../../chunk-5FI4545P.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as Submit};
1
+ import{submitTransaction as n}from"../../internal/transactionSubmission";import{validateFeePayerDataOnSubmission as o}from"./helpers";class m{constructor(t){this.config=t}async simple(t){return o(this.config,t),n({aptosConfig:this.config,...t})}async multiAgent(t){return o(this.config,t),n({aptosConfig:this.config,...t})}}export{m as Submit};
2
2
  //# sourceMappingURL=submit.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/api/transactionSubmission/submit.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { submitTransaction } from \"../../internal/transactionSubmission\";\nimport { AccountAuthenticator, AnyRawTransaction, InputTransactionPluginData } from \"../../transactions\";\nimport { PendingTransactionResponse } from \"../../types\";\nimport { AptosConfig } from \"../aptosConfig\";\nimport { validateFeePayerDataOnSubmission } from \"./helpers\";\n\n/**\n * A class to handle all `Submit` transaction operations.\n * @group Implementation\n */\nexport class Submit {\n readonly config: AptosConfig;\n\n /**\n * Initializes a new instance of the Aptos client with the specified configuration.\n * This allows you to interact with the Aptos blockchain using the provided settings.\n *\n * @param config - The configuration settings for the Aptos client.\n * @param config.network - The network to connect to (e.g., TESTNET, MAINNET).\n * @param config.nodeUrl - The URL of the Aptos node to connect to.\n * @param config.faucetUrl - The URL of the faucet for obtaining test tokens.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for the Aptos client\n * const config = new AptosConfig({\n * network: Network.TESTNET, // Use the TESTNET for testing\n * nodeUrl: \"https://testnet.aptos.dev\", // Specify the node URL\n * faucetUrl: \"https://faucet.testnet.aptos.dev\" // Specify the faucet URL\n * });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Submits a transaction to the Aptos blockchain using the provided transaction details and authenticators.\n * This function allows you to execute transactions securely by specifying the sender and optional fee payer authenticators.\n *\n * @param args - The arguments for submitting the transaction.\n * @param args.transaction - The raw transaction data to be submitted.\n * @param args.senderAuthenticator - The authenticator for the sender's account.\n * @param [args.feePayerAuthenticator] - The optional authenticator for the fee payer's account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const sender = Account.generate(); // Generate a new sender account\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [Account.generate().accountAddress, 100], // Replace with a real destination account\n * },\n * });\n *\n * // Submit the transaction\n * const response = await aptos.simple({\n * transaction,\n * senderAuthenticator: sender.getAuthenticator(), // Use the sender's authenticator\n * });\n *\n * console.log(\"Transaction submitted:\", response);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n async simple(\n args: {\n transaction: AnyRawTransaction;\n senderAuthenticator: AccountAuthenticator;\n feePayerAuthenticator?: AccountAuthenticator;\n } & InputTransactionPluginData,\n ): Promise<PendingTransactionResponse> {\n validateFeePayerDataOnSubmission(this.config, args);\n return submitTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Submits a multi-agent transaction to the Aptos network, allowing multiple signers to authorize the transaction.\n * This function is useful for scenarios where a transaction requires approval from multiple accounts.\n *\n * @param args - The parameters for the multi-agent transaction.\n * @param args.transaction - The raw transaction to be submitted.\n * @param args.senderAuthenticator - The authenticator for the sender account.\n * @param args.additionalSignersAuthenticators - An array of authenticators for additional signers.\n * @param [args.feePayerAuthenticator] - An optional authenticator for the fee payer account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Account } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const sender = Account.generate(); // Generate a new sender account\n * const additionalSigner1 = Account.generate(); // Generate an additional signer account\n * const additionalSigner2 = Account.generate(); // Generate another additional signer account\n *\n * const transaction = await aptos.transaction.build.simple({\n * sender: sender.accountAddress,\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [additionalSigner1.accountAddress, 100],\n * },\n * });\n *\n * const response = await aptos.multiAgent({\n * transaction,\n * senderAuthenticator: sender.getAuthenticator(), // Use the sender's authenticator\n * additionalSignersAuthenticators: [\n * additionalSigner1.getAuthenticator(), // Use the first additional signer's authenticator\n * additionalSigner2.getAuthenticator(), // Use the second additional signer's authenticator\n * ],\n * });\n *\n * console.log(response); // Log the response from the transaction submission\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\n async multiAgent(\n args: {\n transaction: AnyRawTransaction;\n senderAuthenticator: AccountAuthenticator;\n additionalSignersAuthenticators: Array<AccountAuthenticator>;\n feePayerAuthenticator?: AccountAuthenticator;\n } & InputTransactionPluginData,\n ): Promise<PendingTransactionResponse> {\n validateFeePayerDataOnSubmission(this.config, args);\n return submitTransaction({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"AAGA,OAAS,qBAAAA,MAAyB,uCAIlC,OAAS,oCAAAC,MAAwC,YAM1C,MAAMC,CAAO,CAiClB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAwCA,MAAM,OACJC,EAKqC,CACrC,OAAAH,EAAiC,KAAK,OAAQG,CAAI,EAC3CJ,EAAkB,CAAE,YAAa,KAAK,OAAQ,GAAGI,CAAK,CAAC,CAChE,CA+CA,MAAM,WACJA,EAMqC,CACrC,OAAAH,EAAiC,KAAK,OAAQG,CAAI,EAC3CJ,EAAkB,CAAE,YAAa,KAAK,OAAQ,GAAGI,CAAK,CAAC,CAChE,CACF","names":["submitTransaction","validateFeePayerDataOnSubmission","Submit","config","args"]}
@@ -1,5 +1,5 @@
1
1
  import { ProcessorType } from '../utils/const.mjs';
2
- import { A as AptosConfig, bN as AnyNumber } from '../account-ClxOwjdh.mjs';
2
+ import { A as AptosConfig, bN as AnyNumber } from '../account-BortO8g2.mjs';
3
3
  import '../types/indexer.mjs';
4
4
  import '../types/generated/operations.mjs';
5
5
  import '../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-TGRLDWXV.mjs";import"../chunk-N3O3ULF7.mjs";import"../chunk-YOZBVVKL.mjs";import"../chunk-GMQCQDW4.mjs";import"../chunk-UL777LTI.mjs";import"../chunk-7ECCT6PK.mjs";import"../chunk-DNRUDMMV.mjs";import"../chunk-GFFKEZ56.mjs";import"../chunk-LWL57YFU.mjs";import"../chunk-HGLO5LDS.mjs";import"../chunk-CW35YAMN.mjs";import"../chunk-6WDVDEQZ.mjs";import"../chunk-FZY4PMEE.mjs";import"../chunk-TOBQ5UE6.mjs";import"../chunk-MT2RJ7H3.mjs";import"../chunk-Q4W3WJ2U.mjs";import"../chunk-ORMOQWWH.mjs";import"../chunk-FLZPUYXQ.mjs";import"../chunk-7DQDJ2SA.mjs";import"../chunk-HNBVYE3N.mjs";import"../chunk-RGKRCZ36.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-IJE2LVZG.mjs";import"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-4RXKALLC.mjs";import"../chunk-OLILO7VD.mjs";import"../chunk-5FI4545P.mjs";import"../chunk-KDMSOCZY.mjs";export{a as waitForIndexerOnVersion};
1
+ import{waitForIndexer as e}from"../internal/transaction";async function t(o){o.minimumLedgerVersion!==void 0&&await e({aptosConfig:o.config,minimumLedgerVersion:o.minimumLedgerVersion,processorType:o.processorType})}export{t as waitForIndexerOnVersion};
2
2
  //# sourceMappingURL=utils.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/api/utils.ts"],"sourcesContent":["import { waitForIndexer } from \"../internal/transaction\";\nimport { ProcessorType } from \"../utils\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { AnyNumber } from \"../types\";\n\n/**\n * Waits for the indexer to reach a specified ledger version, allowing for synchronization with the blockchain.\n * This function is useful for ensuring that your application is working with the most up-to-date data before proceeding.\n *\n * @param args - The parameters for waiting on the indexer.\n * @param args.config - The configuration object for Aptos.\n * @param [args.minimumLedgerVersion] - The minimum ledger version to wait for. If not specified, the function will not wait.\n * @param args.processorType - The type of processor to wait for.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, ProcessorType } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Wait for the indexer to reach a specific ledger version\n * await aptos.waitForIndexerOnVersion({\n * config: config,\n * minimumLedgerVersion: 1000n, // replace with a real ledger version\n * processorType: ProcessorType.DEFAULT,\n * });\n *\n * console.log(\"Indexer is synced to the specified ledger version.\");\n * }\n * runExample().catch(console.error);\n * ```\n * @group Implementation\n */\nexport async function waitForIndexerOnVersion(args: {\n config: AptosConfig;\n minimumLedgerVersion?: AnyNumber;\n processorType: ProcessorType;\n}) {\n if (args.minimumLedgerVersion !== undefined) {\n await waitForIndexer({\n aptosConfig: args.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: args.processorType,\n });\n }\n}\n"],"mappings":"AAAA,OAAS,kBAAAA,MAAsB,0BAmC/B,eAAsBC,EAAwBC,EAI3C,CACGA,EAAK,uBAAyB,QAChC,MAAMF,EAAe,CACnB,YAAaE,EAAK,OAClB,qBAAsBA,EAAK,qBAC3B,cAAeA,EAAK,aACtB,CAAC,CAEL","names":["waitForIndexer","waitForIndexerOnVersion","args"]}
@@ -1,4 +1,4 @@
1
- import { bH as Uint8, bI as Uint16, bJ as Uint32, bK as Uint64, bL as Uint128, bM as Uint256 } from '../account-ClxOwjdh.mjs';
1
+ import { bH as Uint8, bI as Uint16, bJ as Uint32, bK as Uint64, bL as Uint128, bM as Uint256 } from '../account-BortO8g2.mjs';
2
2
  import '../types/indexer.mjs';
3
3
  import '../types/generated/operations.mjs';
4
4
  import '../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f}from"../chunk-56CNRT2K.mjs";import"../chunk-KDMSOCZY.mjs";export{e as MAX_U128_BIG_INT,b as MAX_U16_NUMBER,f as MAX_U256_BIG_INT,c as MAX_U32_NUMBER,d as MAX_U64_BIG_INT,a as MAX_U8_NUMBER};
1
+ const r=255,p=65535,c=4294967295,e=18446744073709551615n,s=340282366920938463463374607431768211455n,x=115792089237316195423570985008687907853269984665640564039457584007913129639935n;export{s as MAX_U128_BIG_INT,p as MAX_U16_NUMBER,x as MAX_U256_BIG_INT,c as MAX_U32_NUMBER,e as MAX_U64_BIG_INT,r as MAX_U8_NUMBER};
2
2
  //# sourceMappingURL=consts.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/bcs/consts.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256 } from \"../types\";\n\n// Upper bound values for uint8, uint16, uint64 etc. These are all derived as\n// 2^N - 1, where N is the number of bits in the type.\nexport const MAX_U8_NUMBER: Uint8 = 255;\nexport const MAX_U16_NUMBER: Uint16 = 65535;\nexport const MAX_U32_NUMBER: Uint32 = 4294967295;\nexport const MAX_U64_BIG_INT: Uint64 = 18446744073709551615n;\nexport const MAX_U128_BIG_INT: Uint128 = 340282366920938463463374607431768211455n;\nexport const MAX_U256_BIG_INT: Uint256 =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935n;\n"],"mappings":"AAOO,MAAMA,EAAuB,IACvBC,EAAyB,MACzBC,EAAyB,WACzBC,EAA0B,sBAC1BC,EAA4B,yCAC5BC,EACX","names":["MAX_U8_NUMBER","MAX_U16_NUMBER","MAX_U32_NUMBER","MAX_U64_BIG_INT","MAX_U128_BIG_INT","MAX_U256_BIG_INT"]}
@@ -1,4 +1,4 @@
1
- export { D as Deserializable, a as Deserializer } from '../account-ClxOwjdh.mjs';
1
+ export { D as Deserializable, a as Deserializer } from '../account-BortO8g2.mjs';
2
2
  import '../types/indexer.mjs';
3
3
  import '../types/generated/operations.mjs';
4
4
  import '../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-FLZPUYXQ.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-KDMSOCZY.mjs";export{a as Deserializer};
1
+ import{MAX_U32_NUMBER as n}from"./consts";import{Hex as a}from"../core/hex";class s{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){const i=a.hexInputToUint8Array(e);return new s(i)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");const i=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,i}remaining(){return this.buffer.byteLength-this.offset}assertFinished(){if(this.remaining()!==0)throw new Error("Buffer has remaining bytes")}deserializeStr(){const e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,i){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(i===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(i)}return this.deserialize(e)}}deserializeBytes(){const e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){const e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){const e=this.deserializeU32(),i=this.deserializeU32();return BigInt(BigInt(i)<<BigInt(32)|BigInt(e))}deserializeU128(){const e=this.deserializeU64(),i=this.deserializeU64();return BigInt(i<<BigInt(64)|e)}deserializeU256(){const e=this.deserializeU128(),i=this.deserializeU128();return BigInt(i<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),i=0;for(;e<n;){const r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(i),(r&128)===0)break;i+=7}if(e>n)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){const i=this.deserializeUleb128AsU32(),r=new Array;for(let t=0;t<i;t+=1)r.push(this.deserialize(e));return r}}export{s as Deserializer};
2
2
  //# sourceMappingURL=deserializer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/bcs/deserializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport { MAX_U32_NUMBER } from \"./consts\";\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256, HexInput } from \"../types\";\nimport { Hex } from \"../core/hex\";\n\n/**\n * This interface exists to define Deserializable<T> inputs for functions that\n * deserialize a byte buffer into a type T.\n * It is not intended to be implemented or extended, because Typescript has no support\n * for static methods in interfaces.\n *\n * @template T - The type that this will deserialize into.\n * @group Implementation\n * @category BCS\n */\nexport interface Deserializable<T> {\n /**\n * Deserializes the buffered bytes into an instance of the specified class type.\n * This function provides an alternative syntax for deserialization, allowing users to call\n * `deserializer.deserialize(MyClass)` instead of `MyClass.deserialize(deserializer)`.\n *\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @returns The deserialized value of class type T.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * ```\n * @group Implementation\n * @category BCS\n */\n deserialize(deserializer: Deserializer): T;\n}\n\n/**\n * A class that provides methods for deserializing various data types from a byte buffer.\n * It supports deserialization of primitive types, strings, and complex objects using a BCS (Binary Common Serialization) layout.\n * @group Implementation\n * @category BCS\n */\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Creates a new instance of the class with a copy of the provided data buffer.\n * This prevents outside mutation of the buffer.\n *\n * @param data - The data to be copied into the internal buffer as a Uint8Array.\n * @group Implementation\n * @category BCS\n */\n constructor(data: Uint8Array) {\n // copies data to prevent outside mutation of buffer.\n this.buffer = new ArrayBuffer(data.length);\n new Uint8Array(this.buffer).set(data, 0);\n this.offset = 0;\n }\n\n static fromHex(hex: HexInput): Deserializer {\n const data = Hex.hexInputToUint8Array(hex);\n return new Deserializer(data);\n }\n\n /**\n * Reads a specified number of bytes from the buffer and advances the offset.\n *\n * @param length - The number of bytes to read from the buffer.\n * @throws Throws an error if the read operation exceeds the buffer's length.\n * @group Implementation\n * @category BCS\n */\n private read(length: number): ArrayBuffer {\n if (this.offset + length > this.buffer.byteLength) {\n throw new Error(\"Reached to the end of buffer\");\n }\n\n const bytes = this.buffer.slice(this.offset, this.offset + length);\n this.offset += length;\n return bytes;\n }\n\n /**\n * Returns the number of bytes remaining in the buffer.\n *\n * This information is useful to determine if there's more data to be read.\n *\n * @returns The number of bytes remaining in the buffer.\n * @group Implementation\n * @category BCS\n */\n remaining(): number {\n return this.buffer.byteLength - this.offset;\n }\n\n /**\n * Asserts that the buffer has no remaining bytes.\n *\n * @throws {Error} Throws an error if there are remaining bytes in the buffer.\n * @group Implementation\n * @category BCS\n */\n assertFinished(): void {\n if (this.remaining() !== 0) {\n throw new Error(\"Buffer has remaining bytes\");\n }\n }\n\n /**\n * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes,\n * followed by the actual byte content, and decodes it into a string.\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 * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeStr() === \"1234abcd\");\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * @deprecated use `deserializeOption(\"string\")` instead.\n *\n * The BCS layout for Optional<String> is 0 if none, else 1 followed by the string length and string content.\n * @returns The deserialized string if it exists, otherwise undefined.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00]));\n * assert(deserializer.deserializeOptionStr() === undefined);\n * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeOptionStr() === \"1234abcd\");\n * ```\n */\n deserializeOptionStr(): string | undefined {\n return this.deserializeOption(\"string\");\n }\n\n /**\n * Deserializes an optional value from the buffer.\n *\n * The BCS layout for Optional<T> starts with a boolean byte (0 if none, 1 if some),\n * followed by the value if present.\n *\n * @template T - The type of the value to deserialize\n * @param type - Either a Deserializable class or one of the string literals: \"string\", \"bytes\", or \"fixedBytes\"\n * @param len - Required length when type is \"fixedBytes\", ignored otherwise\n * @returns The deserialized value if present, undefined otherwise\n *\n * @throws {Error} When \"fixedBytes\" is specified without a length\n *\n * @example\n * ```typescript\n * // Deserialize an optional string\n * const deserializer = new Deserializer(new Uint8Array([1, 3, 97, 98, 99]));\n * const optStr = deserializer.deserializeOption(\"string\");\n * // optStr === \"abc\"\n *\n * // Deserialize an optional custom type\n * const deserializer = new Deserializer(new Uint8Array([0]));\n * const optValue = deserializer.deserializeOption(MyClass);\n * // optValue === undefined\n *\n * // Deserialize optional bytes\n * const deserializer = new Deserializer(new Uint8Array([1, 3, 1, 2, 3]));\n * const optBytes = deserializer.deserializeOption(\"bytes\");\n * // optBytes === Uint8Array[1, 2, 3]\n *\n * // Deserialize optional fixed bytes\n * const deserializer = new Deserializer(new Uint8Array([1, 1, 2, 3, 4]));\n * const optBytes = deserializer.deserializeOption(\"fixedBytes\", 4);\n * // optBytes === Uint8Array[1, 2, 3, 4]\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeOption(type: \"string\"): string | undefined;\n deserializeOption(type: \"bytes\"): Uint8Array | undefined;\n deserializeOption(type: \"fixedBytes\", len: number): Uint8Array | undefined;\n deserializeOption<T>(type: Deserializable<T>): T | undefined;\n deserializeOption<T>(\n type: Deserializable<T> | \"string\" | \"bytes\" | \"fixedBytes\",\n len?: number,\n ): T | string | Uint8Array | undefined {\n const exists = this.deserializeBool();\n if (!exists) return undefined;\n\n if (type === \"string\") {\n return this.deserializeStr();\n }\n if (type === \"bytes\") {\n return this.deserializeBytes();\n }\n if (type === \"fixedBytes\") {\n if (len === undefined) {\n throw new Error(\"Fixed bytes length not provided\");\n }\n return this.deserializeFixedBytes(len);\n }\n\n return this.deserialize(type);\n }\n\n /**\n * Deserializes an array of bytes.\n *\n * The BCS layout for \"bytes\" consists of a bytes_length followed by the bytes themselves, where bytes_length is a u32 integer\n * encoded as a uleb128 integer, indicating the length of the bytes array.\n *\n * @returns {Uint8Array} The deserialized array of bytes.\n * @group Implementation\n * @category BCS\n */\n deserializeBytes(): Uint8Array {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes of a specified length.\n *\n * @param len - The number of bytes to read from the source.\n * @group Implementation\n * @category BCS\n */\n deserializeFixedBytes(len: number): Uint8Array {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value from a byte stream.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n * An error is thrown if the byte value is not valid.\n *\n * @returns The deserialized boolean value.\n * @throws Throws an error if the boolean value is invalid.\n * @group Implementation\n * @category BCS\n */\n deserializeBool(): boolean {\n const bool = new Uint8Array(this.read(1))[0];\n if (bool !== 1 && bool !== 0) {\n throw new Error(\"Invalid boolean value\");\n }\n return bool === 1;\n }\n\n /**\n * Deserializes a uint8 number from the binary data.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @returns {number} The deserialized uint8 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint16\": Two bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint32\": Four bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * This function combines two 32-bit values to return a 64-bit unsigned integer in little-endian representation.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU64(): Uint64 {\n const low = this.deserializeU32();\n const high = this.deserializeU32();\n\n // combine the two 32-bit values and return (little endian)\n return BigInt((BigInt(high) << BigInt(32)) | BigInt(low));\n }\n\n /**\n * Deserializes a uint128 number from its binary representation.\n * This function combines two 64-bit values to return a single uint128 value in little-endian format.\n *\n * @returns {BigInt} The deserialized uint128 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU128(): Uint128 {\n const low = this.deserializeU64();\n const high = this.deserializeU64();\n\n // combine the two 64-bit values and return (little endian)\n return BigInt((high << BigInt(64)) | low);\n }\n\n /**\n * Deserializes a uint256 number from its binary representation.\n *\n * The BCS layout for \"uint256\" consists of thirty-two bytes in little-endian format.\n *\n * @returns {BigInt} The deserialized uint256 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU256(): Uint256 {\n const low = this.deserializeU128();\n const high = this.deserializeU128();\n\n // combine the two 128-bit values and return (little endian)\n return BigInt((high << BigInt(128)) | low);\n }\n\n /**\n * Deserializes a uleb128 encoded uint32 number.\n *\n * This function is used for interpreting lengths of variable-length sequences and tags of enum values in BCS encoding.\n *\n * @throws {Error} Throws an error if the parsed value exceeds the maximum uint32 number.\n * @returns {number} The deserialized uint32 value.\n * @group Implementation\n * @category BCS\n */\n deserializeUleb128AsU32(): Uint32 {\n let value: bigint = BigInt(0);\n let shift = 0;\n\n while (value < MAX_U32_NUMBER) {\n const byte = this.deserializeU8();\n value |= BigInt(byte & 0x7f) << BigInt(shift);\n\n if ((byte & 0x80) === 0) {\n break;\n }\n shift += 7;\n }\n\n if (value > MAX_U32_NUMBER) {\n throw new Error(\"Overflow while parsing uleb128-encoded uint32 value\");\n }\n\n return Number(value);\n }\n\n /**\n * Helper function that primarily exists to support alternative syntax for deserialization.\n * That is, if we have a `const deserializer: new Deserializer(...)`, instead of having to use\n * `MyClass.deserialize(deserializer)`, we can call `deserializer.deserialize(MyClass)`.\n *\n * @example const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns the deserialized value of class type T\n * @group Implementation\n * @category BCS\n */\n deserialize<T>(cls: Deserializable<T>): T {\n // NOTE: `deserialize` in `cls.deserialize(this)` here is a static method defined in `cls`,\n // It is separate from the `deserialize` instance method defined here in Deserializer.\n return cls.deserialize(this);\n }\n\n /**\n * Deserializes an array of BCS Deserializable values given an existing Deserializer instance with a loaded byte buffer.\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n * @returns An array of deserialized values of type T.\n * @example\n * // serialize a vector of addresses\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 *\n * // deserialize the bytes into an array of addresses\n * const deserializer = new Deserializer(serializedBytes);\n * const deserializedAddresses = deserializer.deserializeVector(AccountAddress);\n * // deserializedAddresses is now an array of AccountAddress instances\n * @group Implementation\n * @category BCS\n */\n deserializeVector<T>(cls: Deserializable<T>): Array<T> {\n const length = this.deserializeUleb128AsU32();\n const vector = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n vector.push(this.deserialize(cls));\n }\n return vector;\n }\n}\n"],"mappings":"AAIA,OAAS,kBAAAA,MAAsB,WAE/B,OAAS,OAAAC,MAAW,cAuCb,MAAMC,CAAa,CAaxB,YAAYC,EAAkB,CAE5B,KAAK,OAAS,IAAI,YAAYA,EAAK,MAAM,EACzC,IAAI,WAAW,KAAK,MAAM,EAAE,IAAIA,EAAM,CAAC,EACvC,KAAK,OAAS,CAChB,CAEA,OAAO,QAAQC,EAA6B,CAC1C,MAAMD,EAAOF,EAAI,qBAAqBG,CAAG,EACzC,OAAO,IAAIF,EAAaC,CAAI,CAC9B,CAUQ,KAAKE,EAA6B,CACxC,GAAI,KAAK,OAASA,EAAS,KAAK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CAAC,EAAE,UAAU,EAAG,EAAI,CACrD,CAcA,gBAAyB,CACvB,OAAO,IAAI,SAAS,KAAK,KAAK,CAAC,CAAC,EAAE,UAAU,EAAG,EAAI,CACrD,CAcA,gBAAyB,CACvB,MAAMC,EAAM,KAAK,eAAe,EAC1BC,EAAO,KAAK,eAAe,EAGjC,OAAO,OAAQ,OAAOA,CAAI,GAAK,OAAO,EAAE,EAAK,OAAOD,CAAG,CAAC,CAC1D,CAUA,iBAA2B,CACzB,MAAMA,EAAM,KAAK,eAAe,EAC1BC,EAAO,KAAK,eAAe,EAGjC,OAAO,OAAQA,GAAQ,OAAO,EAAE,EAAKD,CAAG,CAC1C,CAWA,iBAA2B,CACzB,MAAMA,EAAM,KAAK,gBAAgB,EAC3BC,EAAO,KAAK,gBAAgB,EAGlC,OAAO,OAAQA,GAAQ,OAAO,GAAG,EAAKD,CAAG,CAC3C,CAYA,yBAAkC,CAChC,IAAIJ,EAAgB,OAAO,CAAC,EACxBM,EAAQ,EAEZ,KAAON,EAAQP,GAAgB,CAC7B,MAAMc,EAAO,KAAK,cAAc,EAGhC,GAFAP,GAAS,OAAOO,EAAO,GAAI,GAAK,OAAOD,CAAK,GAEvCC,EAAO,OAAU,EACpB,MAEFD,GAAS,CACX,CAEA,GAAIN,EAAQP,EACV,MAAM,IAAI,MAAM,qDAAqD,EAGvE,OAAO,OAAOO,CAAK,CACrB,CAiBA,YAAeQ,EAA2B,CAGxC,OAAOA,EAAI,YAAY,IAAI,CAC7B,CA0BA,kBAAqBA,EAAkC,CACrD,MAAMV,EAAS,KAAK,wBAAwB,EACtCW,EAAS,IAAI,MACnB,QAASC,EAAI,EAAGA,EAAIZ,EAAQY,GAAK,EAC/BD,EAAO,KAAK,KAAK,YAAYD,CAAG,CAAC,EAEnC,OAAOC,CACT,CACF","names":["MAX_U32_NUMBER","Hex","Deserializer","data","hex","length","bytes","value","type","len","bool","low","high","shift","byte","cls","vector","i"]}
@@ -1,4 +1,4 @@
1
- export { B as Bool, D as Deserializable, a as Deserializer, F as FixedBytes, k as MoveOption, j as MoveString, M as MoveVector, S as Serializable, i as Serialized, b as Serializer, g as U128, c as U16, h as U256, d as U32, f as U64, U as U8, e as ensureBoolean, o as outOfRangeErrorMessage, v as validateNumberInRange } from '../account-ClxOwjdh.mjs';
1
+ export { B as Bool, D as Deserializable, a as Deserializer, F as FixedBytes, k as MoveOption, j as MoveString, M as MoveVector, S as Serializable, i as Serialized, b as Serializer, g as U128, c as U16, h as U256, d as U32, f as U64, U as U8, e as ensureBoolean, o as outOfRangeErrorMessage, v as validateNumberInRange } from '../account-BortO8g2.mjs';
2
2
  export { EntryFunctionBytes } from './serializable/entryFunctionBytes.mjs';
3
3
  import '../types/indexer.mjs';
4
4
  import '../types/generated/operations.mjs';
@@ -1,2 +1,2 @@
1
- import"../chunk-FZY4PMEE.mjs";import{a as h}from"../chunk-TOBQ5UE6.mjs";import{a as g}from"../chunk-MT2RJ7H3.mjs";import{a as p,b as q,c as r,d as s}from"../chunk-Q4W3WJ2U.mjs";import{a as i,b as j,c as k,d as l,e as m,f as n,g as o}from"../chunk-ORMOQWWH.mjs";import{a}from"../chunk-FLZPUYXQ.mjs";import"../chunk-FD6FGKYY.mjs";import"../chunk-4WPQQPUF.mjs";import"../chunk-IJE2LVZG.mjs";import{a as b,b as c,c as d,d as e,e as f}from"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-KDMSOCZY.mjs";export{i as Bool,a as Deserializer,h as EntryFunctionBytes,g as FixedBytes,s as MoveOption,r as MoveString,p as MoveVector,b as Serializable,q as Serialized,c as Serializer,n as U128,k as U16,o as U256,l as U32,m as U64,j as U8,d as ensureBoolean,e as outOfRangeErrorMessage,f as validateNumberInRange};
1
+ export*from"./deserializer";export*from"./serializer";export*from"./serializable/entryFunctionBytes";export*from"./serializable/fixedBytes";export*from"./serializable/movePrimitives";export*from"./serializable/moveStructs";
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/bcs/index.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from \"./deserializer\";\nexport * from \"./serializer\";\nexport * from \"./serializable/entryFunctionBytes\";\nexport * from \"./serializable/fixedBytes\";\nexport * from \"./serializable/movePrimitives\";\nexport * from \"./serializable/moveStructs\";\n"],"mappings":"AAGA,WAAc,iBACd,WAAc,eACd,WAAc,oCACd,WAAc,4BACd,WAAc,gCACd,WAAc","names":[]}
@@ -1,4 +1,4 @@
1
- import { S as Serializable, aa as EntryFunctionArgument, F as FixedBytes, b as Serializer, a as Deserializer } from '../../account-ClxOwjdh.mjs';
1
+ import { S as Serializable, aa as EntryFunctionArgument, F as FixedBytes, b as Serializer, a as Deserializer } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-TOBQ5UE6.mjs";import"../../chunk-MT2RJ7H3.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as EntryFunctionBytes};
1
+ import{Serializable as l}from"../serializer";import{FixedBytes as i}from"./fixedBytes";class r extends l{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,t){const n=i.deserialize(e,t);return new r(n.value)}}export{r as EntryFunctionBytes};
2
2
  //# sourceMappingURL=entryFunctionBytes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/bcs/serializable/entryFunctionBytes.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Serializer, Serializable } from \"../serializer\";\nimport { Deserializer } from \"../deserializer\";\nimport { FixedBytes } from \"./fixedBytes\";\nimport { EntryFunctionArgument } from \"../../transactions/instances/transactionArgument\";\nimport { HexInput } from \"../../types\";\n\n/**\n * This class exists solely to represent a sequence of fixed bytes as a serialized entry function, because\n * serializing an entry function appends a prefix that's *only* used for entry function arguments.\n *\n * NOTE: Using this class for serialized script functions will lead to erroneous and unexpected behavior.\n *\n * If you wish to convert this class back to a TransactionArgument, you must know the type\n * of the argument beforehand, and use the appropriate class to deserialize the bytes within\n * an instance of this class.\n * @group Implementation\n * @category BCS\n */\nexport class EntryFunctionBytes extends Serializable implements EntryFunctionArgument {\n public readonly value: FixedBytes;\n\n /**\n * Creates an instance of the class with a specified hexadecimal input value.\n *\n * @param value - The hexadecimal input to be converted into FixedBytes.\n * @group Implementation\n * @category BCS\n */\n private constructor(value: HexInput) {\n super();\n this.value = new FixedBytes(value);\n }\n\n // Note that to see the Move, BCS-serialized representation of the underlying fixed byte vector,\n // we must not serialize the length prefix.\n //\n // In other words, this class is only used to represent a sequence of bytes that are already\n // BCS-serialized as a type. To represent those bytes accurately, the BCS-serialized form is the same exact\n // representation.\n\n /**\n * Serializes the value using the provided serializer.\n * This function is essential for accurately representing a sequence of bytes that are already BCS-serialized as a type.\n *\n * Note that to see the Move, BCS-serialized representation of the underlying fixed byte vector,\n * we must not serialize the length prefix.\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.serialize(this.value);\n }\n\n // When we serialize these bytes as an entry function argument, we need to\n // serialize the length prefix. This essentially converts the underlying fixed byte vector to a type-agnostic\n // byte vector to an `any` type.\n // NOTE: This, and the lack of a `serializeForScriptFunction`, is the only meaningful difference between this\n // class and FixedBytes.\n\n /**\n * Serializes the current instance for use as an entry function argument by converting the underlying fixed byte vector to a\n * type-agnostic byte vector.\n * This process includes serializing the length prefix of the byte vector.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.value.value.length);\n serializer.serialize(this);\n }\n\n /**\n * The only way to create an instance of this class is to use this static method.\n * This function should only be used when deserializing a sequence of EntryFunctionPayload arguments.\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @param length - The length of the bytes to deserialize.\n * @returns An instance of this class, which will now only be usable as an EntryFunctionArgument.\n * @group Implementation\n * @category BCS\n */\n static deserialize(deserializer: Deserializer, length: number): EntryFunctionBytes {\n const fixedBytes = FixedBytes.deserialize(deserializer, length);\n return new EntryFunctionBytes(fixedBytes.value);\n }\n}\n"],"mappings":"AAGA,OAAqB,gBAAAA,MAAoB,gBAEzC,OAAS,cAAAC,MAAkB,eAgBpB,MAAMC,UAA2BF,CAA8C,CAU5E,YAAYG,EAAiB,CACnC,MAAM,EACN,KAAK,MAAQ,IAAIF,EAAWE,CAAK,CACnC,CAoBA,UAAUC,EAA8B,CACtCA,EAAW,UAAU,KAAK,KAAK,CACjC,CAiBA,0BAA0BA,EAA8B,CACtDA,EAAW,sBAAsB,KAAK,MAAM,MAAM,MAAM,EACxDA,EAAW,UAAU,IAAI,CAC3B,CAWA,OAAO,YAAYC,EAA4BC,EAAoC,CACjF,MAAMC,EAAaN,EAAW,YAAYI,EAAcC,CAAM,EAC9D,OAAO,IAAIJ,EAAmBK,EAAW,KAAK,CAChD,CACF","names":["Serializable","FixedBytes","EntryFunctionBytes","value","serializer","deserializer","length","fixedBytes"]}
@@ -1,4 +1,4 @@
1
- export { F as FixedBytes } from '../../account-ClxOwjdh.mjs';
1
+ export { F as FixedBytes } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a}from"../../chunk-MT2RJ7H3.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as FixedBytes};
1
+ import{Serializable as s}from"../serializer";import{Hex as a}from"../../core/hex";class i extends s{constructor(e){super(),this.value=a.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){const t=e.deserializeFixedBytes(r);return new i(t)}}export{i as FixedBytes};
2
2
  //# sourceMappingURL=fixedBytes.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/bcs/serializable/fixedBytes.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Serializer, Serializable } from \"../serializer\";\nimport { Deserializer } from \"../deserializer\";\nimport { HexInput } from \"../../types\";\nimport { Hex } from \"../../core/hex\";\nimport { TransactionArgument } from \"../../transactions/instances/transactionArgument\";\n\n/**\n * Represents a contiguous sequence of already serialized BCS bytes.\n * \n * This class differs from most other Serializable classes in that its internal byte buffer is serialized to BCS\n * bytes exactly as-is, without prepending the length of the bytes. It is ideal for scenarios where custom serialization\n * is required, such as passing serialized bytes as transaction arguments. Additionally, it serves as a representation \n * of type-agnostic BCS bytes, akin to a vector<u8>.\n * \n * An example use case includes handling bytes resulting from entry function arguments that have been serialized \n * for an entry function.\n * \n * @example\n * const yourCustomSerializedBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);\n * const fixedBytes = new FixedBytes(yourCustomSerializedBytes);\n * const payload = await generateTransactionPayload({\n * function: \"0xbeefcafe::your_module::your_function_that_requires_custom_serialization\",\n * functionArguments: [yourCustomBytes],\n * });\n * \n * This class is particularly useful when you want to handle a fixed-size byte array without the overhead of \n * length prepending, such as when dealing with 32-byte addresses stored as U8 in a MoveVector<U8>.\n\n * For example, if you store each of the 32 bytes for an address as a U8 in a MoveVector<U8>, when you\n * serialize that MoveVector<U8>, it will be serialized to 33 bytes. If you solely want to pass around\n * the 32 bytes as a Serializable class that *does not* prepend the length to the BCS-serialized representation,\n * use this class.* \n * @param value - HexInput representing a sequence of Uint8 bytes.\n * @returns A Serializable FixedBytes instance, which when serialized, does not prepend the length of the bytes.\n * @see EntryFunctionBytes\n * @group Implementation\n * @category BCS\n */\nexport class FixedBytes extends Serializable implements TransactionArgument {\n public value: Uint8Array;\n\n /**\n * Creates an instance of the class with a specified hexadecimal input.\n * The value is converted from hexadecimal format to a Uint8Array.\n *\n * @param value - The hexadecimal input to be converted.\n * @group Implementation\n * @category BCS\n */\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n /**\n * Serializes the fixed bytes value using the provided serializer.\n * This function is essential for converting the fixed bytes into a format suitable for storage or transmission.\n *\n * @param serializer - The serializer instance used for serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.value);\n }\n\n /**\n * Serializes the current instance for an entry function using the provided serializer.\n * This allows the instance to be converted 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 serializeForEntryFunction(serializer: Serializer): void {\n serializer.serialize(this);\n }\n\n /**\n * Serializes the current instance using the provided serializer.\n * This function is essential for preparing data to be passed as arguments in script functions.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serialize(this);\n }\n\n /**\n * Deserializes a fixed-length byte array from the provided deserializer.\n * This function helps in reconstructing a FixedBytes object from the serialized data.\n *\n * @param deserializer - The deserializer instance used to read the byte data.\n * @param length - The length of the byte array to be deserialized.\n * @group Implementation\n * @category BCS\n */\n static deserialize(deserializer: Deserializer, length: number): FixedBytes {\n const bytes = deserializer.deserializeFixedBytes(length);\n return new FixedBytes(bytes);\n }\n}\n"],"mappings":"AAGA,OAAqB,gBAAAA,MAAoB,gBAGzC,OAAS,OAAAC,MAAW,iBAmCb,MAAMC,UAAmBF,CAA4C,CAW1E,YAAYG,EAAiB,CAC3B,MAAM,EACN,KAAK,MAAQF,EAAI,aAAaE,CAAK,EAAE,aAAa,CACpD,CAUA,UAAUC,EAA8B,CACtCA,EAAW,oBAAoB,KAAK,KAAK,CAC3C,CAUA,0BAA0BA,EAA8B,CACtDA,EAAW,UAAU,IAAI,CAC3B,CAUA,2BAA2BA,EAA8B,CACvDA,EAAW,UAAU,IAAI,CAC3B,CAWA,OAAO,YAAYC,EAA4BC,EAA4B,CACzE,MAAMC,EAAQF,EAAa,sBAAsBC,CAAM,EACvD,OAAO,IAAIJ,EAAWK,CAAK,CAC7B,CACF","names":["Serializable","Hex","FixedBytes","value","serializer","deserializer","length","bytes"]}
@@ -1,4 +1,4 @@
1
- export { B as Bool, g as U128, c as U16, h as U256, d as U32, f as U64, U as U8 } from '../../account-ClxOwjdh.mjs';
1
+ export { B as Bool, g as U128, c as U16, h as U256, d as U32, f as U64, U as U8 } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e,f,g}from"../../chunk-ORMOQWWH.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{a as Bool,f as U128,c as U16,g as U256,d as U32,e as U64,b as U8};
1
+ import{MAX_U128_BIG_INT as U,MAX_U16_NUMBER as d,MAX_U32_NUMBER as p,MAX_U64_BIG_INT as b,MAX_U8_NUMBER as y,MAX_U256_BIG_INT as m}from"../consts";import{Serializable as r,ensureBoolean as B,validateNumberInRange as t}from"../serializer";import{ScriptTransactionArgumentVariants as s}from"../../types";class l extends r{constructor(e){super(),B(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.Bool),e.serialize(this)}deserialize(e){return new a(e.deserializeU256())}static deserialize(e){return new l(e.deserializeBool())}}class n extends r{constructor(e){super(),t(e,0,y),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.U8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}}class o extends r{constructor(e){super(),t(e,0,d),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.U16),e.serialize(this)}static deserialize(e){return new o(e.deserializeU16())}}class z extends r{constructor(e){super(),t(e,0,p),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.U32),e.serialize(this)}static deserialize(e){return new z(e.deserializeU32())}}class c extends r{constructor(e){super(),t(e,BigInt(0),b),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.U64),e.serialize(this)}static deserialize(e){return new c(e.deserializeU64())}}class u extends r{constructor(e){super(),t(e,BigInt(0),U),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.U128),e.serialize(this)}static deserialize(e){return new u(e.deserializeU128())}}class a extends r{constructor(e){super(),t(e,BigInt(0),m),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){const i=this.bcsToBytes();e.serializeBytes(i)}serializeForScriptFunction(e){e.serializeU32AsUleb128(s.U256),e.serialize(this)}static deserialize(e){return new a(e.deserializeU256())}}export{l as Bool,u as U128,o as U16,a as U256,z as U32,c as U64,n as U8};
2
2
  //# sourceMappingURL=movePrimitives.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/bcs/serializable/movePrimitives.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} from \"../consts\";\nimport { Deserializer } from \"../deserializer\";\nimport { Serializable, Serializer, ensureBoolean, validateNumberInRange } from \"../serializer\";\nimport { TransactionArgument } from \"../../transactions/instances/transactionArgument\";\nimport { AnyNumber, Uint16, Uint32, Uint8, 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 *\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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 // eslint-disable-next-line class-methods-use-this\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\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"],"mappings":"AAGA,OACE,oBAAAA,EACA,kBAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,oBAAAC,MACK,YAEP,OAAS,gBAAAC,EAA0B,iBAAAC,EAAe,yBAAAC,MAA6B,gBAE/E,OAA2C,qCAAAC,MAAyC,cAW7E,MAAMC,UAAaJ,CAA4C,CAWpE,YAAYK,EAAgB,CAC1B,MAAM,EAWNJ,EAAcI,CAAK,EACnB,KAAK,MAAQA,CACf,CAUA,UAAUC,EAA8B,CACtCA,EAAW,cAAc,KAAK,KAAK,CACrC,CAUA,0BAA0BA,EAA8B,CACtD,MAAMC,EAAW,KAAK,WAAW,EACjCD,EAAW,eAAeC,CAAQ,CACpC,CAUA,2BAA2BD,EAA8B,CACvDA,EAAW,sBAAsBH,EAAkC,IAAI,EACvEG,EAAW,UAAU,IAAI,CAC3B,CAUA,YAAYE,EAA4B,CACtC,OAAO,IAAIC,EAAKD,EAAa,gBAAgB,CAAC,CAChD,CAEA,OAAO,YAAYA,EAAkC,CACnD,OAAO,IAAIJ,EAAKI,EAAa,gBAAgB,CAAC,CAChD,CACF,CAUO,MAAME,UAAWV,CAA4C,CAGlE,YAAYK,EAAc,CACxB,MAAM,EACNH,EAAsBG,EAAO,EAAGP,CAAa,EAC7C,KAAK,MAAQO,CACf,CAEA,UAAUC,EAA8B,CACtCA,EAAW,YAAY,KAA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AU,IAAI,CAC3B,CAEA,OAAO,YAAYE,EAAkC,CACnD,OAAO,IAAIC,EAAKD,EAAa,gBAAgB,CAAC,CAChD,CACF","names":["MAX_U128_BIG_INT","MAX_U16_NUMBER","MAX_U32_NUMBER","MAX_U64_BIG_INT","MAX_U8_NUMBER","MAX_U256_BIG_INT","Serializable","ensureBoolean","validateNumberInRange","ScriptTransactionArgumentVariants","Bool","value","serializer","bcsBytes","deserializer","U256","U8","U16","U32","U64","U128"]}
@@ -1,4 +1,4 @@
1
- export { k as MoveOption, j as MoveString, M as MoveVector, i as Serialized } from '../../account-ClxOwjdh.mjs';
1
+ export { k as MoveOption, j as MoveString, M as MoveVector, i as Serialized } from '../../account-BortO8g2.mjs';
2
2
  import '../../types/indexer.mjs';
3
3
  import '../../types/generated/operations.mjs';
4
4
  import '../../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a,b,c,d}from"../../chunk-Q4W3WJ2U.mjs";import"../../chunk-ORMOQWWH.mjs";import"../../chunk-FLZPUYXQ.mjs";import"../../chunk-FD6FGKYY.mjs";import"../../chunk-4WPQQPUF.mjs";import"../../chunk-IJE2LVZG.mjs";import"../../chunk-EBMEXURY.mjs";import"../../chunk-STY74NUA.mjs";import"../../chunk-IF4UU2MT.mjs";import"../../chunk-56CNRT2K.mjs";import"../../chunk-KDMSOCZY.mjs";export{d as MoveOption,c as MoveString,a as MoveVector,b as Serialized};
1
+ import{Bool as d,U128 as z,U16 as m,U256 as U,U32 as y,U64 as p,U8 as l}from"./movePrimitives";import{Serializable as s}from"../serializer";import{Deserializer as A}from"../deserializer";import{ScriptTransactionArgumentVariants as w}from"../../types";import{Hex as b}from"../../core/hex";class i extends s{constructor(e){super(),this.values=e}serializeForEntryFunction(e){const r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof l)){new u(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(w.U8Vector),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&e.length===0)r=[];else if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){const n=b.fromHexInput(e);r=Array.from(n.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new i(r.map(n=>new l(n)))}static U16(e){return new i(e.map(r=>new m(r)))}static U32(e){return new i(e.map(r=>new y(r)))}static U64(e){return new i(e.map(r=>new p(r)))}static U128(e){return new i(e.map(r=>new z(r)))}static U256(e){return new i(e.map(r=>new U(r)))}static Bool(e){return new i(e.map(r=>new d(r)))}static MoveString(e){return new i(e.map(r=>new o(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){const n=e.deserializeUleb128AsU32(),a=new Array;for(let c=0;c<n;c+=1)a.push(r.deserialize(e));return new i(a)}}class u extends s{constructor(e){super(),this.value=b.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(w.Serialized),this.serialize(e)}static deserialize(e){return new u(e.deserializeBytes())}toMoveVector(e){const r=new A(this.bcsToBytes());r.deserializeUleb128AsU32();const n=r.deserializeVector(e);return new i(n)}}class o extends s{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){const r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){const n=new TextEncoder().encode(this.value);i.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new o(e.deserializeStr())}}class t extends s{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new i([e]):this.vec=new i([]),[this.value]=this.vec.values}serializeForEntryFunction(e){const r=this.bcsToBytes();e.serializeBytes(r)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new t(e!=null?new l(e):void 0)}static U16(e){return new t(e!=null?new m(e):void 0)}static U32(e){return new t(e!=null?new y(e):void 0)}static U64(e){return new t(e!=null?new p(e):void 0)}static U128(e){return new t(e!=null?new z(e):void 0)}static U256(e){return new t(e!=null?new U(e):void 0)}static Bool(e){return new t(e!=null?new d(e):void 0)}static MoveString(e){return new t(e!=null?new o(e):void 0)}static deserialize(e,r){const n=i.deserialize(e,r);return new t(n.values[0])}}export{t as MoveOption,o as MoveString,i as MoveVector,u as Serialized};
2
2
  //# sourceMappingURL=moveStructs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../../src/bcs/serializable/moveStructs.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Bool, U128, U16, U256, U32, U64, U8 } from \"./movePrimitives\";\nimport { Serializable, Serializer } from \"../serializer\";\nimport { Deserializable, Deserializer } from \"../deserializer\";\nimport { AnyNumber, HexInput, ScriptTransactionArgumentVariants } from \"../../types\";\nimport { Hex } from \"../../core/hex\";\nimport { EntryFunctionArgument, TransactionArgument } from \"../../transactions/instances/transactionArgument\";\n\n/**\n * This class is the Aptos Typescript SDK representation of a Move `vector<T>`,\n * where `T` represents either a primitive type (`bool`, `u8`, `u64`, ...)\n * or a BCS-serializable struct itself.\n *\n * It is a BCS-serializable, array-like type that contains an array of values of type `T`,\n * where `T` is a class that implements `Serializable`.\n *\n * The purpose of this class is to facilitate easy construction of BCS-serializable\n * Move `vector<T>` types.\n *\n * @example\n * // in Move: `vector<u8> [1, 2, 3, 4];`\n * const vecOfU8s = new MoveVector<U8>([new U8(1), new U8(2), new U8(3), new U8(4)]);\n * // in Move: `std::bcs::to_bytes(vector<u8> [1, 2, 3, 4]);`\n * const bcsBytes = vecOfU8s.toUint8Array();\n *\n * // vector<vector<u8>> [ vector<u8> [1], vector<u8> [1, 2, 3, 4], vector<u8> [5, 6, 7, 8] ];\n * const vecOfVecs = new MoveVector<MoveVector<U8>>([\n * new MoveVector<U8>([new U8(1)]),\n * MoveVector.U8([1, 2, 3, 4]),\n * MoveVector.U8([5, 6, 7, 8]),\n * ]);\n *\n * // vector<Option<u8>> [ std::option::some<u8>(1), std::option::some<u8>(2) ];\n * const vecOfOptionU8s = new MoveVector<MoveOption<U8>>([\n * MoveOption.U8(1),\n * MoveOption.U8(2),\n * ]);\n *\n * // vector<MoveString> [ std::string::utf8(b\"hello\"), std::string::utf8(b\"world\") ];\n * const vecOfStrings = new MoveVector([new MoveString(\"hello\"), new MoveString(\"world\")]);\n * const vecOfStrings2 = MoveVector.MoveString([\"hello\", \"world\"]);\n *\n * @param values an Array<T> of values where T is a class that implements Serializable\n * @returns a `MoveVector<T>` with the values `values`\n * @group Implementation\n * @category BCS\n */\nexport class MoveVector<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements TransactionArgument\n{\n public values: Array<T>;\n\n /**\n * Initializes a new instance of the class with an optional value.\n * This constructor sets up the internal vector based on the provided value.\n *\n * @param values - The initial value to be stored in the vector, or null to initialize an empty vector.\n * @group Implementation\n * @category BCS\n */\n constructor(values: Array<T>) {\n super();\n this.values = values;\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows the data to be properly formatted for transmission or storage.\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 const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * NOTE: This function will only work when the inner values in the `MoveVector` are `U8`s.\n * @param serializer\n * @group Implementation\n * @category BCS\n */\n\n /**\n * Serialize the string as a fixed byte string without the length prefix for use in a script function.\n * @param serializer - The serializer used to convert the byte vector into a format suitable for a script function.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n // This checks if the type of a non-empty vector is of type other than U8. If so, we use the Serialized\n // transaction argument type to serialize the argument.\n if (this.values[0] !== undefined && !(this.values[0] instanceof U8)) {\n const serialized = new Serialized(this.bcsToBytes());\n serialized.serializeForScriptFunction(serializer);\n return;\n }\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8Vector);\n serializer.serialize(this);\n }\n\n /**\n * Factory method to generate a MoveVector<U8> from a `number` or `undefined`.\n *\n * This method allows you to create a MoveVector that encapsulates a U8 value, enabling you to handle optional U8 values\n * effectively.\n *\n * @param values - The values used to fill the MoveVector. If `values` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U8> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U8([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U8(values: Array<number> | HexInput): MoveVector<U8> {\n let numbers: Array<number>;\n\n if (Array.isArray(values) && values.length === 0) {\n // Handle empty array, since it won't have a \"first value\"\n numbers = [];\n } else if (Array.isArray(values) && typeof values[0] === \"number\") {\n numbers = values;\n } else if (typeof values === \"string\") {\n const hex = Hex.fromHexInput(values);\n numbers = Array.from(hex.toUint8Array());\n } else if (values instanceof Uint8Array) {\n numbers = Array.from(values);\n } else {\n throw new Error(\"Invalid input type, must be an number[], Uint8Array, or hex string\");\n }\n\n return new MoveVector<U8>(numbers.map((v) => new U8(v)));\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `null`.\n *\n * This method allows you to create a MoveVector that can either hold a U16 value or be empty.\n *\n * @param values - The value used to fill the MoveVector. If `value` is null or undefined, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U16> with an inner value `value`.\n * @example\n * ```typescript\n * const v = MoveVector.U16([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n\n */\n static U16(values: Array<number>): MoveVector<U16> {\n return new MoveVector<U16>(values.map((v) => new U16(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U32> from a `number` or `null`.\n *\n * This method allows you to create a MoveVector that can either hold a U32 value or be empty.\n *\n * @param values - The value used to fill the MoveVector. If `value` is null or undefined,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U32> with an inner value `value`.\n *\n * @example\n * ```\n * const v = MoveVector.U32([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n\n */\n static U32(values: Array<number>): MoveVector<U32> {\n return new MoveVector<U32>(values.map((v) => new U32(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U64> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U64 value that can be checked for presence.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U64> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U64([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U64(values: Array<AnyNumber>): MoveVector<U64> {\n return new MoveVector<U64>(values.map((v) => new U64(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U128> from a number, bigint, or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's `.isSome()`\n * method will return false.\n * @returns A MoveVector<U128> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U128([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U128(values: Array<AnyNumber>): MoveVector<U128> {\n return new MoveVector<U128>(values.map((v) => new U128(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U256> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U256 value, enabling checks for presence or absence of a value.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U256> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U256([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U256(values: Array<AnyNumber>): MoveVector<U256> {\n return new MoveVector<U256>(values.map((v) => new U256(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<Bool> from a `boolean` or `undefined`.\n * This method allows you to create an optional boolean value that can be used in various contexts where a boolean may or may\n * not be present.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<Bool> with an inner value `value`.\n *\n * @example\n * * const v = MoveVector.Bool([true, false, true, false]);\n * @group Implementation\n * @category BCS\n */\n static Bool(values: Array<boolean>): MoveVector<Bool> {\n return new MoveVector<Bool>(values.map((v) => new Bool(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<MoveString> from a `string` or `undefined`.\n * This function creates a MoveVector that encapsulates a MoveString if the provided value is not null or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<MoveString> with an inner value `value`.\n *\n * @example\n * const v = MoveVector.MoveString([\"hello\", \"world\"]);\n * @group Implementation\n * @category BCS\n */\n static MoveString(values: Array<string>): MoveVector<MoveString> {\n return new MoveVector<MoveString>(values.map((v) => new MoveString(v)));\n }\n\n /**\n * Serializes the current object using the provided serializer.\n * This function will serialize the value if it is present.\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 serialize(serializer: Serializer): void {\n serializer.serializeVector(this.values);\n }\n\n /**\n * Deserialize a MoveVector of type T, specifically where T is a Serializable and Deserializable type.\n *\n * NOTE: This only works with a depth of one. Generics will not work.\n *\n * NOTE: This will not work with types that aren't of the Serializable class.\n *\n * If you're looking for a more flexible deserialization function, you can use the deserializeVector function\n * in the Deserializer class.\n *\n * @example\n * const vec = MoveVector.deserialize(deserializer, U64);\n * @param deserializer the Deserializer instance to use, with bytes loaded into it already.\n * @param cls the class to typecast the input values to, must be a Serializable and Deserializable type.\n * @returns a MoveVector of the corresponding class T\n *\n * @group Implementation\n * @category BCS\n */\n static deserialize<T extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<T>,\n ): MoveVector<T> {\n const length = deserializer.deserializeUleb128AsU32();\n const values = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n values.push(cls.deserialize(deserializer));\n }\n return new MoveVector(values);\n }\n}\n\n/**\n * Represents a serialized data structure that encapsulates a byte array.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of byte data, as well as converting to a MoveVector.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class Serialized extends Serializable implements TransactionArgument {\n public readonly value: Uint8Array;\n\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n this.serialize(serializer);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Serialized);\n this.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Serialized {\n return new Serialized(deserializer.deserializeBytes());\n }\n\n /**\n * Deserialize the bytecode into a MoveVector of the specified type.\n * This function allows you to convert serialized data into a usable MoveVector format.\n *\n * @param cls - The class type of the elements in the MoveVector.\n * @group Implementation\n * @category BCS\n */\n toMoveVector<T extends Serializable & EntryFunctionArgument>(cls: Deserializable<T>): MoveVector<T> {\n const deserializer = new Deserializer(this.bcsToBytes());\n deserializer.deserializeUleb128AsU32();\n const vec = deserializer.deserializeVector(cls);\n return new MoveVector(vec);\n }\n}\n\n/**\n * Represents a string value that can be serialized and deserialized.\n * This class extends the Serializable base class and provides methods\n * for serializing the string in different contexts, such as for entry\n * functions and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class MoveString extends Serializable implements TransactionArgument {\n public value: string;\n\n constructor(value: string) {\n super();\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n // Serialize the string as a fixed byte string, i.e., without the length prefix\n const textEncoder = new TextEncoder();\n const fixedStringBytes = textEncoder.encode(this.value);\n // Put those bytes into a vector<u8> and serialize it as a script function argument\n const vectorU8 = MoveVector.U8(fixedStringBytes);\n vectorU8.serializeForScriptFunction(serializer);\n }\n\n static deserialize(deserializer: Deserializer): MoveString {\n return new MoveString(deserializer.deserializeStr());\n }\n}\n\nexport class MoveOption<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements EntryFunctionArgument\n{\n private vec: MoveVector<T>;\n\n public readonly value?: T;\n\n constructor(value?: T | null) {\n super();\n if (typeof value !== \"undefined\" && value !== null) {\n this.vec = new MoveVector([value]);\n } else {\n this.vec = new MoveVector([]);\n }\n\n [this.value] = this.vec.values;\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Retrieves the inner value of the MoveOption.\n *\n * This method is inspired by Rust's `Option<T>.unwrap()`, where attempting to unwrap a `None` value results in a panic.\n * This method will throw an error if the value is not present.\n *\n * @example\n * const option = new MoveOption<Bool>(new Bool(true));\n * const value = option.unwrap(); // Returns the Bool instance\n *\n * @throws {Error} Throws an error if the MoveOption does not contain a value.\n *\n * @returns {T} The contained value if present.\n * @group Implementation\n * @category BCS\n */\n unwrap(): T {\n if (!this.isSome()) {\n throw new Error(\"Called unwrap on a MoveOption with no value\");\n } else {\n return this.vec.values[0];\n }\n }\n\n /**\n * Check if the MoveOption has a value.\n *\n * @returns {boolean} Returns true if there is exactly one value in the MoveOption.\n * @group Implementation\n * @category BCS\n */\n isSome(): boolean {\n return this.vec.values.length === 1;\n }\n\n serialize(serializer: Serializer): void {\n // serialize 0 or 1\n // if 1, serialize the value\n this.vec.serialize(serializer);\n }\n\n /**\n * Factory method to generate a MoveOption<U8> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U8(1).isSome() === true;\n * MoveOption.U8().isSome() === false;\n * MoveOption.U8(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U8> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U8(value?: number | null): MoveOption<U8> {\n return new MoveOption<U8>(value !== null && value !== undefined ? new U8(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U16(1).isSome() === true;\n * MoveOption.U16().isSome() === false;\n * MoveOption.U16(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U16> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U16(value?: number | null): MoveOption<U16> {\n return new MoveOption<U16>(value !== null && value !== undefined ? new U16(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U32> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U32(1).isSome() === true;\n * MoveOption.U32().isSome() === false;\n * MoveOption.U32(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U32> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U32(value?: number | null): MoveOption<U32> {\n return new MoveOption<U32>(value !== null && value !== undefined ? new U32(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U64> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U64(1).isSome() === true;\n * MoveOption.U64().isSome() === false;\n * MoveOption.U64(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U64> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U64(value?: AnyNumber | null): MoveOption<U64> {\n return new MoveOption<U64>(value !== null && value !== undefined ? new U64(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U128> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U128(1).isSome() === true;\n * MoveOption.U128().isSome() === false;\n * MoveOption.U128(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U128> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U128(value?: AnyNumber | null): MoveOption<U128> {\n return new MoveOption<U128>(value !== null && value !== undefined ? new U128(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U256> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U256(1).isSome() === true;\n * MoveOption.U256().isSome() === false;\n * MoveOption.U256(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U256> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U256(value?: AnyNumber | null): MoveOption<U256> {\n return new MoveOption<U256>(value !== null && value !== undefined ? new U256(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<Bool> from a `boolean` or `undefined`.\n *\n * @example\n * MoveOption.Bool(true).isSome() === true;\n * MoveOption.Bool().isSome() === false;\n * MoveOption.Bool(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<Bool> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static Bool(value?: boolean | null): MoveOption<Bool> {\n return new MoveOption<Bool>(value !== null && value !== undefined ? new Bool(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<MoveString> from a `string` or `undefined`.\n *\n * @example\n * MoveOption.MoveString(\"hello\").isSome() === true;\n * MoveOption.MoveString(\"\").isSome() === true;\n * MoveOption.MoveString().isSome() === false;\n * MoveOption.MoveString(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<MoveString> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static MoveString(value?: string | null): MoveOption<MoveString> {\n return new MoveOption<MoveString>(value !== null && value !== undefined ? new MoveString(value) : undefined);\n }\n\n static deserialize<U extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<U>,\n ): MoveOption<U> {\n const vector = MoveVector.deserialize(deserializer, cls);\n return new MoveOption(vector.values[0]);\n }\n}\n"],"mappings":"AAGA,OAAS,QAAAA,EAAM,QAAAC,EAAM,OAAAC,EAAK,QAAAC,EAAM,OAAAC,EAAK,OAAAC,EAAK,MAAAC,MAAU,mBACpD,OAAS,gBAAAC,MAAgC,gBACzC,OAAyB,gBAAAC,MAAoB,kBAC7C,OAA8B,qCAAAC,MAAyC,cACvE,OAAS,OAAAC,MAAW,iBA0Cb,MAAMC,UACHJ,CAEV,CAWE,YAAYK,EAAkB,CAC5B,MAAM,EACN,KAAK,OAASA,CAChB,CAUA,0BAA0BC,EAA8B,CACtD,MAAMC,EAAW,KAAK,WAAW,EACjCD,EAAW,eAAeC,CAAQ,CACpC,CAeA,2BAA2BD,EAA8B,CAGvD,GAAI,KAAK,OAAO,CAAC,IAAM,QAAa,EAAE,KAAK,OAAO,CAAC,YAAaP,GAAK,CAChD,IAAIS,EAAW,KAAK,WAAW,CAAC,EACxC,2BAA2BF,CAAU,EAChD,MACF,CACAA,EAAW,sBAAsBJ,EAAkC,QAAQ,EAC3EI,EAAW,UAAU,IAAI,CAC3B,CAmBA,OAAO,GAAGD,EAAkD,CAC1D,IAAII,EAEJ,GAAI,MAAM,QAAQJ,CAAM,GAAKA,EAAO,SAAW,EAE7CI,EAAU,CAAC,UACF,MAAM,QAAQJ,CAAM,GAAK,OAAOA,EAAO,CAAC,GAAM,SACvDI,EAAUJ,UACD,OAAOA,GAAW,SAAU,CACrC,MAAMK,EAAMP,EAAI,aAAaE,CAAM,EACnCI,EAAU,MAAM,KAAKC,EAAI,aAAa,CAAC,CACzC,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AC7G,CAEA,OAAO,YACLJ,EACAC,EACe,CACf,MAAMO,EAASjB,EAAW,YAAYS,EAAcC,CAAG,EACvD,OAAO,IAAIM,EAAWC,EAAO,OAAO,CAAC,CAAC,CACxC,CACF","names":["Bool","U128","U16","U256","U32","U64","U8","Serializable","Deserializer","ScriptTransactionArgumentVariants","Hex","MoveVector","values","serializer","bcsBytes","Serialized","numbers","hex","v","MoveString","deserializer","cls","length","i","value","vec","fixedStringBytes","MoveOption","vector"]}
@@ -1,4 +1,4 @@
1
- export { S as Serializable, b as Serializer, e as ensureBoolean, o as outOfRangeErrorMessage, v as validateNumberInRange } from '../account-ClxOwjdh.mjs';
1
+ export { S as Serializable, b as Serializer, e as ensureBoolean, o as outOfRangeErrorMessage, v as validateNumberInRange } from '../account-BortO8g2.mjs';
2
2
  import '../types/indexer.mjs';
3
3
  import '../types/generated/operations.mjs';
4
4
  import '../types/generated/types.mjs';
@@ -1,2 +1,2 @@
1
- import{a,b,c,d,e}from"../chunk-EBMEXURY.mjs";import"../chunk-STY74NUA.mjs";import"../chunk-IF4UU2MT.mjs";import"../chunk-56CNRT2K.mjs";import"../chunk-KDMSOCZY.mjs";export{a as Serializable,b as Serializer,c as ensureBoolean,d as outOfRangeErrorMessage,e as validateNumberInRange};
1
+ var y=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=(r,e,i,t)=>{for(var n=t>1?void 0:t?c(e,i):e,f=r.length-1,l;f>=0;f--)(l=r[f])&&(n=(t?l(e,i,n):l(n))||n);return t&&n&&y(e,i,n),n};import{MAX_U128_BIG_INT as b,MAX_U16_NUMBER as B,MAX_U32_NUMBER as h,MAX_U64_BIG_INT as U,MAX_U8_NUMBER as g,MAX_U256_BIG_INT as z}from"./consts";import{Hex as p}from"../core/hex";class S{bcsToBytes(){const e=new o;return this.serialize(e),e.toUint8Array()}bcsToHex(){const e=this.bcsToBytes();return p.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}}class o{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){const i=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(i).set(new Uint8Array(this.buffer)),this.buffer=i}}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);const n=new DataView(this.buffer,this.offset);e.apply(n,[0,t,!0]),this.offset+=i}serializeStr(e){const i=new TextEncoder;this.serializeBytes(i.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){A(e);const 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){const i=BigInt(e)&BigInt(h),t=BigInt(e)>>BigInt(32);this.serializeU32(Number(i)),this.serializeU32(Number(t))}serializeU128(e){const i=BigInt(e)&U,t=BigInt(e)>>BigInt(64);this.serializeU64(i),this.serializeU64(t)}serializeU256(e){const i=BigInt(e)&b,t=BigInt(e)>>BigInt(128);this.serializeU128(i),this.serializeU128(t)}serializeU32AsUleb128(e){let i=e;const 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).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(i=>{i.serialize(this)})}serializeOption(e,i){const 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([a(0,g)],o.prototype,"serializeU8",1),s([a(0,B)],o.prototype,"serializeU16",1),s([a(0,h)],o.prototype,"serializeU32",1),s([a(BigInt(0),U)],o.prototype,"serializeU64",1),s([a(BigInt(0),b)],o.prototype,"serializeU128",1),s([a(BigInt(0),z)],o.prototype,"serializeU256",1),s([a(0,h)],o.prototype,"serializeU32AsUleb128",1);function A(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}const d=(r,e,i)=>`${r} is out of range: [${e}, ${i}]`;function w(r,e,i){const t=BigInt(r);if(t>BigInt(i)||t<BigInt(e))throw new Error(d(r,e,i))}function a(r,e){return(i,t,n)=>{const f=n.value;return n.value=function(u){return w(u,r,e),f.apply(this,[u])},n}}export{S as Serializable,o as Serializer,A as ensureBoolean,d as outOfRangeErrorMessage,w as validateNumberInRange};
2
2
  //# sourceMappingURL=serializer.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../../../src/bcs/serializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\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} from \"./consts\";\nimport { Hex } from \"../core/hex\";\nimport { AnyNumber, Uint16, Uint32, Uint8 } from \"../types\";\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 * 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 * 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.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 if the current size is insufficient.\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 while (this.buffer.byteLength < this.offset + bytes) {\n const newBuffer = new ArrayBuffer(this.buffer.byteLength * 2);\n new Uint8Array(newBuffer).set(new Uint8Array(this.buffer));\n this.buffer = newBuffer;\n }\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 *\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 const dv = new DataView(this.buffer, this.offset);\n fn.apply(dv, [0, 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 const textEncoder = new TextEncoder();\n this.serializeBytes(textEncoder.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 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 *\n * @returns Uint8Array - The byte array representation of the buffer.\n * @group Implementation\n * @category BCS\n */\n toUint8Array(): Uint8Array {\n return new Uint8Array(this.buffer).slice(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 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 // eslint-disable-next-line no-param-reassign\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":"wMAIA,OACE,oBAAAA,EACA,kBAAAC,EACA,kBAAAC,EACA,mBAAAC,EACA,iBAAAC,EACA,oBAAAC,MACK,WACP,OAAS,OAAAC,MAAW,cAUb,MAAeC,CAAa,CAUjC,YAAyB,CACvB,MAAMC,EAAa,IAAIC,EACvB,YAAK,UAAUD,CAAU,EAClBA,EAAW,a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AOpB,CAAK,EAChC,GAAIoB,EAAc,OAAOD,CAAQ,GAAKC,EAAc,OAAOF,CAAQ,EACjE,MAAM,IAAI,MAAMJ,EAAuBd,EAAOkB,EAAUC,CAAQ,CAAC,CAErE,CAWA,SAASN,EAAsCK,EAAaC,EAAa,CACvE,MAAO,CAACE,EAAiBC,EAAqBC,IAAmC,CAC/E,MAAMC,EAAgBD,EAAW,MAEjC,OAAAA,EAAW,MAAQ,SAAcvB,EAAkB,CACjD,OAAAiB,EAAsBjB,EAAOkB,EAAUC,CAAQ,EACxCK,EAAc,MAAM,KAAM,CAACxB,CAAK,CAAC,CAC1C,EAEOuB,CACT,CACF","names":["MAX_U128_BIG_INT","MAX_U16_NUMBER","MAX_U32_NUMBER","MAX_U64_BIG_INT","MAX_U8_NUMBER","MAX_U256_BIG_INT","Hex","Serializable","serializer","Serializer","bcsBytes","length","bytes","newBuffer","values","fn","bytesLength","value","dv","textEncoder","ensureBoolean","byteValue","low","high","val","valueArray","item","len","hasValue","__decorateClass","checkNumberRange","outOfRangeErrorMessage","min","max","validateNumberInRange","minValue","maxValue","valueBigInt","target","propertyKey","descriptor","childFunction"]}
@@ -1,7 +1,7 @@
1
1
  export { LocalNode } from './localNode.mjs';
2
2
  export { Move } from './move.mjs';
3
3
  import 'child_process';
4
- import '../account-ClxOwjdh.mjs';
4
+ import '../account-BortO8g2.mjs';
5
5
  import '../types/indexer.mjs';
6
6
  import '../types/generated/operations.mjs';
7
7
  import '../types/generated/types.mjs';