@aptos-labs/ts-sdk 1.16.0 → 1.17.0-zeta.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 (501) hide show
  1. package/dist/common/{accountAddress-ccLvlUQe.d.ts → accountAddress-jP2Ua0t9.d.ts} +97 -5
  2. package/dist/common/chunk-BHKSQXUZ.js +2 -0
  3. package/dist/common/chunk-BHKSQXUZ.js.map +1 -0
  4. package/dist/common/cli/index.d.ts +1 -1
  5. package/dist/common/cli/index.js +1 -1
  6. package/dist/common/index.d.ts +862 -122
  7. package/dist/common/index.js +28 -28
  8. package/dist/common/index.js.map +1 -1
  9. package/dist/esm/{Ed25519Account-B1VMJOY2.d.mts → Ed25519Account-9zBaZEnp.d.mts} +1 -1
  10. package/dist/esm/account/Account.d.mts +2 -2
  11. package/dist/esm/account/Account.mjs +1 -1
  12. package/dist/esm/account/Ed25519Account.d.mts +2 -2
  13. package/dist/esm/account/Ed25519Account.mjs +1 -1
  14. package/dist/esm/account/EphemeralKeyPair.d.mts +90 -0
  15. package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
  16. package/dist/esm/account/KeylessAccount.d.mts +211 -0
  17. package/dist/esm/account/KeylessAccount.mjs +2 -0
  18. package/dist/esm/account/MultiKeyAccount.d.mts +13 -7
  19. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  20. package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
  21. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  22. package/dist/esm/account/index.d.mts +9 -2
  23. package/dist/esm/account/index.mjs +1 -1
  24. package/dist/esm/api/account.d.mts +4 -4
  25. package/dist/esm/api/account.mjs +1 -1
  26. package/dist/esm/api/ans.d.mts +4 -4
  27. package/dist/esm/api/ans.mjs +1 -1
  28. package/dist/esm/api/aptos.d.mts +12 -3
  29. package/dist/esm/api/aptos.mjs +1 -1
  30. package/dist/esm/api/aptosConfig.d.mts +20 -0
  31. package/dist/esm/api/aptosConfig.mjs +1 -1
  32. package/dist/esm/api/coin.d.mts +5 -5
  33. package/dist/esm/api/coin.mjs +1 -1
  34. package/dist/esm/api/digitalAsset.d.mts +6 -6
  35. package/dist/esm/api/digitalAsset.mjs +1 -1
  36. package/dist/esm/api/event.d.mts +1 -1
  37. package/dist/esm/api/event.mjs +1 -1
  38. package/dist/esm/api/faucet.mjs +1 -1
  39. package/dist/esm/api/fungibleAsset.d.mts +3 -3
  40. package/dist/esm/api/fungibleAsset.mjs +1 -1
  41. package/dist/esm/api/general.d.mts +3 -3
  42. package/dist/esm/api/general.mjs +1 -1
  43. package/dist/esm/api/index.d.mts +10 -2
  44. package/dist/esm/api/index.mjs +1 -1
  45. package/dist/esm/api/keyless.d.mts +85 -0
  46. package/dist/esm/api/keyless.mjs +2 -0
  47. package/dist/esm/api/keyless.mjs.map +1 -0
  48. package/dist/esm/api/staking.d.mts +2 -2
  49. package/dist/esm/api/staking.mjs +1 -1
  50. package/dist/esm/api/table.d.mts +1 -1
  51. package/dist/esm/api/table.mjs +1 -1
  52. package/dist/esm/api/transaction.d.mts +3 -3
  53. package/dist/esm/api/transaction.mjs +1 -1
  54. package/dist/esm/api/transactionSubmission/build.d.mts +3 -3
  55. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  56. package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
  57. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  58. package/dist/esm/api/transactionSubmission/sign.d.mts +4 -4
  59. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  60. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  61. package/dist/esm/api/transactionSubmission/simulate.d.mts +3 -3
  62. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  63. package/dist/esm/api/transactionSubmission/submit.d.mts +3 -3
  64. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  65. package/dist/esm/api/utils.mjs +1 -1
  66. package/dist/esm/bcs/deserializer.d.mts +32 -0
  67. package/dist/esm/bcs/deserializer.mjs +1 -1
  68. package/dist/esm/bcs/index.mjs +1 -1
  69. package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
  70. package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
  71. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  72. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  73. package/dist/esm/bcs/serializer.d.mts +42 -0
  74. package/dist/esm/bcs/serializer.mjs +1 -1
  75. package/dist/esm/chunk-2G4IGSGM.mjs +2 -0
  76. package/dist/esm/{chunk-XHEZAVN3.mjs.map → chunk-2G4IGSGM.mjs.map} +1 -1
  77. package/dist/esm/chunk-37FFZSIM.mjs +2 -0
  78. package/dist/esm/chunk-37FFZSIM.mjs.map +1 -0
  79. package/dist/esm/chunk-3IFR6T3V.mjs +2 -0
  80. package/dist/esm/chunk-3IFR6T3V.mjs.map +1 -0
  81. package/dist/esm/chunk-3RJZNUCQ.mjs +2 -0
  82. package/dist/esm/chunk-3SACE4I2.mjs +2 -0
  83. package/dist/esm/{chunk-T2WZWN6W.mjs.map → chunk-3SACE4I2.mjs.map} +1 -1
  84. package/dist/esm/chunk-472OGHMG.mjs +2 -0
  85. package/dist/esm/chunk-4BJA3QUQ.mjs +2 -0
  86. package/dist/esm/{chunk-NYXLPBKE.mjs.map → chunk-4BJA3QUQ.mjs.map} +1 -1
  87. package/dist/esm/chunk-4CUDBBTC.mjs +2 -0
  88. package/dist/esm/chunk-4CUDBBTC.mjs.map +1 -0
  89. package/dist/esm/chunk-4VPCPASN.mjs +2 -0
  90. package/dist/esm/chunk-54LCK6EN.mjs +2 -0
  91. package/dist/esm/chunk-54LCK6EN.mjs.map +1 -0
  92. package/dist/esm/{chunk-OLKEU7WZ.mjs → chunk-5WFKJO5L.mjs} +2 -2
  93. package/dist/esm/{chunk-HZ3YB6TN.mjs → chunk-64CUEMFI.mjs} +2 -2
  94. package/dist/esm/{chunk-LM7CN4LT.mjs → chunk-64VPA7CM.mjs} +2 -2
  95. package/dist/esm/{chunk-GHYE26Q5.mjs → chunk-6FBKUTGF.mjs} +2 -2
  96. package/dist/esm/chunk-7BW2N4IE.mjs +2 -0
  97. package/dist/esm/{chunk-UF5B4XMN.mjs → chunk-7G3RSOWE.mjs} +2 -2
  98. package/dist/esm/{chunk-AKJZL3HT.mjs → chunk-7M4C4OZN.mjs} +2 -2
  99. package/dist/esm/{chunk-DO444YYD.mjs → chunk-7UKBRLGM.mjs} +2 -2
  100. package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
  101. package/dist/esm/chunk-7Z6DYLCA.mjs.map +1 -0
  102. package/dist/esm/{chunk-BCUSI3N6.mjs → chunk-AOCNYMMX.mjs} +2 -2
  103. package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
  104. package/dist/esm/chunk-AQ4I7VVB.mjs.map +1 -0
  105. package/dist/esm/{chunk-YMHX6GC2.mjs → chunk-B2RYTKNN.mjs} +2 -2
  106. package/dist/esm/chunk-BCZGONNO.mjs +2 -0
  107. package/dist/esm/chunk-BCZGONNO.mjs.map +1 -0
  108. package/dist/esm/chunk-BLWJZXAD.mjs +2 -0
  109. package/dist/esm/chunk-BLWJZXAD.mjs.map +1 -0
  110. package/dist/esm/{chunk-JWTZDA6A.mjs → chunk-BO44HPGU.mjs} +2 -2
  111. package/dist/esm/{chunk-DPWXEJP6.mjs → chunk-BT6IM25V.mjs} +2 -2
  112. package/dist/esm/chunk-CPDSBH23.mjs +2 -0
  113. package/dist/esm/chunk-CPDSBH23.mjs.map +1 -0
  114. package/dist/esm/chunk-DJPYZIJY.mjs +2 -0
  115. package/dist/esm/chunk-DJPYZIJY.mjs.map +1 -0
  116. package/dist/esm/{chunk-JNDRFTEA.mjs → chunk-DPWEHSHH.mjs} +2 -2
  117. package/dist/esm/{chunk-WNVUG2UF.mjs → chunk-EFMAZTIM.mjs} +2 -2
  118. package/dist/esm/chunk-EHL3WIK3.mjs +2 -0
  119. package/dist/esm/chunk-EHL3WIK3.mjs.map +1 -0
  120. package/dist/esm/{chunk-UEI62FBQ.mjs → chunk-F3ZVWLDH.mjs} +2 -2
  121. package/dist/esm/{chunk-UEI62FBQ.mjs.map → chunk-F3ZVWLDH.mjs.map} +1 -1
  122. package/dist/esm/chunk-FBPNHF54.mjs +2 -0
  123. package/dist/esm/{chunk-YJIRT3GJ.mjs → chunk-FGGRPEQ3.mjs} +2 -2
  124. package/dist/esm/chunk-FIG65OJD.mjs +2 -0
  125. package/dist/esm/{chunk-ISIUQQMV.mjs → chunk-FNFQA7NS.mjs} +2 -2
  126. package/dist/esm/{chunk-XXBMHWNV.mjs → chunk-FR6UGCOX.mjs} +2 -2
  127. package/dist/esm/chunk-FR6UGCOX.mjs.map +1 -0
  128. package/dist/esm/{chunk-HMTYASEZ.mjs → chunk-FSO54CI4.mjs} +2 -2
  129. package/dist/esm/{chunk-DBC2JY65.mjs → chunk-GBQU2OCK.mjs} +2 -2
  130. package/dist/esm/{chunk-FW6TF3O2.mjs → chunk-GPWSPT44.mjs} +2 -2
  131. package/dist/esm/{chunk-QKV2H27T.mjs → chunk-GQC73XWZ.mjs} +2 -2
  132. package/dist/esm/chunk-GRHLQDHF.mjs +2 -0
  133. package/dist/esm/chunk-GSCM444Z.mjs +2 -0
  134. package/dist/esm/{chunk-VJL6AF64.mjs → chunk-HGJMVOBH.mjs} +2 -2
  135. package/dist/esm/chunk-HP6YVTTT.mjs +2 -0
  136. package/dist/esm/{chunk-LGOZUIGE.mjs.map → chunk-HP6YVTTT.mjs.map} +1 -1
  137. package/dist/esm/{chunk-MEXWNZY6.mjs → chunk-HXYZECGS.mjs} +2 -2
  138. package/dist/esm/chunk-IBDBKQMF.mjs +2 -0
  139. package/dist/esm/chunk-IBDBKQMF.mjs.map +1 -0
  140. package/dist/esm/chunk-IBN7ETCB.mjs +2 -0
  141. package/dist/esm/{chunk-5NSXEM3O.mjs.map → chunk-IBN7ETCB.mjs.map} +1 -1
  142. package/dist/esm/{chunk-LKVJZTBM.mjs → chunk-IPFITPKC.mjs} +2 -2
  143. package/dist/esm/chunk-IPFITPKC.mjs.map +1 -0
  144. package/dist/esm/chunk-IT7YNITU.mjs +2 -0
  145. package/dist/esm/chunk-IVVWQKCF.mjs +2 -0
  146. package/dist/esm/chunk-IVVWQKCF.mjs.map +1 -0
  147. package/dist/esm/{chunk-TZCETTAW.mjs → chunk-IXFYYWAC.mjs} +2 -2
  148. package/dist/esm/chunk-J3DCBYOY.mjs +2 -0
  149. package/dist/esm/chunk-J3DCBYOY.mjs.map +1 -0
  150. package/dist/esm/{chunk-OOH7MH2H.mjs → chunk-JZOTXY77.mjs} +2 -2
  151. package/dist/esm/chunk-L5CPAOUM.mjs +2 -0
  152. package/dist/esm/chunk-L5CPAOUM.mjs.map +1 -0
  153. package/dist/esm/{chunk-FLUCRNGU.mjs → chunk-L5ZHZWHI.mjs} +2 -2
  154. package/dist/esm/chunk-LDQJ5S77.mjs +2 -0
  155. package/dist/esm/chunk-LDQJ5S77.mjs.map +1 -0
  156. package/dist/esm/{chunk-YTJ73ZX3.mjs → chunk-LIT6V2A6.mjs} +2 -2
  157. package/dist/esm/{chunk-S5AGI7RQ.mjs → chunk-MLX6DFMR.mjs} +2 -2
  158. package/dist/esm/chunk-MNTLX37G.mjs +2 -0
  159. package/dist/esm/chunk-MNTLX37G.mjs.map +1 -0
  160. package/dist/esm/chunk-NMD45OTM.mjs +2 -0
  161. package/dist/esm/chunk-NMD45OTM.mjs.map +1 -0
  162. package/dist/esm/chunk-NW3WUTTD.mjs +2 -0
  163. package/dist/esm/{chunk-BCLP2ENK.mjs → chunk-O7VXANBW.mjs} +2 -2
  164. package/dist/esm/chunk-Q6LFIZ3L.mjs +2 -0
  165. package/dist/esm/chunk-Q6LFIZ3L.mjs.map +1 -0
  166. package/dist/esm/{chunk-43HKFNUB.mjs → chunk-QFVQSFBZ.mjs} +2 -2
  167. package/dist/esm/chunk-QSMVCD52.mjs +2 -0
  168. package/dist/esm/chunk-QSMVCD52.mjs.map +1 -0
  169. package/dist/esm/chunk-R2TZZVTU.mjs +2 -0
  170. package/dist/esm/chunk-R2TZZVTU.mjs.map +1 -0
  171. package/dist/esm/{chunk-V367QLY3.mjs → chunk-S5ABQH5R.mjs} +2 -2
  172. package/dist/esm/chunk-SCHZ67F3.mjs +2 -0
  173. package/dist/esm/chunk-SCHZ67F3.mjs.map +1 -0
  174. package/dist/esm/{chunk-AR3GW64L.mjs → chunk-SNDFJWYM.mjs} +2 -2
  175. package/dist/esm/{chunk-TAVPFLW5.mjs → chunk-SYRND55P.mjs} +2 -2
  176. package/dist/esm/{chunk-JHBMHOSV.mjs → chunk-T5YEMU53.mjs} +2 -2
  177. package/dist/esm/chunk-TJDC5PWD.mjs +2 -0
  178. package/dist/esm/{chunk-LF6IQT54.mjs → chunk-TUCCV62K.mjs} +2 -2
  179. package/dist/esm/chunk-U3S4AX6K.mjs +2 -0
  180. package/dist/esm/chunk-U3S4AX6K.mjs.map +1 -0
  181. package/dist/esm/chunk-U5F4NL24.mjs +2 -0
  182. package/dist/esm/{chunk-QIELBIZW.mjs → chunk-UHZWZWJ7.mjs} +2 -2
  183. package/dist/esm/{chunk-4KMISR2H.mjs → chunk-UMLUOYFK.mjs} +2 -2
  184. package/dist/esm/{chunk-4KMISR2H.mjs.map → chunk-UMLUOYFK.mjs.map} +1 -1
  185. package/dist/esm/{chunk-LVYNEPH4.mjs → chunk-UVTJEMV4.mjs} +2 -2
  186. package/dist/esm/chunk-VIX4BX35.mjs +2 -0
  187. package/dist/esm/chunk-VIX4BX35.mjs.map +1 -0
  188. package/dist/esm/{chunk-RC6B45PP.mjs → chunk-W63KIXLK.mjs} +2 -2
  189. package/dist/esm/chunk-WA2NTBYY.mjs +2 -0
  190. package/dist/esm/{chunk-X6BYF2UD.mjs → chunk-WIYDJE6F.mjs} +2 -2
  191. package/dist/esm/{chunk-OO5EJW3B.mjs → chunk-X3HGM2KT.mjs} +2 -2
  192. package/dist/esm/{chunk-I3MG3W4J.mjs → chunk-X4X5H6NC.mjs} +2 -2
  193. package/dist/esm/chunk-XH33BXEY.mjs +2 -0
  194. package/dist/esm/chunk-XH33BXEY.mjs.map +1 -0
  195. package/dist/esm/{chunk-CX4BEIQT.mjs → chunk-XVZBWW46.mjs} +2 -2
  196. package/dist/esm/{chunk-6SK246YU.mjs → chunk-YA4XTZNZ.mjs} +2 -2
  197. package/dist/esm/chunk-YD5IB4TH.mjs +2 -0
  198. package/dist/esm/chunk-YD5IB4TH.mjs.map +1 -0
  199. package/dist/esm/{chunk-A7J2UMLS.mjs → chunk-YDNOKWV3.mjs} +2 -2
  200. package/dist/esm/chunk-YE5B2S5L.mjs +2 -0
  201. package/dist/esm/chunk-YE5B2S5L.mjs.map +1 -0
  202. package/dist/esm/{chunk-4D42AAH3.mjs → chunk-YRUF6N3U.mjs} +2 -2
  203. package/dist/esm/chunk-YTQVMLFD.mjs +2 -0
  204. package/dist/esm/chunk-YTQVMLFD.mjs.map +1 -0
  205. package/dist/esm/{chunk-ZMXURV35.mjs → chunk-ZIDLP5MI.mjs} +2 -2
  206. package/dist/esm/{chunk-AWPRGMUP.mjs → chunk-ZV5MKFV7.mjs} +2 -2
  207. package/dist/esm/cli/index.mjs +1 -1
  208. package/dist/esm/cli/localNode.mjs +1 -1
  209. package/dist/esm/client/core.mjs +1 -1
  210. package/dist/esm/client/get.d.mts +8 -1
  211. package/dist/esm/client/get.mjs +1 -1
  212. package/dist/esm/client/index.d.mts +2 -2
  213. package/dist/esm/client/index.mjs +1 -1
  214. package/dist/esm/client/post.d.mts +9 -1
  215. package/dist/esm/client/post.mjs +1 -1
  216. package/dist/esm/client/types.mjs +1 -1
  217. package/dist/esm/core/account/index.mjs +1 -1
  218. package/dist/esm/core/account/utils/address.mjs +1 -1
  219. package/dist/esm/core/account/utils/index.mjs +1 -1
  220. package/dist/esm/core/accountAddress.mjs +1 -1
  221. package/dist/esm/core/authenticationKey.d.mts +1 -1
  222. package/dist/esm/core/authenticationKey.mjs +1 -1
  223. package/dist/esm/core/common.mjs +1 -1
  224. package/dist/esm/core/crypto/cryptoHashable.d.mts +21 -0
  225. package/dist/esm/core/crypto/cryptoHashable.mjs +2 -0
  226. package/dist/esm/core/crypto/cryptoHashable.mjs.map +1 -0
  227. package/dist/esm/core/crypto/ed25519.d.mts +1 -1
  228. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  229. package/dist/esm/core/crypto/ephemeral.d.mts +73 -0
  230. package/dist/esm/core/crypto/ephemeral.mjs +2 -0
  231. package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
  232. package/dist/esm/core/crypto/index.d.mts +7 -1
  233. package/dist/esm/core/crypto/index.mjs +1 -1
  234. package/dist/esm/core/crypto/keyless.d.mts +321 -0
  235. package/dist/esm/core/crypto/keyless.mjs +2 -0
  236. package/dist/esm/core/crypto/keyless.mjs.map +1 -0
  237. package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
  238. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  239. package/dist/esm/core/crypto/multiKey.d.mts +1 -1
  240. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  241. package/dist/esm/core/crypto/poseidon.d.mts +19 -0
  242. package/dist/esm/core/crypto/poseidon.mjs +2 -0
  243. package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
  244. package/dist/esm/core/crypto/privateKey.d.mts +1 -1
  245. package/dist/esm/core/crypto/proof.d.mts +21 -0
  246. package/dist/esm/core/crypto/proof.mjs +2 -0
  247. package/dist/esm/core/crypto/proof.mjs.map +1 -0
  248. package/dist/esm/core/crypto/publicKey.d.mts +1 -1
  249. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  250. package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
  251. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  252. package/dist/esm/core/crypto/signature.mjs +1 -1
  253. package/dist/esm/core/crypto/singleKey.d.mts +1 -1
  254. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  255. package/dist/esm/core/crypto/utils.mjs +1 -1
  256. package/dist/esm/core/hex.mjs +1 -1
  257. package/dist/esm/core/index.d.mts +7 -1
  258. package/dist/esm/core/index.mjs +1 -1
  259. package/dist/esm/index.d.mts +15 -7
  260. package/dist/esm/index.mjs +1 -1
  261. package/dist/esm/internal/account.d.mts +3 -3
  262. package/dist/esm/internal/account.mjs +1 -1
  263. package/dist/esm/internal/ans.d.mts +2 -2
  264. package/dist/esm/internal/ans.mjs +1 -1
  265. package/dist/esm/internal/coin.d.mts +4 -4
  266. package/dist/esm/internal/coin.mjs +1 -1
  267. package/dist/esm/internal/digitalAsset.d.mts +2 -2
  268. package/dist/esm/internal/digitalAsset.mjs +1 -1
  269. package/dist/esm/internal/event.d.mts +1 -1
  270. package/dist/esm/internal/event.mjs +1 -1
  271. package/dist/esm/internal/faucet.d.mts +3 -3
  272. package/dist/esm/internal/faucet.mjs +1 -1
  273. package/dist/esm/internal/fungibleAsset.d.mts +3 -3
  274. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  275. package/dist/esm/internal/general.d.mts +2 -16
  276. package/dist/esm/internal/general.mjs +1 -1
  277. package/dist/esm/internal/keyless.d.mts +73 -0
  278. package/dist/esm/internal/keyless.mjs +2 -0
  279. package/dist/esm/internal/keyless.mjs.map +1 -0
  280. package/dist/esm/internal/staking.d.mts +2 -2
  281. package/dist/esm/internal/staking.mjs +1 -1
  282. package/dist/esm/internal/table.mjs +1 -1
  283. package/dist/esm/internal/transaction.d.mts +16 -2
  284. package/dist/esm/internal/transaction.mjs +1 -1
  285. package/dist/esm/internal/transactionSubmission.d.mts +6 -6
  286. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  287. package/dist/esm/internal/view.d.mts +1 -1
  288. package/dist/esm/internal/view.mjs +1 -1
  289. package/dist/esm/transactions/authenticator/account.d.mts +1 -1
  290. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  291. package/dist/esm/transactions/authenticator/index.d.mts +1 -1
  292. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  293. package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
  294. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  295. package/dist/esm/transactions/index.d.mts +2 -2
  296. package/dist/esm/transactions/index.mjs +1 -1
  297. package/dist/esm/transactions/instances/chainId.mjs +1 -1
  298. package/dist/esm/transactions/instances/identifier.mjs +1 -1
  299. package/dist/esm/transactions/instances/index.d.mts +1 -1
  300. package/dist/esm/transactions/instances/index.mjs +1 -1
  301. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  302. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  303. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  304. package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
  305. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  306. package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
  307. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  308. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  309. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  310. package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
  311. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  312. package/dist/esm/transactions/management/index.d.mts +2 -2
  313. package/dist/esm/transactions/management/index.mjs +1 -1
  314. package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
  315. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  316. package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
  317. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  318. package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
  319. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  320. package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +3 -3
  321. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  322. package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +4 -1
  323. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  324. package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +1 -1
  325. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  326. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  327. package/dist/esm/transactions/typeTag/parser.d.mts +3 -1
  328. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  329. package/dist/esm/transactions/types.d.mts +23 -5
  330. package/dist/esm/types/index.d.mts +21 -5
  331. package/dist/esm/types/index.mjs +1 -1
  332. package/dist/esm/types/keyless.d.mts +52 -0
  333. package/dist/esm/types/keyless.mjs +1 -0
  334. package/dist/esm/types/keyless.mjs.map +1 -0
  335. package/dist/esm/utils/apiEndpoints.d.mts +3 -1
  336. package/dist/esm/utils/apiEndpoints.mjs +1 -1
  337. package/dist/esm/utils/const.d.mts +3 -1
  338. package/dist/esm/utils/const.mjs +1 -1
  339. package/dist/esm/utils/helpers.d.mts +4 -1
  340. package/dist/esm/utils/helpers.mjs +1 -1
  341. package/dist/esm/utils/index.d.mts +1 -1
  342. package/dist/esm/utils/index.mjs +1 -1
  343. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  344. package/dist/esm/version.d.mts +1 -1
  345. package/dist/esm/version.mjs +1 -1
  346. package/package.json +11 -4
  347. package/src/account/EphemeralKeyPair.ts +158 -0
  348. package/src/account/KeylessAccount.ts +367 -0
  349. package/src/account/MultiKeyAccount.ts +11 -0
  350. package/src/account/index.ts +2 -0
  351. package/src/api/aptos.ts +6 -0
  352. package/src/api/aptosConfig.ts +46 -1
  353. package/src/api/general.ts +1 -2
  354. package/src/api/keyless.ts +51 -0
  355. package/src/bcs/deserializer.ts +46 -0
  356. package/src/bcs/serializer.ts +58 -0
  357. package/src/client/core.ts +4 -0
  358. package/src/client/get.ts +12 -0
  359. package/src/client/post.ts +18 -0
  360. package/src/core/crypto/cryptoHashable.ts +16 -0
  361. package/src/core/crypto/ephemeral.ts +138 -0
  362. package/src/core/crypto/index.ts +2 -0
  363. package/src/core/crypto/keyless.ts +679 -0
  364. package/src/core/crypto/poseidon.ts +144 -0
  365. package/src/core/crypto/proof.ts +16 -0
  366. package/src/core/crypto/singleKey.ts +11 -0
  367. package/src/internal/general.ts +1 -38
  368. package/src/internal/keyless.ts +121 -0
  369. package/src/internal/transaction.ts +92 -0
  370. package/src/internal/transactionSubmission.ts +6 -1
  371. package/src/transactions/management/accountSequenceNumber.ts +5 -8
  372. package/src/transactions/transactionBuilder/remoteAbi.ts +3 -2
  373. package/src/transactions/transactionBuilder/signingMessage.ts +4 -1
  374. package/src/transactions/transactionBuilder/transactionBuilder.ts +22 -2
  375. package/src/transactions/typeTag/parser.ts +98 -52
  376. package/src/transactions/types.ts +22 -3
  377. package/src/types/index.ts +24 -2
  378. package/src/types/keyless.ts +42 -0
  379. package/src/utils/apiEndpoints.ts +16 -0
  380. package/src/utils/const.ts +2 -0
  381. package/src/utils/helpers.ts +22 -0
  382. package/src/version.ts +1 -1
  383. package/dist/common/chunk-KSEUZTKY.js +0 -2
  384. package/dist/common/chunk-KSEUZTKY.js.map +0 -1
  385. package/dist/esm/chunk-2XVDVF5C.mjs +0 -2
  386. package/dist/esm/chunk-3JPVQHOR.mjs +0 -2
  387. package/dist/esm/chunk-3JPVQHOR.mjs.map +0 -1
  388. package/dist/esm/chunk-43YYG5VO.mjs +0 -2
  389. package/dist/esm/chunk-43YYG5VO.mjs.map +0 -1
  390. package/dist/esm/chunk-5NSXEM3O.mjs +0 -2
  391. package/dist/esm/chunk-5SQAHWDI.mjs +0 -2
  392. package/dist/esm/chunk-5TTCAW72.mjs +0 -2
  393. package/dist/esm/chunk-5TTCAW72.mjs.map +0 -1
  394. package/dist/esm/chunk-6IFMQ5AS.mjs +0 -2
  395. package/dist/esm/chunk-6IFMQ5AS.mjs.map +0 -1
  396. package/dist/esm/chunk-6JFZZLRC.mjs +0 -2
  397. package/dist/esm/chunk-6JFZZLRC.mjs.map +0 -1
  398. package/dist/esm/chunk-AFTMLXYT.mjs +0 -2
  399. package/dist/esm/chunk-CCQRMKD2.mjs +0 -2
  400. package/dist/esm/chunk-CCQRMKD2.mjs.map +0 -1
  401. package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
  402. package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
  403. package/dist/esm/chunk-EUUIYMYC.mjs +0 -2
  404. package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
  405. package/dist/esm/chunk-F7J7ZW4H.mjs +0 -2
  406. package/dist/esm/chunk-FNKDXPPQ.mjs +0 -2
  407. package/dist/esm/chunk-FVN6MJTH.mjs +0 -2
  408. package/dist/esm/chunk-FVN6MJTH.mjs.map +0 -1
  409. package/dist/esm/chunk-FWPK5KC2.mjs +0 -2
  410. package/dist/esm/chunk-FWPK5KC2.mjs.map +0 -1
  411. package/dist/esm/chunk-HYCGMFC2.mjs +0 -2
  412. package/dist/esm/chunk-HYCGMFC2.mjs.map +0 -1
  413. package/dist/esm/chunk-JE7INUQ2.mjs +0 -2
  414. package/dist/esm/chunk-JE7INUQ2.mjs.map +0 -1
  415. package/dist/esm/chunk-LG7RJQ57.mjs +0 -2
  416. package/dist/esm/chunk-LGOZUIGE.mjs +0 -2
  417. package/dist/esm/chunk-LKVJZTBM.mjs.map +0 -1
  418. package/dist/esm/chunk-LX53BIRN.mjs +0 -2
  419. package/dist/esm/chunk-NYXLPBKE.mjs +0 -2
  420. package/dist/esm/chunk-OIH4KBXW.mjs +0 -2
  421. package/dist/esm/chunk-OIH4KBXW.mjs.map +0 -1
  422. package/dist/esm/chunk-OWW6SIDP.mjs +0 -2
  423. package/dist/esm/chunk-OWW6SIDP.mjs.map +0 -1
  424. package/dist/esm/chunk-P2CIREOD.mjs +0 -2
  425. package/dist/esm/chunk-R5NNAF5B.mjs +0 -2
  426. package/dist/esm/chunk-R5NNAF5B.mjs.map +0 -1
  427. package/dist/esm/chunk-ROXFCLDT.mjs +0 -2
  428. package/dist/esm/chunk-RTSWVT2Q.mjs +0 -2
  429. package/dist/esm/chunk-RTSWVT2Q.mjs.map +0 -1
  430. package/dist/esm/chunk-T2WZWN6W.mjs +0 -2
  431. package/dist/esm/chunk-UO3NZ5AH.mjs +0 -1
  432. package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
  433. package/dist/esm/chunk-V3DEJBS6.mjs +0 -2
  434. package/dist/esm/chunk-V6J6AW5T.mjs +0 -2
  435. package/dist/esm/chunk-V6J6AW5T.mjs.map +0 -1
  436. package/dist/esm/chunk-VEB6NALT.mjs +0 -2
  437. package/dist/esm/chunk-VEB6NALT.mjs.map +0 -1
  438. package/dist/esm/chunk-WZSVQBPA.mjs +0 -2
  439. package/dist/esm/chunk-XHEZAVN3.mjs +0 -2
  440. package/dist/esm/chunk-XXBMHWNV.mjs.map +0 -1
  441. /package/dist/esm/{chunk-UO3NZ5AH.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
  442. /package/dist/esm/{chunk-UVSRX4SV.mjs.map → account/KeylessAccount.mjs.map} +0 -0
  443. /package/dist/esm/{chunk-ROXFCLDT.mjs.map → chunk-3RJZNUCQ.mjs.map} +0 -0
  444. /package/dist/esm/{chunk-LX53BIRN.mjs.map → chunk-472OGHMG.mjs.map} +0 -0
  445. /package/dist/esm/{chunk-AFTMLXYT.mjs.map → chunk-4VPCPASN.mjs.map} +0 -0
  446. /package/dist/esm/{chunk-OLKEU7WZ.mjs.map → chunk-5WFKJO5L.mjs.map} +0 -0
  447. /package/dist/esm/{chunk-HZ3YB6TN.mjs.map → chunk-64CUEMFI.mjs.map} +0 -0
  448. /package/dist/esm/{chunk-LM7CN4LT.mjs.map → chunk-64VPA7CM.mjs.map} +0 -0
  449. /package/dist/esm/{chunk-GHYE26Q5.mjs.map → chunk-6FBKUTGF.mjs.map} +0 -0
  450. /package/dist/esm/{chunk-2XVDVF5C.mjs.map → chunk-7BW2N4IE.mjs.map} +0 -0
  451. /package/dist/esm/{chunk-UF5B4XMN.mjs.map → chunk-7G3RSOWE.mjs.map} +0 -0
  452. /package/dist/esm/{chunk-AKJZL3HT.mjs.map → chunk-7M4C4OZN.mjs.map} +0 -0
  453. /package/dist/esm/{chunk-DO444YYD.mjs.map → chunk-7UKBRLGM.mjs.map} +0 -0
  454. /package/dist/esm/{chunk-BCUSI3N6.mjs.map → chunk-AOCNYMMX.mjs.map} +0 -0
  455. /package/dist/esm/{chunk-YMHX6GC2.mjs.map → chunk-B2RYTKNN.mjs.map} +0 -0
  456. /package/dist/esm/{chunk-JWTZDA6A.mjs.map → chunk-BO44HPGU.mjs.map} +0 -0
  457. /package/dist/esm/{chunk-DPWXEJP6.mjs.map → chunk-BT6IM25V.mjs.map} +0 -0
  458. /package/dist/esm/{chunk-JNDRFTEA.mjs.map → chunk-DPWEHSHH.mjs.map} +0 -0
  459. /package/dist/esm/{chunk-WNVUG2UF.mjs.map → chunk-EFMAZTIM.mjs.map} +0 -0
  460. /package/dist/esm/{chunk-LG7RJQ57.mjs.map → chunk-FBPNHF54.mjs.map} +0 -0
  461. /package/dist/esm/{chunk-YJIRT3GJ.mjs.map → chunk-FGGRPEQ3.mjs.map} +0 -0
  462. /package/dist/esm/{chunk-5SQAHWDI.mjs.map → chunk-FIG65OJD.mjs.map} +0 -0
  463. /package/dist/esm/{chunk-ISIUQQMV.mjs.map → chunk-FNFQA7NS.mjs.map} +0 -0
  464. /package/dist/esm/{chunk-HMTYASEZ.mjs.map → chunk-FSO54CI4.mjs.map} +0 -0
  465. /package/dist/esm/{chunk-DBC2JY65.mjs.map → chunk-GBQU2OCK.mjs.map} +0 -0
  466. /package/dist/esm/{chunk-FW6TF3O2.mjs.map → chunk-GPWSPT44.mjs.map} +0 -0
  467. /package/dist/esm/{chunk-QKV2H27T.mjs.map → chunk-GQC73XWZ.mjs.map} +0 -0
  468. /package/dist/esm/{chunk-FNKDXPPQ.mjs.map → chunk-GRHLQDHF.mjs.map} +0 -0
  469. /package/dist/esm/{chunk-WZSVQBPA.mjs.map → chunk-GSCM444Z.mjs.map} +0 -0
  470. /package/dist/esm/{chunk-VJL6AF64.mjs.map → chunk-HGJMVOBH.mjs.map} +0 -0
  471. /package/dist/esm/{chunk-MEXWNZY6.mjs.map → chunk-HXYZECGS.mjs.map} +0 -0
  472. /package/dist/esm/{chunk-EUUIYMYC.mjs.map → chunk-IT7YNITU.mjs.map} +0 -0
  473. /package/dist/esm/{chunk-TZCETTAW.mjs.map → chunk-IXFYYWAC.mjs.map} +0 -0
  474. /package/dist/esm/{chunk-OOH7MH2H.mjs.map → chunk-JZOTXY77.mjs.map} +0 -0
  475. /package/dist/esm/{chunk-FLUCRNGU.mjs.map → chunk-L5ZHZWHI.mjs.map} +0 -0
  476. /package/dist/esm/{chunk-YTJ73ZX3.mjs.map → chunk-LIT6V2A6.mjs.map} +0 -0
  477. /package/dist/esm/{chunk-S5AGI7RQ.mjs.map → chunk-MLX6DFMR.mjs.map} +0 -0
  478. /package/dist/esm/{chunk-P2CIREOD.mjs.map → chunk-NW3WUTTD.mjs.map} +0 -0
  479. /package/dist/esm/{chunk-BCLP2ENK.mjs.map → chunk-O7VXANBW.mjs.map} +0 -0
  480. /package/dist/esm/{chunk-43HKFNUB.mjs.map → chunk-QFVQSFBZ.mjs.map} +0 -0
  481. /package/dist/esm/{chunk-V367QLY3.mjs.map → chunk-S5ABQH5R.mjs.map} +0 -0
  482. /package/dist/esm/{chunk-AR3GW64L.mjs.map → chunk-SNDFJWYM.mjs.map} +0 -0
  483. /package/dist/esm/{chunk-TAVPFLW5.mjs.map → chunk-SYRND55P.mjs.map} +0 -0
  484. /package/dist/esm/{chunk-JHBMHOSV.mjs.map → chunk-T5YEMU53.mjs.map} +0 -0
  485. /package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-TJDC5PWD.mjs.map} +0 -0
  486. /package/dist/esm/{chunk-LF6IQT54.mjs.map → chunk-TUCCV62K.mjs.map} +0 -0
  487. /package/dist/esm/{chunk-V3DEJBS6.mjs.map → chunk-U5F4NL24.mjs.map} +0 -0
  488. /package/dist/esm/{chunk-QIELBIZW.mjs.map → chunk-UHZWZWJ7.mjs.map} +0 -0
  489. /package/dist/esm/{chunk-LVYNEPH4.mjs.map → chunk-UVTJEMV4.mjs.map} +0 -0
  490. /package/dist/esm/{chunk-RC6B45PP.mjs.map → chunk-W63KIXLK.mjs.map} +0 -0
  491. /package/dist/esm/{chunk-F7J7ZW4H.mjs.map → chunk-WA2NTBYY.mjs.map} +0 -0
  492. /package/dist/esm/{chunk-X6BYF2UD.mjs.map → chunk-WIYDJE6F.mjs.map} +0 -0
  493. /package/dist/esm/{chunk-OO5EJW3B.mjs.map → chunk-X3HGM2KT.mjs.map} +0 -0
  494. /package/dist/esm/{chunk-I3MG3W4J.mjs.map → chunk-X4X5H6NC.mjs.map} +0 -0
  495. /package/dist/esm/{chunk-CX4BEIQT.mjs.map → chunk-XVZBWW46.mjs.map} +0 -0
  496. /package/dist/esm/{chunk-6SK246YU.mjs.map → chunk-YA4XTZNZ.mjs.map} +0 -0
  497. /package/dist/esm/{chunk-A7J2UMLS.mjs.map → chunk-YDNOKWV3.mjs.map} +0 -0
  498. /package/dist/esm/{chunk-4D42AAH3.mjs.map → chunk-YRUF6N3U.mjs.map} +0 -0
  499. /package/dist/esm/{chunk-ZMXURV35.mjs.map → chunk-ZIDLP5MI.mjs.map} +0 -0
  500. /package/dist/esm/{chunk-AWPRGMUP.mjs.map → chunk-ZV5MKFV7.mjs.map} +0 -0
  501. /package/dist/esm/{publicKey-B3XRNhHO.d.mts → publicKey-lq5djCIY.d.mts} +0 -0
@@ -0,0 +1 @@
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 } from \"../types\";\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 */\nexport interface Deserializable<T> {\n deserialize(deserializer: Deserializer): T;\n}\n\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\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 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 * Deserializes a string. UTF8 string is supported. Reads the string's bytes length \"l\" first,\n * and then reads \"l\" bytes of content. Decodes the byte array 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 * ```ts\n * const deserializer = new Deserializer(new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeStr() === \"1234abcd\");\n * ```\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * Deserializes a an optional string.\n *\n * BCS layout for Optional<String>: 0 if none, else 1 | string_length | string_content\n * @example\n * ```ts\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 const exists = this.deserializeUleb128AsU32();\n if (exists === 1) {\n return this.deserializeStr();\n }\n return undefined;\n }\n\n /**\n * Deserializes a an optional deserializable class.\n *\n * BCS layout for Optional<T>: 0 if none, else 1 | bcs representation of class\n *\n * @example\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n *\n * const deserializer = new Deserializer(new Uint8Array([0]));\n * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function\n * // value is undefined\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns the deserialized value of class type T\n */\n deserializeOption<T>(cls: Deserializable<T>): T | undefined {\n const exists = this.deserializeUleb128AsU32();\n if (exists === 1) {\n return this.deserialize(cls);\n }\n return undefined;\n }\n\n /**\n * Deserializes an array of bytes.\n *\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 */\n deserializeBytes(): Uint8Array {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes. The number of bytes to read is already known.\n *\n */\n deserializeFixedBytes(len: number): Uint8Array {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value.\n *\n * BCS layout for \"boolean\": One byte. \"0x01\" for true and \"0x00\" for false.\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.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number.\n *\n * BCS layout for \"uint16\": Two bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number.\n *\n * BCS layout for \"uint32\": Four bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * BCS layout for \"uint64\": Eight bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\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.\n *\n * BCS layout for \"uint128\": Sixteen bytes. Binary format in little-endian representation.\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.\n *\n * BCS layout for \"uint256\": Thirty-two bytes. Binary format in little-endian representation.\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 * BCS use uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values\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 */\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\n * instance with a loaded byte buffer.\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\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 * @returns an array of deserialized values of type T\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":"yCAiBO,IAAMA,EAAN,KAAmB,CAKxB,YAAYC,EAAkB,CAE5B,KAAK,OAAS,IAAI,YAAYA,EAAK,MAAM,EACzC,IAAI,WAAW,KAAK,MAAM,EAAE,IAAIA,EAAM,CAAC,EACvC,KAAK,OAAS,CAChB,CAEQ,KAAKC,EAA6B,CACxC,GAAI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BAA2B,CACzB,IAAMA,EAAM,KAAK,eAAe,EAC1BC,EAAO,KAAK,eAAe,EAGjC,OAAO,OAAQA,GAAQ,OAAO,EAAE,EAAKD,CAAG,CAC1C,CAOA,iBAA2B,CACzB,IAAMA,EAAM,KAAK,gBAAgB,EAC3BC,EAAO,KAAK,gBAAgB,EAGlC,OAAO,OAAQA,GAAQ,OAAO,GAAG,EAAKD,CAAG,CAC3C,CAOA,yBAAkC,CAChC,IAAIJ,EAAgB,OAAO,CAAC,EACxBM,EAAQ,EAEZ,KAAON,EAAQO,GAAgB,CAC7B,IAAMC,EAAO,KAAK,cAAc,EAGhC,GAFAR,GAAS,OAAOQ,EAAO,GAAI,GAAK,OAAOF,CAAK,EAEvC,EAAAE,EAAO,KACV,MAEFF,GAAS,CACX,CAEA,GAAIN,EAAQO,EACV,MAAM,IAAI,MAAM,qDAAqD,EAGvE,OAAO,OAAOP,CAAK,CACrB,CAeA,YAAeC,EAA2B,CAGxC,OAAOA,EAAI,YAAY,IAAI,CAC7B,CAyBA,kBAAqBA,EAAkC,CACrD,IAAMH,EAAS,KAAK,wBAAwB,EACtCW,EAAS,IAAI,MACnB,QAASC,EAAI,EAAGA,EAAIZ,EAAQY,GAAK,EAC/BD,EAAO,KAAK,KAAK,YAAYR,CAAG,CAAC,EAEnC,OAAOQ,CACT,CACF","names":["Deserializer","data","length","bytes","value","cls","len","bool","low","high","shift","MAX_U32_NUMBER","byte","vector","i"]}
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./chunk-3IFR6T3V.mjs";function t(i,r){let l=r.bcsToBytes(),a=new e(l);return i.deserialize(a)}export{t as a};
2
+ //# sourceMappingURL=chunk-3RJZNUCQ.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-6FBKUTGF.mjs";import{a as p}from"./chunk-4BJA3QUQ.mjs";var l={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function c(s,R){let{url:o,method:i,body:u,contentType:d,params:t,overrides:e,originMethod:n}=s,r={...e?.HEADERS,"x-aptos-client":`aptos-typescript-sdk/${p}`,"content-type":d??"application/json","x-aptos-typescript-sdk-origin-method":n};return e?.AUTH_TOKEN&&(r.Authorization=`Bearer ${e?.AUTH_TOKEN}`),e?.API_KEY&&(r.Authorization=`Bearer ${e?.API_KEY}`),R.provider({url:o,method:i,body:u,params:t,headers:r,overrides:e})}async function N(s,R,o){let{url:i,path:u}=s,d=u?`${i}/${u}`:i,t=await c({...s,url:d},R.client),e={status:t.status,statusText:t.statusText,data:t.data,headers:t.headers,config:t.config,request:t.request,url:d};if(e.status===401)throw new a(s,e,`Error: ${e.data}`);if(o==="Indexer"){let r=e.data;if(r.errors)throw new a(s,e,`Indexer error: ${r.errors[0].message}`??`Indexer unhandled Error ${t.status} : ${t.statusText}`);e.data=r.data}else if((o==="Pepper"||o==="Prover")&&e.status>=400)throw new a(s,e,`${t.data}`);if(e.status>=200&&e.status<300)return e;let n;throw e&&e.data&&"message"in e.data&&"error_code"in e.data?n=JSON.stringify(e.data):e.status in l?n=l[e.status]:n=`Unhandled Error ${e.status} : ${e.statusText}`,new a(s,e,`${o} error: ${n}`)}export{c as a,N as b};
2
+ //# sourceMappingURL=chunk-3SACE4I2.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/core.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { AptosApiError, AptosResponse } from \"./types\";\nimport { VERSION } from \"../version\";\nimport { AnyNumber, AptosRequest, Client, ClientRequest, ClientResponse, MimeType } from \"../types\";\nimport { AptosApiType } from \"../utils\";\n\n/**\n * Meaningful errors map\n */\nconst errors: Record<number, string> = {\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 429: \"Too Many Requests\",\n 500: \"Internal Server Error\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n};\n\n/**\n * Given a url and method, sends the request with axios and\n * returns the response.\n */\nexport async function request<Req, Res>(options: ClientRequest<Req>, client: Client): Promise<ClientResponse<Res>> {\n const { url, method, body, contentType, params, overrides, originMethod } = options;\n const headers: Record<string, string | AnyNumber | boolean | undefined> = {\n ...overrides?.HEADERS,\n \"x-aptos-client\": `aptos-typescript-sdk/${VERSION}`,\n \"content-type\": contentType ?? MimeType.JSON,\n \"x-aptos-typescript-sdk-origin-method\": originMethod,\n };\n\n if (overrides?.AUTH_TOKEN) {\n headers.Authorization = `Bearer ${overrides?.AUTH_TOKEN}`;\n }\n if (overrides?.API_KEY) {\n headers.Authorization = `Bearer ${overrides?.API_KEY}`;\n }\n\n /*\n * make a call using the @aptos-labs/aptos-client package\n * {@link https://www.npmjs.com/package/@aptos-labs/aptos-client}\n */\n return client.provider<Req, Res>({\n url,\n method,\n body,\n params,\n headers,\n overrides,\n });\n}\n\n/**\n * The main function to use when doing an API request.\n *\n * @param options AptosRequest\n * @param aptosConfig The config information for the SDK client instance\n * @returns the response or AptosApiError\n */\nexport async function aptosRequest<Req extends {}, Res extends {}>(\n options: AptosRequest,\n aptosConfig: AptosConfig,\n apiType: AptosApiType,\n): Promise<AptosResponse<Req, Res>> {\n const { url, path } = options;\n const fullUrl = path ? `${url}/${path}` : url;\n const response = await request<Req, Res>({ ...options, url: fullUrl }, aptosConfig.client);\n\n const result: AptosResponse<Req, Res> = {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n request: response.request,\n url: fullUrl,\n };\n\n // Handle case for `Unauthorized` error (i.e API_KEY error)\n if (result.status === 401) {\n throw new AptosApiError(options, result, `Error: ${result.data}`);\n }\n\n // to support both fullnode and indexer responses,\n // check if it is an indexer query, and adjust response.data\n if (apiType === AptosApiType.INDEXER) {\n const indexerResponse = result.data as any;\n // Handle Indexer general errors\n if (indexerResponse.errors) {\n throw new AptosApiError(\n options,\n result,\n `Indexer error: ${indexerResponse.errors[0].message}` ??\n `Indexer unhandled Error ${response.status} : ${response.statusText}`,\n );\n }\n result.data = indexerResponse.data as Res;\n }\n\n if (result.status >= 200 && result.status < 300) {\n return result;\n }\n\n let errorMessage: string;\n\n if (result && result.data && \"message\" in result.data && \"error_code\" in result.data) {\n errorMessage = JSON.stringify(result.data);\n } else if (result.status in errors) {\n // If it's not an API type, it must come form infra, these are prehandled\n errorMessage = errors[result.status];\n } else {\n // Everything else is unhandled\n errorMessage = `Unhandled Error ${result.status} : ${result.statusText}`;\n }\n\n // We have to explicitly check for all request types, because if the error is a non-indexer error, but\n // comes from an indexer request (e.g. 404), we'll need to mention it appropriately\n throw new AptosApiError(options, result, `${apiType} error: ${errorMessage}`);\n}\n"],"mappings":"kFAYA,IAAMA,EAAiC,CACrC,IAAK,cACL,IAAK,eACL,IAAK,YACL,IAAK,YACL,IAAK,oBACL,IAAK,wBACL,IAAK,cACL,IAAK,qBACP,EAMA,eAAsBC,EAAkBC,EAA6BC,EAA8C,CACjH,GAAM,CAAE,IAAAC,EAAK,OAAAC,EAAQ,KAAAC,EAAM,YAAAC,EAAa,OAAAC,EAAQ,UAAAC,EAAW,aAAAC,CAAa,EAAIR,EACtES,EAAoE,CACxE,GAAGF,GAAW,QACd,iBAAkB,wBAAwBG,CAAO,GACjD,eAAgBL,sBAChB,uCAAwCG,CAC1C,EAEA,OAAID,GAAW,aACbE,EAAQ,cAAgB,UAAUF,GAAW,UAAU,IAErDA,GAAW,UACbE,EAAQ,cAAgB,UAAUF,GAAW,OAAO,IAO/CN,EAAO,SAAmB,CAC/B,IAAAC,EACA,OAAAC,EACA,KAAAC,EACA,OAAAE,EACA,QAAAG,EACA,UAAAF,CACF,CAAC,CACH,CASA,eAAsBI,EACpBX,EACAY,EACAC,EACkC,CAClC,GAAM,CAAE,IAAAX,EAAK,KAAAY,CAAK,EAAId,EAChBe,EAAUD,EAAO,GAAGZ,CAAG,IAAIY,CAAI,GAAKZ,EACpCc,EAAW,MAAMjB,EAAkB,CAAE,GAAGC,EAAS,IAAKe,CAAQ,EAAGH,EAAY,MAAM,EAEnFK,EAAkC,CACtC,OAAQD,EAAS,OACjB,WAAYA,EAAS,WACrB,KAAMA,EAAS,KACf,QAASA,EAAS,QAClB,OAAQA,EAAS,OACjB,QAASA,EAAS,QAClB,IAAKD,CACP,EAGA,GAAIE,EAAO,SAAW,IACpB,MAAM,IAAIC,EAAclB,EAASiB,EAAQ,UAAUA,EAAO,IAAI,EAAE,EAKlE,GAAIJ,cAAkC,CACpC,IAAMM,EAAkBF,EAAO,KAE/B,GAAIE,EAAgB,OAClB,MAAM,IAAID,EACRlB,EACAiB,EACA,kBAAkBE,EAAgB,OAAO,CAAC,EAAE,OAAO,IACjD,2BAA2BH,EAAS,MAAM,MAAMA,EAAS,UAAU,EACvE,EAEFC,EAAO,KAAOE,EAAgB,IAChC,CAEA,GAAIF,EAAO,QAAU,KAAOA,EAAO,OAAS,IAC1C,OAAOA,EAGT,IAAIG,EAEJ,MAAIH,GAAUA,EAAO,MAAQ,YAAaA,EAAO,MAAQ,eAAgBA,EAAO,KAC9EG,EAAe,KAAK,UAAUH,EAAO,IAAI,EAChCA,EAAO,UAAUnB,EAE1BsB,EAAetB,EAAOmB,EAAO,MAAM,EAGnCG,EAAe,mBAAmBH,EAAO,MAAM,MAAMA,EAAO,UAAU,GAKlE,IAAIC,EAAclB,EAASiB,EAAQ,GAAGJ,CAAO,WAAWO,CAAY,EAAE,CAC9E","names":["errors","request","options","client","url","method","body","contentType","params","overrides","originMethod","headers","VERSION","aptosRequest","aptosConfig","apiType","path","fullUrl","response","result","AptosApiError","indexerResponse","errorMessage"]}
1
+ {"version":3,"sources":["../../src/client/core.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { AptosApiError, AptosResponse } from \"./types\";\nimport { VERSION } from \"../version\";\nimport { AnyNumber, AptosRequest, Client, ClientRequest, ClientResponse, MimeType } from \"../types\";\nimport { AptosApiType } from \"../utils\";\n\n/**\n * Meaningful errors map\n */\nconst errors: Record<number, string> = {\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 429: \"Too Many Requests\",\n 500: \"Internal Server Error\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n};\n\n/**\n * Given a url and method, sends the request with axios and\n * returns the response.\n */\nexport async function request<Req, Res>(options: ClientRequest<Req>, client: Client): Promise<ClientResponse<Res>> {\n const { url, method, body, contentType, params, overrides, originMethod } = options;\n const headers: Record<string, string | AnyNumber | boolean | undefined> = {\n ...overrides?.HEADERS,\n \"x-aptos-client\": `aptos-typescript-sdk/${VERSION}`,\n \"content-type\": contentType ?? MimeType.JSON,\n \"x-aptos-typescript-sdk-origin-method\": originMethod,\n };\n\n if (overrides?.AUTH_TOKEN) {\n headers.Authorization = `Bearer ${overrides?.AUTH_TOKEN}`;\n }\n if (overrides?.API_KEY) {\n headers.Authorization = `Bearer ${overrides?.API_KEY}`;\n }\n\n /*\n * make a call using the @aptos-labs/aptos-client package\n * {@link https://www.npmjs.com/package/@aptos-labs/aptos-client}\n */\n return client.provider<Req, Res>({\n url,\n method,\n body,\n params,\n headers,\n overrides,\n });\n}\n\n/**\n * The main function to use when doing an API request.\n *\n * @param options AptosRequest\n * @param aptosConfig The config information for the SDK client instance\n * @returns the response or AptosApiError\n */\nexport async function aptosRequest<Req extends {}, Res extends {}>(\n options: AptosRequest,\n aptosConfig: AptosConfig,\n apiType: AptosApiType,\n): Promise<AptosResponse<Req, Res>> {\n const { url, path } = options;\n const fullUrl = path ? `${url}/${path}` : url;\n const response = await request<Req, Res>({ ...options, url: fullUrl }, aptosConfig.client);\n\n const result: AptosResponse<Req, Res> = {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n request: response.request,\n url: fullUrl,\n };\n\n // Handle case for `Unauthorized` error (i.e API_KEY error)\n if (result.status === 401) {\n throw new AptosApiError(options, result, `Error: ${result.data}`);\n }\n\n // to support both fullnode and indexer responses,\n // check if it is an indexer query, and adjust response.data\n if (apiType === AptosApiType.INDEXER) {\n const indexerResponse = result.data as any;\n // Handle Indexer general errors\n if (indexerResponse.errors) {\n throw new AptosApiError(\n options,\n result,\n `Indexer error: ${indexerResponse.errors[0].message}` ??\n `Indexer unhandled Error ${response.status} : ${response.statusText}`,\n );\n }\n result.data = indexerResponse.data as Res;\n } else if (apiType === AptosApiType.PEPPER || apiType === AptosApiType.PROVER) {\n if (result.status >= 400) {\n throw new AptosApiError(options, result, `${response.data}`);\n }\n }\n\n if (result.status >= 200 && result.status < 300) {\n return result;\n }\n\n let errorMessage: string;\n\n if (result && result.data && \"message\" in result.data && \"error_code\" in result.data) {\n errorMessage = JSON.stringify(result.data);\n } else if (result.status in errors) {\n // If it's not an API type, it must come form infra, these are prehandled\n errorMessage = errors[result.status];\n } else {\n // Everything else is unhandled\n errorMessage = `Unhandled Error ${result.status} : ${result.statusText}`;\n }\n\n // We have to explicitly check for all request types, because if the error is a non-indexer error, but\n // comes from an indexer request (e.g. 404), we'll need to mention it appropriately\n throw new AptosApiError(options, result, `${apiType} error: ${errorMessage}`);\n}\n"],"mappings":"6EAYA,IAAMA,EAAiC,CACrC,IAAK,cACL,IAAK,eACL,IAAK,YACL,IAAK,YACL,IAAK,oBACL,IAAK,wBACL,IAAK,cACL,IAAK,qBACP,EAMA,eAAsBC,EAAkBC,EAA6BC,EAA8C,CACjH,GAAM,CAAE,IAAAC,EAAK,OAAAC,EAAQ,KAAAC,EAAM,YAAAC,EAAa,OAAAC,EAAQ,UAAAC,EAAW,aAAAC,CAAa,EAAIR,EACtES,EAAoE,CACxE,GAAGF,GAAW,QACd,iBAAkB,wBAAwBG,CAAO,GACjD,eAAgBL,sBAChB,uCAAwCG,CAC1C,EAEA,OAAID,GAAW,aACbE,EAAQ,cAAgB,UAAUF,GAAW,UA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mBH,EAAO,MAAM,MAAMA,EAAO,UAAU,GAKlE,IAAIC,EAAclB,EAASiB,EAAQ,GAAGJ,CAAO,WAAWO,CAAY,EAAE,CAC9E","names":["errors","request","options","client","url","method","body","contentType","params","overrides","originMethod","headers","VERSION","aptosRequest","aptosConfig","apiType","path","fullUrl","response","result","AptosApiError","indexerResponse","errorMessage"]}
@@ -0,0 +1,2 @@
1
+ import{b as m}from"./chunk-FIG65OJD.mjs";import{a as h}from"./chunk-NW3WUTTD.mjs";import{b as t}from"./chunk-F3ZVWLDH.mjs";import{a as u}from"./chunk-UMLUOYFK.mjs";var o=class i extends u{constructor(e,s,a,n,d,l,_){super();this.sender=e,this.sequence_number=s,this.payload=a,this.max_gas_amount=n,this.gas_unit_price=d,this.expiration_timestamp_secs=l,this.chain_id=_}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let s=t.deserialize(e),a=e.deserializeU64(),n=m.deserialize(e),d=e.deserializeU64(),l=e.deserializeU64(),_=e.deserializeU64(),b=h.deserialize(e);return new i(s,a,n,d,l,_,b)}},c=class extends u{static deserialize(r){let e=r.deserializeUleb128AsU32();switch(e){case 0:return p.load(r);case 1:return y.load(r);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},p=class i extends c{constructor(e,s){super();this.raw_txn=e,this.secondary_signer_addresses=s}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let s=o.deserialize(e),a=e.deserializeVector(t);return new i(s,a)}},y=class i extends c{constructor(e,s,a){super();this.raw_txn=e,this.secondary_signer_addresses=s,this.fee_payer_address=a}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let s=o.deserialize(e),a=e.deserializeVector(t),n=t.deserialize(e);return new i(s,a,n)}};export{o as a,c as b,p as c,y as d};
2
+ //# sourceMappingURL=chunk-472OGHMG.mjs.map
@@ -0,0 +1,2 @@
1
+ var o="1.17.0";export{o as a};
2
+ //# sourceMappingURL=chunk-4BJA3QUQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/version.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The current version of the SDK\n *\n * hardcoded for now, we would want to have it injected dynamically\n */\nexport const VERSION = \"1.16.0\";\n"],"mappings":"AAQO,IAAMA,EAAU","names":["VERSION"]}
1
+ {"version":3,"sources":["../../src/version.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The current version of the SDK\n *\n * hardcoded for now, we would want to have it injected dynamically\n */\nexport const VERSION = \"1.17.0\";\n"],"mappings":"AAQO,IAAMA,EAAU","names":["VERSION"]}
@@ -0,0 +1,2 @@
1
+ import{a,c}from"./chunk-BO44HPGU.mjs";import{i as o,j as l}from"./chunk-54LCK6EN.mjs";import{a as n,c as s}from"./chunk-XVZBWW46.mjs";import{b}from"./chunk-WA2NTBYY.mjs";import{a as p}from"./chunk-4VPCPASN.mjs";import{a as y}from"./chunk-EFMAZTIM.mjs";var f=class t extends b{constructor(e){super();if(this.publicKey=e,e instanceof n)this.variant=0;else if(e instanceof a)this.variant=1;else if(e instanceof o)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:i}=e;return i instanceof u?this.publicKey.verifySignature({message:r,signature:i.signature}):!1}authKey(){return y.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=n.deserialize(e);break;case 1:i=a.deserialize(e);break;case 3:i=o.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new t(i)}static isPublicKey(e){return e instanceof t}isEd25519(){return this.publicKey instanceof n}isSecp256k1PublicKey(){return this.publicKey instanceof a}},u=class t extends p{constructor(e){super();if(this.signature=e,e instanceof s)this.variant=0;else if(e instanceof c)this.variant=1;else if(e instanceof l)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=s.deserialize(e);break;case 1:i=c.deserialize(e);break;case 3:i=l.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new t(i)}};export{f as a,u as b};
2
+ //# sourceMappingURL=chunk-4CUDBBTC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/crypto/singleKey.ts"],"sourcesContent":["import { Deserializer, Serializer } from \"../../bcs\";\nimport { AnyPublicKeyVariant, AnySignatureVariant, SigningScheme as AuthenticationKeyScheme } from \"../../types\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { AccountPublicKey, PublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Secp256k1PublicKey, Secp256k1Signature } from \"./secp256k1\";\nimport { KeylessPublicKey, KeylessSignature } from \"./keyless\";\nimport { Signature } from \"./signature\";\n\n/**\n * Represents any public key supported by Aptos.\n *\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n *\n * Any unified authentication key is represented in the SDK as `AnyPublicKey`.\n */\nexport class AnyPublicKey extends AccountPublicKey {\n /**\n * Reference to the inner public key\n */\n public readonly publicKey: PublicKey;\n\n /**\n * Index of the underlying enum variant\n */\n public readonly variant: AnyPublicKeyVariant;\n\n // region Constructors\n\n constructor(publicKey: PublicKey) {\n super();\n this.publicKey = publicKey;\n if (publicKey instanceof Ed25519PublicKey) {\n this.variant = AnyPublicKeyVariant.Ed25519;\n } else if (publicKey instanceof Secp256k1PublicKey) {\n this.variant = AnyPublicKeyVariant.Secp256k1;\n } else if (publicKey instanceof KeylessPublicKey) {\n this.variant = AnyPublicKeyVariant.Keyless;\n } else {\n throw new Error(\"Unsupported public key type\");\n }\n }\n\n // endregion\n\n // region AccountPublicKey\n\n verifySignature(args: VerifySignatureArgs): boolean {\n const { message, signature } = args;\n if (!(signature instanceof AnySignature)) {\n return false;\n }\n\n return this.publicKey.verifySignature({\n message,\n signature: signature.signature,\n });\n }\n\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.SingleKey,\n input: this.toUint8Array(),\n });\n }\n\n toUint8Array() {\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.publicKey.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): AnyPublicKey {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let publicKey: PublicKey;\n switch (variantIndex) {\n case AnyPublicKeyVariant.Ed25519:\n publicKey = Ed25519PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Secp256k1:\n publicKey = Secp256k1PublicKey.deserialize(deserializer);\n break;\n case AnyPublicKeyVariant.Keyless:\n publicKey = KeylessPublicKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for AnyPublicKey: ${variantIndex}`);\n }\n return new AnyPublicKey(publicKey);\n }\n\n // endregion\n\n /**\n * @deprecated use `instanceof AnyPublicKey` instead.\n */\n static isPublicKey(publicKey: AccountPublicKey): publicKey is AnyPublicKey {\n return publicKey instanceof AnyPublicKey;\n }\n\n /**\n * @deprecated use `publicKey instanceof Ed25519PublicKey` instead.\n */\n isEd25519(): boolean {\n return this.publicKey instanceof Ed25519PublicKey;\n }\n\n /**\n * @deprecated use `publicKey instanceof Secp256k1PublicKey` instead.\n */\n isSecp256k1PublicKey(): boolean {\n return this.publicKey instanceof Secp256k1PublicKey;\n }\n}\n\n/**\n * Instance of signature that uses the SingleKey authentication scheme.\n * This signature can only be generated by a `SingleKeySigner`, since it uses the\n * same authentication scheme.\n */\nexport class AnySignature extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: AnySignatureVariant;\n\n // region Constructors\n\n constructor(signature: Signature) {\n super();\n this.signature = signature;\n\n if (signature instanceof Ed25519Signature) {\n this.variant = AnySignatureVariant.Ed25519;\n } else if (signature instanceof Secp256k1Signature) {\n this.variant = AnySignatureVariant.Secp256k1;\n } else if (signature instanceof KeylessSignature) {\n this.variant = AnySignatureVariant.Keyless;\n } else {\n throw new Error(\"Unsupported signature type\");\n }\n }\n\n // endregion\n\n // region AccountSignature\n\n toUint8Array() {\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): AnySignature {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let signature: Signature;\n switch (variantIndex) {\n case AnySignatureVariant.Ed25519:\n signature = Ed25519Signature.deserialize(deserializer);\n break;\n case AnySignatureVariant.Secp256k1:\n signature = Secp256k1Signature.deserialize(deserializer);\n break;\n case AnySignatureVariant.Keyless:\n signature = KeylessSignature.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for AnySignature: ${variantIndex}`);\n }\n return new AnySignature(signature);\n }\n\n // endregion\n}\n"],"mappings":"4PAiBO,IAAMA,EAAN,MAAMC,UAAqBC,CAAiB,CAajD,YAAYC,EAAsB,CAChC,MAAM,EACN,QAAK,UAAYA,EACbA,aAAqBC,EACvB,KAAK,QAAU,UACND,aAAqBE,EAC9B,KAAK,QAAU,UACNF,aAAqBG,EAC9B,KAAK,QAAU,MAEf,OAAM,IAAI,MA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AK,UAAU,UAAUA,CAAU,CACrC,CAEA,OAAO,YAAYC,EAA0C,CAC3D,IAAMC,EAAeD,EAAa,wBAAwB,EACtDJ,EACJ,OAAQK,EAAc,CACpB,OACEL,EAAYQ,EAAiB,YAAYJ,CAAY,EACrD,MACF,OACEJ,EAAYS,EAAmB,YAAYL,CAAY,EACvD,MACF,OACEJ,EAAYU,EAAiB,YAAYN,CAAY,EACrD,MACF,QACE,MAAM,IAAI,MAAM,2CAA2CC,CAAY,EAAE,CAC7E,CACA,OAAO,IAAIC,EAAaN,CAAS,CACnC,CAGF","names":["AnyPublicKey","_AnyPublicKey","AccountPublicKey","publicKey","Ed25519PublicKey","Secp256k1PublicKey","KeylessPublicKey","args","message","signature","AnySignature","AuthenticationKey","serializer","deserializer","variantIndex","_AnySignature","Signature","Ed25519Signature","Secp256k1Signature","KeylessSignature"]}
@@ -0,0 +1,2 @@
1
+ import{a as r}from"./chunk-UMLUOYFK.mjs";import{b as t}from"./chunk-AOCNYMMX.mjs";var o=class extends r{toString(){let i=this.toUint8Array();return t.fromHexInput(i).toString()}};export{o as a};
2
+ //# sourceMappingURL=chunk-4VPCPASN.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a as T}from"./chunk-37FFZSIM.mjs";import{a as w,b as m}from"./chunk-L5CPAOUM.mjs";import{a as h,c as v,d as B,e as P}from"./chunk-IVVWQKCF.mjs";import{a as I,c as V}from"./chunk-XVZBWW46.mjs";import{b as C}from"./chunk-WA2NTBYY.mjs";import{a as y}from"./chunk-4VPCPASN.mjs";import{a as U}from"./chunk-EFMAZTIM.mjs";import{b}from"./chunk-F3ZVWLDH.mjs";import{a as _}from"./chunk-AH44UPM4.mjs";import{b as A}from"./chunk-IBDBKQMF.mjs";import{a as E}from"./chunk-3IFR6T3V.mjs";import{a as d,b as H}from"./chunk-UMLUOYFK.mjs";import{b as u}from"./chunk-AOCNYMMX.mjs";import{jwtDecode as F}from"jwt-decode";var ge=1e7,L=120,N=30,O=330,fe=120,Se=350,xe=300,be=93,o=class o extends C{constructor(e,t){super();let a=u.fromHexInput(t).toUint8Array();if(a.length!==o.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${o.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=a}authKey(){let e=new H;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),U.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return u.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),a=e.deserializeBytes();return new o(t,a)}static load(e){let t=e.deserializeStr(),a=e.deserializeBytes();return new o(t,a)}static isPublicKey(e){return e instanceof o}static create(e){return D(e),new o(e.iss,D(e))}static fromJWTAndPepper(e){let{jwt:t,pepper:a,uidKey:n="sub"}=e,s=F(t),c=s.iss;if(typeof s.aud!="string")throw new Error("aud was not found or an array of values");let R=s.aud,k=s[n];return o.create({iss:c,uidKey:n,uidVal:k,aud:R,pepper:a})}};o.ID_COMMITMENT_LENGTH=32;var z=o;function D(i){let{uidKey:r,uidVal:e,aud:t,pepper:a}=i,n=[v(u.fromHexInput(a).toUint8Array()),h(t,L),h(e,O),h(r,N)];return B(P(n),z.ID_COMMITMENT_LENGTH)}var M=class i extends y{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:a,expiryDateSecs:n,ephemeralPublicKey:s,ephemeralSignature:c}=e;this.jwtHeader=t,this.ephemeralCertificate=a,this.expiryDateSecs=n,this.ephemeralPublicKey=s,this.ephemeralSignature=c}toUint8Array(){return this.bcsToBytes()}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=g.deserialize(e),a=e.deserializeStr(),n=e.deserializeU64(),s=w.deserialize(e),c=m.deserialize(e);return new i({jwtHeader:a,expiryDateSecs:Number(n),ephemeralCertificate:t,ephemeralPublicKey:s,ephemeralSignature:c})}static getSimulationSignature(){return new i({jwtHeader:"{}",ephemeralCertificate:new g(new x({proof:new S(new f({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new w(new I(new Uint8Array(32))),ephemeralSignature:new m(new V(new Uint8Array(64)))})}static isSignature(e){return e instanceof i}},g=class i extends y{constructor(e,t){super();this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new i(x.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},l=class i extends d{constructor(e){super();if(this.data=u.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new i(t)}},p=class i extends d{constructor(e){super();if(this.data=u.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new i(t)}},f=class i extends T{constructor(e){super();let{a:t,b:a,c:n}=e;this.a=new l(t),this.b=new p(a),this.c=new l(n)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=l.deserialize(e).bcsToBytes(),a=p.deserialize(e).bcsToBytes(),n=l.deserialize(e).bcsToBytes();return new i({a:t,b:a,c:n})}},S=class i extends d{constructor(e,t){super();this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new i(f.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},x=class i extends y{constructor(e){super();let{proof:t,expHorizonSecs:a,trainingWheelsSignature:n,extraField:s,overrideAudVal:c}=e;this.proof=t,this.expHorizonSecs=a,this.trainingWheelsSignature=n,this.extraField=s,this.overrideAudVal=c}toUint8Array(){return this.bcsToBytes()}static fromBytes(e){return i.deserialize(new E(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=S.deserialize(e),a=Number(e.deserializeU64()),n=e.deserializeOptionStr(),s=e.deserializeOptionStr(),c=e.deserializeOption(m);return new i({proof:t,expHorizonSecs:a,trainingWheelsSignature:c,extraField:n,overrideAudVal:s})}},K=class i{constructor(r,e){this.verficationKey=r,this.maxExpHorizonSecs=e}static create(r,e){return new i(new G({alphaG1:r.alpha_g1,betaG2:r.beta_g2,deltaG2:r.delta_g2,gammaAbcG1:r.gamma_abc_g1,gammaG2:r.gamma_g2}),e)}},G=class i{constructor(r){let{alphaG1:e,betaG2:t,deltaG2:a,gammaAbcG1:n,gammaG2:s}=r;this.alphaG1=new l(e),this.betaG2=new p(t),this.deltaG2=new p(a),this.gammaAbcG1=[new l(n[0]),new l(n[1])],this.gammaG2=new p(s)}static fromGroth16VerificationKeyResponse(r){return new i({alphaG1:r.alpha_g1,betaG2:r.beta_g2,deltaG2:r.delta_g2,gammaAbcG1:r.gamma_abc_g1,gammaG2:r.gamma_g2})}};async function we(i){let{aptosConfig:r}=i;return _(async()=>{let e=await j(i),t=await Z(i);return K.create(t,Number(e.max_exp_horizon_secs))},`keyless-configuration-${r.network}`,1e3*60*5)()}async function j(i){let{aptosConfig:r,options:e}=i,t="0x1::keyless_account::Configuration",{data:a}=await A({aptosConfig:r,originMethod:"getKeylessConfigurationResource",path:`accounts/${b.from("0x1").toString()}/resource/${t}`,params:{ledger_version:e?.ledgerVersion}});return a.data}async function Z(i){let{aptosConfig:r,options:e}=i,t="0x1::keyless_account::Groth16VerificationKey",{data:a}=await A({aptosConfig:r,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${b.from("0x1").toString()}/resource/${t}`,params:{ledger_version:e?.ledgerVersion}});return a.data}export{ge as a,L as b,N as c,O as d,fe as e,Se as f,xe as g,be as h,z as i,M as j,g as k,f as l,S as m,x as n,K as o,we as p};
2
+ //# sourceMappingURL=chunk-54LCK6EN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/core/crypto/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { AccountPublicKey, PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { Deserializer, Serializable, Serializer } from \"../../bcs\";\nimport { Hex } from \"../hex\";\nimport {\n HexInput,\n EphemeralCertificateVariant,\n AnyPublicKeyVariant,\n SigningScheme,\n ZkpVariant,\n LedgerVersionArg,\n MoveResource,\n} from \"../../types\";\nimport { EphemeralPublicKey, EphemeralSignature } from \"./ephemeral\";\nimport { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from \"./poseidon\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Proof } from \"./proof\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport { Groth16VerificationKeyResponse, KeylessConfigurationResponse } from \"../../types/keyless\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { getAptosFullNode } from \"../../client\";\nimport { memoizeAsync } from \"../../utils/memoize\";\nimport { AccountAddress } from \"../accountAddress\";\n\nexport const EPK_HORIZON_SECS = 10000000;\nexport const MAX_AUD_VAL_BYTES = 120;\nexport const MAX_UID_KEY_BYTES = 30;\nexport const MAX_UID_VAL_BYTES = 330;\nexport const MAX_ISS_VAL_BYTES = 120;\nexport const MAX_EXTRA_FIELD_BYTES = 350;\nexport const MAX_JWT_HEADER_B64_BYTES = 300;\nexport const MAX_COMMITED_EPK_BYTES = 93;\n\n/**\n * Represents the KeylessPublicKey public key\n *\n * KeylessPublicKey authentication key is represented in the SDK as `AnyPublicKey`.\n */\nexport class KeylessPublicKey extends AccountPublicKey {\n /**\n * The number of bytes that `idCommitment` should be\n */\n static readonly ID_COMMITMENT_LENGTH: number = 32;\n\n /**\n * The value of the 'iss' claim on the JWT which identifies the OIDC provider.\n */\n readonly iss: string;\n\n /**\n * A value representing a cryptographic commitment to a user identity.\n *\n * It is calculated from the aud, uidKey, uidVal, pepper.\n */\n readonly idCommitment: Uint8Array;\n\n constructor(iss: string, idCommitment: HexInput) {\n super();\n const idcBytes = Hex.fromHexInput(idCommitment).toUint8Array();\n if (idcBytes.length !== KeylessPublicKey.ID_COMMITMENT_LENGTH) {\n throw new Error(`Id Commitment length in bytes should be ${KeylessPublicKey.ID_COMMITMENT_LENGTH}`);\n }\n this.iss = iss;\n this.idCommitment = idcBytes;\n }\n\n /**\n * Get the authentication key for the keyless public key\n *\n * @returns AuthenticationKey\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Keyless);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: SigningScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n\n /**\n * Get the public key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the public key\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Get the public key as a hex string with the 0x prefix.\n *\n * @returns string representation of the public key\n */\n toString(): string {\n return Hex.fromHexInput(this.toUint8Array()).toString();\n }\n\n /**\n * Verifies a signed data with a public key\n *\n * @param args.message message\n * @param args.signature The signature\n * @returns true if the signature is valid\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {\n throw new Error(\"Not yet implemented\");\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.iss);\n serializer.serializeBytes(this.idCommitment);\n }\n\n static deserialize(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n static load(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n static isPublicKey(publicKey: PublicKey): publicKey is KeylessPublicKey {\n return publicKey instanceof KeylessPublicKey;\n }\n\n /**\n * Creates a KeylessPublicKey from the JWT components plus pepper\n *\n * @param args.iss the iss of the identity\n * @param args.uidKey the key to use to get the uidVal in the JWT token\n * @param args.uidVal the value of the uidKey in the JWT token\n * @param args.aud the client ID of the application\n * @param args.pepper The pepper used to maintain privacy of the account\n * @returns KeylessPublicKey\n */\n static create(args: {\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n }): KeylessPublicKey {\n computeIdCommitment(args);\n return new KeylessPublicKey(args.iss, computeIdCommitment(args));\n }\n\n static fromJWTAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {\n const { jwt, pepper, uidKey = \"sub\" } = args;\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n const iss = jwtPayload.iss!;\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const aud = jwtPayload.aud!;\n const uidVal = jwtPayload[uidKey];\n return KeylessPublicKey.create({ iss, uidKey, uidVal, aud, pepper });\n }\n}\n\nfunction computeIdCommitment(args: { uidKey: string; uidVal: string; aud: string; pepper: HexInput }): Uint8Array {\n const { uidKey, uidVal, aud, pepper } = args;\n\n const fields = [\n bytesToBigIntLE(Hex.fromHexInput(pepper).toUint8Array()),\n hashStrToField(aud, MAX_AUD_VAL_BYTES),\n hashStrToField(uidVal, MAX_UID_VAL_BYTES),\n hashStrToField(uidKey, MAX_UID_KEY_BYTES),\n ];\n\n return bigIntToBytesLE(poseidonHash(fields), KeylessPublicKey.ID_COMMITMENT_LENGTH);\n}\n\n/**\n * A signature of a message signed via Keyless Accounnt that uses proofs or the jwt token to authenticate.\n */\nexport class KeylessSignature extends Signature {\n /**\n * The inner signature ZeroKnowledgeSigniature or OpenIdSignature\n */\n readonly ephemeralCertificate: EphemeralCertificate;\n\n /**\n * The jwt header in the token used to create the proof/signature. In json string representation.\n */\n readonly jwtHeader: string;\n\n /**\n * The expiry timestamp in seconds of the EphemeralKeyPair used to sign\n */\n readonly expiryDateSecs: number;\n\n /**\n * The ephemeral public key used to verify the signature\n */\n readonly ephemeralPublicKey: EphemeralPublicKey;\n\n /**\n * The signature resulting from signing with the private key of the EphemeralKeyPair\n */\n readonly ephemeralSignature: EphemeralSignature;\n\n constructor(args: {\n jwtHeader: string;\n ephemeralCertificate: EphemeralCertificate;\n expiryDateSecs: number;\n ephemeralPublicKey: EphemeralPublicKey;\n ephemeralSignature: EphemeralSignature;\n }) {\n super();\n const { jwtHeader, ephemeralCertificate, expiryDateSecs, ephemeralPublicKey, ephemeralSignature } = args;\n this.jwtHeader = jwtHeader;\n this.ephemeralCertificate = ephemeralCertificate;\n this.expiryDateSecs = expiryDateSecs;\n this.ephemeralPublicKey = ephemeralPublicKey;\n this.ephemeralSignature = ephemeralSignature;\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n serialize(serializer: Serializer): void {\n this.ephemeralCertificate.serialize(serializer);\n serializer.serializeStr(this.jwtHeader);\n serializer.serializeU64(this.expiryDateSecs);\n this.ephemeralPublicKey.serialize(serializer);\n this.ephemeralSignature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessSignature {\n const ephemeralCertificate = EphemeralCertificate.deserialize(deserializer);\n const jwtHeader = deserializer.deserializeStr();\n const expiryDateSecs = deserializer.deserializeU64();\n const ephemeralPublicKey = EphemeralPublicKey.deserialize(deserializer);\n const ephemeralSignature = EphemeralSignature.deserialize(deserializer);\n return new KeylessSignature({\n jwtHeader,\n expiryDateSecs: Number(expiryDateSecs),\n ephemeralCertificate,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n static getSimulationSignature(): KeylessSignature {\n return new KeylessSignature({\n jwtHeader: \"{}\",\n ephemeralCertificate: new EphemeralCertificate(\n new ZeroKnowledgeSig({\n proof: new ZkProof(\n new Groth16Zkp({ a: new Uint8Array(32), b: new Uint8Array(64), c: new Uint8Array(32) }),\n ZkpVariant.Groth16,\n ),\n expHorizonSecs: 0,\n }),\n EphemeralCertificateVariant.ZkProof,\n ),\n expiryDateSecs: 0,\n ephemeralPublicKey: new EphemeralPublicKey(new Ed25519PublicKey(new Uint8Array(32))),\n ephemeralSignature: new EphemeralSignature(new Ed25519Signature(new Uint8Array(64))),\n });\n }\n\n static isSignature(signature: Signature): signature is KeylessSignature {\n return signature instanceof KeylessSignature;\n }\n}\n\n/**\n * A container for a signature that is a ZeroKnowledgeSig. Can be expanded to support OpenIdSignature.\n */\nexport class EphemeralCertificate extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: EphemeralCertificateVariant;\n\n constructor(signature: Signature, variant: EphemeralCertificateVariant) {\n super();\n this.signature = signature;\n this.variant = variant;\n }\n\n /**\n * Get the public key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the public key\n */\n toUint8Array(): Uint8Array {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): EphemeralCertificate {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case EphemeralCertificateVariant.ZkProof:\n return new EphemeralCertificate(ZeroKnowledgeSig.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for EphemeralCertificate: ${variant}`);\n }\n }\n}\n\nclass G1Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 32) {\n throw new Error(\"Input needs to be 32 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G1Bytes {\n const bytes = deserializer.deserializeFixedBytes(32);\n return new G1Bytes(bytes);\n }\n}\n\nclass G2Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 64) {\n throw new Error(\"Input needs to be 64 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G2Bytes {\n const bytes = deserializer.deserializeFixedBytes(64);\n return new G2Bytes(bytes);\n }\n}\n\n/**\n * A representation of a Groth16 proof. The points are the compressed serialization of affine reprentation of the proof.\n */\nexport class Groth16Zkp extends Proof {\n /**\n * The bytes of G1 proof point a\n */\n a: G1Bytes;\n\n /**\n * The bytes of G2 proof point b\n */\n b: G2Bytes;\n\n /**\n * The bytes of G1 proof point c\n */\n c: G1Bytes;\n\n constructor(args: { a: HexInput; b: HexInput; c: HexInput }) {\n super();\n const { a, b, c } = args;\n this.a = new G1Bytes(a);\n this.b = new G2Bytes(b);\n this.c = new G1Bytes(c);\n }\n\n serialize(serializer: Serializer): void {\n this.a.serialize(serializer);\n this.b.serialize(serializer);\n this.c.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Groth16Zkp {\n const a = G1Bytes.deserialize(deserializer).bcsToBytes();\n const b = G2Bytes.deserialize(deserializer).bcsToBytes();\n const c = G1Bytes.deserialize(deserializer).bcsToBytes();\n return new Groth16Zkp({ a, b, c });\n }\n}\n\n/**\n * A container for a different zero knowledge proof types\n */\nexport class ZkProof extends Serializable {\n public readonly proof: Proof;\n\n /**\n * Index of the underlying enum variant\n */\n private readonly variant: ZkpVariant;\n\n constructor(proof: Proof, variant: ZkpVariant) {\n super();\n this.proof = proof;\n this.variant = variant;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): ZkProof {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case ZkpVariant.Groth16:\n return new ZkProof(Groth16Zkp.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for ZkProof: ${variant}`);\n }\n }\n}\n\n/**\n * The signature representation of a proof\n */\nexport class ZeroKnowledgeSig extends Signature {\n /**\n * The proof\n */\n readonly proof: ZkProof;\n\n /**\n * The max lifespan of the proof\n */\n readonly expHorizonSecs: number;\n\n /**\n * A key value pair on the JWT token that can be specified on the signature which would reveal the value on chain.\n * Can be used to assert identity or other attributes.\n */\n readonly extraField?: string;\n\n /**\n * The 'aud' value of the recovery service which is set when recovering an account.\n */\n readonly overrideAudVal?: string;\n\n /**\n * The training wheels signature\n */\n readonly trainingWheelsSignature?: EphemeralSignature;\n\n constructor(args: {\n proof: ZkProof;\n expHorizonSecs: number;\n extraField?: string;\n overrideAudVal?: string;\n trainingWheelsSignature?: EphemeralSignature;\n }) {\n super();\n const { proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal } = args;\n this.proof = proof;\n this.expHorizonSecs = expHorizonSecs;\n this.trainingWheelsSignature = trainingWheelsSignature;\n this.extraField = extraField;\n this.overrideAudVal = overrideAudVal;\n }\n\n /**\n * Get the signature in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the signature\n */\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n /**\n * Return a ZeroKnowledgeSig object from its bcs serialization in bytes.\n *\n * @returns ZeroKnowledgeSig\n */\n static fromBytes(bytes: Uint8Array): ZeroKnowledgeSig {\n return ZeroKnowledgeSig.deserialize(new Deserializer(bytes));\n }\n\n serialize(serializer: Serializer): void {\n this.proof.serialize(serializer);\n serializer.serializeU64(this.expHorizonSecs);\n serializer.serializeOptionStr(this.extraField);\n serializer.serializeOptionStr(this.overrideAudVal);\n serializer.serializeOption(this.trainingWheelsSignature);\n }\n\n static deserialize(deserializer: Deserializer): ZeroKnowledgeSig {\n const proof = ZkProof.deserialize(deserializer);\n const expHorizonSecs = Number(deserializer.deserializeU64());\n const extraField = deserializer.deserializeOptionStr();\n const overrideAudVal = deserializer.deserializeOptionStr();\n const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);\n return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });\n }\n}\n\n/**\n * A class which represents the on-chain configuration for how Keyless accounts work\n */\nexport class KeylessConfiguration {\n /**\n * The verification key used to verify Groth16 proofs on chain\n */\n readonly verficationKey: Groth16VerificationKey;\n\n /**\n * The maximum lifespan of an ephemeral key pair. This is configured on chain.\n */\n readonly maxExpHorizonSecs: number;\n\n constructor(verficationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {\n this.verficationKey = verficationKey;\n this.maxExpHorizonSecs = maxExpHorizonSecs;\n }\n\n static create(res: Groth16VerificationKeyResponse, maxExpHorizonSecs: number): KeylessConfiguration {\n return new KeylessConfiguration(\n new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n }),\n maxExpHorizonSecs,\n );\n }\n}\n\n/**\n * A representation of the verification key stored on chain used to verify Groth16 proofs\n */\nclass Groth16VerificationKey {\n // The docstrings below are borrowed from ark-groth16\n\n /**\n * The `alpha * G`, where `G` is the generator of G1\n */\n readonly alphaG1: G1Bytes;\n\n /**\n * The `alpha * H`, where `H` is the generator of G2\n */\n readonly betaG2: G2Bytes;\n\n /**\n * The `delta * H`, where `H` is the generator of G2\n */\n readonly deltaG2: G2Bytes;\n\n /**\n * The `gamma^{-1} * (beta * a_i + alpha * b_i + c_i) * H`, where H is the generator of G1\n */\n readonly gammaAbcG1: G1Bytes[];\n\n /**\n * The `gamma * H`, where `H` is the generator of G2\n */\n readonly gammaG2: G2Bytes;\n\n constructor(args: {\n alphaG1: HexInput;\n betaG2: HexInput;\n deltaG2: HexInput;\n gammaAbcG1: [HexInput, HexInput];\n gammaG2: HexInput;\n }) {\n const { alphaG1, betaG2, deltaG2, gammaAbcG1, gammaG2 } = args;\n this.alphaG1 = new G1Bytes(alphaG1);\n this.betaG2 = new G2Bytes(betaG2);\n this.deltaG2 = new G2Bytes(deltaG2);\n this.gammaAbcG1 = [new G1Bytes(gammaAbcG1[0]), new G1Bytes(gammaAbcG1[1])];\n this.gammaG2 = new G2Bytes(gammaG2);\n }\n\n static fromGroth16VerificationKeyResponse(res: Groth16VerificationKeyResponse): Groth16VerificationKey {\n return new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n });\n }\n}\n\n/**\n * Gets the parameters of how Keyless Accounts are configured on chain including the verifying key and the max expiry horizon\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns KeylessConfiguration\n */\nexport async function getKeylessConfig(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfiguration> {\n const { aptosConfig } = args;\n return memoizeAsync(\n async () => {\n const config = await getKeylessConfigurationResource(args);\n const vk = await getGroth16VerificationKeyResource(args);\n return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));\n },\n `keyless-configuration-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\n/**\n * Gets the KeylessConfiguration set on chain\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns KeylessConfigurationResponse\n */\nasync function getKeylessConfigurationResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfigurationResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Configuration\";\n const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({\n aptosConfig,\n originMethod: \"getKeylessConfigurationResource\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n\n/**\n * Gets the Groth16VerificationKey set on chain\n *\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns Groth16VerificationKeyResponse\n */\nasync function getGroth16VerificationKeyResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<Groth16VerificationKeyResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Groth16VerificationKey\";\n const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({\n aptosConfig,\n originMethod: \"getGroth16VerificationKeyResource\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n\n return data.data;\n}\n"],"mappings":"0jBAGA,OAAqB,aAAAA,MAAiB,aAyB/B,IAAMC,GAAmB,IACnBC,EAAoB,IACpBC,EAAoB,GACpBC,EAAoB,IACpBC,GAAoB,IACpBC,GAAwB,IACxBC,GAA2B,IAC3BC,GAAyB,GAOzBC,EAAN,MAAMA,UAAyBC,CAAiB,CAkBrD,YAAYC,EAAaC,EAAwB,CAC/C,MAAM,EACN,IAAMC,EAAWC,EAAI,aAAaF,CAAY,EAAE,aAAa,EAC7D,GAAIC,EAAS,SAAWJ,EAAiB,qBACvC,MAAM,IAAI,MAAM,2CAA2CA,EAAiB,oBAAoB,EAAE,EAEpG,KAAK,IAAME,EACX,KAAK,aAAeE,CACtB,CAOA,SAA6B,CAC3B,IAAME,EAAa,IAAIC,EACvB,OAAAD,EAAW,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AAyBF,EAAY,OAAO,GAC5C,IAAO,GAAK,CACd,EAAE,CACJ,CAQA,eAAeG,EAAgCzE,EAGL,CACxC,GAAM,CAAE,YAAAsE,EAAa,QAAAM,CAAQ,EAAI5E,EAC3B6E,EAAe,sCACf,CAAE,KAAArC,CAAK,EAAI,MAAMsC,EAAiE,CACtF,YAAAR,EACA,aAAc,kCACd,KAAM,YAAYS,EAAe,KAAK,KAAK,EAAE,SAAS,CAAC,aAAaF,CAAY,GAChF,OAAQ,CAAE,eAAgBD,GAAS,aAAc,CACnD,CAAC,EAED,OAAOpC,EAAK,IACd,CAQA,eAAemC,EAAkC3E,EAGL,CAC1C,GAAM,CAAE,YAAAsE,EAAa,QAAAM,CAAQ,EAAI5E,EAC3B6E,EAAe,+CACf,CAAE,KAAArC,CAAK,EAAI,MAAMsC,EAAmE,CACxF,YAAAR,EACA,aAAc,oCACd,KAAM,YAAYS,EAAe,KAAK,KAAK,EAAE,SAAS,CAAC,aAAaF,CAAY,GAChF,OAAQ,CAAE,eAAgBD,GAAS,aAAc,CACnD,CAAC,EAED,OAAOpC,EAAK,IACd","names":["jwtDecode","EPK_HORIZON_SECS","MAX_AUD_VAL_BYTES","MAX_UID_KEY_BYTES","MAX_UID_VAL_BYTES","MAX_ISS_VAL_BYTES","MAX_EXTRA_FIELD_BYTES","MAX_JWT_HEADER_B64_BYTES","MAX_COMMITED_EPK_BYTES","_KeylessPublicKey","AccountPublicKey","iss","idCommitment","idcBytes","Hex","serializer","Serializer","AuthenticationKey","args","deserializer","addressSeed","publicKey","computeIdCommitment","jwt","pepper","uidKey","jwtPayload","jwtDecode","aud","uidVal","KeylessPublicKey","fields","bytesToBigIntLE","hashStrToField","bigIntToBytesLE","poseidonHash","KeylessSignature","_KeylessSignature","Signature","jwtHeader","ephemeralCertificate","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","EphemeralCertificate","EphemeralPublicKey","EphemeralSignature","ZeroKnowledgeSig","ZkProof","Groth16Zkp","Ed25519PublicKey","Ed25519Signature","signature","_EphemeralCertificate","variant","G1Bytes","_G1Bytes","Serializable","data","bytes","G2Bytes","_G2Bytes","_Groth16Zkp","Proof","a","b","c","_ZkProof","proof","_ZeroKnowledgeSig","expHorizonSecs","trainingWheelsSignature","extraField","overrideAudVal","Deserializer","KeylessConfiguration","_KeylessConfiguration","verficationKey","maxExpHorizonSecs","res","Groth16VerificationKey","_Groth16VerificationKey","alphaG1","betaG2","deltaG2","gammaAbcG1","gammaG2","getKeylessConfig","aptosConfig","memoizeAsync","config","getKeylessConfigurationResource","vk","getGroth16VerificationKeyResource","options","resourceType","getAptosFullNode","AccountAddress"]}
@@ -1,2 +1,2 @@
1
- import{a as o}from"./chunk-ZMXURV35.mjs";import{a as r,b as i,c as s}from"./chunk-QKV2H27T.mjs";var t=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await o({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),r({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await o({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),i({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await o({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),s({aptosConfig:this.config,...e})}};export{t as a};
2
- //# sourceMappingURL=chunk-OLKEU7WZ.mjs.map
1
+ import{a as r,b as i,c as s}from"./chunk-GQC73XWZ.mjs";import{a as o}from"./chunk-ZIDLP5MI.mjs";var t=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await o({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),r({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await o({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),i({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await o({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),s({aptosConfig:this.config,...e})}};export{t as a};
2
+ //# sourceMappingURL=chunk-5WFKJO5L.mjs.map
@@ -1,2 +1,2 @@
1
- import{c as a}from"./chunk-TAVPFLW5.mjs";import e from"eventemitter3";var i=class extends e{constructor(t){super(),this.config=t}start(t){let{sender:n}=t;this.account=n,this.transactionWorker=new a(this.config,n),this.transactionWorker.start(),this.registerToEvents()}push(t){let{data:n,options:o}=t;for(let r of n)this.transactionWorker.push(r,o)}registerToEvents(){this.transactionWorker.on("transactionSent",async t=>{this.emit("transactionSent",t)}),this.transactionWorker.on("transactionSendFailed",async t=>{this.emit("transactionSendFailed",t)}),this.transactionWorker.on("transactionExecuted",async t=>{this.emit("transactionExecuted",t)}),this.transactionWorker.on("transactionExecutionFailed",async t=>{this.emit("transactionExecutionFailed",t)}),this.transactionWorker.on("executionFinish",async t=>{this.emit("executionFinish",t)})}forSingleAccount(t){try{let{sender:n,data:o,options:r}=t;this.start({sender:n}),this.push({data:o,options:r})}catch(n){throw new Error(`failed to submit transactions with error: ${n}`)}}};export{i as a};
2
- //# sourceMappingURL=chunk-HZ3YB6TN.mjs.map
1
+ import{c as a}from"./chunk-SYRND55P.mjs";import e from"eventemitter3";var i=class extends e{constructor(t){super();this.config=t}start(t){let{sender:n}=t;this.account=n,this.transactionWorker=new a(this.config,n),this.transactionWorker.start(),this.registerToEvents()}push(t){let{data:n,options:o}=t;for(let r of n)this.transactionWorker.push(r,o)}registerToEvents(){this.transactionWorker.on("transactionSent",async t=>{this.emit("transactionSent",t)}),this.transactionWorker.on("transactionSendFailed",async t=>{this.emit("transactionSendFailed",t)}),this.transactionWorker.on("transactionExecuted",async t=>{this.emit("transactionExecuted",t)}),this.transactionWorker.on("transactionExecutionFailed",async t=>{this.emit("transactionExecutionFailed",t)}),this.transactionWorker.on("executionFinish",async t=>{this.emit("executionFinish",t)})}forSingleAccount(t){try{let{sender:n,data:o,options:r}=t;this.start({sender:n}),this.push({data:o,options:r})}catch(n){throw new Error(`failed to submit transactions with error: ${n}`)}}};export{i as a};
2
+ //# sourceMappingURL=chunk-64CUEMFI.mjs.map
@@ -1,2 +1,2 @@
1
- import{f as e,g as s,h as t,i as o,j as r,k as i,l as a,m,n as c,o as g,p as u,q as p,r as d}from"./chunk-QIELBIZW.mjs";var A=class{constructor(n){this.config=n}async getOwnerAddress(n){return e({aptosConfig:this.config,...n})}async getExpiration(n){return t({aptosConfig:this.config,...n})}async getTargetAddress(n){return i({aptosConfig:this.config,...n})}async setTargetAddress(n){return a({aptosConfig:this.config,...n})}async getPrimaryName(n){return o({aptosConfig:this.config,...n})}async setPrimaryName(n){return r({aptosConfig:this.config,...n})}async registerName(n){return s({aptosConfig:this.config,...n})}async renewDomain(n){return d({aptosConfig:this.config,...n})}async getName(n){return m({aptosConfig:this.config,...n})}async getAccountNames(n){return c({aptosConfig:this.config,...n})}async getAccountDomains(n){return g({aptosConfig:this.config,...n})}async getAccountSubdomains(n){return u({aptosConfig:this.config,...n})}async getDomainSubdomains(n){return p({aptosConfig:this.config,...n})}};export{A as a};
2
- //# sourceMappingURL=chunk-LM7CN4LT.mjs.map
1
+ import{f as e,g as s,h as t,i as o,j as r,k as i,l as a,m,n as c,o as g,p as u,q as p,r as d}from"./chunk-UHZWZWJ7.mjs";var A=class{constructor(n){this.config=n}async getOwnerAddress(n){return e({aptosConfig:this.config,...n})}async getExpiration(n){return t({aptosConfig:this.config,...n})}async getTargetAddress(n){return i({aptosConfig:this.config,...n})}async setTargetAddress(n){return a({aptosConfig:this.config,...n})}async getPrimaryName(n){return o({aptosConfig:this.config,...n})}async setPrimaryName(n){return r({aptosConfig:this.config,...n})}async registerName(n){return s({aptosConfig:this.config,...n})}async renewDomain(n){return d({aptosConfig:this.config,...n})}async getName(n){return m({aptosConfig:this.config,...n})}async getAccountNames(n){return c({aptosConfig:this.config,...n})}async getAccountDomains(n){return g({aptosConfig:this.config,...n})}async getAccountSubdomains(n){return u({aptosConfig:this.config,...n})}async getDomainSubdomains(n){return p({aptosConfig:this.config,...n})}};export{A as a};
2
+ //# sourceMappingURL=chunk-64VPA7CM.mjs.map
@@ -1,2 +1,2 @@
1
- var s=class extends Error{constructor(e,t,a){super(a),this.name="AptosApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data,this.request=e}};export{s as a};
2
- //# sourceMappingURL=chunk-GHYE26Q5.mjs.map
1
+ var s=class extends Error{constructor(e,t,a){super(a);this.name="AptosApiError",this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data,this.request=e}};export{s as a};
2
+ //# sourceMappingURL=chunk-6FBKUTGF.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a as r}from"./chunk-UMLUOYFK.mjs";import{b as i}from"./chunk-AOCNYMMX.mjs";var t=class a extends r{constructor(e){super();this.value=i.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,s){let o=e.deserializeFixedBytes(s);return new a(o)}};export{t as a};
2
+ //# sourceMappingURL=chunk-7BW2N4IE.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as n}from"./chunk-ZMXURV35.mjs";import{a as s,b as t,c as r,d as i,e as c,f as u,g as d,h as A,i as g,j as m,k as a,l as p,m as f,n as y,o as C,p as O,q as T}from"./chunk-MEXWNZY6.mjs";import{e as o}from"./chunk-CYNQRMO5.mjs";var l=class{constructor(e){this.config=e}async getAccountInfo(e){return s({aptosConfig:this.config,...e})}async getAccountModules(e){return t({aptosConfig:this.config,...e})}async getAccountModule(e){return r({aptosConfig:this.config,...e})}async getAccountTransactions(e){return i({aptosConfig:this.config,...e})}async getAccountResources(e){return c({aptosConfig:this.config,...e})}async getAccountResource(e){return u({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return d({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),A({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),g({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),m({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),a({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),p({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),y({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),C({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:o,...e})}async getAccountCoinAmount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),f({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),O({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return T({aptosConfig:this.config,...e})}};export{l as a};
2
- //# sourceMappingURL=chunk-UF5B4XMN.mjs.map
1
+ import{a as s,b as t,c as r,d as i,e as c,f as u,g as d,h as A,i as g,j as m,k as a,l as p,m as f,n as y,o as C,p as O,q as T}from"./chunk-HXYZECGS.mjs";import{a as n}from"./chunk-ZIDLP5MI.mjs";import{e as o}from"./chunk-YE5B2S5L.mjs";var l=class{constructor(e){this.config=e}async getAccountInfo(e){return s({aptosConfig:this.config,...e})}async getAccountModules(e){return t({aptosConfig:this.config,...e})}async getAccountModule(e){return r({aptosConfig:this.config,...e})}async getAccountTransactions(e){return i({aptosConfig:this.config,...e})}async getAccountResources(e){return c({aptosConfig:this.config,...e})}async getAccountResource(e){return u({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return d({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),A({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),g({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),m({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),a({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),p({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),y({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),C({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:o,...e})}async getAccountCoinAmount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),f({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),O({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return T({aptosConfig:this.config,...e})}};export{l as a};
2
+ //# sourceMappingURL=chunk-7G3RSOWE.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-V367QLY3.mjs";import{h as t}from"./chunk-R5NNAF5B.mjs";var r=class{constructor(o){this.config=o}async fundAccount(o){let n=await i({aptosConfig:this.config,...o});return o.options?.waitForIndexer!==!1&&await t({aptosConfig:this.config,minimumLedgerVersion:BigInt(n.version)}),n}};export{r as a};
2
- //# sourceMappingURL=chunk-AKJZL3HT.mjs.map
1
+ import{a as i}from"./chunk-S5ABQH5R.mjs";import{h as t}from"./chunk-MNTLX37G.mjs";var r=class{constructor(o){this.config=o}async fundAccount(o){let n=await i({aptosConfig:this.config,...o});return o.options?.waitForIndexer!==!1&&await t({aptosConfig:this.config,minimumLedgerVersion:BigInt(n.version)}),n}};export{r as a};
2
+ //# sourceMappingURL=chunk-7M4C4OZN.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as t}from"./chunk-ZMXURV35.mjs";import{a as o,b as r,c as s}from"./chunk-6SK246YU.mjs";var a=class{constructor(e){this.config=e}async getTableItem(e){return o({aptosConfig:this.config,...e})}async getTableItemsData(e){return await t({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),r({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await t({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),s({aptosConfig:this.config,...e})}};export{a};
2
- //# sourceMappingURL=chunk-DO444YYD.mjs.map
1
+ import{a as o,b as r,c as s}from"./chunk-YA4XTZNZ.mjs";import{a as t}from"./chunk-ZIDLP5MI.mjs";var a=class{constructor(e){this.config=e}async getTableItem(e){return o({aptosConfig:this.config,...e})}async getTableItemsData(e){return await t({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),r({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await t({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),s({aptosConfig:this.config,...e})}};export{a};
2
+ //# sourceMappingURL=chunk-7UKBRLGM.mjs.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-7Z6DYLCA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-LG7RJQ57.mjs";import{bytesToHex as s,hexToBytes as o}from"@noble/hashes/utils";var l=(e=>(e.TOO_SHORT="too_short",e.INVALID_LENGTH="invalid_length",e.INVALID_HEX_CHARS="invalid_hex_chars",e))(l||{}),i=class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return s(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let r=t;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new a("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new a("Hex string must be an even number of hex characters.","invalid_length");try{return new n(o(r))}catch(e){throw new a(`Hex string contains invalid hex characters: ${e?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,e)=>r===t.data[e])}};export{l as a,i as b};
2
- //# sourceMappingURL=chunk-BCUSI3N6.mjs.map
1
+ import{a}from"./chunk-FBPNHF54.mjs";import{bytesToHex as s,hexToBytes as o}from"@noble/hashes/utils";var l=(e=>(e.TOO_SHORT="too_short",e.INVALID_LENGTH="invalid_length",e.INVALID_HEX_CHARS="invalid_hex_chars",e))(l||{}),i=class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return s(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let r=t;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new a("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new a("Hex string must be an even number of hex characters.","invalid_length");try{return new n(o(r))}catch(e){throw new a(`Hex string contains invalid hex characters: ${e?.message}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(r){return{valid:!1,invalidReason:r?.invalidReason,invalidReasonMessage:r?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((r,e)=>r===t.data[e])}};export{l as a,i as b};
2
+ //# sourceMappingURL=chunk-AOCNYMMX.mjs.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-AQ4I7VVB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,2 +1,2 @@
1
- import{a as t}from"./chunk-V6J6AW5T.mjs";var o=class{constructor(n){this.config=n}async simple(n){return t({aptosConfig:this.config,...n})}async multiAgent(n){return t({aptosConfig:this.config,...n})}};export{o as a};
2
- //# sourceMappingURL=chunk-YMHX6GC2.mjs.map
1
+ import{a as t}from"./chunk-VIX4BX35.mjs";var o=class{constructor(n){this.config=n}async simple(n){return t({aptosConfig:this.config,...n})}async multiAgent(n){return t({aptosConfig:this.config,...n})}};export{o as a};
2
+ //# sourceMappingURL=chunk-B2RYTKNN.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a as s}from"./chunk-HXYZECGS.mjs";import{a as e,b as n}from"./chunk-YTQVMLFD.mjs";var r=class{constructor(t,i,o,a,c){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=i,this.maxWaitTime=o,this.maximumInFlight=a,this.sleepTime=c}async nextSequenceNumber(){for(;this.lock;)await e(this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let i=n();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await e(this.sleepTime),n()-i>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(i){console.error("error in getting next sequence number for this account",i)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await s({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await s({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await e(this.sleepTime);this.lock=!0;try{await this.update();let t=n();for(;this.lastUncommintedNumber!==this.currentNumber;)n()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await e(this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};export{r as a};
2
+ //# sourceMappingURL=chunk-BCZGONNO.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/transactions/management/accountSequenceNumber.ts"],"sourcesContent":["/**\n * A wrapper that handles and manages an account sequence number.\n *\n * Submit up to `maximumInFlight` transactions per account in parallel with a timeout of `sleepTime`\n * If local assumes `maximumInFlight` are in flight, determine the actual committed state from the network\n * If there are less than `maximumInFlight` due to some being committed, adjust the window\n * If `maximumInFlight` are in flight, wait `sleepTime` seconds before re-evaluating\n * If ever waiting more than `maxWaitTime` restart the sequence number to the current on-chain state\n *\n * Assumptions:\n * Accounts are expected to be managed by a single AccountSequenceNumber and not used otherwise.\n * They are initialized to the current on-chain state, so if there are already transactions in\n * flight, they may take some time to reset.\n * Accounts are automatically initialized if not explicitly\n *\n * Notes:\n * This is co-routine safe, that is many async tasks can be reading from this concurrently.\n * The state of an account cannot be used across multiple AccountSequenceNumber services.\n * The synchronize method will create a barrier that prevents additional nextSequenceNumber\n * calls until it is complete.\n * This only manages the distribution of sequence numbers it does not help handle transaction\n * failures.\n * If a transaction fails, you should call synchronize and wait for timeouts.\n */\n\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { Account } from \"../../account\";\nimport { getInfo } from \"../../internal/account\";\nimport { nowInSeconds, sleep } from \"../../utils/helpers\";\n\nexport class AccountSequenceNumber {\n readonly aptosConfig: AptosConfig;\n\n readonly account: Account;\n\n // sequence number on chain\n lastUncommintedNumber: bigint | null = null;\n\n // local sequence number\n currentNumber: bigint | null = null;\n\n /**\n * We want to guarantee that we preserve ordering of workers to requests.\n *\n * `lock` is used to try to prevent multiple coroutines from accessing a shared resource at the same time,\n * which can result in race conditions and data inconsistency.\n * This code actually doesn't do it though, since we aren't giving out a slot, it is still somewhat a race condition.\n *\n * The ideal solution is likely that each thread grabs the next number from a incremental integer.\n * When they complete, they increment that number and that entity is able to enter the `lock`.\n * That would guarantee ordering.\n */\n lock = false;\n\n maxWaitTime: number;\n\n maximumInFlight: number;\n\n sleepTime: number;\n\n constructor(\n aptosConfig: AptosConfig,\n account: Account,\n maxWaitTime: number,\n maximumInFlight: number,\n sleepTime: number,\n ) {\n this.aptosConfig = aptosConfig;\n this.account = account;\n this.maxWaitTime = maxWaitTime;\n this.maximumInFlight = maximumInFlight;\n this.sleepTime = sleepTime;\n }\n\n /**\n * Returns the next available sequence number for this account\n *\n * @returns next available sequence number\n */\n async nextSequenceNumber(): Promise<bigint | null> {\n /* eslint-disable no-await-in-loop */\n while (this.lock) {\n await sleep(this.sleepTime);\n }\n\n this.lock = true;\n let nextNumber = BigInt(0);\n try {\n if (this.lastUncommintedNumber === null || this.currentNumber === null) {\n await this.initialize();\n }\n\n if (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {\n await this.update();\n\n const startTime = nowInSeconds();\n while (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {\n await sleep(this.sleepTime);\n if (nowInSeconds() - startTime > this.maxWaitTime) {\n /* eslint-disable no-console */\n console.warn(\n `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,\n );\n await this.initialize();\n } else {\n await this.update();\n }\n }\n }\n nextNumber = this.currentNumber!;\n this.currentNumber! += BigInt(1);\n } catch (e) {\n console.error(\"error in getting next sequence number for this account\", e);\n } finally {\n this.lock = false;\n }\n return nextNumber;\n }\n\n /**\n * Initializes this account with the sequence number on chain\n */\n async initialize(): Promise<void> {\n const { sequence_number: sequenceNumber } = await getInfo({\n aptosConfig: this.aptosConfig,\n accountAddress: this.account.accountAddress,\n });\n this.currentNumber = BigInt(sequenceNumber);\n this.lastUncommintedNumber = BigInt(sequenceNumber);\n }\n\n /**\n * Updates this account sequence number with the one on-chain\n *\n * @returns on-chain sequence number for this account\n */\n async update(): Promise<bigint> {\n const { sequence_number: sequenceNumber } = await getInfo({\n aptosConfig: this.aptosConfig,\n accountAddress: this.account.accountAddress,\n });\n this.lastUncommintedNumber = BigInt(sequenceNumber);\n return this.lastUncommintedNumber;\n }\n\n /**\n * Synchronizes local sequence number with the seqeunce number on chain for this account.\n *\n * Poll the network until all submitted transactions have either been committed or until\n * the maximum wait time has elapsed\n */\n async synchronize(): Promise<void> {\n if (this.lastUncommintedNumber === this.currentNumber) return;\n\n /* eslint-disable no-await-in-loop */\n while (this.lock) {\n await sleep(this.sleepTime);\n }\n\n this.lock = true;\n\n try {\n await this.update();\n const startTime = nowInSeconds();\n while (this.lastUncommintedNumber !== this.currentNumber) {\n if (nowInSeconds() - startTime > this.maxWaitTime) {\n /* eslint-disable no-console */\n console.warn(\n `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,\n );\n await this.initialize();\n } else {\n await sleep(this.sleepTime);\n await this.update();\n }\n }\n } catch (e) {\n console.error(\"error in synchronizing this account sequence number with the one on chain\", e);\n } finally {\n this.lock = false;\n }\n }\n}\n"],"mappings":"yFA8BO,IAAMA,EAAN,KAA4B,CA8BjC,YACEC,EACAC,EACAC,EACAC,EACAC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,CAQA,MAAM,aAA6B,CACjC,GAAI,KAAK,wBAA0B,KAAK,cAGxC,MAAO,KAAK,MACV,MAAML,EAAM,KAAK,SAAS,EAG5B,KAAK,KAAO,GAEZ,GAAI,CACF,MAAM,KAAK,OAAO,EAClB,IAAME,EAAYC,EAAa,EAC/B,KAAO,KAAK,wBAA0B,KAAK,eACrCA,EAAa,EAAID,EAAY,KAAK,aAEpC,QAAQ,KACN,iEAAiE,KAAK,QAAQ,eAAe,SAAS,CAAC,EACzG,EACA,MAAM,KAAK,WAAW,IAEtB,MAAMF,EAAM,KAAK,SAAS,EAC1B,MAAM,KAAK,OAAO,EAGxB,OAASI,EAAG,CACV,QAAQ,MAAM,4EAA6EA,CAAC,CAC9F,QAAE,CACA,KAAK,KAAO,EACd,EACF,CACF","names":["AccountSequenceNumber","aptosConfig","account","maxWaitTime","maximumInFlight","sleepTime","sleep","nextNumber","startTime","nowInSeconds","e","sequenceNumber","getInfo"]}
@@ -0,0 +1,2 @@
1
+ import{a as l}from"./chunk-J3DCBYOY.mjs";import{e as o}from"./chunk-HP6YVTTT.mjs";import{a as g,b as c}from"./chunk-ZV5MKFV7.mjs";var y=class a{constructor(i){let{multiKey:e,signers:s}=i;this.publicKey=e,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let r=[];for(let t of s)r.push(this.publicKey.getIndex(t.publicKey));let n=s.map((t,u)=>[t,r[u]]);n.sort((t,u)=>t[1]-u[1]),this.signers=n.map(t=>t[0]),this.signerIndicies=n.map(t=>t[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:r})}static fromPublicKeysAndSigners(i){let{publicKeys:e,signaturesRequired:s,signers:r}=i,n=new g({publicKeys:e,signaturesRequired:s});return new a({multiKey:n,signers:r})}static isMultiKeySigner(i){return i instanceof a}signWithAuthenticator(i){return new o(this.publicKey,this.sign(i))}signTransactionWithAuthenticator(i){return new o(this.publicKey,this.signTransaction(i))}async waitForProofFetch(){let i=this.signers.filter(e=>e instanceof l);await Promise.all(i.filter(e=>e.proof instanceof Promise).map(e=>e.proof))}sign(i){let e=[];for(let s of this.signers)e.push(s.sign(i));return new c({signatures:e,bitmap:this.signaturesBitmap})}signTransaction(i){let e=[];for(let s of this.signers)e.push(s.signTransaction(i));return new c({signatures:e,bitmap:this.signaturesBitmap})}verifySignature(i){let{message:e,signature:s}=i;if(!this.signerIndicies.every((n,t)=>t===0||n>=this.signerIndicies[t-1]))return!1;for(let n=0;n<s.signatures.length;n+=1){let t=s.signatures[n];if(!this.publicKey.publicKeys[this.signerIndicies[n]].verifySignature({message:e,signature:t}))return!1}return!0}};export{y as a};
2
+ //# sourceMappingURL=chunk-BLWJZXAD.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/account/MultiKeyAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"./Account\";\nimport { MultiKey, MultiKeySignature, PublicKey } from \"../core/crypto\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport { HexInput, SigningScheme } from \"../types\";\nimport { AccountAuthenticatorMultiKey } from \"../transactions/authenticator/account\";\nimport { AnyRawTransaction } from \"../transactions/types\";\nimport { KeylessAccount } from \"./KeylessAccount\";\n\nexport interface VerifyMultiKeySignatureArgs {\n message: HexInput;\n signature: MultiKeySignature;\n}\n\n/**\n * Signer implementation for the MultiKey authentication scheme.\n *\n * This accounts to use a M of N signing scheme. M and N are specified in the {@link MultiKey}\n * It signs messages via the array of M number of Accounts that individually correspond to a public key in the {@link MultiKey}.\n *\n * Note: Generating a signer instance does not create the account on-chain.\n */\nexport class MultiKeyAccount implements Account {\n /**\n * Public key associated with the account\n */\n readonly publicKey: MultiKey;\n\n /**\n * Account address associated with the account\n */\n readonly accountAddress: AccountAddress;\n\n /**\n * Signing scheme used to sign transactions\n */\n readonly signingScheme: SigningScheme;\n\n /**\n * The signers used to sign messages. These signers should correspond to public keys in the\n * MultiKeyAccount's public key. The number of signers should be equal or greater\n * than this.publicKey.signaturesRequired\n */\n readonly signers: Account[];\n\n /**\n * An array of indicies where for signer[i], signerIndicies[i] is the index of the corresponding public key in\n * publicKey.publicKeys. Used to derive the right public key to use for verification.\n */\n readonly signerIndicies: number[];\n\n readonly signaturesBitmap: Uint8Array;\n\n /**\n * constructor for MultiKeyAccount\n *\n * @param args.multiKey the multikey of the account which consists of N public keys and a number M which is\n * the number of required signatures.\n * @param args.signers an array of M signers that will be used to sign the transaction\n * @returns MultiKeyAccount\n */\n constructor(args: { multiKey: MultiKey; signers: Account[] }) {\n const { multiKey, signers } = args;\n\n this.publicKey = multiKey;\n this.signingScheme = SigningScheme.MultiKey;\n\n this.accountAddress = this.publicKey.authKey().derivedAddress();\n\n // Get the index of each respective signer in the bitmap\n const bitPositions: number[] = [];\n for (const signer of signers) {\n bitPositions.push(this.publicKey.getIndex(signer.publicKey));\n }\n // Zip signers and bit positions and sort signers by bit positions in order\n // to ensure the signature is signed in ascending order according to the bitmap.\n // Authentication on chain will fail otherwise.\n const signersAndBitPosition: [Account, number][] = signers.map((signer, index) => [signer, bitPositions[index]]);\n signersAndBitPosition.sort((a, b) => a[1] - b[1]);\n this.signers = signersAndBitPosition.map((value) => value[0]);\n this.signerIndicies = signersAndBitPosition.map((value) => value[1]);\n this.signaturesBitmap = this.publicKey.createBitmap({ bits: bitPositions });\n }\n\n /**\n * Static constructor for MultiKeyAccount\n *\n * @param args.publicKeys the N public keys of the MultiKeyAccount\n * @param args.signaturesRequired the number of signatures required\n * @param args.signers an array of M signers that will be used to sign the transaction\n * @returns MultiKeyAccount\n */\n static fromPublicKeysAndSigners(args: {\n publicKeys: PublicKey[];\n signaturesRequired: number;\n signers: Account[];\n }): MultiKeyAccount {\n const { publicKeys, signaturesRequired, signers } = args;\n const multiKey = new MultiKey({ publicKeys, signaturesRequired });\n return new MultiKeyAccount({ multiKey, signers });\n }\n\n static isMultiKeySigner(account: Account): account is MultiKeyAccount {\n return account instanceof MultiKeyAccount;\n }\n\n /**\n * Sign a message using the account's signers.\n * @param message the signing message, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorMultiKey {\n return new AccountAuthenticatorMultiKey(this.publicKey, this.sign(message));\n }\n\n /**\n * Sign a transaction using the account's signers.\n * @param transaction the raw transaction\n * @return the AccountAuthenticator containing the signature of the transaction, together with the account's public key\n */\n signTransactionWithAuthenticator(transaction: AnyRawTransaction): AccountAuthenticatorMultiKey {\n return new AccountAuthenticatorMultiKey(this.publicKey, this.signTransaction(transaction));\n }\n\n /**\n * Waits for any proofs on any KeylessAccount signers to be fetched. If the proof is fetched a syncronously, call this\n * to ensure signing with the KeylessAccount does not fail as the proof must be ready.\n * @return\n */\n async waitForProofFetch() {\n const keylessSigners = this.signers.filter((signer) => signer instanceof KeylessAccount) as KeylessAccount[];\n await Promise.all(keylessSigners.filter((signer) => signer.proof instanceof Promise).map((signer) => signer.proof));\n }\n\n /**\n * Sign the given message using the MultiKeyAccount's signers\n * @param message in HexInput format\n * @returns MultiKeySignature\n */\n sign(data: HexInput): MultiKeySignature {\n const signatures = [];\n for (const signer of this.signers) {\n signatures.push(signer.sign(data));\n }\n return new MultiKeySignature({ signatures, bitmap: this.signaturesBitmap });\n }\n\n /**\n * Sign the given transaction using the MultiKeyAccount's signers\n * @param transaction the transaction to be signed\n * @returns MultiKeySignature\n */\n signTransaction(transaction: AnyRawTransaction): MultiKeySignature {\n const signatures = [];\n for (const signer of this.signers) {\n signatures.push(signer.signTransaction(transaction));\n }\n return new MultiKeySignature({ signatures, bitmap: this.signaturesBitmap });\n }\n\n /**\n * Verify the given message and signature with the public key.\n *\n * @param args.message raw message data in HexInput format\n * @param args.signatures signed message MultiKeySignature\n * @returns boolean\n */\n verifySignature(args: VerifyMultiKeySignatureArgs): boolean {\n const { message, signature } = args;\n const isSignerIndiciesSorted = this.signerIndicies.every(\n (value, i) => i === 0 || value >= this.signerIndicies[i - 1],\n );\n if (!isSignerIndiciesSorted) {\n return false;\n }\n for (let i = 0; i < signature.signatures.length; i += 1) {\n const singleSignature = signature.signatures[i];\n const publicKey = this.publicKey.publicKeys[this.signerIndicies[i]];\n if (!publicKey.verifySignature({ message, signature: singleSignature })) {\n return false;\n }\n }\n return true;\n }\n}\n"],"mappings":"kIAwBO,IAAMA,EAAN,MAAMC,CAAmC,CAuC9C,YAAYC,EAAkD,CAC5D,GAAM,CAAE,SAAAC,EAAU,QAAAC,CAAQ,EAAIF,EAE9B,KAAK,UAAYC,EACjB,KAAK,cAAgB,EAErB,KAAK,eAAiB,KAAK,UAAU,QAAQ,EAAE,eAAe,EAG9D,IAAME,EAAyB,CAAC,EAChC,QAAWC,KAAUF,EACnBC,EAAa,KAAK,KAAK,UAAU,SAASC,EAAO,SAAS,CAAC,EAK7D,IAAMC,EAA6CH,EAAQ,IAAI,CAACE,EAAQE,IAAU,CAACF,EAAQD,EAAaG,CAAK,CAAC,CAAC,EAC/GD,EAAsB,KAAK,CAACE,EAAGC,IAAMD,EAAE,CAAC,EAAIC,EAAE,CAAC,CAAC,EAChD,KAAK,QAAUH,EAAsB,IAAKI,GAAUA,EAAM,CAAC,CAAC,EAC5D,KAAK,eAAiBJ,EAAsB,IAAKI,GAAUA,EAAM,CAAC,CAAC,EACnE,KAAK,iBAAmB,KAAK,UAAU,aAAa,CAAE,KAAMN,CAAa,CAAC,CAC5E,CAUA,OAAO,yBAAyBH,EAIZ,CAClB,GAAM,CAAE,WAAAU,EAAY,mBAAAC,EAAoB,QAAAT,CAAQ,EAAIF,EAC9CC,EAAW,IAAIW,EAAS,CAAE,WAAAF,EAAY,mBAAAC,CAAmB,CAAC,EAChE,OAAO,IAAIZ,EAAgB,CAAE,SAAAE,EAAU,QAAAC,CAAQ,CAAC,CAClD,CAEA,OAAO,iBAAiBW,EAA8C,CACpE,OAAOA,aAAmBd,CAC5B,CAOA,sBAAsBe,EAAiD,CACrE,OAAO,IAAIC,EAA6B,KAAK,UAAW,KAAK,KAAKD,CAAO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index","a","b","value","publicKeys","signaturesRequired","MultiKey","account","message","AccountAuthenticatorMultiKey","transaction","keylessSigners","KeylessAccount","data","signatures","MultiKeySignature","signature","i","singleSignature"]}
@@ -1,2 +1,2 @@
1
- import{a as d}from"./chunk-AFTMLXYT.mjs";import{a as u}from"./chunk-F7EMGK4M.mjs";import{e as g,j as h}from"./chunk-LR65XHSF.mjs";import{a as f}from"./chunk-F7J7ZW4H.mjs";import{a as p}from"./chunk-4KMISR2H.mjs";import{b as s}from"./chunk-BCUSI3N6.mjs";import{sha3_256 as H}from"@noble/hashes/sha3";import{secp256k1 as o}from"@noble/curves/secp256k1";import{HDKey as S}from"@scure/bip32";var n=class n extends f{constructor(e){super();let r=s.fromHexInput(e);if(r.toUint8Array().length!==n.LENGTH)throw new Error(`PublicKey length should be ${n.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof y))return!1;let l=u(r),c=s.fromHexInput(l).toUint8Array(),A=H(c),x=i.toUint8Array();return o.verify(x,A,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new n(r)}static isPublicKey(e){return e instanceof n}};n.LENGTH=65;var m=n,t=class t extends p{constructor(e){super();let r=s.fromHexInput(e);if(r.toUint8Array().length!==t.LENGTH)throw new Error(`PrivateKey length should be ${t.LENGTH}`);this.key=r}static generate(){let e=o.utils.randomPrivateKey();return new t(e)}static fromDerivationPath(e,r){if(!g(e))throw new Error(`Invalid derivation path ${e}`);return t.fromDerivationPathInner(e,h(r))}static fromDerivationPathInner(e,r){let{privateKey:i}=S.fromMasterSeed(r).derive(e);if(i===null)throw new Error("Invalid key");return new t(i)}sign(e){let r=u(e),i=s.fromHexInput(r),l=H(i.toUint8Array()),c=o.sign(l,this.key.toUint8Array(),{lowS:!0});return new y(c.toCompactRawBytes())}publicKey(){let e=o.getPublicKey(this.key.toUint8Array(),!1);return new m(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new t(r)}static isPrivateKey(e){return e instanceof t}};t.LENGTH=32;var v=t,a=class a extends d{constructor(e){super();let r=s.fromHexInput(e);if(r.toUint8Array().length!==a.LENGTH)throw new Error(`Signature length should be ${a.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new a(r)}};a.LENGTH=64;var y=a;export{m as a,v as b,y as c};
2
- //# sourceMappingURL=chunk-JWTZDA6A.mjs.map
1
+ import{a as d}from"./chunk-WA2NTBYY.mjs";import{a as v}from"./chunk-4VPCPASN.mjs";import{a as u}from"./chunk-TJDC5PWD.mjs";import{e as h,j as f}from"./chunk-LR65XHSF.mjs";import{a as g}from"./chunk-UMLUOYFK.mjs";import{b as s}from"./chunk-AOCNYMMX.mjs";import{sha3_256 as A}from"@noble/hashes/sha3";import{secp256k1 as o}from"@noble/curves/secp256k1";import{HDKey as U}from"@scure/bip32";var n=class n extends d{constructor(e){super();let r=s.fromHexInput(e);if(r.toUint8Array().length!==n.LENGTH)throw new Error(`PublicKey length should be ${n.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof y))return!1;let l=u(r),c=s.fromHexInput(l).toUint8Array(),x=A(c),S=i.toUint8Array();return o.verify(S,x,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new n(r)}static isPublicKey(e){return e instanceof n}};n.LENGTH=65;var m=n,t=class t extends g{constructor(e){super();let r=s.fromHexInput(e);if(r.toUint8Array().length!==t.LENGTH)throw new Error(`PrivateKey length should be ${t.LENGTH}`);this.key=r}static generate(){let e=o.utils.randomPrivateKey();return new t(e)}static fromDerivationPath(e,r){if(!h(e))throw new Error(`Invalid derivation path ${e}`);return t.fromDerivationPathInner(e,f(r))}static fromDerivationPathInner(e,r){let{privateKey:i}=U.fromMasterSeed(r).derive(e);if(i===null)throw new Error("Invalid key");return new t(i)}sign(e){let r=u(e),i=s.fromHexInput(r),l=A(i.toUint8Array()),c=o.sign(l,this.key.toUint8Array(),{lowS:!0});return new y(c.toCompactRawBytes())}publicKey(){let e=o.getPublicKey(this.key.toUint8Array(),!1);return new m(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new t(r)}static isPrivateKey(e){return e instanceof t}};t.LENGTH=32;var H=t,a=class a extends v{constructor(e){super();let r=s.fromHexInput(e);if(r.toUint8Array().length!==a.LENGTH)throw new Error(`Signature length should be ${a.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new a(r)}};a.LENGTH=64;var y=a;export{m as a,H as b,y as c};
2
+ //# sourceMappingURL=chunk-BO44HPGU.mjs.map
@@ -1,2 +1,2 @@
1
- import{a as c}from"./chunk-V6J6AW5T.mjs";import{c as p}from"./chunk-JE7INUQ2.mjs";import{e as o}from"./chunk-OIH4KBXW.mjs";import{o as u,r as g,s as A}from"./chunk-S3EDNXZE.mjs";import{f as a,i as r}from"./chunk-S5AGI7RQ.mjs";async function G(t){let{aptosConfig:s,options:e}=t,n={query:A,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await o({aptosConfig:s,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function h(t){let{aptosConfig:s,options:e}=t,n={query:g,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await o({aptosConfig:s,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function M(t){let{aptosConfig:s,options:e}=t,n={query:u,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await o({aptosConfig:s,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var b={typeParameters:[{constraints:[]}],parameters:[p("0x1::object::Object"),new r,new a]};async function x(t){let{aptosConfig:s,sender:e,fungibleAssetMetadataAddress:n,recipient:i,amount:l,options:f}=t;return c({aptosConfig:s,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,i,l],abi:b},options:f})}export{G as a,h as b,M as c,x as d};
2
- //# sourceMappingURL=chunk-DPWXEJP6.mjs.map
1
+ import{a as c}from"./chunk-VIX4BX35.mjs";import{c as p}from"./chunk-XH33BXEY.mjs";import{c as o}from"./chunk-DJPYZIJY.mjs";import{o as u,r as g,s as A}from"./chunk-S3EDNXZE.mjs";import{f as a,i as r}from"./chunk-MLX6DFMR.mjs";async function G(t){let{aptosConfig:s,options:e}=t,n={query:A,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await o({aptosConfig:s,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function h(t){let{aptosConfig:s,options:e}=t,n={query:g,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await o({aptosConfig:s,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function M(t){let{aptosConfig:s,options:e}=t,n={query:u,variables:{where_condition:e?.where,limit:e?.limit,offset:e?.offset}};return(await o({aptosConfig:s,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var b={typeParameters:[{constraints:[]}],parameters:[p("0x1::object::Object"),new r,new a]};async function x(t){let{aptosConfig:s,sender:e,fungibleAssetMetadataAddress:n,recipient:i,amount:l,options:f}=t;return c({aptosConfig:s,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,i,l],abi:b},options:f})}export{G as a,h as b,M as c,x as d};
2
+ //# sourceMappingURL=chunk-BT6IM25V.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a as l}from"./chunk-7M4C4OZN.mjs";import{a as f}from"./chunk-O7VXANBW.mjs";import{a as g}from"./chunk-LDQJ5S77.mjs";import{a as u}from"./chunk-R2TZZVTU.mjs";import{a as y}from"./chunk-5WFKJO5L.mjs";import{a as m}from"./chunk-7UKBRLGM.mjs";import{a as h}from"./chunk-GBQU2OCK.mjs";import{a as s}from"./chunk-7G3RSOWE.mjs";import{a as p}from"./chunk-64VPA7CM.mjs";import{a as d}from"./chunk-NMD45OTM.mjs";import{a as r}from"./chunk-GPWSPT44.mjs";import{a}from"./chunk-FSO54CI4.mjs";import{a as c}from"./chunk-LIT6V2A6.mjs";var t=class{constructor(e){this.config=new d(e),this.account=new s(this.config),this.ans=new p(this.config),this.coin=new r(this.config),this.digitalAsset=new a(this.config),this.event=new c(this.config),this.faucet=new l(this.config),this.fungibleAsset=new f(this.config),this.general=new g(this.config),this.staking=new y(this.config),this.transaction=new h(this.config),this.table=new m(this.config),this.keyless=new u(this.config)}};function n(A,e,b){Object.getOwnPropertyNames(e.prototype).forEach(i=>{let o=Object.getOwnPropertyDescriptor(e.prototype,i);o&&(o.value=function(...w){return this[b][i](...w)},Object.defineProperty(A.prototype,i,o))})}n(t,s,"account");n(t,p,"ans");n(t,r,"coin");n(t,a,"digitalAsset");n(t,c,"event");n(t,l,"faucet");n(t,f,"fungibleAsset");n(t,g,"general");n(t,y,"staking");n(t,h,"transaction");n(t,m,"table");n(t,u,"keyless");export{t as a};
2
+ //# sourceMappingURL=chunk-CPDSBH23.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/api/aptos.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account } from \"./account\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { Coin } from \"./coin\";\nimport { DigitalAsset } from \"./digitalAsset\";\nimport { Event } from \"./event\";\nimport { Faucet } from \"./faucet\";\nimport { FungibleAsset } from \"./fungibleAsset\";\nimport { General } from \"./general\";\nimport { ANS } from \"./ans\";\nimport { Staking } from \"./staking\";\nimport { Transaction } from \"./transaction\";\nimport { Table } from \"./table\";\nimport { Keyless } from \"./keyless\";\n\n/**\n * This class is the main entry point into Aptos's\n * APIs and separates functionality into different namespaces.\n *\n * To use the SDK, create a new Aptos instance to get access\n * to all the sdk functionality.\n *\n * @example\n *\n * const aptos = new Aptos();\n */\nexport class Aptos {\n readonly config: AptosConfig;\n\n readonly account: Account;\n\n readonly ans: ANS;\n\n readonly coin: Coin;\n\n readonly digitalAsset: DigitalAsset;\n\n readonly event: Event;\n\n readonly faucet: Faucet;\n\n readonly fungibleAsset: FungibleAsset;\n\n readonly general: General;\n\n readonly staking: Staking;\n\n readonly transaction: Transaction;\n\n readonly table: Table;\n\n readonly keyless: Keyless;\n\n constructor(settings?: AptosConfig) {\n this.config = new AptosConfig(settings);\n this.account = new Account(this.config);\n this.ans = new ANS(this.config);\n this.coin = new Coin(this.config);\n this.digitalAsset = new DigitalAsset(this.config);\n this.event = new Event(this.config);\n this.faucet = new Faucet(this.config);\n this.fungibleAsset = new FungibleAsset(this.config);\n this.general = new General(this.config);\n this.staking = new Staking(this.config);\n this.transaction = new Transaction(this.config);\n this.table = new Table(this.config);\n this.keyless = new Keyless(this.config);\n }\n}\n\n// extends Aptos interface so all the methods and properties\n// from the other classes will be recognized by typescript.\nexport interface Aptos\n extends Account,\n ANS,\n Coin,\n DigitalAsset,\n Event,\n Faucet,\n FungibleAsset,\n General,\n Keyless,\n Staking,\n Table,\n Omit<Transaction, \"build\" | \"simulate\" | \"submit\" | \"batch\"> {}\n\n/**\nIn TypeScript, we can’t inherit or extend from more than one class,\nMixins helps us to get around that by creating a partial classes\nthat we can combine to form a single class that contains all the methods and properties from the partial classes.\n{@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n\nHere, we combine any subclass and the Aptos class.\n*/\nfunction applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {\n // Mixin instance methods\n Object.getOwnPropertyNames(baseClass.prototype).forEach((propertyName) => {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(baseClass.prototype, propertyName);\n if (!propertyDescriptor) return;\n // eslint-disable-next-line func-names\n propertyDescriptor.value = function (...args: any) {\n return (this as any)[baseClassProp][propertyName](...args);\n };\n Object.defineProperty(targetClass.prototype, propertyName, propertyDescriptor);\n });\n}\n\napplyMixin(Aptos, Account, \"account\");\napplyMixin(Aptos, ANS, \"ans\");\napplyMixin(Aptos, Coin, \"coin\");\napplyMixin(Aptos, DigitalAsset, \"digitalAsset\");\napplyMixin(Aptos, Event, \"event\");\napplyMixin(Aptos, Faucet, \"faucet\");\napplyMixin(Aptos, FungibleAsset, \"fungibleAsset\");\napplyMixin(Aptos, General, \"general\");\napplyMixin(Aptos, Staking, \"staking\");\napplyMixin(Aptos, Transaction, \"transaction\");\napplyMixin(Aptos, Table, \"table\");\napplyMixin(Aptos, Keyless, \"keyless\");\n"],"mappings":"ghBA4BO,IAAMA,EAAN,KAAY,CA2BjB,YAAYC,EAAwB,CAClC,KAAK,OAAS,IAAIC,EAAYD,CAAQ,EACtC,KAAK,QAAU,IAAIE,EAAQ,KAAK,MAAM,EACtC,KAAK,IAAM,IAAIC,EAAI,KAAK,MAAM,EAC9B,KAAK,KAAO,IAAIC,EAAK,KAAK,MAAM,EAChC,KAAK,aAAe,IAAIC,EAAa,KAAK,MAAM,EAChD,KAAK,MAAQ,IAAIC,EAAM,KAAK,MAAM,EAClC,KAAK,OAAS,IAAIC,EAAO,KAAK,MAAM,EACpC,KAAK,cAAgB,IAAIC,EAAc,KAAK,MAAM,EAClD,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,EACtC,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,EACtC,KAAK,YAAc,IAAIC,EAAY,KAAK,MAAM,EAC9C,KAAK,MAAQ,IAAIC,EAAM,KAAK,MAAM,EAClC,KAAK,QAAU,IAAIC,EAAQ,KAAK,MAAM,CACxC,CACF,EA0BA,SAASC,EAAWC,EAAkBC,EAAgBC,EAAuB,CAE3E,OAAO,oBAAoBD,EAAU,SAAS,EAAE,QAASE,GAAiB,CACxE,IAAMC,EAAqB,OAAO,yBAAyBH,EAAU,UAAWE,CAAY,EACvFC,IAELA,EAAmB,MAAQ,YAAaC,EAAW,CACjD,OAAQ,KAAaH,CAAa,EAAEC,CAAY,EAAE,GAAGE,CAAI,CAC3D,EACA,OAAO,eAAeL,EAAY,UAAWG,EAAcC,CAAkB,EAC/E,CAAC,CACH,CAEAL,EAAWf,EAAOG,EAAS,SAAS,EACpCY,EAAWf,EAAOI,EAAK,KAAK,EAC5BW,EAAWf,EAAOK,EAAM,MAAM,EAC9BU,EAAWf,EAAOM,EAAc,cAAc,EAC9CS,EAAWf,EAAOO,EAAO,OAAO,EAChCQ,EAAWf,EAAOQ,EAAQ,QAAQ,EAClCO,EAAWf,EAAOS,EAAe,eAAe,EAChDM,EAAWf,EAAOU,EAAS,SAAS,EACpCK,EAAWf,EAAOW,EAAS,SAAS,EACpCI,EAAWf,EAAOY,EAAa,aAAa,EAC5CG,EAAWf,EAAOa,EAAO,OAAO,EAChCE,EAAWf,EAAOc,EAAS,SAAS","names":["Aptos","settings","AptosConfig","Account","ANS","Coin","DigitalAsset","Event","Faucet","FungibleAsset","General","Staking","Transaction","Table","Keyless","applyMixin","targetClass","baseClass","baseClassProp","propertyName","propertyDescriptor","args"]}
@@ -0,0 +1,2 @@
1
+ import{m as c,v as n}from"./chunk-S3EDNXZE.mjs";import{b as i}from"./chunk-IBDBKQMF.mjs";import{c as p}from"./chunk-2G4IGSGM.mjs";async function d(o){let{aptosConfig:s}=o,{data:e}=await i({aptosConfig:s,originMethod:"getLedgerInfo",path:""});return e}async function C(o){let{aptosConfig:s,limit:e}=o;return(await a({aptosConfig:s,query:{query:c,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function a(o){let{aptosConfig:s,query:e,originMethod:t}=o,{data:r}=await p({aptosConfig:s,originMethod:t??"queryIndexer",path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return r}async function u(o){let{aptosConfig:s}=o;return(await a({aptosConfig:s,query:{query:n},originMethod:"getProcessorStatuses"})).processor_status}async function h(o){let s=await u({aptosConfig:o.aptosConfig});return BigInt(s[0].last_success_version)}async function T(o){let{aptosConfig:s,processorType:e}=o;return(await a({aptosConfig:s,query:{query:n,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}export{d as a,C as b,a as c,u as d,h as e,T as f};
2
+ //# sourceMappingURL=chunk-DJPYZIJY.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/internal/general.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/general}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * general namespace and without having a dependency cycle error.\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosFullNode, postAptosIndexer } from \"../client\";\nimport { GetChainTopUserTransactionsResponse, GetProcessorStatusResponse, GraphqlQuery, LedgerInfo } from \"../types\";\nimport { GetChainTopUserTransactionsQuery, GetProcessorStatusQuery } from \"../types/generated/operations\";\nimport { GetChainTopUserTransactions, GetProcessorStatus } from \"../types/generated/queries\";\nimport { ProcessorType } from \"../utils/const\";\n\nexport async function getLedgerInfo(args: { aptosConfig: AptosConfig }): Promise<LedgerInfo> {\n const { aptosConfig } = args;\n const { data } = await getAptosFullNode<{}, LedgerInfo>({\n aptosConfig,\n originMethod: \"getLedgerInfo\",\n path: \"\",\n });\n return data;\n}\n\nexport async function getChainTopUserTransactions(args: {\n aptosConfig: AptosConfig;\n limit: number;\n}): Promise<GetChainTopUserTransactionsResponse> {\n const { aptosConfig, limit } = args;\n const graphqlQuery = {\n query: GetChainTopUserTransactions,\n variables: { limit },\n };\n\n const data = await queryIndexer<GetChainTopUserTransactionsQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getChainTopUserTransactions\",\n });\n\n return data.user_transactions;\n}\n\nexport async function queryIndexer<T extends {}>(args: {\n aptosConfig: AptosConfig;\n query: GraphqlQuery;\n originMethod?: string;\n}): Promise<T> {\n const { aptosConfig, query, originMethod } = args;\n const { data } = await postAptosIndexer<GraphqlQuery, T>({\n aptosConfig,\n originMethod: originMethod ?? \"queryIndexer\",\n path: \"\",\n body: query,\n overrides: { WITH_CREDENTIALS: false },\n });\n return data;\n}\n\nexport async function getProcessorStatuses(args: { aptosConfig: AptosConfig }): Promise<GetProcessorStatusResponse> {\n const { aptosConfig } = args;\n\n const graphqlQuery = {\n query: GetProcessorStatus,\n };\n\n const data = await queryIndexer<GetProcessorStatusQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getProcessorStatuses\",\n });\n\n return data.processor_status;\n}\n\nexport async function getIndexerLastSuccessVersion(args: { aptosConfig: AptosConfig }): Promise<bigint> {\n const response = await getProcessorStatuses({ aptosConfig: args.aptosConfig });\n return BigInt(response[0].last_success_version);\n}\n\nexport async function getProcessorStatus(args: {\n aptosConfig: AptosConfig;\n processorType: ProcessorType;\n}): Promise<GetProcessorStatusResponse[0]> {\n const { aptosConfig, processorType } = args;\n\n const whereCondition: { processor: { _eq: string } } = {\n processor: { _eq: processorType },\n };\n\n const graphqlQuery = {\n query: GetProcessorStatus,\n variables: {\n where_condition: whereCondition,\n },\n };\n\n const data = await queryIndexer<GetProcessorStatusQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getProcessorStatus\",\n });\n\n return data.processor_status[0];\n}\n"],"mappings":"kIAiBA,eAAsBA,EAAcC,EAAyD,CAC3F,GAAM,CAAE,YAAAC,CAAY,EAAID,EAClB,CAAE,KAAAE,CAAK,EAAI,MAAMC,EAAiC,CACtD,YAAAF,EACA,aAAc,gBACd,KAAM,EACR,CAAC,EACD,OAAOC,CACT,CAEA,eAAsBE,EAA4BJ,EAGD,CAC/C,GAAM,CAAE,YAAAC,EAAa,MAAAI,CAAM,EAAIL,EAY/B,OANa,MAAMM,EAA+C,CAChE,YAAAL,EACA,MAPmB,CACnB,MAAOM,EACP,UAAW,CAAE,MAAAF,CAAM,CACrB,EAKE,aAAc,6BAChB,CAAC,GAEW,iBACd,CAEA,eAAsBC,EAA2BN,EAIlC,CACb,GAAM,CAAE,YAAAC,EAAa,MAAAO,EAAO,aAAAC,CAAa,EAAIT,EACvC,CAAE,KAAAE,CAAK,EAAI,MAAMQ,EAAkC,CACvD,YAAAT,EACA,aAAcQ,GAAgB,eAC9B,KAAM,GACN,KAAMD,EACN,UAAW,CAAE,iBAAkB,EAAM,CACvC,CAAC,EACD,OAAON,CACT,CAEA,eAAsBS,EAAqBX,EAAyE,CAClH,GAAM,CAAE,YAAAC,CAAY,EAAID,EAYxB,OANa,MAAMM,EAAsC,CACvD,YAAAL,EACA,MANmB,CACnB,MAAOW,CACT,EAKE,aAAc,sBAChB,CAAC,GAEW,gBACd,CAEA,eAAsBC,EAA6Bb,EAAqD,CACtG,IAAMc,EAAW,MAAMH,EAAqB,CAAE,YAAaX,EAAK,WAAY,CAAC,EAC7E,OAAO,OAAOc,EAAS,CAAC,EAAE,oBAAoB,CAChD,CAEA,eAAsBC,EAAmBf,EAGE,CACzC,GAAM,CAAE,YAAAC,EAAa,cAAAe,CAAc,EAAIhB,EAmBvC,OANa,MAAMM,EAAsC,CACvD,YAAAL,EACA,MATmB,CACnB,MAAOW,EACP,UAAW,CACT,gBAPmD,CACrD,UAAW,CAAE,IAAKI,CAAc,CAClC,CAME,CACF,EAKE,aAAc,oBAChB,CAAC,GAEW,iBAAiB,CAAC,CAChC","names":["getLedgerInfo","args","aptosConfig","data","getAptosFullNode","getChainTopUserTransactions","limit","queryIndexer","GetChainTopUserTransactions","query","originMethod","postAptosIndexer","getProcessorStatuses","GetProcessorStatus","getIndexerLastSuccessVersion","response","getProcessorStatus","processorType"]}
@@ -1,2 +1,2 @@
1
- import{b as c}from"./chunk-UEI62FBQ.mjs";import{sha3_256 as n}from"@noble/hashes/sha3";var d=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,254]);return new c(n(o))},f=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,255]);return new c(n(o))},a=(e,r,t)=>{let s=`${r}::${t}`;return d(e,s)};export{d as a,f as b,a as c};
2
- //# sourceMappingURL=chunk-JNDRFTEA.mjs.map
1
+ import{b as c}from"./chunk-F3ZVWLDH.mjs";import{sha3_256 as n}from"@noble/hashes/sha3";var d=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,254]);return new c(n(o))},f=(e,r)=>{let t=e.bcsToBytes(),s=typeof r=="string"?Buffer.from(r,"utf8"):r,o=new Uint8Array([...t,...s,255]);return new c(n(o))},a=(e,r,t)=>{let s=`${r}::${t}`;return d(e,s)};export{d as a,f as b,a as c};
2
+ //# sourceMappingURL=chunk-DPWEHSHH.mjs.map
@@ -1,2 +1,2 @@
1
- import{b as s}from"./chunk-UEI62FBQ.mjs";import{a as o}from"./chunk-4KMISR2H.mjs";import{b as n}from"./chunk-BCUSI3N6.mjs";import{sha3_256 as d}from"@noble/hashes/sha3";var r=class r extends o{constructor(t){super();let{data:e}=t,i=n.fromHexInput(e);if(i.toUint8Array().length!==r.LENGTH)throw new Error(`Authentication Key length should be ${r.LENGTH}`);this.data=i}serialize(t){t.serializeFixedBytes(this.data.toUint8Array())}static deserialize(t){let e=t.deserializeFixedBytes(r.LENGTH);return new r({data:e})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(t){let{scheme:e,input:i}=t,u=n.fromHexInput(i).toUint8Array(),h=new Uint8Array([...u,e]),a=d.create();a.update(h);let y=a.digest();return new r({data:y})}static fromPublicKeyAndScheme(t){let{publicKey:e}=t;return e.authKey()}static fromPublicKey(t){let{publicKey:e}=t;return e.authKey()}derivedAddress(){return new s(this.data.toUint8Array())}};r.LENGTH=32;var c=r;export{c as a};
2
- //# sourceMappingURL=chunk-WNVUG2UF.mjs.map
1
+ import{b as s}from"./chunk-F3ZVWLDH.mjs";import{a as o}from"./chunk-UMLUOYFK.mjs";import{b as n}from"./chunk-AOCNYMMX.mjs";import{sha3_256 as d}from"@noble/hashes/sha3";var r=class r extends o{constructor(t){super();let{data:e}=t,i=n.fromHexInput(e);if(i.toUint8Array().length!==r.LENGTH)throw new Error(`Authentication Key length should be ${r.LENGTH}`);this.data=i}serialize(t){t.serializeFixedBytes(this.data.toUint8Array())}static deserialize(t){let e=t.deserializeFixedBytes(r.LENGTH);return new r({data:e})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(t){let{scheme:e,input:i}=t,u=n.fromHexInput(i).toUint8Array(),h=new Uint8Array([...u,e]),a=d.create();a.update(h);let y=a.digest();return new r({data:y})}static fromPublicKeyAndScheme(t){let{publicKey:e}=t;return e.authKey()}static fromPublicKey(t){let{publicKey:e}=t;return e.authKey()}derivedAddress(){return new s(this.data.toUint8Array())}};r.LENGTH=32;var c=r;export{c as a};
2
+ //# sourceMappingURL=chunk-EFMAZTIM.mjs.map
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-J3DCBYOY.mjs";import{b as x}from"./chunk-YTQVMLFD.mjs";import{l as g,m,n as y,p as d}from"./chunk-54LCK6EN.mjs";import{b as l}from"./chunk-L5CPAOUM.mjs";import{e as u,f as h}from"./chunk-2G4IGSGM.mjs";import{b as n}from"./chunk-AOCNYMMX.mjs";async function K(t){let{aptosConfig:r,jwt:e,ephemeralKeyPair:o,uidKey:p="sub",derivationPath:s}=t,i={jwt_b64:e,epk:o.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:o.expiryDateSecs,epk_blinder:n.fromHexInput(o.blinder).toStringWithoutPrefix(),uid_key:p,derivation_path:s},{data:c}=await u({aptosConfig:r,path:"fetch",body:i,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return n.fromHexInput(c.pepper).toUint8Array()}async function w(t){let{aptosConfig:r,jwt:e,ephemeralKeyPair:o,pepper:p,uidKey:s="sub"}=t,{maxExpHorizonSecs:i}=await d({aptosConfig:r});if(i<o.expiryDateSecs-x())throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${i}`);let c={jwt_b64:e,epk:o.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:n.fromHexInput(o.blinder).toStringWithoutPrefix(),exp_date_secs:o.expiryDateSecs,exp_horizon_secs:i,pepper:n.fromHexInput(p).toStringWithoutPrefix(),uid_key:s},{data:P}=await h({aptosConfig:r,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),f=P.proof,b=new g({a:f.a,b:f.b,c:f.c});return new y({proof:new m(b,0),trainingWheelsSignature:l.fromHex(P.training_wheels_signature),expHorizonSecs:i})}async function T(t){let{proofFetchCallback:r}=t,{pepper:e}=t;if(e===void 0?e=await K(t):e=n.fromHexInput(e).toUint8Array(),e.length!==a.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${a.PEPPER_LENGTH} bytes`);let o=w({...t,pepper:e}),p=r?o:await o;return a.create({...t,proof:p,pepper:e,proofFetchCallback:r})}export{K as a,w as b,T as c};
2
+ //# sourceMappingURL=chunk-EHL3WIK3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/internal/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/keyless}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * keyless namespace and without having a dependency cycle error.\n */\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { postAptosPepperService, postAptosProvingService } from \"../client\";\nimport { EphemeralSignature, Groth16Zkp, Hex, ZeroKnowledgeSig, ZkProof, getKeylessConfig } from \"../core\";\nimport { HexInput, ZkpVariant } from \"../types\";\nimport { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from \"../account\";\nimport { PepperFetchRequest, PepperFetchResponse, ProverRequest, ProverResponse } from \"../types/keyless\";\nimport { nowInSeconds } from \"../utils/helpers\";\n\nexport async function getPepper(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n derivationPath?: string;\n}): Promise<Uint8Array> {\n const { aptosConfig, jwt, ephemeralKeyPair, uidKey = \"sub\", derivationPath } = args;\n\n const body = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),\n exp_date_secs: ephemeralKeyPair.expiryDateSecs,\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n uid_key: uidKey,\n derivation_path: derivationPath,\n };\n const { data } = await postAptosPepperService<PepperFetchRequest, PepperFetchResponse>({\n aptosConfig,\n path: \"fetch\",\n body,\n originMethod: \"getPepper\",\n overrides: { WITH_CREDENTIALS: false },\n });\n return Hex.fromHexInput(data.pepper).toUint8Array();\n}\n\nexport async function getProof(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n}): Promise<ZeroKnowledgeSig> {\n const { aptosConfig, jwt, ephemeralKeyPair, pepper, uidKey = \"sub\" } = args;\n const { maxExpHorizonSecs } = await getKeylessConfig({ aptosConfig });\n if (maxExpHorizonSecs < ephemeralKeyPair.expiryDateSecs - nowInSeconds()) {\n throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${maxExpHorizonSecs}`);\n }\n const json = {\n jwt_b64: jwt,\n epk: ephemeralKeyPair.getPublicKey().bcsToHex().toStringWithoutPrefix(),\n epk_blinder: Hex.fromHexInput(ephemeralKeyPair.blinder).toStringWithoutPrefix(),\n exp_date_secs: ephemeralKeyPair.expiryDateSecs,\n exp_horizon_secs: maxExpHorizonSecs,\n pepper: Hex.fromHexInput(pepper).toStringWithoutPrefix(),\n uid_key: uidKey,\n };\n\n const { data } = await postAptosProvingService<ProverRequest, ProverResponse>({\n aptosConfig,\n path: \"prove\",\n body: json,\n originMethod: \"getProof\",\n overrides: { WITH_CREDENTIALS: false },\n });\n\n const proofPoints = data.proof;\n const groth16Zkp = new Groth16Zkp({\n a: proofPoints.a,\n b: proofPoints.b,\n c: proofPoints.c,\n });\n\n const signedProof = new ZeroKnowledgeSig({\n proof: new ZkProof(groth16Zkp, ZkpVariant.Groth16),\n trainingWheelsSignature: EphemeralSignature.fromHex(data.training_wheels_signature),\n expHorizonSecs: maxExpHorizonSecs,\n });\n return signedProof;\n}\n\nexport async function deriveKeylessAccount(args: {\n aptosConfig: AptosConfig;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n proofFetchCallback?: ProofFetchCallback;\n}): Promise<KeylessAccount> {\n const { proofFetchCallback } = args;\n let { pepper } = args;\n if (pepper === undefined) {\n pepper = await getPepper(args);\n } else {\n pepper = Hex.fromHexInput(pepper).toUint8Array();\n }\n\n if (pepper.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);\n }\n\n const proofPromise = getProof({ ...args, pepper });\n // If a callback is provided, pass in the proof as a promise to KeylessAccount.create. This will make the proof be fetched in the\n // background and the callback will handle the outcome of the fetch. This allows the developer to not have to block on the proof fetch\n // allowing for faster rendering of UX.\n //\n // If no callback is provided, the just await the proof fetch and continue syncronously.\n const proof = proofFetchCallback ? proofPromise : await proofPromise;\n\n const keylessAccount = KeylessAccount.create({ ...args, proof, pepper, proofFetchCallback });\n\n return keylessAccount;\n}\n"],"mappings":"wQAiBA,eAAsB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EAAGA,EAAY,EACf,EAAGA,EAAY,CACjB,CAAC,EAOD,OALoB,IAAIG,EAAiB,CACvC,MAAO,IAAIC,EAAQH,GAA8B,EACjD,wBAAyBI,EAAmB,QAAQd,EAAK,yBAAyB,EAClF,eAAgBI,CAClB,CAAC,CAEH,CAEA,eAAsBW,EAAqBvB,EAOf,CAC1B,GAAM,CAAE,mBAAAwB,CAAmB,EAAIxB,EAC3B,CAAE,OAAAW,CAAO,EAAIX,EAOjB,GANIW,IAAW,OACbA,EAAS,MAAMZ,EAAUC,CAAI,EAE7BW,EAASJ,EAAI,aAAaI,CAAM,EAAE,aAAa,EAG7CA,EAAO,SAAWc,EAAe,cACnC,MAAM,IAAI,MAAM,sBAAsBA,EAAe,aAAa,QAAQ,EAG5E,IAAMC,EAAehB,EAAS,CAAE,GAAGV,EAAM,OAAAW,CAAO,CAAC,EAM3CgB,EAAQH,EAAqBE,EAAe,MAAMA,EAIxD,OAFuBD,EAAe,OAAO,CAAE,GAAGzB,EAAM,MAAA2B,EAAO,OAAAhB,EAAQ,mBAAAa,CAAmB,CAAC,CAG7F","names":["getPepper","args","aptosConfig","jwt","ephemeralKeyPair","uidKey","derivationPath","body","Hex","data","postAptosPepperService","getProof","pepper","maxExpHorizonSecs","getKeylessConfig","nowInSeconds","json","postAptosProvingService","proofPoints","groth16Zkp","Groth16Zkp","ZeroKnowledgeSig","ZkProof","EphemeralSignature","deriveKeylessAccount","proofFetchCallback","KeylessAccount","proofPromise","proof"]}
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-4KMISR2H.mjs";import{a as i}from"./chunk-LG7RJQ57.mjs";import{bytesToHex as o,hexToBytes as l}from"@noble/hashes/utils";var h=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s))(h||{}),r=class r extends a{constructor(t){if(super(),t.length!==r.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=o(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return o(this.data)}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){let e=this.bcsToBytes();t.serializeBytes(e)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let e=t.deserializeFixedBytes(r.LENGTH);return new r(e)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let e=r.fromString(t);if(t.length!==r.LONG_STRING_LENGTH+2)if(e.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return e}static fromString(t){let e=t;if(t.startsWith("0x")&&(e=t.slice(2)),e.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(e.length>64)throw new i("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let n;try{n=l(e.padStart(64,"0"))}catch(d){throw new i(`Hex characters are invalid: ${d?.message}`,"invalid_hex_chars")}return new r(n)}static from(t){return t instanceof r?t:t instanceof Uint8Array?new r(t):r.fromString(t)}static fromStrict(t){return t instanceof r?t:t instanceof Uint8Array?new r(t):r.fromStringStrict(t)}static isValid(t){try{return t.strict?r.fromStrict(t.input):r.from(t.input),{valid:!0}}catch(e){return{valid:!1,invalidReason:e?.invalidReason,invalidReasonMessage:e?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,n)=>e===t.data[n])}};r.LENGTH=32,r.LONG_STRING_LENGTH=64,r.ZERO=r.from("0x0"),r.ONE=r.from("0x1"),r.TWO=r.from("0x2"),r.THREE=r.from("0x3"),r.FOUR=r.from("0x4");var c=r;export{h as a,c as b};
2
- //# sourceMappingURL=chunk-UEI62FBQ.mjs.map
1
+ import{a}from"./chunk-UMLUOYFK.mjs";import{a as i}from"./chunk-FBPNHF54.mjs";import{bytesToHex as o,hexToBytes as l}from"@noble/hashes/utils";var h=(s=>(s.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",s.INVALID_HEX_CHARS="invalid_hex_chars",s.TOO_SHORT="too_short",s.TOO_LONG="too_long",s.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",s.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",s.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",s))(h||{}),r=class r extends a{constructor(t){super();if(t.length!==r.LENGTH)throw new i("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=t}isSpecial(){return this.data.slice(0,this.data.length-1).every(t=>t===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let t=o(this.data);return this.isSpecial()&&(t=t[t.length-1]),t}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return o(this.data)}toUint8Array(){return this.data}serialize(t){t.serializeFixedBytes(this.data)}serializeForEntryFunction(t){let e=this.bcsToBytes();t.serializeBytes(e)}serializeForScriptFunction(t){t.serializeU32AsUleb128(3),t.serialize(this)}static deserialize(t){let e=t.deserializeFixedBytes(r.LENGTH);return new r(e)}static fromStringStrict(t){if(!t.startsWith("0x"))throw new i("Hex string must start with a leading 0x.","leading_zero_x_required");let e=r.fromString(t);if(t.length!==r.LONG_STRING_LENGTH+2)if(e.isSpecial()){if(t.length!==3)throw new i(`The given hex string ${t} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new i(`The given hex string ${t} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return e}static fromString(t){let e=t;if(t.startsWith("0x")&&(e=t.slice(2)),e.length===0)throw new i("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(e.length>64)throw new i("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let n;try{n=l(e.padStart(64,"0"))}catch(d){throw new i(`Hex characters are invalid: ${d?.message}`,"invalid_hex_chars")}return new r(n)}static from(t){return t instanceof r?t:t instanceof Uint8Array?new r(t):r.fromString(t)}static fromStrict(t){return t instanceof r?t:t instanceof Uint8Array?new r(t):r.fromStringStrict(t)}static isValid(t){try{return t.strict?r.fromStrict(t.input):r.from(t.input),{valid:!0}}catch(e){return{valid:!1,invalidReason:e?.invalidReason,invalidReasonMessage:e?.message}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,n)=>e===t.data[n])}};r.LENGTH=32,r.LONG_STRING_LENGTH=64,r.ZERO=r.from("0x0"),r.ONE=r.from("0x1"),r.TWO=r.from("0x2"),r.THREE=r.from("0x3"),r.FOUR=r.from("0x4");var c=r;export{h as a,c as b};
2
+ //# sourceMappingURL=chunk-F3ZVWLDH.mjs.map