@aptos-labs/ts-sdk 1.28.0 → 1.29.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 (337) hide show
  1. package/README.md +103 -82
  2. package/dist/common/{accountAddress-OVl7-qVN.d.ts → accountAddress-DUCC2ffJ.d.ts} +9 -2
  3. package/dist/common/cli/index.d.ts +1 -1
  4. package/dist/common/index.d.ts +266 -42
  5. package/dist/common/index.js +28 -28
  6. package/dist/common/index.js.map +1 -1
  7. package/dist/esm/account/AbstractKeylessAccount.d.mts +207 -0
  8. package/dist/esm/account/AbstractKeylessAccount.mjs +2 -0
  9. package/dist/esm/account/Account.mjs +1 -1
  10. package/dist/esm/account/Ed25519Account.mjs +1 -1
  11. package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
  12. package/dist/esm/account/FederatedKeylessAccount.d.mts +75 -0
  13. package/dist/esm/account/FederatedKeylessAccount.mjs +2 -0
  14. package/dist/esm/account/KeylessAccount.d.mts +13 -130
  15. package/dist/esm/account/KeylessAccount.mjs +1 -1
  16. package/dist/esm/account/MultiKeyAccount.mjs +1 -1
  17. package/dist/esm/account/SingleKeyAccount.mjs +1 -1
  18. package/dist/esm/account/index.d.mts +4 -1
  19. package/dist/esm/account/index.mjs +1 -1
  20. package/dist/esm/api/account.d.mts +1 -1
  21. package/dist/esm/api/account.mjs +1 -1
  22. package/dist/esm/api/ans.mjs +1 -1
  23. package/dist/esm/api/aptos.d.mts +4 -0
  24. package/dist/esm/api/aptos.mjs +1 -1
  25. package/dist/esm/api/coin.d.mts +2 -2
  26. package/dist/esm/api/coin.mjs +1 -1
  27. package/dist/esm/api/digitalAsset.d.mts +2 -2
  28. package/dist/esm/api/digitalAsset.mjs +1 -1
  29. package/dist/esm/api/event.d.mts +1 -1
  30. package/dist/esm/api/event.mjs +1 -1
  31. package/dist/esm/api/faucet.mjs +1 -1
  32. package/dist/esm/api/fungibleAsset.d.mts +1 -1
  33. package/dist/esm/api/fungibleAsset.mjs +1 -1
  34. package/dist/esm/api/general.d.mts +2 -2
  35. package/dist/esm/api/general.mjs +1 -1
  36. package/dist/esm/api/index.d.mts +4 -0
  37. package/dist/esm/api/index.mjs +1 -1
  38. package/dist/esm/api/keyless.d.mts +34 -20
  39. package/dist/esm/api/keyless.mjs +1 -1
  40. package/dist/esm/api/object.d.mts +2 -2
  41. package/dist/esm/api/object.mjs +1 -1
  42. package/dist/esm/api/staking.d.mts +2 -2
  43. package/dist/esm/api/staking.mjs +1 -1
  44. package/dist/esm/api/table.d.mts +1 -1
  45. package/dist/esm/api/table.mjs +1 -1
  46. package/dist/esm/api/transaction.d.mts +33 -9
  47. package/dist/esm/api/transaction.mjs +1 -1
  48. package/dist/esm/api/transactionSubmission/build.mjs +1 -1
  49. package/dist/esm/api/transactionSubmission/management.mjs +1 -1
  50. package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
  51. package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
  52. package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
  53. package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
  54. package/dist/esm/api/utils.mjs +1 -1
  55. package/dist/esm/bcs/index.mjs +1 -1
  56. package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
  57. package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
  58. package/dist/esm/{chunk-OTNGLTKS.mjs → chunk-2BTTX2KO.mjs} +2 -2
  59. package/dist/esm/{chunk-NPFW6ZFY.mjs → chunk-2F7Z7RMW.mjs} +2 -2
  60. package/dist/esm/{chunk-P2EKDA7R.mjs → chunk-367OG3DB.mjs} +2 -2
  61. package/dist/esm/{chunk-5L3UXSQI.mjs → chunk-3W2DHZXK.mjs} +2 -2
  62. package/dist/esm/chunk-44GYWUSH.mjs +2 -0
  63. package/dist/esm/chunk-44GYWUSH.mjs.map +1 -0
  64. package/dist/esm/{chunk-UWPO7WWS.mjs → chunk-45IUUCAV.mjs} +2 -2
  65. package/dist/esm/{chunk-YFMFXRJX.mjs → chunk-4HR32TSY.mjs} +2 -2
  66. package/dist/esm/chunk-4TB3AWQE.mjs +2 -0
  67. package/dist/esm/chunk-4TB3AWQE.mjs.map +1 -0
  68. package/dist/esm/{chunk-3HTSCV3R.mjs → chunk-53RB2PRH.mjs} +2 -2
  69. package/dist/esm/{chunk-GKERWKMB.mjs → chunk-5PCNWXRN.mjs} +2 -2
  70. package/dist/esm/{chunk-OPTI3MH2.mjs → chunk-5VD4MHB3.mjs} +2 -2
  71. package/dist/esm/{chunk-VTEZ6TBO.mjs → chunk-6UZ3VI5Y.mjs} +2 -2
  72. package/dist/esm/{chunk-Z2AJWV6D.mjs → chunk-7VKFXX5Q.mjs} +2 -2
  73. package/dist/esm/{chunk-GR4PHW7K.mjs → chunk-A42BPAD4.mjs} +2 -2
  74. package/dist/esm/{chunk-QQHA2Y46.mjs → chunk-ADE6MVXC.mjs} +2 -2
  75. package/dist/esm/chunk-ADE6MVXC.mjs.map +1 -0
  76. package/dist/esm/{chunk-2CAGPXCX.mjs → chunk-APN6AV5Q.mjs} +2 -2
  77. package/dist/esm/chunk-BA4RBST6.mjs +2 -0
  78. package/dist/esm/chunk-BA4RBST6.mjs.map +1 -0
  79. package/dist/esm/{chunk-4ENUSVZB.mjs → chunk-BSAHPS6E.mjs} +2 -2
  80. package/dist/esm/{chunk-NDJKEFNU.mjs → chunk-BWNTSJOC.mjs} +2 -2
  81. package/dist/esm/chunk-CB6H4VMZ.mjs +2 -0
  82. package/dist/esm/chunk-CB6H4VMZ.mjs.map +1 -0
  83. package/dist/esm/{chunk-LS6G4DZV.mjs → chunk-CRA2MFJC.mjs} +2 -2
  84. package/dist/esm/{chunk-VQVNUN5Y.mjs → chunk-D3Q4BC3I.mjs} +2 -2
  85. package/dist/esm/chunk-E4O26ZJB.mjs +2 -0
  86. package/dist/esm/chunk-E4O26ZJB.mjs.map +1 -0
  87. package/dist/esm/{chunk-5TBIWC7N.mjs → chunk-ELYS7CWV.mjs} +2 -2
  88. package/dist/esm/chunk-F3M2UQA4.mjs +2 -0
  89. package/dist/esm/chunk-F3M2UQA4.mjs.map +1 -0
  90. package/dist/esm/{chunk-ZXYTLPP6.mjs → chunk-F63E4CR7.mjs} +2 -2
  91. package/dist/esm/{chunk-JOROI7FE.mjs → chunk-F76N4MQO.mjs} +2 -2
  92. package/dist/esm/{chunk-F5PNGH44.mjs → chunk-FZ5EYP3D.mjs} +2 -2
  93. package/dist/esm/chunk-G5XLMQ5E.mjs +2 -0
  94. package/dist/esm/chunk-G5XLMQ5E.mjs.map +1 -0
  95. package/dist/esm/chunk-GAEAYY44.mjs +1 -0
  96. package/dist/esm/chunk-GAEAYY44.mjs.map +1 -0
  97. package/dist/esm/{chunk-O4BBULNE.mjs → chunk-GDO6Q2FI.mjs} +2 -2
  98. package/dist/esm/{chunk-WYQLUB4H.mjs → chunk-GDUAFXIQ.mjs} +2 -2
  99. package/dist/esm/chunk-GMBSQDPO.mjs +2 -0
  100. package/dist/esm/chunk-GMBSQDPO.mjs.map +1 -0
  101. package/dist/esm/{chunk-Q7MD4V7H.mjs → chunk-GWSDIX6C.mjs} +2 -2
  102. package/dist/esm/chunk-HEZ2ZYZA.mjs +1 -0
  103. package/dist/esm/chunk-HEZ2ZYZA.mjs.map +1 -0
  104. package/dist/esm/{chunk-WX6P3Q4I.mjs → chunk-HHGJXVAE.mjs} +2 -2
  105. package/dist/esm/{chunk-AVSM2BJR.mjs → chunk-HKBBA653.mjs} +2 -2
  106. package/dist/esm/{chunk-6CHBLB3V.mjs → chunk-HVMFZF6P.mjs} +2 -2
  107. package/dist/esm/{chunk-ZNC3FRSK.mjs → chunk-IR4SLC2M.mjs} +2 -2
  108. package/dist/esm/{chunk-GGPA6QTN.mjs → chunk-J64ARI4E.mjs} +2 -2
  109. package/dist/esm/{chunk-3F3FCWT5.mjs → chunk-JH6VLTMS.mjs} +2 -2
  110. package/dist/esm/{chunk-ORGMRM5K.mjs → chunk-KUOB4DDE.mjs} +2 -2
  111. package/dist/esm/{chunk-2XYA7NOU.mjs → chunk-KUZ2YTJH.mjs} +2 -2
  112. package/dist/esm/{chunk-HBQLX5QF.mjs → chunk-L2QXU6F4.mjs} +2 -2
  113. package/dist/esm/{chunk-QQU4IQ27.mjs → chunk-LNEZEYYE.mjs} +2 -2
  114. package/dist/esm/{chunk-53DBMWMU.mjs → chunk-MAMPMCO7.mjs} +2 -2
  115. package/dist/esm/chunk-MDJ66AA3.mjs +2 -0
  116. package/dist/esm/chunk-MDJ66AA3.mjs.map +1 -0
  117. package/dist/esm/{chunk-56F7EYFE.mjs → chunk-MNVUSJEK.mjs} +2 -2
  118. package/dist/esm/{chunk-SUAA25UP.mjs → chunk-O2BPA6TS.mjs} +2 -2
  119. package/dist/esm/{chunk-NKDHR2DA.mjs → chunk-OKAQO57B.mjs} +2 -2
  120. package/dist/esm/chunk-OMV7445F.mjs +2 -0
  121. package/dist/esm/chunk-OMV7445F.mjs.map +1 -0
  122. package/dist/esm/chunk-P2EIZ7WL.mjs +2 -0
  123. package/dist/esm/chunk-P2EIZ7WL.mjs.map +1 -0
  124. package/dist/esm/{chunk-PDNA4H34.mjs → chunk-P3TAY5PP.mjs} +2 -2
  125. package/dist/esm/{chunk-EJMPY5MF.mjs → chunk-Q3TAEOH5.mjs} +2 -2
  126. package/dist/esm/chunk-Q4XR6QOZ.mjs +2 -0
  127. package/dist/esm/{chunk-F7EMGK4M.mjs.map → chunk-Q4XR6QOZ.mjs.map} +1 -1
  128. package/dist/esm/{chunk-MNVDBUF3.mjs → chunk-QBSU3L5Q.mjs} +2 -2
  129. package/dist/esm/{chunk-3GOJQ5JD.mjs → chunk-QPB6EJVM.mjs} +2 -2
  130. package/dist/esm/{chunk-KRIIRH5L.mjs → chunk-R76DHMGR.mjs} +2 -2
  131. package/dist/esm/{chunk-52HZTDBB.mjs → chunk-RXE6NNOL.mjs} +2 -2
  132. package/dist/esm/chunk-RXE6NNOL.mjs.map +1 -0
  133. package/dist/esm/{chunk-JUNVPIW4.mjs → chunk-S2KDCIZN.mjs} +2 -2
  134. package/dist/esm/{chunk-YPQZJ72F.mjs → chunk-S2W4D6NZ.mjs} +2 -2
  135. package/dist/esm/{chunk-5P7MXLZA.mjs → chunk-SDWE6WMM.mjs} +2 -2
  136. package/dist/esm/chunk-SRPI2FFA.mjs +2 -0
  137. package/dist/esm/chunk-SRPI2FFA.mjs.map +1 -0
  138. package/dist/esm/chunk-STUXKQVZ.mjs +2 -0
  139. package/dist/esm/chunk-STUXKQVZ.mjs.map +1 -0
  140. package/dist/esm/{chunk-WLZYSLHP.mjs → chunk-SWNFKKRE.mjs} +2 -2
  141. package/dist/esm/{chunk-DVIRUFCY.mjs → chunk-TQWGQLM6.mjs} +2 -2
  142. package/dist/esm/chunk-UAEODDZS.mjs +2 -0
  143. package/dist/esm/{chunk-ZXVQ2OBJ.mjs.map → chunk-UAEODDZS.mjs.map} +1 -1
  144. package/dist/esm/{chunk-VYXJ7FUF.mjs → chunk-WJRZWAIS.mjs} +2 -2
  145. package/dist/esm/{chunk-LFUBUXHD.mjs → chunk-X34JJPW5.mjs} +2 -2
  146. package/dist/esm/{chunk-EXMQBH3I.mjs → chunk-XMW65WCQ.mjs} +2 -2
  147. package/dist/esm/chunk-Y2GWUE7C.mjs +2 -0
  148. package/dist/esm/chunk-Y2GWUE7C.mjs.map +1 -0
  149. package/dist/esm/chunk-Y3BATGHX.mjs +2 -0
  150. package/dist/esm/chunk-Y3BATGHX.mjs.map +1 -0
  151. package/dist/esm/{chunk-54QUDAAC.mjs → chunk-YU3IYJRL.mjs} +2 -2
  152. package/dist/esm/{chunk-NBO2BDDZ.mjs → chunk-ZROQH5YL.mjs} +2 -2
  153. package/dist/esm/cli/index.mjs +1 -1
  154. package/dist/esm/client/core.mjs +1 -1
  155. package/dist/esm/client/get.mjs +1 -1
  156. package/dist/esm/client/index.mjs +1 -1
  157. package/dist/esm/client/post.mjs +1 -1
  158. package/dist/esm/core/account/index.mjs +1 -1
  159. package/dist/esm/core/account/utils/address.mjs +1 -1
  160. package/dist/esm/core/account/utils/index.mjs +1 -1
  161. package/dist/esm/core/accountAddress.mjs +1 -1
  162. package/dist/esm/core/authenticationKey.mjs +1 -1
  163. package/dist/esm/core/crypto/ed25519.mjs +1 -1
  164. package/dist/esm/core/crypto/ephemeral.mjs +1 -1
  165. package/dist/esm/core/crypto/federatedKeyless.d.mts +97 -0
  166. package/dist/esm/core/crypto/federatedKeyless.mjs +2 -0
  167. package/dist/esm/core/crypto/federatedKeyless.mjs.map +1 -0
  168. package/dist/esm/core/crypto/index.d.mts +4 -2
  169. package/dist/esm/core/crypto/index.mjs +1 -1
  170. package/dist/esm/core/crypto/keyless.mjs +1 -1
  171. package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
  172. package/dist/esm/core/crypto/multiKey.mjs +1 -1
  173. package/dist/esm/core/crypto/poseidon.d.mts +1 -1
  174. package/dist/esm/core/crypto/poseidon.mjs +1 -1
  175. package/dist/esm/core/crypto/proof.mjs +1 -1
  176. package/dist/esm/core/crypto/publicKey.mjs +1 -1
  177. package/dist/esm/core/crypto/secp256k1.mjs +1 -1
  178. package/dist/esm/core/crypto/signature.mjs +1 -1
  179. package/dist/esm/core/crypto/singleKey.mjs +1 -1
  180. package/dist/esm/core/crypto/utils.mjs +1 -1
  181. package/dist/esm/core/index.d.mts +2 -0
  182. package/dist/esm/core/index.mjs +1 -1
  183. package/dist/esm/index.d.mts +6 -1
  184. package/dist/esm/index.mjs +1 -1
  185. package/dist/esm/internal/account.d.mts +1 -7
  186. package/dist/esm/internal/account.mjs +1 -1
  187. package/dist/esm/internal/ans.mjs +1 -1
  188. package/dist/esm/internal/coin.mjs +1 -1
  189. package/dist/esm/internal/digitalAsset.mjs +1 -1
  190. package/dist/esm/internal/event.mjs +1 -1
  191. package/dist/esm/internal/faucet.mjs +1 -1
  192. package/dist/esm/internal/fungibleAsset.mjs +1 -1
  193. package/dist/esm/internal/general.mjs +1 -1
  194. package/dist/esm/internal/keyless.d.mts +25 -14
  195. package/dist/esm/internal/keyless.mjs +1 -1
  196. package/dist/esm/internal/object.mjs +1 -1
  197. package/dist/esm/internal/staking.mjs +1 -1
  198. package/dist/esm/internal/table.mjs +1 -1
  199. package/dist/esm/internal/transaction.mjs +1 -1
  200. package/dist/esm/internal/transactionSubmission.d.mts +22 -2
  201. package/dist/esm/internal/transactionSubmission.mjs +1 -1
  202. package/dist/esm/internal/view.mjs +1 -1
  203. package/dist/esm/transactions/authenticator/account.mjs +1 -1
  204. package/dist/esm/transactions/authenticator/index.mjs +1 -1
  205. package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
  206. package/dist/esm/transactions/index.mjs +1 -1
  207. package/dist/esm/transactions/instances/index.mjs +1 -1
  208. package/dist/esm/transactions/instances/moduleId.mjs +1 -1
  209. package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
  210. package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
  211. package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
  212. package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
  213. package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
  214. package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
  215. package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
  216. package/dist/esm/transactions/management/index.mjs +1 -1
  217. package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
  218. package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
  219. package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
  220. package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
  221. package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
  222. package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
  223. package/dist/esm/transactions/typeTag/index.mjs +1 -1
  224. package/dist/esm/transactions/typeTag/parser.mjs +1 -1
  225. package/dist/esm/types/index.d.mts +8 -1
  226. package/dist/esm/types/index.mjs +1 -1
  227. package/dist/esm/utils/index.mjs +1 -1
  228. package/dist/esm/utils/normalizeBundle.mjs +1 -1
  229. package/dist/esm/version.d.mts +1 -1
  230. package/dist/esm/version.mjs +1 -1
  231. package/package.json +1 -1
  232. package/src/account/AbstractKeylessAccount.ts +329 -0
  233. package/src/account/EphemeralKeyPair.ts +9 -2
  234. package/src/account/FederatedKeylessAccount.ts +116 -0
  235. package/src/account/KeylessAccount.ts +13 -297
  236. package/src/account/MultiKeyAccount.ts +4 -2
  237. package/src/account/index.ts +2 -0
  238. package/src/api/account.ts +68 -22
  239. package/src/api/keyless.ts +50 -4
  240. package/src/api/transaction.ts +40 -20
  241. package/src/core/crypto/federatedKeyless.ts +134 -0
  242. package/src/core/crypto/index.ts +2 -0
  243. package/src/core/crypto/keyless.ts +4 -3
  244. package/src/core/crypto/poseidon.ts +4 -4
  245. package/src/core/crypto/singleKey.ts +6 -0
  246. package/src/core/crypto/utils.ts +2 -2
  247. package/src/internal/account.ts +1 -54
  248. package/src/internal/keyless.ts +86 -8
  249. package/src/internal/transactionSubmission.ts +63 -10
  250. package/src/transactions/transactionBuilder/transactionBuilder.ts +25 -14
  251. package/src/types/index.ts +7 -0
  252. package/src/version.ts +1 -1
  253. package/dist/esm/chunk-52HZTDBB.mjs.map +0 -1
  254. package/dist/esm/chunk-7Z6DYLCA.mjs +0 -1
  255. package/dist/esm/chunk-AQ4I7VVB.mjs +0 -1
  256. package/dist/esm/chunk-BIGX2RJL.mjs +0 -2
  257. package/dist/esm/chunk-BIGX2RJL.mjs.map +0 -1
  258. package/dist/esm/chunk-DCNBMUKN.mjs +0 -2
  259. package/dist/esm/chunk-DCNBMUKN.mjs.map +0 -1
  260. package/dist/esm/chunk-EQSON7Y5.mjs +0 -2
  261. package/dist/esm/chunk-EQSON7Y5.mjs.map +0 -1
  262. package/dist/esm/chunk-F7EMGK4M.mjs +0 -2
  263. package/dist/esm/chunk-G773HST5.mjs +0 -2
  264. package/dist/esm/chunk-G773HST5.mjs.map +0 -1
  265. package/dist/esm/chunk-IVOEXGOG.mjs +0 -2
  266. package/dist/esm/chunk-IVOEXGOG.mjs.map +0 -1
  267. package/dist/esm/chunk-IVVWQKCF.mjs +0 -2
  268. package/dist/esm/chunk-IVVWQKCF.mjs.map +0 -1
  269. package/dist/esm/chunk-LJZPPBTH.mjs +0 -2
  270. package/dist/esm/chunk-LJZPPBTH.mjs.map +0 -1
  271. package/dist/esm/chunk-QQHA2Y46.mjs.map +0 -1
  272. package/dist/esm/chunk-SCYGW3VV.mjs +0 -2
  273. package/dist/esm/chunk-SCYGW3VV.mjs.map +0 -1
  274. package/dist/esm/chunk-T53MZO2U.mjs +0 -2
  275. package/dist/esm/chunk-T53MZO2U.mjs.map +0 -1
  276. package/dist/esm/chunk-VYXS7TLB.mjs +0 -2
  277. package/dist/esm/chunk-VYXS7TLB.mjs.map +0 -1
  278. package/dist/esm/chunk-XSTCHOUI.mjs +0 -2
  279. package/dist/esm/chunk-XSTCHOUI.mjs.map +0 -1
  280. package/dist/esm/chunk-ZWX3NHGU.mjs +0 -2
  281. package/dist/esm/chunk-ZWX3NHGU.mjs.map +0 -1
  282. package/dist/esm/chunk-ZXVQ2OBJ.mjs +0 -2
  283. /package/dist/esm/{chunk-7Z6DYLCA.mjs.map → account/AbstractKeylessAccount.mjs.map} +0 -0
  284. /package/dist/esm/{chunk-AQ4I7VVB.mjs.map → account/FederatedKeylessAccount.mjs.map} +0 -0
  285. /package/dist/esm/{chunk-OTNGLTKS.mjs.map → chunk-2BTTX2KO.mjs.map} +0 -0
  286. /package/dist/esm/{chunk-NPFW6ZFY.mjs.map → chunk-2F7Z7RMW.mjs.map} +0 -0
  287. /package/dist/esm/{chunk-P2EKDA7R.mjs.map → chunk-367OG3DB.mjs.map} +0 -0
  288. /package/dist/esm/{chunk-5L3UXSQI.mjs.map → chunk-3W2DHZXK.mjs.map} +0 -0
  289. /package/dist/esm/{chunk-UWPO7WWS.mjs.map → chunk-45IUUCAV.mjs.map} +0 -0
  290. /package/dist/esm/{chunk-YFMFXRJX.mjs.map → chunk-4HR32TSY.mjs.map} +0 -0
  291. /package/dist/esm/{chunk-3HTSCV3R.mjs.map → chunk-53RB2PRH.mjs.map} +0 -0
  292. /package/dist/esm/{chunk-GKERWKMB.mjs.map → chunk-5PCNWXRN.mjs.map} +0 -0
  293. /package/dist/esm/{chunk-OPTI3MH2.mjs.map → chunk-5VD4MHB3.mjs.map} +0 -0
  294. /package/dist/esm/{chunk-VTEZ6TBO.mjs.map → chunk-6UZ3VI5Y.mjs.map} +0 -0
  295. /package/dist/esm/{chunk-Z2AJWV6D.mjs.map → chunk-7VKFXX5Q.mjs.map} +0 -0
  296. /package/dist/esm/{chunk-GR4PHW7K.mjs.map → chunk-A42BPAD4.mjs.map} +0 -0
  297. /package/dist/esm/{chunk-2CAGPXCX.mjs.map → chunk-APN6AV5Q.mjs.map} +0 -0
  298. /package/dist/esm/{chunk-4ENUSVZB.mjs.map → chunk-BSAHPS6E.mjs.map} +0 -0
  299. /package/dist/esm/{chunk-NDJKEFNU.mjs.map → chunk-BWNTSJOC.mjs.map} +0 -0
  300. /package/dist/esm/{chunk-LS6G4DZV.mjs.map → chunk-CRA2MFJC.mjs.map} +0 -0
  301. /package/dist/esm/{chunk-VQVNUN5Y.mjs.map → chunk-D3Q4BC3I.mjs.map} +0 -0
  302. /package/dist/esm/{chunk-5TBIWC7N.mjs.map → chunk-ELYS7CWV.mjs.map} +0 -0
  303. /package/dist/esm/{chunk-ZXYTLPP6.mjs.map → chunk-F63E4CR7.mjs.map} +0 -0
  304. /package/dist/esm/{chunk-JOROI7FE.mjs.map → chunk-F76N4MQO.mjs.map} +0 -0
  305. /package/dist/esm/{chunk-F5PNGH44.mjs.map → chunk-FZ5EYP3D.mjs.map} +0 -0
  306. /package/dist/esm/{chunk-O4BBULNE.mjs.map → chunk-GDO6Q2FI.mjs.map} +0 -0
  307. /package/dist/esm/{chunk-WYQLUB4H.mjs.map → chunk-GDUAFXIQ.mjs.map} +0 -0
  308. /package/dist/esm/{chunk-Q7MD4V7H.mjs.map → chunk-GWSDIX6C.mjs.map} +0 -0
  309. /package/dist/esm/{chunk-WX6P3Q4I.mjs.map → chunk-HHGJXVAE.mjs.map} +0 -0
  310. /package/dist/esm/{chunk-AVSM2BJR.mjs.map → chunk-HKBBA653.mjs.map} +0 -0
  311. /package/dist/esm/{chunk-6CHBLB3V.mjs.map → chunk-HVMFZF6P.mjs.map} +0 -0
  312. /package/dist/esm/{chunk-ZNC3FRSK.mjs.map → chunk-IR4SLC2M.mjs.map} +0 -0
  313. /package/dist/esm/{chunk-GGPA6QTN.mjs.map → chunk-J64ARI4E.mjs.map} +0 -0
  314. /package/dist/esm/{chunk-3F3FCWT5.mjs.map → chunk-JH6VLTMS.mjs.map} +0 -0
  315. /package/dist/esm/{chunk-ORGMRM5K.mjs.map → chunk-KUOB4DDE.mjs.map} +0 -0
  316. /package/dist/esm/{chunk-2XYA7NOU.mjs.map → chunk-KUZ2YTJH.mjs.map} +0 -0
  317. /package/dist/esm/{chunk-HBQLX5QF.mjs.map → chunk-L2QXU6F4.mjs.map} +0 -0
  318. /package/dist/esm/{chunk-QQU4IQ27.mjs.map → chunk-LNEZEYYE.mjs.map} +0 -0
  319. /package/dist/esm/{chunk-53DBMWMU.mjs.map → chunk-MAMPMCO7.mjs.map} +0 -0
  320. /package/dist/esm/{chunk-56F7EYFE.mjs.map → chunk-MNVUSJEK.mjs.map} +0 -0
  321. /package/dist/esm/{chunk-SUAA25UP.mjs.map → chunk-O2BPA6TS.mjs.map} +0 -0
  322. /package/dist/esm/{chunk-NKDHR2DA.mjs.map → chunk-OKAQO57B.mjs.map} +0 -0
  323. /package/dist/esm/{chunk-PDNA4H34.mjs.map → chunk-P3TAY5PP.mjs.map} +0 -0
  324. /package/dist/esm/{chunk-EJMPY5MF.mjs.map → chunk-Q3TAEOH5.mjs.map} +0 -0
  325. /package/dist/esm/{chunk-MNVDBUF3.mjs.map → chunk-QBSU3L5Q.mjs.map} +0 -0
  326. /package/dist/esm/{chunk-3GOJQ5JD.mjs.map → chunk-QPB6EJVM.mjs.map} +0 -0
  327. /package/dist/esm/{chunk-KRIIRH5L.mjs.map → chunk-R76DHMGR.mjs.map} +0 -0
  328. /package/dist/esm/{chunk-JUNVPIW4.mjs.map → chunk-S2KDCIZN.mjs.map} +0 -0
  329. /package/dist/esm/{chunk-YPQZJ72F.mjs.map → chunk-S2W4D6NZ.mjs.map} +0 -0
  330. /package/dist/esm/{chunk-5P7MXLZA.mjs.map → chunk-SDWE6WMM.mjs.map} +0 -0
  331. /package/dist/esm/{chunk-WLZYSLHP.mjs.map → chunk-SWNFKKRE.mjs.map} +0 -0
  332. /package/dist/esm/{chunk-DVIRUFCY.mjs.map → chunk-TQWGQLM6.mjs.map} +0 -0
  333. /package/dist/esm/{chunk-VYXJ7FUF.mjs.map → chunk-WJRZWAIS.mjs.map} +0 -0
  334. /package/dist/esm/{chunk-LFUBUXHD.mjs.map → chunk-X34JJPW5.mjs.map} +0 -0
  335. /package/dist/esm/{chunk-EXMQBH3I.mjs.map → chunk-XMW65WCQ.mjs.map} +0 -0
  336. /package/dist/esm/{chunk-54QUDAAC.mjs.map → chunk-YU3IYJRL.mjs.map} +0 -0
  337. /package/dist/esm/{chunk-NBO2BDDZ.mjs.map → chunk-ZROQH5YL.mjs.map} +0 -0
@@ -110,6 +110,7 @@ export enum AnyPublicKeyVariant {
110
110
  Ed25519 = 0,
111
111
  Secp256k1 = 1,
112
112
  Keyless = 3,
113
+ FederatedKeyless = 4,
113
114
  }
114
115
 
115
116
  export enum AnySignatureVariant {
@@ -1013,6 +1014,12 @@ export type MoveStruct = {
1013
1014
  * Whether the struct is a native struct of Move
1014
1015
  */
1015
1016
  is_native: boolean;
1017
+ /**
1018
+ * Whether the struct is a module event (aka v2 event). This will be false for v1
1019
+ * events because the value is derived from the #[event] attribute on the struct in
1020
+ * the Move source code. This attribute is only relevant for v2 events.
1021
+ */
1022
+ is_event: boolean;
1016
1023
  /**
1017
1024
  * Abilities associated with the struct
1018
1025
  */
package/src/version.ts CHANGED
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * hardcoded for now, we would want to have it injected dynamically
8
8
  */
9
- export const VERSION = "1.28.0";
9
+ export const VERSION = "1.29.0";
@@ -1 +0,0 @@
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, AccountAddressInput } 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[]; address?: AccountAddressInput }) {\n const { multiKey, signers, address } = args;\n\n this.publicKey = multiKey;\n this.signingScheme = SigningScheme.MultiKey;\n\n this.accountAddress = address ? AccountAddress.from(address) : 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 const promises = keylessSigners.map(async (signer) => signer.waitForProofFetch());\n await Promise.all(promises);\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":"2KAwBO,IAAMA,EAAN,MAAMC,CAAmC,CAuC9C,YAAYC,EAAiF,C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D,IAAI,MAAOd,GAAWA,EAAO,kBAAkB,CAAC,EAChF,MAAM,QAAQ,IAAIa,CAAQ,CAC5B,CAOA,KAAKE,EAAmC,CACtC,IAAMC,EAAa,CAAC,EACpB,QAAWhB,KAAU,KAAK,QACxBgB,EAAW,KAAKhB,EAAO,KAAKe,CAAI,CAAC,EAEnC,OAAO,IAAIE,EAAkB,CAAE,WAAAD,EAAY,OAAQ,KAAK,gBAAiB,CAAC,CAC5E,CAOA,gBAAgBJ,EAAmD,CACjE,IAAMI,EAAa,CAAC,EACpB,QAAWhB,KAAU,KAAK,QACxBgB,EAAW,KAAKhB,EAAO,gBAAgBY,CAAW,CAAC,EAErD,OAAO,IAAIK,EAAkB,CAAE,WAAAD,EAAY,OAAQ,KAAK,gBAAiB,CAAC,CAC5E,CASA,gBAAgBtB,EAA4C,CAC1D,GAAM,CAAE,QAAAgB,EAAS,UAAAQ,CAAU,EAAIxB,EAI/B,GAAI,CAH2B,KAAK,eAAe,MACjD,CAACW,EAAOc,IAAMA,IAAM,GAAKd,GAAS,KAAK,eAAec,EAAI,CAAC,CAC7D,EAEE,MAAO,GAET,QAASA,EAAI,EAAGA,EAAID,EAAU,WAAW,OAAQC,GAAK,EAAG,CACvD,IAAMC,EAAkBF,EAAU,WAAWC,CAAC,EAE9C,GAAI,CADc,KAAK,UAAU,WAAW,KAAK,eAAeA,CAAC,CAAC,EACnD,gBAAgB,CAAE,QAAAT,EAAS,UAAWU,CAAgB,CAAC,EACpE,MAAO,EAEX,CACA,MAAO,EACT,CACF","names":["MultiKeyAccount","_MultiKeyAccount","args","multiKey","signers","address","AccountAddress","bitPositions","signer","signersAndBitPosition","index","a","b","value","publicKeys","signaturesRequired","MultiKey","account","message","AccountAuthenticatorMultiKey","transaction","promises","KeylessAccount","data","signatures","MultiKeySignature","signature","i","singleSignature"]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-7Z6DYLCA.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-AQ4I7VVB.mjs.map
@@ -1,2 +0,0 @@
1
- import{a as A}from"./chunk-3F3FCWT5.mjs";import{a as T}from"./chunk-6CHBLB3V.mjs";import{a as y}from"./chunk-EJMPY5MF.mjs";import{a as d}from"./chunk-NPFW6ZFY.mjs";import{d as g,e as a,h as m,i as p,j as f}from"./chunk-EQSON7Y5.mjs";import{a as i,b as s,c as r,d as e,e as c,g as u}from"./chunk-F5PNGH44.mjs";var h=class{constructor(n){this.config=n,this.build=new y(this.config),this.simulate=new A(this.config),this.submit=new T(this.config),this.batch=new d(this.config)}async getTransactions(n){return i({aptosConfig:this.config,...n})}async getTransactionByVersion(n){return r({aptosConfig:this.config,...n})}async getTransactionByHash(n){return e({aptosConfig:this.config,...n})}async isPendingTransaction(n){return c({aptosConfig:this.config,...n})}async waitForTransaction(n){return u({aptosConfig:this.config,...n})}async getGasPriceEstimation(){return s({aptosConfig:this.config})}getSigningMessage(n){return g(n)}async publishPackageTransaction(n){return p({aptosConfig:this.config,...n})}async rotateAuthKey(n){return f({aptosConfig:this.config,...n})}sign(n){return a({...n})}signAsFeePayer(n){let{signer:t,transaction:o}=n;if(!o.feePayerAddress)throw new Error(`Transaction ${o} is not a Fee Payer transaction`);return o.feePayerAddress=t.accountAddress,a({signer:t,transaction:o})}async batchTransactionsForSingleAccount(n){try{let{sender:t,data:o,options:P}=n;this.batch.forSingleAccount({sender:t,data:o,options:P})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(n){let{signer:t,transaction:o}=n;return m({aptosConfig:this.config,signer:t,transaction:o})}};export{h as a};
2
- //# sourceMappingURL=chunk-BIGX2RJL.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/transaction.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"./aptosConfig\";\nimport {\n getGasPriceEstimation,\n getTransactionByHash,\n getTransactionByVersion,\n getTransactions,\n isTransactionPending,\n waitForTransaction,\n} from \"../internal/transaction\";\nimport {\n AnyNumber,\n CommittedTransactionResponse,\n GasEstimation,\n HexInput,\n PaginationArgs,\n PendingTransactionResponse,\n TransactionResponse,\n WaitForTransactionOptions,\n} from \"../types\";\nimport {\n getSigningMessage,\n publicPackageTransaction,\n rotateAuthKey,\n signAndSubmitTransaction,\n signTransaction,\n} from \"../internal/transactionSubmission\";\nimport {\n AccountAuthenticator,\n AnyRawTransaction,\n InputGenerateTransactionOptions,\n InputGenerateTransactionPayloadData,\n} from \"../transactions\";\nimport { AccountAddressInput, PrivateKey } from \"../core\";\nimport { Account } from \"../account\";\nimport { Build } from \"./transactionSubmission/build\";\nimport { Simulate } from \"./transactionSubmission/simulate\";\nimport { Submit } from \"./transactionSubmission/submit\";\nimport { TransactionManagement } from \"./transactionSubmission/management\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\n\nexport class Transaction {\n readonly config: AptosConfig;\n\n readonly build: Build;\n\n readonly simulate: Simulate;\n\n readonly submit: Submit;\n\n readonly batch: TransactionManagement;\n\n constructor(config: AptosConfig) {\n this.config = config;\n this.build = new Build(this.config);\n this.simulate = new Simulate(this.config);\n this.submit = new Submit(this.config);\n this.batch = new TransactionManagement(this.config);\n }\n\n /**\n * Queries on-chain transactions. This function will not return pending\n * transactions. For that, use `getTransactionsByHash`.\n *\n * @example\n * const transactions = await aptos.getTransactions()\n *\n * @param args.options.offset The number transaction to start with\n * @param args.options.limit Number of results to return\n *\n * @returns Array of on-chain transactions\n */\n async getTransactions(args?: { options?: PaginationArgs }): Promise<TransactionResponse[]> {\n return getTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries on-chain transaction by version. This function will not return pending transactions.\n *\n * @example\n * const transaction = await aptos.getTransactions({ledgerVersion:1})\n *\n * @param args.ledgerVersion - Transaction version is an unsigned 64-bit number.\n * @returns On-chain transaction. Only on-chain transactions have versions, so this\n * function cannot be used to query pending transactions.\n */\n async getTransactionByVersion(args: { ledgerVersion: AnyNumber }): Promise<TransactionResponse> {\n return getTransactionByVersion({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries on-chain transaction by transaction hash. This function will return pending transactions.\n *\n * @example\n * const transaction = await aptos.getTransactionByHash({transactionHash:\"0x123\"})\n *\n * @param args.transactionHash - Transaction hash should be hex-encoded bytes string with 0x prefix.\n * @returns Transaction from mempool (pending) or on-chain (committed) transaction\n */\n async getTransactionByHash(args: { transactionHash: HexInput }): Promise<TransactionResponse> {\n return getTransactionByHash({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Defines if specified transaction is currently in pending state\n *\n * To create a transaction hash:\n *\n * 1. Create a hash message from the bytes: \"Aptos::Transaction\" bytes + the BCS-serialized Transaction bytes.\n * 2. Apply hash algorithm SHA3-256 to the hash message bytes.\n * 3. Hex-encode the hash bytes with 0x prefix.\n *\n * @example\n * const isPendingTransaction = await aptos.isPendingTransaction({transactionHash:\"0x123\"})\n *\n * @param args.transactionHash A hash of transaction\n * @returns `true` if transaction is in pending state and `false` otherwise\n */\n async isPendingTransaction(args: { transactionHash: HexInput }): Promise<boolean> {\n return isTransactionPending({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Waits for a transaction to move past the pending state.\n *\n * There are 4 cases.\n * 1. Transaction is successfully processed and committed to the chain.\n * - The function will resolve with the transaction response from the API.\n * 2. Transaction is rejected for some reason, and is therefore not committed to the blockchain.\n * - The function will throw an AptosApiError with an HTTP status code indicating some problem with the request.\n * 3. Transaction is committed but execution failed, meaning no changes were\n * written to the blockchain state.\n * - If `checkSuccess` is true, the function will throw a FailedTransactionError\n * If `checkSuccess` is false, the function will resolve with the transaction response where the `success` field is false.\n * 4. Transaction does not move past the pending state within `args.options.timeoutSecs` seconds.\n * - The function will throw a WaitForTransactionError\n *\n * @example\n * const transaction = await aptos.waitForTransaction({transactionHash:\"0x123\"})\n *\n * @param args.transactionHash The hash of a transaction previously submitted to the blockchain.\n * @param args.options.timeoutSecs Timeout in seconds. Defaults to 20 seconds.\n * @param args.options.checkSuccess A boolean which controls whether the function will error if the transaction failed.\n * Defaults to true. See case 3 above.\n * @returns The transaction on-chain. See above for more details.\n */\n async waitForTransaction(args: {\n transactionHash: HexInput;\n options?: WaitForTransactionOptions;\n }): Promise<CommittedTransactionResponse> {\n return waitForTransaction({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Gives an estimate of the gas unit price required to get a\n * transaction on chain in a reasonable amount of time.\n * For more information {@link https://api.mainnet.aptoslabs.com/v1/spec#/operations/estimate_gas_price}\n *\n * @returns Object holding the outputs of the estimate gas API\n *\n * @example\n * const gasPrice = await aptos.waitForTransaction()\n */\n async getGasPriceEstimation(): Promise<GasEstimation> {\n return getGasPriceEstimation({\n aptosConfig: this.config,\n });\n }\n\n /**\n * Returns a signing message for a transaction.\n *\n * This allows a user to sign a transaction using their own preferred signing method, and\n * then submit it to the network.\n *\n * @example\n * const transaction = await aptos.transaction.build.simple({...})\n * const message = await aptos.getSigningMessage({transaction})\n *\n * @param args.transaction A raw transaction for signing elsewhere\n */\n // eslint-disable-next-line class-methods-use-this\n getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {\n return getSigningMessage(args);\n }\n\n /**\n * Generates a transaction to publish a move package to chain.\n *\n * To get the `metadataBytes` and `byteCode`, can compile using Aptos CLI with command\n * `aptos move compile --save-metadata ...`,\n * For more info {@link https://aptos.dev/tutorials/your-first-dapp/#step-4-publish-a-move-module}\n *\n * @example\n * const transaction = await aptos.publishPackageTransaction({\n * account: alice,\n * metadataBytes,\n * moduleBytecode: [byteCode],\n * })\n *\n * @param args.account The publisher account\n * @param args.metadataBytes The package metadata bytes\n * @param args.moduleBytecode An array of the bytecode of each module in the package in compiler output order\n *\n * @returns A SimpleTransaction that can be simulated or submitted to chain\n */\n async publishPackageTransaction(args: {\n account: AccountAddressInput;\n metadataBytes: HexInput;\n moduleBytecode: Array<HexInput>;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return publicPackageTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Rotate an account's auth key. After rotation, only the new private key can be used to sign txns for\n * the account.\n * Note: Only legacy Ed25519 scheme is supported for now.\n * More info: {@link https://aptos.dev/guides/account-management/key-rotation/}\n *\n * @example\n * const response = await aptos.rotateAuthKey({\n * fromAccount: alice,\n * toNewPrivateKey: new ED25519PublicKey(\"0x123\"),\n * })\n *\n * @param args.fromAccount The account to rotate the auth key for\n * @param args.toNewPrivateKey The new private key to rotate to\n *\n * @returns PendingTransactionResponse\n */\n async rotateAuthKey(args: { fromAccount: Account; toNewPrivateKey: PrivateKey }): Promise<TransactionResponse> {\n return rotateAuthKey({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sign a transaction that can later be submitted to chain\n *\n * @example\n * const transaction = await aptos.transaction.build.simple({...})\n * const transaction = await aptos.transaction.sign({\n * signer: alice,\n * transaction\n * })\n *\n * @param args.signer The signer account\n * @param args.transaction A raw transaction to sign on\n *\n * @returns AccountAuthenticator\n */\n // eslint-disable-next-line class-methods-use-this\n sign(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n return signTransaction({\n ...args,\n });\n }\n\n /**\n * Sign a transaction as a fee payer that can later be submitted to chain\n *\n * @example\n * const transaction = await aptos.transaction.build.simple({...})\n * const transaction = await aptos.transaction.signAsFeePayer({\n * signer: alice,\n * transaction\n * })\n *\n * @param args.signer The fee payer signer account\n * @param args.transaction A raw transaction to sign on\n *\n * @returns AccountAuthenticator\n */\n // eslint-disable-next-line class-methods-use-this\n signAsFeePayer(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n\n // if transaction doesnt hold a \"feePayerAddress\" prop it means\n // this is not a fee payer transaction\n if (!transaction.feePayerAddress) {\n throw new Error(`Transaction ${transaction} is not a Fee Payer transaction`);\n }\n\n // Set the feePayerAddress to the signer account address\n transaction.feePayerAddress = signer.accountAddress;\n\n return signTransaction({\n signer,\n transaction,\n });\n }\n\n // TRANSACTION SUBMISSION //\n\n /**\n * @deprecated Prefer to use `aptos.transaction.batch.forSingleAccount()`\n *\n * Batch transactions for a single account.\n *\n * This function uses a transaction worker that receives payloads to be processed\n * and submitted to chain.\n * Note that this process is best for submitting multiple transactions that\n * dont rely on each other, i.e batch funds, batch token mints, etc.\n *\n * If any worker failure, the functions throws an error.\n *\n * @param args.sender The sender account to sign and submit the transaction\n * @param args.data An array of transaction payloads\n * @param args.options optional. Transaction generation configurations (excluding accountSequenceNumber)\n *\n * @return void. Throws if any error\n */\n async batchTransactionsForSingleAccount(args: {\n sender: Account;\n data: InputGenerateTransactionPayloadData[];\n options?: Omit<InputGenerateTransactionOptions, \"accountSequenceNumber\">;\n }): Promise<void> {\n try {\n const { sender, data, options } = args;\n this.batch.forSingleAccount({ sender, data, options });\n } catch (error: any) {\n throw new Error(`failed to submit transactions with error: ${error}`);\n }\n }\n\n /**\n * Sign and submit a single signer transaction to chain\n *\n * @param args.signer The signer account to sign the transaction\n * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses\n *\n * @example\n * const transaction = await aptos.transaction.build.simple({...})\n * const transaction = await aptos.signAndSubmitTransaction({\n * signer: alice,\n * transaction\n * })\n *\n * @return PendingTransactionResponse\n */\n async signAndSubmitTransaction(args: {\n signer: Account;\n transaction: AnyRawTransaction;\n }): Promise<PendingTransactionResponse> {\n const { signer, transaction } = args;\n return signAndSubmitTransaction({\n aptosConfig: this.config,\n signer,\n transaction,\n });\n }\n}\n"],"mappings":"qTA2CO,IAAMA,EAAN,KAAkB,CAWvB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,EACd,KAAK,MAAQ,IAAIC,EAAM,KAAK,MAAM,EAClC,KAAK,SAAW,IAAIC,EAAS,KAAK,MAAM,EACxC,KAAK,OAAS,IAAIC,EAAO,KAAK,MAAM,EACpC,KAAK,MAAQ,IAAIC,EAAsB,KAAK,MAAM,CACpD,CAcA,MAAM,gBAAgBC,EA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AK,MAAM,iBAAiB,CAAE,OAAAa,EAAQ,KAAAC,EAAM,QAAAC,CAAQ,CAAC,CACvD,OAASC,EAAY,CACnB,MAAM,IAAI,MAAM,6CAA6CA,CAAK,EAAE,CACtE,CACF,CAiBA,MAAM,yBAAyBhB,EAGS,CACtC,GAAM,CAAE,OAAAW,EAAQ,YAAAC,CAAY,EAAIZ,EAChC,OAAOiB,EAAyB,CAC9B,YAAa,KAAK,OAClB,OAAAN,EACA,YAAAC,CACF,CAAC,CACH,CACF","names":["Transaction","config","Build","Simulate","Submit","TransactionManagement","args","getTransactions","getTransactionByVersion","getTransactionByHash","isTransactionPending","waitForTransaction","getGasPriceEstimation","getSigningMessage","publicPackageTransaction","rotateAuthKey","signTransaction","signer","transaction","sender","data","options","error","signAndSubmitTransaction"]}
@@ -1,2 +0,0 @@
1
- import{a as I}from"./chunk-NBO2BDDZ.mjs";import{a as A,b as a,c as g,d as m,e as p,f,g as y,h as C,i as T,j as O,k as l,l as P,m as R,n as V,o as L,p as h,q as S}from"./chunk-XSTCHOUI.mjs";import{a as n}from"./chunk-5P7MXLZA.mjs";import{g as u,h as d}from"./chunk-UAL27G6B.mjs";import{e as i,f as c}from"./chunk-EXP5STXZ.mjs";var w=class{constructor(e){this.config=e}async getAccountInfo(e){return A({aptosConfig:this.config,...e})}async getAccountModules(e){return a({aptosConfig:this.config,...e})}async getAccountModule(e){return g({aptosConfig:this.config,...e})}async getAccountTransactions(e){return m({aptosConfig:this.config,...e})}async getAccountResources(e){return p({aptosConfig:this.config,...e})}async getAccountResource(e){return f({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return y({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),C({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),T({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),O({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),l({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"}),V({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),L({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:i,faMetadataAddress:c,...e})}async getAccountCoinAmount(e){let{coinType:t,faMetadataAddress:s}=e;await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"});let r=t;if(t===void 0&&s!==void 0)try{let o=(await I({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[s]}})).at(0);o.vec.length>0&&d(o.vec[0])&&(r=u(o.vec[0]))}catch{}return R({aptosConfig:this.config,...e,coinType:r})}async getAccountOwnedObjects(e){return await n({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),h({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return S({aptosConfig:this.config,...e})}};export{w as a};
2
- //# sourceMappingURL=chunk-DCNBMUKN.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/account.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account as AccountModule } from \"../account\";\nimport { AccountAddress, PrivateKey, AccountAddressInput } from \"../core\";\nimport {\n AccountData,\n AnyNumber,\n GetAccountCoinsDataResponse,\n GetAccountCollectionsWithOwnedTokenResponse,\n GetAccountOwnedTokensFromCollectionResponse,\n GetAccountOwnedTokensQueryResponse,\n GetObjectDataQueryResponse,\n LedgerVersionArg,\n MoveModuleBytecode,\n MoveResource,\n MoveStructId,\n MoveValue,\n OrderByArg,\n PaginationArgs,\n TokenStandardArg,\n TransactionResponse,\n WhereArg,\n} from \"../types\";\nimport {\n deriveAccountFromPrivateKey,\n getAccountCoinAmount,\n getAccountCoinsCount,\n getAccountCoinsData,\n getAccountCollectionsWithOwnedTokens,\n getAccountOwnedObjects,\n getAccountOwnedTokens,\n getAccountOwnedTokensFromCollectionAddress,\n getAccountTokensCount,\n getAccountTransactionsCount,\n getInfo,\n getModule,\n getModules,\n getResource,\n getResources,\n getTransactions,\n lookupOriginalAccountAddress,\n} from \"../internal/account\";\nimport { APTOS_COIN, APTOS_FA, ProcessorType } from \"../utils/const\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { waitForIndexerOnVersion } from \"./utils\";\nimport { CurrentFungibleAssetBalancesBoolExp } from \"../types/generated/types\";\nimport { view } from \"../internal/view\";\nimport { isEncodedStruct, parseEncodedStruct } from \"../utils\";\n\n/**\n * A class to query all `Account` related queries on Aptos.\n */\nexport class Account {\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Queries the current state for an Aptos account given its account address\n *\n * @param args.accountAddress Aptos account address\n *\n * @returns The account data\n *\n * @example An example of the returned account\n * ```\n * {\n * sequence_number: \"1\",\n * authentication_key: \"0x5307b5f4bc67829097a8ba9b43dba3b88261eeccd1f709d9bde240fc100fbb69\"\n * }\n * ```\n */\n async getAccountInfo(args: { accountAddress: AccountAddressInput }): Promise<AccountData> {\n return getInfo({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for all modules in an account given an account address\n *\n * Note: In order to get all account modules, this function may call the API\n * multiple times as it auto paginates.\n *\n * @param args.accountAddress Aptos account address\n * @param args.options.offset The number module to start returning results from\n * @param args.options.limit The number of results to return\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n *\n * @returns Account modules\n */\n\n async getAccountModules(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs & LedgerVersionArg;\n }): Promise<MoveModuleBytecode[]> {\n return getModules({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for a specific account module given account address and module name\n *\n * @param args.accountAddress Aptos account address\n * @param args.moduleName The name of the module\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n *\n * @returns Account module\n *\n * @example\n * const module = await aptos.getAccountModule({accountAddress:\"0x456\"})\n * // An example of an account module response\n * ```\n * {\n * bytecode: \"0xa11ceb0b0600000006010002030206050807070f0d081c200\",\n * abi: { address: \"0x1\" }\n * }\n * ```\n */\n async getAccountModule(args: {\n accountAddress: AccountAddressInput;\n moduleName: string;\n options?: LedgerVersionArg;\n }): Promise<MoveModuleBytecode> {\n return getModule({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries account transactions given an account address\n *\n * Note: In order to get all account transactions, this function may call the API\n * multiple times as it auto paginates.\n *\n * @example\n * const transactions = await aptos.getAccountTransactions({accountAddress:\"0x456\"})\n *\n * @param args.accountAddress Aptos account address\n * @param args.options.offset The number transaction to start returning results from\n * @param args.options.limit The number of results to return\n *\n * @returns The account transactions\n */\n async getAccountTransactions(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs;\n }): Promise<TransactionResponse[]> {\n return getTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries all account resources given an account address\n *\n * Note: In order to get all account resources, this function may call the API\n * multiple times as it auto paginates.\n *\n * @example\n * const resources = await aptos.getAccountResources({accountAddress:\"0x456\"})\n *\n * @param args.accountAddress Aptos account address\n * @param args.options.offset The number resource to start returning results from\n * @param args.options.limit The number of results to return\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns Account resources\n */\n async getAccountResources(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs & LedgerVersionArg;\n }): Promise<MoveResource[]> {\n return getResources({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries a specific account resource given account address and resource type. Note that the default is `any` in order\n * to allow for ease of accessing properties of the object.\n *\n * @type The typed output of the resource\n * @param args.accountAddress Aptos account address\n * @param args.resourceType String representation of an on-chain Move struct type, i.e \"0x1::aptos_coin::AptosCoin\"\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n *\n * @returns Account resource\n *\n * @example\n * const resource = await aptos.getAccountResource({accountAddress:\"0x456\"})\n *\n */\n async getAccountResource<T extends {} = any>(args: {\n accountAddress: AccountAddressInput;\n resourceType: MoveStructId;\n options?: LedgerVersionArg;\n }): Promise<T> {\n return getResource<T>({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Looks up the account address for a given authentication key\n *\n * This handles both if the account's authentication key has been rotated or not.\n *\n * @example\n * const accountAddress = await aptos.lookupOriginalAccountAddress({authenticationKey:account.accountAddress})\n *\n * @param args.authenticationKey The authentication key\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options.ledgerVersion The ledger version to query, if not provided it will get the latest version\n * @returns Promise<AccountAddress> The accountAddress associated with the authentication key\n */\n async lookupOriginalAccountAddress(args: {\n authenticationKey: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: LedgerVersionArg;\n }): Promise<AccountAddress> {\n return lookupOriginalAccountAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries the current count of tokens owned by an account\n *\n * @example\n * const tokensCount = await aptos.getAccountTokensCount({accountAddress:\"0x456\"})\n *\n * @param args.accountAddress The account address\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @returns Current count of tokens owned by the account\n */\n async getAccountTokensCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.ACCOUNT_TRANSACTION_PROCESSOR,\n });\n return getAccountTokensCount({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the account's current owned tokens.\n *\n * This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.\n * If you want to get only the token from a specific standard, you can pass an optional tokenStandard param\n *\n * @example\n * const accountOwnedTokens = await aptos.getAccountOwnedTokens({accountAddress:\"0x456\"})\n *\n * @param args.accountAddress The account address we want to get the tokens for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options.tokenStandard The NFT standard to query for\n * @param args.options.offset The number token to start returning results from\n * @param args.options.limit The number of results to return\n * @param args.options.orderBy The order to sort the tokens by\n * @returns Tokens array with the token data\n */\n async getAccountOwnedTokens(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensQueryResponse[0]>;\n }): Promise<GetAccountOwnedTokensQueryResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountOwnedTokens({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries all current tokens of a specific collection that an account owns by the collection address\n *\n * This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.\n * If you want to get only the token from a specific standard, you can pass an optional tokenStandard param\n *\n * @example\n * const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({accountAddress:\"0x123\", collectionAddress:\"0x456\"})\n *\n * @param args.accountAddress The account address we want to get the tokens for\n * @param args.collectionAddress The address of the collection being queried\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options.tokenStandard The NFT standard to query for\n * @param args.options.offset The number token to start returning results from\n * @param args.options.limit The number of results to return\n * @param args.options.orderBy The order to sort the tokens by\n * @returns Tokens array with the token data\n */\n async getAccountOwnedTokensFromCollectionAddress(args: {\n accountAddress: AccountAddressInput;\n collectionAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensFromCollectionResponse[0]>;\n }): Promise<GetAccountOwnedTokensFromCollectionResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountOwnedTokensFromCollectionAddress({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries for all collections that an account currently has tokens for.\n *\n * This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.\n * If you want to get only the token from a specific standard, you can pass an optional tokenStandard param\n *\n * @example\n * const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({accountAddress:\"0x123\"})\n *\n * @param args.accountAddress The account address we want to get the collections for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options.tokenStandard The NFT standard to query for\n * @param args.options.offset The number collection to start returning results from\n * @param args.options.limit The number of results to return\n * @param args.options.orderBy The order to sort the tokens by\n * @returns Collections array with the collections data\n */\n async getAccountCollectionsWithOwnedTokens(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountCollectionsWithOwnedTokenResponse[0]>;\n }): Promise<GetAccountCollectionsWithOwnedTokenResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountCollectionsWithOwnedTokens({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the current count of transactions submitted by an account\n *\n * @example\n * const accountTransactionsCount = await aptos.getAccountTransactionsCount({accountAddress:\"0x123\"})\n *\n * @param args.accountAddress The account address we want to get the total count for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @returns Current count of transactions made by an account\n */\n async getAccountTransactionsCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.ACCOUNT_TRANSACTION_PROCESSOR,\n });\n return getAccountTransactionsCount({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries an account's coins data\n *\n * @example\n * const accountCoinsData = await aptos.getAccountCoinsData({accountAddress:\"0x123\"})\n *\n * @param args.accountAddress The account address we want to get the coins data for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options.offset optional. The number coin to start returning results from\n * @param args.options.limit optional. The number of results to return\n * @param args.options.orderBy optional. The order to sort the coins by\n * @param args.options.where optional. Filter the results by\n * @returns Array with the coins data\n */\n async getAccountCoinsData(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs &\n OrderByArg<GetAccountCoinsDataResponse[0]> &\n WhereArg<CurrentFungibleAssetBalancesBoolExp>;\n }): Promise<GetAccountCoinsDataResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getAccountCoinsData({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the current count of an account's coins aggregated\n *\n * @example\n * const accountCoinsCount = await aptos.getAccountCoinsCount({accountAddress:\"0x123\"})\n *\n * @param args.accountAddress The account address we want to get the total count for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @returns Current count of the aggregated count of all account's coins\n */\n async getAccountCoinsCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getAccountCoinsCount({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries the account's APT amount\n *\n * @example\n * const accountAPTAmount = await aptos.getAccountAPTAmount({accountAddress:\"0x123\"})\n *\n * @param args.accountAddress The account address we want to get the total count for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @returns Current amount of account's APT\n */\n async getAccountAPTAmount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n return this.getAccountCoinAmount({ coinType: APTOS_COIN, faMetadataAddress: APTOS_FA, ...args });\n }\n\n /**\n * Queries the account's coin amount by the coin type\n *\n * @example\n * const accountCoinAmount = await aptos.getAccountCoinAmount({accountAddress:\"0x123\", coinType:\"0x1::aptos_coin::AptosCoin\"})\n *\n * @param args.accountAddress The account address we want to get the total count for\n * @param args.coinType The coin type to query.\n * Note: faMetadataAddress will automatically fill this in if not provided when migrated to fungible assets\n * @param args.faMetadataAddress The fungible asset metadata address to query.\n * Note: coinType will automatically fill this in if not provided when migrated to fungible assets\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @returns Current amount of account's coin\n */\n async getAccountCoinAmount(args: {\n accountAddress: AccountAddressInput;\n coinType?: MoveStructId;\n faMetadataAddress?: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n const { coinType, faMetadataAddress } = args;\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n\n // Attempt to populate the CoinType field if the FA address is provided.\n // We cannot do this internally due to dependency cycles issue.\n let coinAssetType: MoveStructId | undefined = coinType;\n if (coinType === undefined && faMetadataAddress !== undefined) {\n try {\n const pairedCoinTypeStruct = (\n await view({\n aptosConfig: this.config,\n payload: { function: \"0x1::coin::paired_coin\", functionArguments: [faMetadataAddress] },\n })\n ).at(0) as { vec: MoveValue[] };\n\n // Check if the Option has a value, and if so, parse the struct\n if (pairedCoinTypeStruct.vec.length > 0 && isEncodedStruct(pairedCoinTypeStruct.vec[0])) {\n coinAssetType = parseEncodedStruct(pairedCoinTypeStruct.vec[0]);\n }\n } catch (error) {\n /* No paired coin type found */\n }\n }\n\n return getAccountCoinAmount({ aptosConfig: this.config, ...args, coinType: coinAssetType });\n }\n\n /**\n * Queries an account's owned objects\n *\n * @example\n * const accountOwnedObjects = await aptos.getAccountOwnedObjects({accountAddress:\"0x123\"})\n *\n * @param args.accountAddress The account address we want to get the objects for\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options.offset The starting position to start returning results from\n * @param args.options.limit The number of results to return\n * @param args.options.orderBy The order to sort the objects by\n * @returns Objects array with the object data\n */\n async getAccountOwnedObjects(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs & OrderByArg<GetObjectDataQueryResponse[0]>;\n }): Promise<GetObjectDataQueryResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.DEFAULT,\n });\n return getAccountOwnedObjects({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Derives an account by providing a private key.\n * This functions resolves the provided private key type and derives the public key from it.\n *\n * If the privateKey is a Secp256k1 type, it derives the account using the derived public key and\n * auth key using the SingleKey scheme locally.\n *\n * If the privateKey is a ED25519 type, it looks up the authentication key on chain, and uses it to resolve\n * whether it is a Legacy ED25519 key or a Unified ED25519 key. It then derives the account based\n * on that.\n *\n * @example\n * const account = await aptos.deriveAccountFromPrivateKey({privateKey:new Ed25519PrivateKey(\"0x123\")})\n *\n * @param args.privateKey An account private key\n * @returns Account type\n */\n async deriveAccountFromPrivateKey(args: { privateKey: PrivateKey }): Promise<AccountModule> {\n return deriveAccountFromPrivateKey({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"sUAqDO,IAAMA,EAAN,KAAc,CACnB,YAAqBC,EAAqB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AAqB,IAAI,CAAC,CAAC,IACpFD,EAAgBI,EAAmBH,EAAqB,IAAI,CAAC,CAAC,EAElE,MAAgB,CAEhB,CAGF,OAAOI,EAAqB,CAAE,YAAa,KAAK,OAAQ,GAAGzB,EAAM,SAAUoB,CAAc,CAAC,CAC5F,CAeA,MAAM,uBAAuBpB,EAIW,CACtC,aAAMQ,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBR,EAAK,qBAC3B,iCACF,CAAC,EACM0B,EAAuB,CAC5B,YAAa,KAAK,OAClB,GAAG1B,CACL,CAAC,CACH,CAmBA,MAAM,4BAA4BA,EAA0D,CAC1F,OAAO2B,EAA4B,CAAE,YAAa,KAAK,OAAQ,GAAG3B,CAAK,CAAC,CAC1E,CACF","names":["Account","config","args","getInfo","getModules","getModule","getTransactions","getResources","getResource","lookupOriginalAccountAddress","waitForIndexerOnVersion","getAccountTokensCount","getAccountOwnedTokens","getAccountOwnedTokensFromCollectionAddress","getAccountCollectionsWithOwnedTokens","getAccountTransactionsCount","getAccountCoinsData","getAccountCoinsCount","APTOS_COIN","APTOS_FA","coinType","faMetadataAddress","coinAssetType","pairedCoinTypeStruct","view","isEncodedStruct","parseEncodedStruct","getAccountCoinAmount","getAccountOwnedObjects","deriveAccountFromPrivateKey"]}
@@ -1,2 +0,0 @@
1
- import{a as g,f as d,g as b,i as S}from"./chunk-T53MZO2U.mjs";import{a as C}from"./chunk-XSTCHOUI.mjs";import{a as P}from"./chunk-3GOJQ5JD.mjs";import{a as w}from"./chunk-52HZTDBB.mjs";import{a as I}from"./chunk-IVOEXGOG.mjs";import{d as l}from"./chunk-SUAA25UP.mjs";import{a as T}from"./chunk-WLZYSLHP.mjs";import{c as f,m as s}from"./chunk-SUJLWCRN.mjs";import{b as p}from"./chunk-OHRL766V.mjs";import{b as A}from"./chunk-LS6G4DZV.mjs";import{a as r}from"./chunk-QQU4IQ27.mjs";import{b as y}from"./chunk-YPHH6CAO.mjs";async function h(t){let a=await D(t);return G(t,a)}async function D(t){let{aptosConfig:a,data:n}=t,e,o;return"bytecode"in n?o=await g(n):"multisigAddress"in n?(e={aptosConfig:a,multisigAddress:n.multisigAddress,function:n.function,functionArguments:n.functionArguments,typeArguments:n.typeArguments,abi:n.abi},o=await g(e)):(e={aptosConfig:a,function:n.function,functionArguments:n.functionArguments,typeArguments:n.typeArguments,abi:n.abi},o=await g(e)),o}async function G(t,a){let{aptosConfig:n,sender:e,options:o}=t,i;if(K(t)&&(i=p.ZERO.toString()),U(t)){let{secondarySignerAddresses:c}=t;return d({aptosConfig:n,sender:e,payload:a,options:o,secondarySignerAddresses:c,feePayerAddress:i})}return d({aptosConfig:n,sender:e,payload:a,options:o,feePayerAddress:i})}function K(t){return t.withFeePayer===!0}function U(t){return"secondarySignerAddresses"in t}function Y(t){let{transaction:a}=t;return l(a)}function _(t){let{signer:a,transaction:n}=t;return a.signTransactionWithAuthenticator(n)}async function $(t){let{aptosConfig:a,transaction:n,signerPublicKey:e,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:c}=t,u=b({transaction:n,signerPublicKey:e,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:c}),{data:m}=await A({aptosConfig:a,body:u,path:"transactions/simulate",params:{estimate_gas_unit_price:t.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:t.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:t.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return m}async function B(t){let{aptosConfig:a}=t,n=S({...t}),{data:e}=await A({aptosConfig:a,body:n,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return e}async function M(t){let{aptosConfig:a,signer:n,transaction:e}=t;(n instanceof I||n instanceof w)&&await n.waitForProofFetch();let o=_({signer:n,transaction:e});return B({aptosConfig:a,transaction:e,senderAuthenticator:o})}var N={typeParameters:[],parameters:[s.u8(),new s(s.u8())]};async function nn(t){let{aptosConfig:a,account:n,metadataBytes:e,moduleBytecode:o,options:i}=t,c=o.map(u=>r.U8(u));return h({aptosConfig:a,sender:p.from(n),data:{function:"0x1::code::publish_package_txn",functionArguments:[r.U8(e),new r(c)],abi:N},options:i})}var F={typeParameters:[],parameters:[new f,s.u8(),new f,s.u8(),s.u8(),s.u8()]};async function tn(t){let{aptosConfig:a,fromAccount:n,toNewPrivateKey:e}=t,o=await C({aptosConfig:a,accountAddress:n.accountAddress}),i=P.fromPrivateKey({privateKey:e,legacy:!0}),u=new T({sequenceNumber:BigInt(o.sequence_number),originator:n.accountAddress,currentAuthKey:p.from(o.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),m=n.sign(u),R=i.sign(u),x=await h({aptosConfig:a,sender:n.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new y(n.signingScheme),r.U8(n.publicKey.toUint8Array()),new y(i.signingScheme),r.U8(i.publicKey.toUint8Array()),r.U8(m.toUint8Array()),r.U8(R.toUint8Array())],abi:F}});return M({aptosConfig:a,signer:n,transaction:x})}export{h as a,D as b,G as c,Y as d,_ as e,$ as f,B as g,M as h,nn as i,tn as j};
2
- //# sourceMappingURL=chunk-EQSON7Y5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/internal/transactionSubmission.ts"],"sourcesContent":["/**\n * This file contains the underlying implementations for exposed submission API surface in\n * the {@link api/transaction}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * transaction namespace and without having a dependency cycle error.\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { MoveVector, U8 } from \"../bcs\";\nimport { postAptosFullNode } from \"../client\";\nimport { Account, KeylessAccount, MultiKeyAccount } from \"../account\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { PrivateKey } from \"../core/crypto\";\nimport { AccountAuthenticator } from \"../transactions/authenticator/account\";\nimport { RotationProofChallenge } from \"../transactions/instances/rotationProofChallenge\";\nimport {\n buildTransaction,\n generateTransactionPayload,\n generateSignedTransactionForSimulation,\n generateSignedTransaction,\n} from \"../transactions/transactionBuilder/transactionBuilder\";\nimport {\n InputGenerateTransactionData,\n AnyRawTransaction,\n InputSimulateTransactionData,\n InputGenerateTransactionOptions,\n InputGenerateTransactionPayloadDataWithRemoteABI,\n InputSubmitTransactionData,\n InputGenerateMultiAgentRawTransactionData,\n InputGenerateSingleSignerRawTransactionData,\n AnyTransactionPayloadInstance,\n EntryFunctionABI,\n} from \"../transactions/types\";\nimport { getInfo } from \"./account\";\nimport { UserTransactionResponse, PendingTransactionResponse, MimeType, HexInput, TransactionResponse } from \"../types\";\nimport { TypeTagU8, TypeTagVector, generateSigningMessageForTransaction } from \"../transactions\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\nimport { MultiAgentTransaction } from \"../transactions/instances/multiAgentTransaction\";\n\n/**\n * We are defining function signatures, each with its specific input and output.\n * These are the possible function signature for `generateTransaction` function.\n * When we call `generateTransaction` function with the relevant type properties,\n * Typescript can infer the return type based on the appropriate function overload.\n */\nexport async function generateTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateSingleSignerRawTransactionData,\n): Promise<SimpleTransaction>;\nexport async function generateTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateMultiAgentRawTransactionData,\n): Promise<MultiAgentTransaction>;\n/**\n * Generates any transaction by passing in the required arguments\n *\n * @param args.sender The transaction sender's account address as a AccountAddressInput\n * @param args.data EntryFunctionData | ScriptData | MultiSigData\n * @param args.feePayerAddress optional. For a fee payer (aka sponsored) transaction\n * @param args.secondarySignerAddresses optional. For a multi-agent or fee payer (aka sponsored) transactions\n * @param args.options optional. GenerateTransactionOptions type\n *\n * @example\n * For a single signer entry function\n * move function name, move function type arguments, move function arguments\n * `\n * data: {\n * function:\"0x1::aptos_account::transfer\",\n * typeArguments:[]\n * functionArguments :[receiverAddress,10]\n * }\n * `\n *\n * @example\n * For a single signer script function\n * module bytecode, move function type arguments, move function arguments\n * ```\n * data: {\n * bytecode:\"0x001234567\",\n * typeArguments:[],\n * functionArguments :[receiverAddress,10]\n * }\n * ```\n *\n * @return An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses? : Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n */\nexport async function generateTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateTransactionData,\n): Promise<AnyRawTransaction> {\n const payload = await buildTransactionPayload(args);\n return buildRawTransaction(args, payload);\n}\n\nexport async function buildTransactionPayload(\n args: { aptosConfig: AptosConfig } & InputGenerateTransactionData,\n): Promise<AnyTransactionPayloadInstance> {\n const { aptosConfig, data } = args;\n // Merge in aptosConfig for remote ABI on non-script payloads\n let generateTransactionPayloadData: InputGenerateTransactionPayloadDataWithRemoteABI;\n let payload: AnyTransactionPayloadInstance;\n\n if (\"bytecode\" in data) {\n // TODO: Add ABI checking later\n payload = await generateTransactionPayload(data);\n } else if (\"multisigAddress\" in data) {\n generateTransactionPayloadData = {\n aptosConfig,\n multisigAddress: data.multisigAddress,\n function: data.function,\n functionArguments: data.functionArguments,\n typeArguments: data.typeArguments,\n abi: data.abi,\n };\n payload = await generateTransactionPayload(generateTransactionPayloadData);\n } else {\n generateTransactionPayloadData = {\n aptosConfig,\n function: data.function,\n functionArguments: data.functionArguments,\n typeArguments: data.typeArguments,\n abi: data.abi,\n };\n payload = await generateTransactionPayload(generateTransactionPayloadData);\n }\n return payload;\n}\n\nexport async function buildRawTransaction(\n args: { aptosConfig: AptosConfig } & InputGenerateTransactionData,\n payload: AnyTransactionPayloadInstance,\n): Promise<AnyRawTransaction> {\n const { aptosConfig, sender, options } = args;\n\n let feePayerAddress;\n if (isFeePayerTransactionInput(args)) {\n feePayerAddress = AccountAddress.ZERO.toString();\n }\n\n if (isMultiAgentTransactionInput(args)) {\n const { secondarySignerAddresses } = args;\n return buildTransaction({\n aptosConfig,\n sender,\n payload,\n options,\n secondarySignerAddresses,\n feePayerAddress,\n });\n }\n\n return buildTransaction({\n aptosConfig,\n sender,\n payload,\n options,\n feePayerAddress,\n });\n}\n\nfunction isFeePayerTransactionInput(data: InputGenerateTransactionData): boolean {\n return data.withFeePayer === true;\n}\n\nfunction isMultiAgentTransactionInput(\n data: InputGenerateTransactionData,\n): data is InputGenerateMultiAgentRawTransactionData {\n return \"secondarySignerAddresses\" in data;\n}\n\n/**\n * Builds a signing message that can be signed by external signers\n *\n * Note: Please prefer using `signTransaction` unless signing outside the SDK\n *\n * @param args.transaction AnyRawTransaction, as generated by `generateTransaction()`\n *\n * @return The message to be signed\n */\nexport function getSigningMessage(args: { transaction: AnyRawTransaction }): Uint8Array {\n const { transaction } = args;\n return generateSigningMessageForTransaction(transaction);\n}\n\n/**\n * Sign a transaction that can later be submitted to chain\n *\n * @param args.signer The signer account to sign the transaction\n * @param args.transaction An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses? : Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n *\n * @return The signer AccountAuthenticator\n */\nexport function signTransaction(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n return signer.signTransactionWithAuthenticator(transaction);\n}\n\n/**\n * Simulates a transaction before singing it.\n *\n * @param args.signerPublicKey The signer public key\n * @param args.transaction The raw transaction to simulate\n * @param args.secondarySignersPublicKeys optional. For when the transaction is a multi signers transaction\n * @param args.feePayerPublicKey optional. For when the transaction is a fee payer (aka sponsored) transaction\n * @param args.options optional. A config to simulate the transaction with\n */\nexport async function simulateTransaction(\n args: { aptosConfig: AptosConfig } & InputSimulateTransactionData,\n): Promise<Array<UserTransactionResponse>> {\n const { aptosConfig, transaction, signerPublicKey, secondarySignersPublicKeys, feePayerPublicKey, options } = args;\n\n const signedTransaction = generateSignedTransactionForSimulation({\n transaction,\n signerPublicKey,\n secondarySignersPublicKeys,\n feePayerPublicKey,\n options,\n });\n\n const { data } = await postAptosFullNode<Uint8Array, Array<UserTransactionResponse>>({\n aptosConfig,\n body: signedTransaction,\n path: \"transactions/simulate\",\n params: {\n estimate_gas_unit_price: args.options?.estimateGasUnitPrice ?? false,\n estimate_max_gas_amount: args.options?.estimateMaxGasAmount ?? false,\n estimate_prioritized_gas_unit_price: args.options?.estimatePrioritizedGasUnitPrice ?? false,\n },\n originMethod: \"simulateTransaction\",\n contentType: MimeType.BCS_SIGNED_TRANSACTION,\n });\n return data;\n}\n\n/**\n * Submit transaction to chain\n *\n * @param args.transaction A aptos transaction type\n * @param args.senderAuthenticator The account authenticator of the transaction sender\n * @param args.secondarySignerAuthenticators optional. For when the transaction is a multi signers transaction\n *\n * @return PendingTransactionResponse\n */\nexport async function submitTransaction(\n args: {\n aptosConfig: AptosConfig;\n } & InputSubmitTransactionData,\n): Promise<PendingTransactionResponse> {\n const { aptosConfig } = args;\n const signedTransaction = generateSignedTransaction({ ...args });\n const { data } = await postAptosFullNode<Uint8Array, PendingTransactionResponse>({\n aptosConfig,\n body: signedTransaction,\n path: \"transactions\",\n originMethod: \"submitTransaction\",\n contentType: MimeType.BCS_SIGNED_TRANSACTION,\n });\n return data;\n}\n\nexport async function signAndSubmitTransaction(args: {\n aptosConfig: AptosConfig;\n signer: Account;\n transaction: AnyRawTransaction;\n}): Promise<PendingTransactionResponse> {\n const { aptosConfig, signer, transaction } = args;\n // If the signer contains a KeylessAccount, await proof fetching in case the proof\n // was fetched asyncronously.\n if (signer instanceof KeylessAccount || signer instanceof MultiKeyAccount) {\n await signer.waitForProofFetch();\n }\n const authenticator = signTransaction({ signer, transaction });\n return submitTransaction({\n aptosConfig,\n transaction,\n senderAuthenticator: authenticator,\n });\n}\n\nconst packagePublishAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [TypeTagVector.u8(), new TypeTagVector(TypeTagVector.u8())],\n};\n\nexport async function publicPackageTransaction(args: {\n aptosConfig: AptosConfig;\n account: AccountAddressInput;\n metadataBytes: HexInput;\n moduleBytecode: Array<HexInput>;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, account, metadataBytes, moduleBytecode, options } = args;\n\n const totalByteCode = moduleBytecode.map((bytecode) => MoveVector.U8(bytecode));\n\n return generateTransaction({\n aptosConfig,\n sender: AccountAddress.from(account),\n data: {\n function: \"0x1::code::publish_package_txn\",\n functionArguments: [MoveVector.U8(metadataBytes), new MoveVector(totalByteCode)],\n abi: packagePublishAbi,\n },\n options,\n });\n}\n\nconst rotateAuthKeyAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [\n new TypeTagU8(),\n TypeTagVector.u8(),\n new TypeTagU8(),\n TypeTagVector.u8(),\n TypeTagVector.u8(),\n TypeTagVector.u8(),\n ],\n};\n\n/**\n * TODO: Need to refactor and move this function out of transactionSubmission\n */\nexport async function rotateAuthKey(args: {\n aptosConfig: AptosConfig;\n fromAccount: Account;\n toNewPrivateKey: PrivateKey;\n}): Promise<TransactionResponse> {\n const { aptosConfig, fromAccount, toNewPrivateKey } = args;\n const accountInfo = await getInfo({\n aptosConfig,\n accountAddress: fromAccount.accountAddress,\n });\n\n const newAccount = Account.fromPrivateKey({ privateKey: toNewPrivateKey, legacy: true });\n\n const challenge = new RotationProofChallenge({\n sequenceNumber: BigInt(accountInfo.sequence_number),\n originator: fromAccount.accountAddress,\n currentAuthKey: AccountAddress.from(accountInfo.authentication_key),\n newPublicKey: newAccount.publicKey,\n });\n\n // Sign the challenge\n const challengeHex = challenge.bcsToBytes();\n const proofSignedByCurrentPrivateKey = fromAccount.sign(challengeHex);\n const proofSignedByNewPrivateKey = newAccount.sign(challengeHex);\n\n // Generate transaction\n const rawTxn = await generateTransaction({\n aptosConfig,\n sender: fromAccount.accountAddress,\n data: {\n function: \"0x1::account::rotate_authentication_key\",\n functionArguments: [\n new U8(fromAccount.signingScheme), // from scheme\n MoveVector.U8(fromAccount.publicKey.toUint8Array()),\n new U8(newAccount.signingScheme), // to scheme\n MoveVector.U8(newAccount.publicKey.toUint8Array()),\n MoveVector.U8(proofSignedByCurrentPrivateKey.toUint8Array()),\n MoveVector.U8(proofSignedByNewPrivateKey.toUint8Array()),\n ],\n abi: rotateAuthKeyAbi,\n },\n });\n return signAndSubmitTransaction({\n aptosConfig,\n signer: fromAccount,\n transaction: rawTxn,\n });\n}\n"],"mappings":"wgBA2FA,eAAsBA,EACpBC,EAC4B,CAC5B,IAAMC,EAAU,MAAMC,EAAwBF,CAAI,EAClD,OAAOG,EAAoBH,EAAMC,CAAO,CAC1C,CAEA,eAAsBC,EACpBF,EACwC,CACxC,GAAM,CAAE,YAAAI,EAAa,KAAAC,CAAK,EAAIL,EAE1BM,EACAL,EAEJ,MAAI,aAAcI,EAEhBJ,EAAU,MAAMM,EAA2BF,CAAI,EACtC,oBAAqBA,GAC9BC,EAAiC,CAC/B,YAAAF,EACA,gBAAiBC,EAAK,gBACtB,SAAUA,EAAK,SACf,kBAAmBA,EAAK,kBACxB,cAAeA,EAAK,cACpB,IAAKA,EAAK,GACZ,EACAJ,EAAU,MAAMM,EAA2BD,CAA8B,IAEzEA,EAAiC,CAC/B,YAAAF,EACA,SAAUC,EAAK,SACf,kBAAmBA,EAAK,kBACxB,cAAeA,EAAK,cACpB,IAAKA,EAAK,GACZ,EACAJ,EAAU,MAAMM,EAA2BD,CAA8B,GAEpEL,CACT,CAEA,eAAsBE,EACpBH,EACAC,EAC4B,CAC5B,GAAM,CAAE,YAAAG,EAAa,OAAAI,EAAQ,QAAAC,CAAQ,EAAIT,EAErCU,EAKJ,GAJIC,EAA2BX,CAAI,IACjCU,EAAkBE,EAAe,KAAK,SAAS,GAG7CC,EAA6Bb,CAAI,EAAG,CACtC,GAAM,CAAE,yBAAAc,CAAyB,EAAId,EACrC,OAAOe,EAAiB,CACtB,YAAAX,EACA,OAAAI,EACA,QAAAP,EACA,QAAAQ,EACA,yBAAAK,EACA,gBAAAJ,CACF,CAAC,CACH,CAEA,OAAOK,EAAiB,CACtB,YAAAX,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AgB,OAAOL,EAAY,eAAe,EAClD,WAAYF,EAAY,eACxB,eAAgBlC,EAAe,KAAKoC,EAAY,kBAAkB,EAClE,aAAcE,EAAW,SAC3B,CAAC,EAG8B,WAAW,EACpCI,EAAiCR,EAAY,KAAKM,CAAY,EAC9DG,EAA6BL,EAAW,KAAKE,CAAY,EAGzDI,EAAS,MAAMzD,EAAoB,CACvC,YAAAK,EACA,OAAQ0C,EAAY,eACpB,KAAM,CACJ,SAAU,0CACV,kBAAmB,CACjB,IAAIW,EAAGX,EAAY,aAAa,EAChCJ,EAAW,GAAGI,EAAY,UAAU,aAAa,CAAC,EAClD,IAAIW,EAAGP,EAAW,aAAa,EAC/BR,EAAW,GAAGQ,EAAW,UAAU,aAAa,CAAC,EACjDR,EAAW,GAAGY,EAA+B,aAAa,CAAC,EAC3DZ,EAAW,GAAGa,EAA2B,aAAa,CAAC,CACzD,EACA,IAAKZ,CACP,CACF,CAAC,EACD,OAAOb,EAAyB,CAC9B,YAAA1B,EACA,OAAQ0C,EACR,YAAaU,CACf,CAAC,CACH","names":["generateTransaction","args","payload","buildTransactionPayload","buildRawTransaction","aptosConfig","data","generateTransactionPayloadData","generateTransactionPayload","sender","options","feePayerAddress","isFeePayerTransactionInput","AccountAddress","isMultiAgentTransactionInput","secondarySignerAddresses","buildTransaction","getSigningMessage","transaction","generateSigningMessageForTransaction","signTransaction","signer","simulateTransaction","signerPublicKey","secondarySignersPublicKeys","feePayerPublicKey","signedTransaction","generateSignedTransactionForSimulation","postAptosFullNode","submitTransaction","generateSignedTransaction","signAndSubmitTransaction","KeylessAccount","MultiKeyAccount","authenticator","packagePublishAbi","TypeTagVector","publicPackageTransaction","account","metadataBytes","moduleBytecode","totalByteCode","bytecode","MoveVector","rotateAuthKeyAbi","TypeTagU8","rotateAuthKey","fromAccount","toNewPrivateKey","accountInfo","getInfo","newAccount","Account","challengeHex","RotationProofChallenge","proofSignedByCurrentPrivateKey","proofSignedByNewPrivateKey","rawTxn","U8"]}
@@ -1,2 +0,0 @@
1
- import{b as t}from"./chunk-BCUSI3N6.mjs";var o=r=>typeof r=="string"?t.isValid(r).valid?r:Buffer.from(r,"utf8"):r;export{o as a};
2
- //# sourceMappingURL=chunk-F7EMGK4M.mjs.map
@@ -1,2 +0,0 @@
1
- var g=(e=>(e.JSON="application/json",e.BCS="application/x-bcs",e.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",e.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",e))(g||{}),y=(t=>(t[t.Bool=0]="Bool",t[t.U8=1]="U8",t[t.U64=2]="U64",t[t.U128=3]="U128",t[t.Address=4]="Address",t[t.Signer=5]="Signer",t[t.Vector=6]="Vector",t[t.Struct=7]="Struct",t[t.U16=8]="U16",t[t.U32=9]="U32",t[t.U256=10]="U256",t[t.Reference=254]="Reference",t[t.Generic=255]="Generic",t))(y||{}),d=(o=>(o[o.U8=0]="U8",o[o.U64=1]="U64",o[o.U128=2]="U128",o[o.Address=3]="Address",o[o.U8Vector=4]="U8Vector",o[o.Bool=5]="Bool",o[o.U16=6]="U16",o[o.U32=7]="U32",o[o.U256=8]="U256",o[o.Serialized=9]="Serialized",o))(d||{}),u=(s=>(s[s.Script=0]="Script",s[s.EntryFunction=2]="EntryFunction",s[s.Multisig=3]="Multisig",s))(u||{}),c=(i=>(i[i.MultiAgentTransaction=0]="MultiAgentTransaction",i[i.FeePayerTransaction=1]="FeePayerTransaction",i))(c||{}),l=(r=>(r[r.Ed25519=0]="Ed25519",r[r.MultiEd25519=1]="MultiEd25519",r[r.MultiAgent=2]="MultiAgent",r[r.FeePayer=3]="FeePayer",r[r.SingleSender=4]="SingleSender",r))(l||{}),_=(e=>(e[e.Ed25519=0]="Ed25519",e[e.MultiEd25519=1]="MultiEd25519",e[e.SingleKey=2]="SingleKey",e[e.MultiKey=3]="MultiKey",e))(_||{}),x=(s=>(s[s.Ed25519=0]="Ed25519",s[s.Secp256k1=1]="Secp256k1",s[s.Keyless=3]="Keyless",s))(x||{}),h=(s=>(s[s.Ed25519=0]="Ed25519",s[s.Secp256k1=1]="Secp256k1",s[s.Keyless=3]="Keyless",s))(h||{}),v=(p=>(p[p.Ed25519=0]="Ed25519",p))(v||{}),M=(p=>(p[p.Ed25519=0]="Ed25519",p))(M||{}),m=(p=>(p[p.ZkProof=0]="ZkProof",p))(m||{}),R=(p=>(p[p.Groth16=0]="Groth16",p))(R||{}),b=(a=>(a.Pending="pending_transaction",a.User="user_transaction",a.Genesis="genesis_transaction",a.BlockMetadata="block_metadata_transaction",a.StateCheckpoint="state_checkpoint_transaction",a.Validator="validator_transaction",a.BlockEpilogue="block_epilogue_transaction",a))(b||{});function U(n){return n.type==="pending_transaction"}function W(n){return n.type==="user_transaction"}function F(n){return n.type==="genesis_transaction"}function I(n){return n.type==="block_metadata_transaction"}function B(n){return n.type==="state_checkpoint_transaction"}function A(n){return n.type==="validator_transaction"}function P(n){return n.type==="block_epilogue_transaction"}function G(n){return"signature"in n&&n.signature==="ed25519_signature"}function O(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function D(n){return n.type==="multi_agent_signature"}function N(n){return n.type==="fee_payer_signature"}function q(n){return n.type==="multi_ed25519_signature"}var k=(s=>(s.PRIVATE="private",s.PUBLIC="public",s.FRIEND="friend",s))(k||{}),S=(e=>(e.STORE="store",e.DROP="drop",e.KEY="key",e.COPY="copy",e))(S||{}),f=(i=>(i.VALIDATOR="validator",i.FULL_NODE="full_node",i))(f||{}),C=(e=>(e[e.Ed25519=0]="Ed25519",e[e.MultiEd25519=1]="MultiEd25519",e[e.SingleKey=2]="SingleKey",e[e.MultiKey=3]="MultiKey",e))(C||{}),T=(i=>(i[i.Ed25519=0]="Ed25519",i[i.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",i))(T||{}),E=(r=>(r[r.DeriveAuid=251]="DeriveAuid",r[r.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",r[r.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",r[r.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",r[r.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",r))(E||{});export{g as a,y as b,d as c,u as d,c as e,l as f,_ as g,x as h,h as i,v as j,M as k,m as l,R as m,b as n,U as o,W as p,F as q,I as r,B as s,A as t,P as u,G as v,O as w,D as x,N as y,q as z,k as A,S as B,f as C,C as D,T as E,E as F};
2
- //# sourceMappingURL=chunk-G773HST5.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Network } from \"../utils/apiEndpoints\";\nimport { OrderBy, TokenStandard } from \"./indexer\";\n\nexport * from \"./indexer\";\n\nexport enum MimeType {\n /**\n * JSON representation, used for transaction submission and accept type JSON output\n */\n JSON = \"application/json\",\n /**\n * BCS representation, used for accept type BCS output\n */\n BCS = \"application/x-bcs\",\n /**\n * BCS representation, used for transaction submission in BCS input\n */\n BCS_SIGNED_TRANSACTION = \"application/x.aptos.signed_transaction+bcs\",\n BCS_VIEW_FUNCTION = \"application/x.aptos.view_function+bcs\",\n}\n\n/**\n * Hex data as input to a function\n */\nexport type HexInput = string | Uint8Array;\n\n/**\n * TypeTag enum as they are represented in Rust\n * {@link https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/move-core/types/src/language_storage.rs#L27}\n */\nexport enum TypeTagVariants {\n Bool = 0,\n U8 = 1,\n U64 = 2,\n U128 = 3,\n Address = 4,\n Signer = 5,\n Vector = 6,\n Struct = 7,\n U16 = 8,\n U32 = 9,\n U256 = 10,\n Reference = 254, // This is specifically a placeholder and does not represent a real type\n Generic = 255, // This is specifically a placeholder and does not represent a real type\n}\n\n/**\n * Script transaction arguments enum as they are represented in Rust\n * {@link https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/move-core/types/src/transaction_argument.rs#L11}\n */\nexport enum ScriptTransactionArgumentVariants {\n U8 = 0,\n U64 = 1,\n U128 = 2,\n Address = 3,\n U8Vector = 4,\n Bool = 5,\n U16 = 6,\n U32 = 7,\n U256 = 8,\n Serialized = 9,\n}\n\n/**\n * Transaction payload enum as they are represented in Rust\n * {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/mod.rs#L478}\n */\nexport enum TransactionPayloadVariants {\n Script = 0,\n EntryFunction = 2,\n Multisig = 3,\n}\n\n/**\n * Transaction variants enum as they are represented in Rust\n * {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/mod.rs#L440}\n */\nexport enum TransactionVariants {\n MultiAgentTransaction = 0,\n FeePayerTransaction = 1,\n}\n\n/**\n * Transaction Authenticator enum as they are represented in Rust\n * {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L44}\n */\nexport enum TransactionAuthenticatorVariant {\n Ed25519 = 0,\n MultiEd25519 = 1,\n MultiAgent = 2,\n FeePayer = 3,\n SingleSender = 4,\n}\n\n/**\n * Transaction Authenticator enum as they are represented in Rust\n * {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L414}\n */\nexport enum AccountAuthenticatorVariant {\n Ed25519 = 0,\n MultiEd25519 = 1,\n SingleKey = 2,\n MultiKey = 3,\n}\n\nexport enum AnyPublicKeyVariant {\n Ed25519 = 0,\n Secp256k1 = 1,\n Keyless = 3,\n}\n\nexport enum AnySignatureVariant {\n Ed25519 = 0,\n Secp256k1 = 1,\n Keyless = 3,\n}\n\nexport enum EphemeralPublicKeyVariant {\n Ed25519 = 0,\n}\n\nexport enum EphemeralSignatureVariant {\n Ed25519 = 0,\n}\n\nexport enum EphemeralCertificateVariant {\n ZkProof = 0,\n}\n\nexport enum ZkpVariant {\n Groth16 = 0,\n}\n\n/**\n * BCS types\n */\nexport type Uint8 = number;\nexport type Uint16 = number;\nexport type Uint32 = number;\nexport type Uint64 = bigint;\nexport type Uint128 = bigint;\nexport type Uint256 = bigint;\nexport type AnyNumber = number | bigint;\n\n/**\n * Set of configuration options that can be provided when initializing the SDK.\n * The purpose of these options is to configure various aspects of the SDK's\n * behavior and interaction with the Aptos network\n */\nexport type AptosSettings = {\n readonly network?: Network;\n\n readonly fullnode?: string;\n\n readonly faucet?: string;\n\n readonly indexer?: string;\n\n readonly pepper?: string;\n\n readonly prover?: string;\n\n readonly clientConfig?: ClientConfig;\n\n readonly client?: Client;\n\n readonly fullnodeConfig?: FullNodeConfig;\n\n readonly indexerConfig?: IndexerConfig;\n\n readonly faucetConfig?: FaucetConfig;\n};\n\n/**\n *\n * Controls the number of results that are returned and the starting position of those results.\n * @param offset parameter specifies the starting position of the query result within the set of data. Default is 0.\n * @param limit specifies the maximum number of items or records to return in a query result. Default is 25.\n */\nexport interface PaginationArgs {\n offset?: AnyNumber;\n limit?: number;\n}\n\nexport interface TokenStandardArg {\n tokenStandard?: TokenStandard;\n}\n\nexport interface OrderByArg<T extends {}> {\n orderBy?: OrderBy<T>;\n}\n\nexport interface WhereArg<T extends {}> {\n where?: T;\n}\n\n/**\n * QUERY TYPES\n */\n\n/**\n * A configuration object we can pass with the request to the server.\n *\n * @param API_KEY - api key generated from developer portal {@link https://developers.aptoslabs.com/manage/api-keys}}\n * @param HEADERS - extra headers we want to send with the request\n * @param WITH_CREDENTIALS - whether to carry cookies. By default, it is set to true and cookies will be sent\n */\nexport type ClientConfig = ClientHeadersType & {\n WITH_CREDENTIALS?: boolean;\n API_KEY?: string;\n};\n\n/**\n * A Fullnode only configuration object\n *\n * @param HEADERS - extra headers we want to send with the request\n */\nexport type FullNodeConfig = ClientHeadersType;\n\n/**\n * An Indexer only configuration object\n *\n * @param HEADERS - extra headers we want to send with the request\n */\nexport type IndexerConfig = ClientHeadersType;\n\n/**\n * A Faucet only configuration object\n *\n * @param HEADERS - extra headers we want to send with the request\n * @param AUTH_TOKEN - an auth token to send with a faucet request\n */\nexport type FaucetConfig = ClientHeadersType & {\n AUTH_TOKEN?: string;\n};\n\n/**\n * General type definition for client HEADERS\n */\nexport type ClientHeadersType = {\n HEADERS?: Record<string, string | number | boolean>;\n};\n\nexport interface ClientRequest<Req> {\n url: string;\n method: \"GET\" | \"POST\";\n originMethod?: string;\n body?: Req;\n contentType?: string;\n params?: any;\n overrides?: ClientConfig & FullNodeConfig & IndexerConfig & FaucetConfig;\n headers?: Record<string, any>;\n}\n\nexport interface ClientResponse<Res> {\n status: number;\n statusText: string;\n data: Res;\n config?: any;\n request?: any;\n response?: any;\n headers?: any;\n}\n\nexport interface Client {\n provider<Req, Res>(requestOptions: ClientRequest<Req>): Promise<ClientResponse<Res>>;\n}\n\n/**\n * The API request type\n *\n * @param url - the url to make the request to, i.e https://fullnode.devnet.aptoslabs.com/v1\n * @param method - the request method \"GET\" | \"POST\"\n * @param endpoint (optional) - the endpoint to make the request to, i.e transactions\n * @param body (optional) - the body of the request\n * @param contentType (optional) - the content type to set the `content-type` header to,\n * by default is set to `application/json`\n * @param params (optional) - query params to add to the request\n * @param originMethod (optional) - the local method the request came from\n * @param overrides (optional) - a `ClientConfig` object type to override request data\n */\nexport type AptosRequest = {\n url: string;\n method: \"GET\" | \"POST\";\n path?: string;\n body?: any;\n contentType?: string;\n acceptType?: string;\n params?: Record<string, string | AnyNumber | boolean | undefined>;\n originMethod?: string;\n overrides?: ClientConfig & FullNodeConfig & IndexerConfig & FaucetConfig;\n};\n\n/**\n * Specifies ledger version of transactions. By default latest version will be used\n */\nexport type LedgerVersionArg = {\n ledgerVersion?: AnyNumber;\n};\n\n/**\n * RESPONSE TYPES\n */\n\n/**\n * Type holding the outputs of the estimate gas API\n */\nexport type GasEstimation = {\n /**\n * The deprioritized estimate for the gas unit price\n */\n deprioritized_gas_estimate?: number;\n /**\n * The current estimate for the gas unit price\n */\n gas_estimate: number;\n /**\n * The prioritized estimate for the gas unit price\n */\n prioritized_gas_estimate?: number;\n};\n\nexport type MoveResource<T = {}> = {\n type: MoveStructId;\n data: T;\n};\n\nexport type AccountData = {\n sequence_number: string;\n authentication_key: string;\n};\n\nexport type MoveModuleBytecode = {\n bytecode: string;\n abi?: MoveModule;\n};\n\n/**\n * TRANSACTION TYPES\n */\n\nexport enum TransactionResponseType {\n Pending = \"pending_transaction\",\n User = \"user_transaction\",\n Genesis = \"genesis_transaction\",\n BlockMetadata = \"block_metadata_transaction\",\n StateCheckpoint = \"state_checkpoint_transaction\",\n Validator = \"validator_transaction\",\n BlockEpilogue = \"block_epilogue_transaction\",\n}\n\nexport type TransactionResponse = PendingTransactionResponse | CommittedTransactionResponse;\nexport type CommittedTransactionResponse =\n | UserTransactionResponse\n | GenesisTransactionResponse\n | BlockMetadataTransactionResponse\n | StateCheckpointTransactionResponse\n | ValidatorTransactionResponse\n | BlockEpilogueTransactionResponse;\n\nexport function isPendingTransactionResponse(response: TransactionResponse): response is PendingTransactionResponse {\n return response.type === TransactionResponseType.Pending;\n}\n\nexport function isUserTransactionResponse(response: TransactionResponse): response is UserTransactionResponse {\n return response.type === TransactionResponseType.User;\n}\n\nexport function isGenesisTransactionResponse(response: TransactionResponse): response is GenesisTransactionResponse {\n return response.type === TransactionResponseType.Genesis;\n}\n\nexport function isBlockMetadataTransactionResponse(\n response: TransactionResponse,\n): response is BlockMetadataTransactionResponse {\n return response.type === TransactionResponseType.BlockMetadata;\n}\n\nexport function isStateCheckpointTransactionResponse(\n response: TransactionResponse,\n): response is StateCheckpointTransactionResponse {\n return response.type === TransactionResponseType.StateCheckpoint;\n}\n\nexport function isValidatorTransactionResponse(\n response: TransactionResponse,\n): response is ValidatorTransactionResponse {\n return response.type === TransactionResponseType.Validator;\n}\n\nexport function isBlockEpilogueTransactionResponse(\n response: TransactionResponse,\n): response is BlockEpilogueTransactionResponse {\n return response.type === TransactionResponseType.BlockEpilogue;\n}\n\nexport type PendingTransactionResponse = {\n type: TransactionResponseType.Pending;\n hash: string;\n sender: string;\n sequence_number: string;\n max_gas_amount: string;\n gas_unit_price: string;\n expiration_timestamp_secs: string;\n payload: TransactionPayloadResponse;\n signature?: TransactionSignature;\n};\n\nexport type UserTransactionResponse = {\n type: TransactionResponseType.User;\n version: string;\n hash: string;\n state_change_hash: string;\n event_root_hash: string;\n state_checkpoint_hash: string | null;\n gas_used: string;\n /**\n * Whether the transaction was successful\n */\n success: boolean;\n /**\n * The VM status of the transaction, can tell useful information in a failure\n */\n vm_status: string;\n accumulator_root_hash: string;\n /**\n * Final state of resources changed by the transaction\n */\n changes: Array<WriteSetChange>;\n sender: string;\n sequence_number: string;\n max_gas_amount: string;\n gas_unit_price: string;\n expiration_timestamp_secs: string;\n payload: TransactionPayloadResponse;\n signature?: TransactionSignature;\n /**\n * Events generated by the transaction\n */\n events: Array<Event>;\n timestamp: string;\n};\n\nexport type GenesisTransactionResponse = {\n type: TransactionResponseType.Genesis;\n version: string;\n hash: string;\n state_change_hash: string;\n event_root_hash: string;\n state_checkpoint_hash?: string;\n gas_used: string;\n /**\n * Whether the transaction was successful\n */\n success: boolean;\n /**\n * The VM status of the transaction, can tell useful information in a failure\n */\n vm_status: string;\n accumulator_root_hash: string;\n /**\n * Final state of resources changed by the transaction\n */\n changes: Array<WriteSetChange>;\n payload: GenesisPayload;\n /**\n * Events emitted during genesis\n */\n events: Array<Event>;\n};\n\nexport type BlockMetadataTransactionResponse = {\n type: TransactionResponseType.BlockMetadata;\n version: string;\n hash: string;\n state_change_hash: string;\n event_root_hash: string;\n state_checkpoint_hash: string | null;\n gas_used: string;\n /**\n * Whether the transaction was successful\n */\n success: boolean;\n /**\n * The VM status of the transaction, can tell useful information in a failure\n */\n vm_status: string;\n accumulator_root_hash: string;\n /**\n * Final state of resources changed by the transaction\n */\n changes: Array<WriteSetChange>;\n id: string;\n epoch: string;\n round: string;\n /**\n * The events emitted at the block creation\n */\n events: Array<Event>;\n /**\n * Previous block votes\n */\n previous_block_votes_bitvec: Array<number>;\n proposer: string;\n /**\n * The indices of the proposers who failed to propose\n */\n failed_proposer_indices: Array<number>;\n timestamp: string;\n};\n\nexport type StateCheckpointTransactionResponse = {\n type: TransactionResponseType.StateCheckpoint;\n version: string;\n hash: string;\n state_change_hash: string;\n event_root_hash: string;\n state_checkpoint_hash: string | null;\n gas_used: string;\n /**\n * Whether the transaction was successful\n */\n success: boolean;\n /**\n * The VM status of the transaction, can tell useful information in a failure\n */\n vm_status: string;\n accumulator_root_hash: string;\n /**\n * Final state of resources changed by the transaction\n */\n changes: Array<WriteSetChange>;\n timestamp: string;\n};\n\nexport type ValidatorTransactionResponse = {\n type: TransactionResponseType.Validator;\n version: string;\n hash: string;\n state_change_hash: string;\n event_root_hash: string;\n state_checkpoint_hash: string | null;\n gas_used: string;\n /**\n * Whether the transaction was successful\n */\n success: boolean;\n /**\n * The VM status of the transaction, can tell useful information in a failure\n */\n vm_status: string;\n accumulator_root_hash: string;\n /**\n * Final state of resources changed by the transaction\n */\n changes: Array<WriteSetChange>;\n /**\n * The events emitted by the validator transaction\n */\n events: Array<Event>;\n timestamp: string;\n};\n\n/**\n * BlockEndInfo describes the gas state of the block\n */\nexport type BlockEndInfo = {\n block_gas_limit_reached: boolean;\n block_output_limit_reached: boolean;\n block_effective_block_gas_units: number;\n block_approx_output_size: number;\n};\n\n/**\n * BlockEpilogueTransactionResponse is a transaction that is executed at the end of a block keeping track of data from\n * the whole block\n */\nexport type BlockEpilogueTransactionResponse = {\n type: TransactionResponseType.BlockEpilogue;\n version: string;\n hash: string;\n state_change_hash: string;\n event_root_hash: string;\n state_checkpoint_hash: string | null;\n gas_used: string;\n /**\n * Whether the transaction was successful\n */\n success: boolean;\n /**\n * The VM status of the transaction, can tell useful information in a failure\n */\n vm_status: string;\n accumulator_root_hash: string;\n /**\n * Final state of resources changed by the transaction\n */\n changes: Array<WriteSetChange>;\n timestamp: string;\n block_end_info: BlockEndInfo | null;\n};\n\n/**\n * WRITESET CHANGE TYPES\n */\n\nexport type WriteSetChange =\n | WriteSetChangeDeleteModule\n | WriteSetChangeDeleteResource\n | WriteSetChangeDeleteTableItem\n | WriteSetChangeWriteModule\n | WriteSetChangeWriteResource\n | WriteSetChangeWriteTableItem;\n\nexport type WriteSetChangeDeleteModule = {\n type: string;\n address: string;\n /**\n * State key hash\n */\n state_key_hash: string;\n module: MoveModuleId;\n};\n\nexport type WriteSetChangeDeleteResource = {\n type: string;\n address: string;\n state_key_hash: string;\n resource: string;\n};\n\nexport type WriteSetChangeDeleteTableItem = {\n type: string;\n state_key_hash: string;\n handle: string;\n key: string;\n data?: DeletedTableData;\n};\n\nexport type WriteSetChangeWriteModule = {\n type: string;\n address: string;\n state_key_hash: string;\n data: MoveModuleBytecode;\n};\n\nexport type WriteSetChangeWriteResource = {\n type: string;\n address: string;\n state_key_hash: string;\n data: MoveResource;\n};\n\nexport type WriteSetChangeWriteTableItem = {\n type: string;\n state_key_hash: string;\n handle: string;\n key: string;\n value: string;\n data?: DecodedTableData;\n};\n\nexport type DecodedTableData = {\n /**\n * Key of table in JSON\n */\n key: any;\n /**\n * Type of key\n */\n key_type: string;\n /**\n * Value of table in JSON\n */\n value: any;\n /**\n * Type of value\n */\n value_type: string;\n};\n\n/**\n * Deleted table data\n */\nexport type DeletedTableData = {\n /**\n * Deleted key\n */\n key: any;\n /**\n * Deleted key type\n */\n key_type: string;\n};\n\nexport type TransactionPayloadResponse = EntryFunctionPayloadResponse | ScriptPayloadResponse | MultisigPayloadResponse;\n\nexport type EntryFunctionPayloadResponse = {\n type: string;\n function: MoveFunctionId;\n /**\n * Type arguments of the function\n */\n type_arguments: Array<string>;\n /**\n * Arguments of the function\n */\n arguments: Array<any>;\n};\n\nexport type ScriptPayloadResponse = {\n type: string;\n code: MoveScriptBytecode;\n /**\n * Type arguments of the function\n */\n type_arguments: Array<string>;\n /**\n * Arguments of the function\n */\n arguments: Array<any>;\n};\n\nexport type MultisigPayloadResponse = {\n type: string;\n multisig_address: string;\n transaction_payload?: EntryFunctionPayloadResponse;\n};\n\nexport type GenesisPayload = {\n type: string;\n write_set: WriteSet;\n};\n\n/**\n * Move script bytecode\n */\nexport type MoveScriptBytecode = {\n bytecode: string;\n abi?: MoveFunction;\n};\n\n/**\n * These are the JSON representations of transaction signatures returned from the node API.\n */\nexport type TransactionSignature =\n | TransactionEd25519Signature\n | TransactionSecp256k1Signature\n | TransactionMultiEd25519Signature\n | TransactionMultiAgentSignature\n | TransactionFeePayerSignature;\n\nexport function isEd25519Signature(signature: TransactionSignature): signature is TransactionFeePayerSignature {\n return \"signature\" in signature && signature.signature === \"ed25519_signature\";\n}\n\nexport function isSecp256k1Signature(signature: TransactionSignature): signature is TransactionFeePayerSignature {\n return \"signature\" in signature && signature.signature === \"secp256k1_ecdsa_signature\";\n}\n\nexport function isMultiAgentSignature(signature: TransactionSignature): signature is TransactionMultiAgentSignature {\n return signature.type === \"multi_agent_signature\";\n}\n\nexport function isFeePayerSignature(signature: TransactionSignature): signature is TransactionFeePayerSignature {\n return signature.type === \"fee_payer_signature\";\n}\n\nexport function isMultiEd25519Signature(\n signature: TransactionSignature,\n): signature is TransactionMultiEd25519Signature {\n return signature.type === \"multi_ed25519_signature\";\n}\n\nexport type TransactionEd25519Signature = {\n type: string;\n public_key: string;\n signature: \"ed25519_signature\";\n};\n\nexport type TransactionSecp256k1Signature = {\n type: string;\n public_key: string;\n signature: \"secp256k1_ecdsa_signature\";\n};\n\nexport type TransactionMultiEd25519Signature = {\n type: \"multi_ed25519_signature\";\n /**\n * The public keys for the Ed25519 signature\n */\n public_keys: Array<string>;\n /**\n * Signature associated with the public keys in the same order\n */\n signatures: Array<string>;\n /**\n * The number of signatures required for a successful transaction\n */\n threshold: number;\n bitmap: string;\n};\n\nexport type TransactionMultiAgentSignature = {\n type: \"multi_agent_signature\";\n sender: AccountSignature;\n /**\n * The other involved parties' addresses\n */\n secondary_signer_addresses: Array<string>;\n /**\n * The associated signatures, in the same order as the secondary addresses\n */\n secondary_signers: Array<AccountSignature>;\n};\n\nexport type TransactionFeePayerSignature = {\n type: \"fee_payer_signature\";\n sender: AccountSignature;\n /**\n * The other involved parties' addresses\n */\n secondary_signer_addresses: Array<string>;\n /**\n * The associated signatures, in the same order as the secondary addresses\n */\n secondary_signers: Array<AccountSignature>;\n fee_payer_address: string;\n fee_payer_signer: AccountSignature;\n};\n\n/**\n * The union of all single account signatures.\n */\nexport type AccountSignature =\n | TransactionEd25519Signature\n | TransactionSecp256k1Signature\n | TransactionMultiEd25519Signature;\n\nexport type WriteSet = ScriptWriteSet | DirectWriteSet;\n\nexport type ScriptWriteSet = {\n type: string;\n execute_as: string;\n script: ScriptPayloadResponse;\n};\n\nexport type DirectWriteSet = {\n type: string;\n changes: Array<WriteSetChange>;\n events: Array<Event>;\n};\n\nexport type EventGuid = {\n creation_number: string;\n account_address: string;\n};\n\nexport type Event = {\n guid: EventGuid;\n sequence_number: string;\n type: string;\n /**\n * The JSON representation of the event\n */\n data: any;\n};\n\n/**\n * Map of Move types to local TypeScript types\n */\nexport type MoveUint8Type = number;\nexport type MoveUint16Type = number;\nexport type MoveUint32Type = number;\nexport type MoveUint64Type = string;\nexport type MoveUint128Type = string;\nexport type MoveUint256Type = string;\nexport type MoveAddressType = string;\nexport type MoveObjectType = string;\nexport type MoveOptionType = MoveType | null | undefined;\n/**\n * This is the format for a fully qualified struct, resource, or entry function in Move.\n */\nexport type MoveStructId = `${string}::${string}::${string}`;\n// These are the same, unfortunately, it reads really strangely to take a StructId for a Function and there wasn't a\n// good middle ground name.\nexport type MoveFunctionId = MoveStructId;\n\n// TODO: Add support for looking up ABI to add proper typing\nexport type MoveStructType = {};\n\nexport type MoveType =\n | boolean\n | string\n | MoveUint8Type\n | MoveUint16Type\n | MoveUint32Type\n | MoveUint64Type\n | MoveUint128Type\n | MoveUint256Type\n | MoveAddressType\n | MoveObjectType\n | MoveStructType\n | Array<MoveType>;\n\n/**\n * Possible Move values acceptable by move functions (entry, view)\n *\n * Map of a Move value to the corresponding TypeScript value\n *\n * `Bool -> boolean`\n *\n * `u8, u16, u32 -> number`\n *\n * `u64, u128, u256 -> string`\n *\n * `String -> string`\n *\n * `Address -> 0x${string}`\n *\n * `Struct - 0x${string}::${string}::${string}`\n *\n * `Object -> 0x${string}`\n *\n * `Vector -> Array<MoveValue>`\n *\n * `Option -> MoveValue | null | undefined`\n */\nexport type MoveValue =\n | boolean\n | string\n | MoveUint8Type\n | MoveUint16Type\n | MoveUint32Type\n | MoveUint64Type\n | MoveUint128Type\n | MoveUint256Type\n | MoveAddressType\n | MoveObjectType\n | MoveStructId\n | MoveOptionType\n | Array<MoveValue>;\n\n/**\n * Move module id is a string representation of Move module.\n * Module name is case-sensitive.\n */\nexport type MoveModuleId = `${string}::${string}`;\n\n/**\n * Move function visibility\n */\nexport enum MoveFunctionVisibility {\n PRIVATE = \"private\",\n PUBLIC = \"public\",\n FRIEND = \"friend\",\n}\n\n/**\n * Move function ability\n */\nexport enum MoveAbility {\n STORE = \"store\",\n DROP = \"drop\",\n KEY = \"key\",\n COPY = \"copy\",\n}\n\n/**\n * Move abilities tied to the generic type param and associated with the function that uses it\n */\nexport type MoveFunctionGenericTypeParam = {\n constraints: Array<MoveAbility>;\n};\n\n/**\n * Move struct field\n */\nexport type MoveStructField = {\n name: string;\n type: string;\n};\n\n/**\n * A Move module\n */\nexport type MoveModule = {\n address: string;\n name: string;\n /**\n * Friends of the module\n */\n friends: Array<MoveModuleId>;\n /**\n * Public functions of the module\n */\n exposed_functions: Array<MoveFunction>;\n /**\n * Structs of the module\n */\n structs: Array<MoveStruct>;\n};\n\n/**\n * A move struct\n */\nexport type MoveStruct = {\n name: string;\n /**\n * Whether the struct is a native struct of Move\n */\n is_native: boolean;\n /**\n * Abilities associated with the struct\n */\n abilities: Array<MoveAbility>;\n /**\n * Generic types associated with the struct\n */\n generic_type_params: Array<MoveFunctionGenericTypeParam>;\n /**\n * Fields associated with the struct\n */\n fields: Array<MoveStructField>;\n};\n\n/**\n * Move function\n */\nexport type MoveFunction = {\n name: string;\n visibility: MoveFunctionVisibility;\n /**\n * Whether the function can be called as an entry function directly in a transaction\n */\n is_entry: boolean;\n /**\n * Whether the function is a view function or not\n */\n is_view: boolean;\n /**\n * Generic type params associated with the Move function\n */\n generic_type_params: Array<MoveFunctionGenericTypeParam>;\n /**\n * Parameters associated with the move function\n */\n params: Array<string>;\n /**\n * Return type of the function\n */\n return: Array<string>;\n};\n\nexport enum RoleType {\n VALIDATOR = \"validator\",\n FULL_NODE = \"full_node\",\n}\n\nexport type LedgerInfo = {\n /**\n * Chain ID of the current chain\n */\n chain_id: number;\n epoch: string;\n ledger_version: string;\n oldest_ledger_version: string;\n ledger_timestamp: string;\n node_role: RoleType;\n oldest_block_height: string;\n block_height: string;\n /**\n * Git hash of the build of the API endpoint. Can be used to determine the exact\n * software version used by the API endpoint.\n */\n git_hash?: string;\n};\n\n/**\n * A Block type\n */\nexport type Block = {\n block_height: string;\n block_hash: string;\n block_timestamp: string;\n first_version: string;\n last_version: string;\n /**\n * The transactions in the block in sequential order\n */\n transactions?: Array<TransactionResponse>;\n};\n\n// REQUEST TYPES\n\n/**\n * Table Item request for the GetTableItem API\n */\nexport type TableItemRequest = {\n key_type: MoveValue;\n value_type: MoveValue;\n /**\n * The value of the table item's key\n */\n key: any;\n};\n\n/**\n * A list of Authentication Key schemes that are supported by Aptos.\n *\n * They are combinations of signing schemes and derive schemes.\n */\nexport type AuthenticationKeyScheme = SigningScheme | DeriveScheme;\n\nexport enum SigningScheme {\n /**\n * For Ed25519PublicKey\n */\n Ed25519 = 0,\n /**\n * For MultiEd25519PublicKey\n */\n MultiEd25519 = 1,\n /**\n * For SingleKey ecdsa\n */\n SingleKey = 2,\n\n MultiKey = 3,\n}\n\nexport enum SigningSchemeInput {\n /**\n * For Ed25519PublicKey\n */\n Ed25519 = 0,\n /**\n * For Secp256k1Ecdsa\n */\n Secp256k1Ecdsa = 2,\n}\n\n/**\n * Scheme used for deriving account addresses from other data\n */\nexport enum DeriveScheme {\n /**\n * Derives an address using an AUID, used for objects\n */\n DeriveAuid = 251,\n /**\n * Derives an address from another object address\n */\n DeriveObjectAddressFromObject = 252,\n /**\n * Derives an address from a GUID, used for objects\n */\n DeriveObjectAddressFromGuid = 253,\n /**\n * Derives an address from seed bytes, used for named objects\n */\n DeriveObjectAddressFromSeed = 254,\n /**\n * Derives an address from seed bytes, used for resource accounts\n */\n DeriveResourceAccountAddress = 255,\n}\n\n/**\n * Option properties to pass for waitForTransaction() function\n */\nexport type WaitForTransactionOptions = {\n timeoutSecs?: number;\n checkSuccess?: boolean;\n // Default behavior is to wait for the indexer. Set this to false to disable waiting.\n waitForIndexer?: boolean;\n};\n\n/**\n * Input type to generate an account using Single Signer\n * Ed25519 or Legacy Ed25519\n */\nexport type GenerateAccountWithEd25519 = {\n scheme: SigningSchemeInput.Ed25519;\n legacy: boolean;\n};\n\n/**\n * Input type to generate an account using Single Signer\n * Secp256k1\n */\nexport type GenerateAccountWithSingleSignerSecp256k1Key = {\n scheme: SigningSchemeInput.Secp256k1Ecdsa;\n legacy?: false;\n};\n\nexport type GenerateAccount = GenerateAccountWithEd25519 | GenerateAccountWithSingleSignerSecp256k1Key;\n"],"mappings":"AAQO,IAAKA,OAIVA,EAAA,KAAO,mBAIPA,EAAA,IAAM,oBAINA,EAAA,uBAAyB,6CACzBA,EAAA,kBAAoB,wCAbVA,OAAA,IAyBAC,OACVA,IAAA,KAAO,GAAP,OACAA,IAAA,GAAK,GAAL,KACAA,IAAA,IAAM,GAAN,MACAA,IAAA,KAAO,GAAP,OACAA,IAAA,QAAU,GAAV,UACAA,IAAA,OAAS,GAAT,SACAA,IAAA,OAAS,GAAT,SACAA,IAAA,OAAS,GAAT,SACAA,IAAA,IAAM,GAAN,MACAA,IAAA,IAAM,GAAN,MACAA,IAAA,KAAO,IAAP,OACAA,IAAA,UAAY,KAAZ,YACAA,IAAA,QAAU,KAAV,UAbUA,OAAA,IAoBAC,OACVA,IAAA,GAAK,GAAL,KACAA,IAAA,IAAM,GAAN,MACAA,IAAA,KAAO,GAAP,OACAA,IAAA,QAAU,GAAV,UACAA,IAAA,SAAW,GAAX,WACAA,IAAA,KAAO,GAAP,OACAA,IAAA,IAAM,GAAN,MACAA,IA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EACdH,EAC8C,CAC9C,OAAOA,EAAS,OAAS,4BAC3B,CAEO,SAASI,EACdJ,EACgD,CAChD,OAAOA,EAAS,OAAS,8BAC3B,CAEO,SAASK,EACdL,EAC0C,CAC1C,OAAOA,EAAS,OAAS,uBAC3B,CAEO,SAASM,EACdN,EAC8C,CAC9C,OAAOA,EAAS,OAAS,4BAC3B,CAsWO,SAASO,EAAmBC,EAA4E,CAC7G,MAAO,cAAeA,GAAaA,EAAU,YAAc,mBAC7D,CAEO,SAASC,EAAqBD,EAA4E,CAC/G,MAAO,cAAeA,GAAaA,EAAU,YAAc,2BAC7D,CAEO,SAASE,EAAsBF,EAA8E,CAClH,OAAOA,EAAU,OAAS,uBAC5B,CAEO,SAASG,EAAoBH,EAA4E,CAC9G,OAAOA,EAAU,OAAS,qBAC5B,CAEO,SAASI,EACdJ,EAC+C,CAC/C,OAAOA,EAAU,OAAS,yBAC5B,CAoLO,IAAKK,OACVA,EAAA,QAAU,UACVA,EAAA,OAAS,SACTA,EAAA,OAAS,SAHCA,OAAA,IASAC,OACVA,EAAA,MAAQ,QACRA,EAAA,KAAO,OACPA,EAAA,IAAM,MACNA,EAAA,KAAO,OAJGA,OAAA,IA6FAC,OACVA,EAAA,UAAY,YACZA,EAAA,UAAY,YAFFA,OAAA,IA4DAC,OAIVA,IAAA,QAAU,GAAV,UAIAA,IAAA,aAAe,GAAf,eAIAA,IAAA,UAAY,GAAZ,YAEAA,IAAA,SAAW,GAAX,WAdUA,OAAA,IAiBAC,OAIVA,IAAA,QAAU,GAAV,UAIAA,IAAA,eAAiB,GAAjB,iBARUA,OAAA,IAcAC,OAIVA,IAAA,WAAa,KAAb,aAIAA,IAAA,8BAAgC,KAAhC,gCAIAA,IAAA,4BAA8B,KAA9B,8BAIAA,IAAA,4BAA8B,KAA9B,8BAIAA,IAAA,6BAA+B,KAA/B,+BApBUA,OAAA","names":["MimeType","TypeTagVariants","ScriptTransactionArgumentVariants","TransactionPayloadVariants","TransactionVariants","TransactionAuthenticatorVariant","AccountAuthenticatorVariant","AnyPublicKeyVariant","AnySignatureVariant","EphemeralPublicKeyVariant","EphemeralSignatureVariant","EphemeralCertificateVariant","ZkpVariant","TransactionResponseType","isPendingTransactionResponse","response","isUserTransactionResponse","isGenesisTransactionResponse","isBlockMetadataTransactionResponse","isStateCheckpointTransactionResponse","isValidatorTransactionResponse","isBlockEpilogueTransactionResponse","isEd25519Signature","signature","isSecp256k1Signature","isMultiAgentSignature","isFeePayerSignature","isMultiEd25519Signature","MoveFunctionVisibility","MoveAbility","RoleType","SigningScheme","SigningSchemeInput","DeriveScheme"]}
@@ -1,2 +0,0 @@
1
- import{a as T}from"./chunk-QQHA2Y46.mjs";import{a as x,b as v}from"./chunk-SUAA25UP.mjs";import{d as g}from"./chunk-2XYA7NOU.mjs";import{a as y,b as m}from"./chunk-ZWX3NHGU.mjs";import{i as F,j as E,k as b,n as f}from"./chunk-VYXS7TLB.mjs";import{b as S}from"./chunk-OHRL766V.mjs";import{a as w}from"./chunk-KEYAPEAX.mjs";import{a as d}from"./chunk-A63SMUOU.mjs";import{b as K}from"./chunk-BCUSI3N6.mjs";import{d as A}from"./chunk-UAL27G6B.mjs";import{jwtDecode as z}from"jwt-decode";import Z from"eventemitter3";var o=class o extends d{constructor(e){super();let{address:r,ephemeralKeyPair:t,uidKey:i,uidVal:a,aud:c,pepper:p,proof:n,proofFetchCallback:s,jwt:l}=e;if(this.ephemeralKeyPair=t,this.publicKey=F.create(e),this.accountAddress=r?S.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=i,this.uidVal=a,this.aud=c,this.jwt=l,this.emitter=new Z,this.proofOrPromise=n,n instanceof f)this.proof=n;else{if(s===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async u=>{await s(u),this.emitter.removeAllListeners()}),this.init(n)}this.signingScheme=2;let h=K.fromHexInput(p).toUint8Array();if(h.length!==o.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${o.PEPPER_LENGTH}`);this.pepper=h}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),t=e.deserializeStr(),i=e.deserializeFixedBytes(31),a=T.deserialize(e),c=f.deserialize(e);return o.create({proof:c,pepper:i,uidKey:t,jwt:r,ephemeralKeyPair:a})}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(e){let r=new m(this.sign(e)),t=new y(this.publicKey);return new g(t,r)}signTransactionWithAuthenticator(e){let r=new m(this.signTransaction(e)),t=new y(this.publicKey);return new g(t,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw new Error("EphemeralKeyPair is expired");if(this.proof===void 0)throw new Error("Proof not defined");let t=this.ephemeralKeyPair.getPublicKey(),i=this.ephemeralKeyPair.sign(e);return new E({jwtHeader:A(this.jwt.split(".")[0]),ephemeralCertificate:new b(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:t,ephemeralSignature:i})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let r=x(e),i=new P(r,this.proof.proof).hash();return this.sign(i)}verifySignature(e){let{message:r,signature:t}=e;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:r,signature:t.ephemeralSignature}))}static fromBytes(e){return o.deserialize(new w(e))}static create(e){let{address:r,proof:t,jwt:i,ephemeralKeyPair:a,pepper:c,uidKey:p="sub",proofFetchCallback:n}=e,s=z(i),l=s.iss;if(typeof s.aud!="string")throw new Error("aud was not found or an array of values");let h=s.aud,u=s[p];return new o({address:r,proof:t,ephemeralKeyPair:a,iss:l,uidKey:p,uidVal:u,aud:h,pepper:c,jwt:i,proofFetchCallback:n})}};o.PEPPER_LENGTH=31;var k=o,P=class extends d{constructor(r,t){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=r,this.proof=t}serialize(r){r.serializeFixedBytes(this.transaction.bcsToBytes()),r.serializeOption(this.proof)}hash(){return v(this.bcsToBytes(),this.domainSeparator)}};export{k as a};
2
- //# sourceMappingURL=chunk-IVOEXGOG.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/KeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport EventEmitter from \"eventemitter3\";\nimport { EphemeralCertificateVariant, HexInput, SigningScheme } from \"../types\";\nimport { AccountAddress } from \"../core/accountAddress\";\nimport {\n AnyPublicKey,\n AnySignature,\n KeylessPublicKey,\n KeylessSignature,\n EphemeralCertificate,\n ZeroKnowledgeSig,\n ZkProof,\n} from \"../core/crypto\";\n\nimport { Account } from \"./Account\";\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Hex } from \"../core/hex\";\nimport { AccountAuthenticatorSingleKey } from \"../transactions/authenticator/account\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { deriveTransactionType, generateSigningMessage } from \"../transactions/transactionBuilder/signingMessage\";\nimport { AnyRawTransaction, AnyRawTransactionInstance } from \"../transactions/types\";\nimport { base64UrlDecode } from \"../utils/helpers\";\n\n/**\n * Account implementation for the Keyless authentication scheme.\n *\n * Used to represent a Keyless based account and sign transactions with it.\n *\n * Use KeylessAccount.fromJWTAndProof to instantiate a KeylessAccount with a JWT, proof and EphemeralKeyPair.\n *\n * When the proof expires or the JWT becomes invalid, the KeylessAccount must be instantiated again with a new JWT,\n * EphemeralKeyPair, and corresponding proof.\n */\nexport class KeylessAccount extends Serializable implements Account {\n static readonly PEPPER_LENGTH: number = 31;\n\n /**\n * The KeylessPublicKey associated with the account\n */\n readonly publicKey: KeylessPublicKey;\n\n /**\n * The EphemeralKeyPair used to generate sign.\n */\n readonly ephemeralKeyPair: EphemeralKeyPair;\n\n /**\n * The claim on the JWT to identify a user. This is typically 'sub' or 'email'.\n */\n readonly uidKey: string;\n\n /**\n * The value of the uidKey claim on the JWT. This intended to be a stable user identifier.\n */\n readonly uidVal: string;\n\n /**\n * The value of the 'aud' claim on the JWT, also known as client ID. This is the identifier for the dApp's\n * OIDC registration with the identity provider.\n */\n readonly aud: string;\n\n /**\n * A value contains 31 bytes of entropy that preserves privacy of the account. Typically fetched from a pepper provider.\n */\n readonly pepper: Uint8Array;\n\n /**\n * Account address associated with the account\n */\n readonly accountAddress: AccountAddress;\n\n /**\n * The zero knowledge signature (if ready) which contains the proof used to validate the EphemeralKeyPair.\n */\n proof: ZeroKnowledgeSig | undefined;\n\n /**\n * The proof of the EphemeralKeyPair or a promise that provides the proof. This is used to allow for awaiting on\n * fetching the proof.\n */\n readonly proofOrPromise: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n\n /**\n * Signing scheme used to sign transactions\n */\n readonly signingScheme: SigningScheme;\n\n /**\n * The JWT token used to derive the account\n */\n readonly jwt: string;\n\n /**\n * An event emitter used to assist in handling asycronous proof fetching.\n */\n private readonly emitter: EventEmitter<ProofFetchEvents>;\n\n // Use the static constructor 'create' instead.\n private constructor(args: {\n address?: AccountAddress;\n ephemeralKeyPair: EphemeralKeyPair;\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n }) {\n super();\n const { address, ephemeralKeyPair, uidKey, uidVal, aud, pepper, proof, proofFetchCallback, jwt } = args;\n this.ephemeralKeyPair = ephemeralKeyPair;\n this.publicKey = KeylessPublicKey.create(args);\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n this.uidKey = uidKey;\n this.uidVal = uidVal;\n this.aud = aud;\n this.jwt = jwt;\n this.emitter = new EventEmitter<ProofFetchEvents>();\n this.proofOrPromise = proof;\n if (proof instanceof ZeroKnowledgeSig) {\n this.proof = proof;\n } else {\n if (proofFetchCallback === undefined) {\n throw new Error(\"Must provide callback for async proof fetch\");\n }\n this.emitter.on(\"proofFetchFinish\", async (status) => {\n await proofFetchCallback(status);\n this.emitter.removeAllListeners();\n });\n this.init(proof);\n }\n this.signingScheme = SigningScheme.SingleKey;\n const pepperBytes = Hex.fromHexInput(pepper).toUint8Array();\n if (pepperBytes.length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper length in bytes should be ${KeylessAccount.PEPPER_LENGTH}`);\n }\n this.pepper = pepperBytes;\n }\n\n /**\n * This initializes the asyncronous proof fetch\n * @return\n */\n async init(promise: Promise<ZeroKnowledgeSig>) {\n try {\n this.proof = await promise;\n this.emitter.emit(\"proofFetchFinish\", { status: \"Success\" });\n } catch (error) {\n if (error instanceof Error) {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: error.toString() });\n } else {\n this.emitter.emit(\"proofFetchFinish\", { status: \"Failed\", error: \"Unknown\" });\n }\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.ephemeralKeyPair.serialize(serializer);\n if (this.proof === undefined) {\n throw new Error(\"Connot serialize - proof undefined\");\n }\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n return KeylessAccount.create({\n proof,\n pepper,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n /**\n * Checks if the proof is expired. If so the account must be rederived with a new EphemeralKeyPair\n * and JWT token.\n * @return boolean\n */\n isExpired(): boolean {\n return this.ephemeralKeyPair.isExpired();\n }\n\n /**\n * Sign a message using Keyless.\n * @param message the message to sign, as binary input\n * @return the AccountAuthenticator containing the signature, together with the account's public key\n */\n signWithAuthenticator(message: HexInput): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.sign(message));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Sign a transaction using Keyless.\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): AccountAuthenticatorSingleKey {\n const signature = new AnySignature(this.signTransaction(transaction));\n const publicKey = new AnyPublicKey(this.publicKey);\n return new AccountAuthenticatorSingleKey(publicKey, signature);\n }\n\n /**\n * Waits for asyncronous proof fetching to finish.\n * @return\n */\n async waitForProofFetch() {\n if (this.proofOrPromise instanceof Promise) {\n await this.proofOrPromise;\n }\n }\n\n /**\n * Sign the given message using Keyless.\n * @param message in HexInput format\n * @returns Signature\n */\n sign(data: HexInput): KeylessSignature {\n const { expiryDateSecs } = this.ephemeralKeyPair;\n if (this.isExpired()) {\n throw new Error(\"EphemeralKeyPair is expired\");\n }\n if (this.proof === undefined) {\n throw new Error(\"Proof not defined\");\n }\n const ephemeralPublicKey = this.ephemeralKeyPair.getPublicKey();\n const ephemeralSignature = this.ephemeralKeyPair.sign(data);\n\n return new KeylessSignature({\n jwtHeader: base64UrlDecode(this.jwt.split(\".\")[0]),\n ephemeralCertificate: new EphemeralCertificate(this.proof, EphemeralCertificateVariant.ZkProof),\n expiryDateSecs,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n /**\n * Sign the given transaction with Keyless.\n * Signs the transaction and proof to guard against proof malleability.\n * @param transaction the transaction to be signed\n * @returns KeylessSignature\n */\n signTransaction(transaction: AnyRawTransaction): KeylessSignature {\n if (this.proof === undefined) {\n throw new Error(\"Proof not found\");\n }\n const raw = deriveTransactionType(transaction);\n const txnAndProof = new TransactionAndProof(raw, this.proof.proof);\n const signMess = txnAndProof.hash();\n return this.sign(signMess);\n }\n\n /**\n * Note - This function is currently incomplete and should only be used to verify ownership of the KeylessAccount\n *\n * Verifies a signature given the message.\n *\n * TODO: Groth16 proof verification\n *\n * @param args.message the message that was signed.\n * @param args.signature the KeylessSignature to verify\n * @returns boolean\n */\n verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {\n const { message, signature } = args;\n if (this.isExpired()) {\n return false;\n }\n if (!this.ephemeralKeyPair.getPublicKey().verifySignature({ message, signature: signature.ephemeralSignature })) {\n return false;\n }\n return true;\n }\n\n static fromBytes(bytes: Uint8Array): KeylessAccount {\n return KeylessAccount.deserialize(new Deserializer(bytes));\n }\n\n static create(args: {\n address?: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper: HexInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n }): KeylessAccount {\n const { address, proof, jwt, ephemeralKeyPair, pepper, uidKey = \"sub\", proofFetchCallback } = args;\n\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 new KeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss,\n uidKey,\n uidVal,\n aud,\n pepper,\n jwt,\n proofFetchCallback,\n });\n }\n}\n\n/**\n * A container class to hold a transaction and a proof. It implements CryptoHashable which is used to create\n * the signing message for Keyless transactions. We sign over the proof to ensure non-malleability.\n */\nclass TransactionAndProof extends Serializable {\n /**\n * The transaction to sign.\n */\n transaction: AnyRawTransactionInstance;\n\n /**\n * The zero knowledge proof used in signing the transaction.\n */\n proof?: ZkProof;\n\n /**\n * The domain separator prefix used when hashing.\n */\n readonly domainSeparator = \"APTOS::TransactionAndProof\";\n\n constructor(transaction: AnyRawTransactionInstance, proof?: ZkProof) {\n super();\n this.transaction = transaction;\n this.proof = proof;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.transaction.bcsToBytes());\n serializer.serializeOption(this.proof);\n }\n\n /**\n * Hashes the bcs serialized from of the class. This is the typescript corollary to the BCSCryptoHash macro in aptos-core.\n *\n * @returns Uint8Array\n */\n hash(): Uint8Array {\n return generateSigningMessage(this.bcsToBytes(), this.domainSeparator);\n }\n}\n\nexport type ProofFetchSuccess = {\n status: \"Success\";\n};\n\nexport type ProofFetchFailure = {\n status: \"Failed\";\n error: string;\n};\n\nexport type ProofFetchStatus = ProofFetchSuccess | ProofFetchFailure;\n\nexport type ProofFetchCallback = (status: ProofFetchStatus) => Promise<void>;\n\nexport interface ProofFetchEvents {\n proofFetchFinish: (status: ProofFetchStatus) => void;\n}\n"],"mappings":"6bAGA,OAAqB,aAAAA,MAAiB,aACtC,OAAOC,MAAkB,gBAgClB,IAAMC,EAAN,MAAMA,UAAuBC,CAAgC,CAkE1D,YAAYC,EAWjB,CACD,MAAM,EACN,GAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,OAAAC,EAAQ,OAAAC,EAAQ,IAAAC,EAAK,OAAAC,EAAQ,MAAAC,EAAO,mBAAAC,EAAoB,IAAAC,CAAI,EAAIT,EAUnG,GATA,KAAK,iBAAmBE,EACxB,KAAK,UAAYQ,EAAiB,OAAOV,CAAI,EAC7C,KAAK,eAAiBC,EAAUU,EAAe,KAAKV,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,EACvG,KAAK,OAASE,EACd,KAAK,OAASC,EACd,KAAK,IAAMC,EACX,KAAK,IAAMI,EACX,KAAK,QAAU,IAAIG,EACnB,KAAK,eAAiBL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M,CAAE,QAAAsB,EAAS,UAAAC,CAAU,EAAIvB,EAI/B,MAHI,OAAK,UAAU,GAGf,CAAC,KAAK,iBAAiB,aAAa,EAAE,gBAAgB,CAAE,QAAAsB,EAAS,UAAWC,EAAU,kBAAmB,CAAC,EAIhH,CAEA,OAAO,UAAUiB,EAAmC,CAClD,OAAO1C,EAAe,YAAY,IAAI2C,EAAaD,CAAK,CAAC,CAC3D,CAEA,OAAO,OAAOxC,EAQK,CACjB,GAAM,CAAE,QAAAC,EAAS,MAAAM,EAAO,IAAAE,EAAK,iBAAAP,EAAkB,OAAAI,EAAQ,OAAAH,EAAS,MAAO,mBAAAK,CAAmB,EAAIR,EAExF0C,EAAaC,EAAkDlC,CAAG,EAClEmC,EAAMF,EAAW,IACvB,GAAI,OAAOA,EAAW,KAAQ,SAC5B,MAAM,IAAI,MAAM,yCAAyC,EAE3D,IAAMrC,EAAMqC,EAAW,IACjBtC,EAASsC,EAAWvC,CAAM,EAChC,OAAO,IAAIL,EAAe,CACxB,QAAAG,EACA,MAAAM,EACA,iBAAAL,EACA,IAAA0C,EACA,OAAAzC,EACA,OAAAC,EACA,IAAAC,EACA,OAAAC,EACA,IAAAG,EACA,mBAAAD,CACF,CAAC,CACH,CACF,EAnSaV,EACK,cAAwB,GADnC,IAAM+C,EAAN/C,EAySDyC,EAAN,cAAkCxC,CAAa,CAgB7C,YAAY6B,EAAwCrB,EAAiB,CACnE,MAAM,EAHR,KAAS,gBAAkB,6BAIzB,KAAK,YAAcqB,EACnB,KAAK,MAAQrB,CACf,CAEA,UAAUY,EAA8B,CACtCA,EAAW,oBAAoB,KAAK,YAAY,WAAW,CAAC,EAC5DA,EAAW,gBAAgB,KAAK,KAAK,CACvC,CAOA,MAAmB,CACjB,OAAO2B,EAAuB,KAAK,WAAW,EAAG,KAAK,eAAe,CACvE,CACF","names":["jwtDecode","EventEmitter","_KeylessAccount","Serializable","args","address","ephemeralKeyPair","uidKey","uidVal","aud","pepper","proof","proofFetchCallback","jwt","KeylessPublicKey","AccountAddress","EventEmitter","ZeroKnowledgeSig","status","pepperBytes","Hex","promise","error","serializer","deserializer","EphemeralKeyPair","message","signature","AnySignature","publicKey","AnyPublicKey","AccountAuthenticatorSingleKey","transaction","data","expiryDateSecs","ephemeralPublicKey","ephemeralSignature","KeylessSignature","base64UrlDecode","EphemeralCertificate","raw","deriveTransactionType","signMess","TransactionAndProof","bytes","Deserializer","jwtPayload","jwtDecode","iss","KeylessAccount","generateSigningMessage"]}
@@ -1,2 +0,0 @@
1
- import{poseidon1 as g,poseidon2 as h,poseidon3 as u,poseidon4 as a,poseidon5 as c,poseidon6 as d,poseidon7 as p,poseidon8 as l,poseidon9 as f,poseidon10 as A,poseidon11 as U,poseidon12 as b,poseidon13 as w,poseidon14 as E,poseidon15 as I,poseidon16 as y}from"poseidon-lite";var e=[g,h,u,a,c,d,p,l,f,A,U,b,w,E,I,y],s=31,B=16,i=(B-1)*s;function x(n,t){let o=new TextEncoder().encode(n);return $(o,t)}function $(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);let r=T(n,t);return k(r)}function m(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);let r=N(n,t);return _(r)}function T(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return m(n,t).concat([BigInt(n.length)])}function _(n){if(n.length>i)throw new Error(`Can't pack more than ${i}. Was given ${n.length} bytes`);return P(n,s).map(t=>L(t))}function P(n,t){let r=[];for(let o=0;o<n.length;o+=t)r.push(n.subarray(o,o+t));return r}function L(n){let t=BigInt(0);for(let r=n.length-1;r>=0;r-=1)t=t<<BigInt(8)|BigInt(n[r]);return t}function C(n,t){let r=new Uint8Array(t);for(let o=0;o<t;o+=1)r[o]=Number(n&BigInt(255)),n>>=BigInt(8);return r}function N(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let r=new Uint8Array(t);r.set(n);for(let o=n.length;o<t;o+=1)r[o]=0;return r}function k(n){if(n.length>e.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${e.length}`);return e[n.length-1](n)}export{x as a,T as b,L as c,C as d,k as e};
2
- //# sourceMappingURL=chunk-IVVWQKCF.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/core/crypto/poseidon.ts"],"sourcesContent":["/* eslint-disable no-bitwise */\nimport {\n poseidon1,\n poseidon2,\n poseidon3,\n poseidon4,\n poseidon5,\n poseidon6,\n poseidon7,\n poseidon8,\n poseidon9,\n poseidon10,\n poseidon11,\n poseidon12,\n poseidon13,\n poseidon14,\n poseidon15,\n poseidon16,\n} from \"poseidon-lite\";\n\nconst numInputsToPoseidonFunc = [\n poseidon1,\n poseidon2,\n poseidon3,\n poseidon4,\n poseidon5,\n poseidon6,\n poseidon7,\n poseidon8,\n poseidon9,\n poseidon10,\n poseidon11,\n poseidon12,\n poseidon13,\n poseidon14,\n poseidon15,\n poseidon16,\n];\n\nconst BYTES_PACKED_PER_SCALAR = 31;\nconst MAX_NUM_INPUT_SCALARS = 16;\nconst MAX_NUM_INPUT_BYTES = (MAX_NUM_INPUT_SCALARS - 1) * BYTES_PACKED_PER_SCALAR;\n\n/**\n * Hashes a string to a field element via poseidon\n *\n * @returns bigint result of the hash\n */\nexport function hashStrToField(str: string, maxSizeBytes: number): bigint {\n const textEncoder = new TextEncoder();\n const strBytes = textEncoder.encode(str);\n return hashBytesWithLen(strBytes, maxSizeBytes);\n}\n\nfunction hashBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Inputted bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n const packed = padAndPackBytesWithLen(bytes, maxSizeBytes);\n return poseidonHash(packed);\n}\n\nfunction padAndPackBytesNoLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n const paddedStrBytes = padUint8ArrayWithZeros(bytes, maxSizeBytes);\n return packBytes(paddedStrBytes);\n}\n\nexport function padAndPackBytesWithLen(bytes: Uint8Array, maxSizeBytes: number): bigint[] {\n if (bytes.length > maxSizeBytes) {\n throw new Error(`Input bytes of length ${bytes} is longer than ${maxSizeBytes}`);\n }\n return padAndPackBytesNoLen(bytes, maxSizeBytes).concat([BigInt(bytes.length)]);\n}\n\nfunction packBytes(bytes: Uint8Array): bigint[] {\n if (bytes.length > MAX_NUM_INPUT_BYTES) {\n throw new Error(`Can't pack more than ${MAX_NUM_INPUT_BYTES}. Was given ${bytes.length} bytes`);\n }\n return chunkUint8Array(bytes, BYTES_PACKED_PER_SCALAR).map((chunk) => bytesToBigIntLE(chunk));\n}\n\nfunction chunkUint8Array(array: Uint8Array, chunkSize: number): Uint8Array[] {\n const result: Uint8Array[] = [];\n for (let i = 0; i < array.length; i += chunkSize) {\n result.push(array.subarray(i, i + chunkSize));\n }\n return result;\n}\n\nexport function bytesToBigIntLE(bytes: Uint8Array): bigint {\n let result = BigInt(0);\n for (let i = bytes.length - 1; i >= 0; i -= 1) {\n result = (result << BigInt(8)) | BigInt(bytes[i]);\n }\n return result;\n}\n\nexport function bigIntToBytesLE(value: bigint, length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n for (let i = 0; i < length; i += 1) {\n bytes[i] = Number(value & BigInt(0xff));\n // eslint-disable-next-line no-param-reassign\n value >>= BigInt(8);\n }\n return bytes;\n}\n\nfunction padUint8ArrayWithZeros(inputArray: Uint8Array, paddedSize: number): Uint8Array {\n if (paddedSize < inputArray.length) {\n throw new Error(\"Padded size must be greater than or equal to the input array size.\");\n }\n\n // Create a new Uint8Array with the padded size\n const paddedArray = new Uint8Array(paddedSize);\n\n // Copy the content of the input array to the new array\n paddedArray.set(inputArray);\n\n // Fill the remaining space with zeros\n for (let i = inputArray.length; i < paddedSize; i += 1) {\n paddedArray[i] = 0;\n }\n\n return paddedArray;\n}\n\n/**\n * Hashes up to 16 scalar elements via the poseidon hashing algorithm.\n *\n * Each element must be scalar fields of the BN254 elliptic curve group.\n *\n * @returns bigint result of the hash\n */\nexport function poseidonHash(inputs: (number | bigint | string)[]): bigint {\n if (inputs.length > numInputsToPoseidonFunc.length) {\n throw new Error(\n `Unable to hash input of length ${inputs.length}. Max input length is ${numInputsToPoseidonFunc.length}`,\n );\n }\n return numInputsToPoseidonFunc[inputs.length - 1](inputs);\n}\n"],"mappings":"AACA,OACE,aAAAA,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,aAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,EACA,cAAAC,MACK,gBAEP,IAAMC,EAA0B,CAC9BhB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,CACF,EAEME,EAA0B,GAC1BC,EAAwB,GACxBC,GAAuBD,EAAwB,GAAKD,EAOnD,SAASG,EAAeC,EAAaC,EAA8B,CAExE,IAAMC,EADc,IAAI,YAAY,EACP,OAAOF,CAAG,EACvC,OAAOG,EAAiBD,EAAUD,CAAY,CAChD,CAEA,SAASE,EAAiBC,EAAmBH,EAA8B,CACzE,GAAIG,EAAM,OAASH,EACjB,MAAM,IAAI,MAAM,4BAA4BG,CAAK,mBAAmBH,CAAY,EAAE,EAEpF,IAAMI,EAASC,EAAuBF,EAAOH,CAAY,EACzD,OAAOM,EAAaF,CAAM,CAC5B,CAEA,SAASG,EAAqBJ,EAAmBH,EAAgC,CAC/E,GAAIG,EAAM,OAASH,EACjB,MAAM,IAAI,MAAM,yBAAyBG,CAAK,mBAAmBH,CAAY,EAAE,EAEjF,IAAMQ,EAAiBC,EAAuBN,EAAOH,CAAY,EACjE,OAAOU,EAAUF,CAAc,CACjC,CAEO,SAASH,EAAuBF,EAAmBH,EAAgC,CACxF,GAA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AAYN,CAAC,EAAI,EAGnB,OAAOM,CACT,CASO,SAASjB,EAAakB,EAA8C,CACzE,GAAIA,EAAO,OAAS9B,EAAwB,OAC1C,MAAM,IAAI,MACR,kCAAkC8B,EAAO,MAAM,0BAA0B9B,EAAwB,MAAM,EACzG,EAEF,OAAOA,EAAwB8B,EAAO,OAAS,CAAC,EAAEA,CAAM,CAC1D","names":["poseidon1","poseidon2","poseidon3","poseidon4","poseidon5","poseidon6","poseidon7","poseidon8","poseidon9","poseidon10","poseidon11","poseidon12","poseidon13","poseidon14","poseidon15","poseidon16","numInputsToPoseidonFunc","BYTES_PACKED_PER_SCALAR","MAX_NUM_INPUT_SCALARS","MAX_NUM_INPUT_BYTES","hashStrToField","str","maxSizeBytes","strBytes","hashBytesWithLen","bytes","packed","padAndPackBytesWithLen","poseidonHash","padAndPackBytesNoLen","paddedStrBytes","padUint8ArrayWithZeros","packBytes","chunkUint8Array","chunk","bytesToBigIntLE","array","chunkSize","result","i","bigIntToBytesLE","value","length","inputArray","paddedSize","paddedArray","inputs"]}
@@ -1,2 +0,0 @@
1
- import{g as b}from"./chunk-XSTCHOUI.mjs";import{a as P}from"./chunk-IVOEXGOG.mjs";import{i as d,l as m,m as x,n as K,p as w}from"./chunk-VYXS7TLB.mjs";import{b as l}from"./chunk-ZXYTLPP6.mjs";import{e as g,f as y}from"./chunk-LS6G4DZV.mjs";import{b as p}from"./chunk-BCUSI3N6.mjs";import{b as h}from"./chunk-UAL27G6B.mjs";async function A(o){let{aptosConfig:n,jwt:s,ephemeralKeyPair:e,uidKey:r="sub",derivationPath:i}=o,t={jwt_b64:s,epk:e.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:e.expiryDateSecs,epk_blinder:p.fromHexInput(e.blinder).toStringWithoutPrefix(),uid_key:r,derivation_path:i},{data:a}=await g({aptosConfig:n,path:"fetch",body:t,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return p.fromHexInput(a.pepper).toUint8Array()}async function E(o){let{aptosConfig:n,jwt:s,ephemeralKeyPair:e,pepper:r=await A(o),uidKey:i="sub"}=o;if(p.fromHexInput(r).toUint8Array().length!==P.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${P.PEPPER_LENGTH} bytes`);let{maxExpHorizonSecs:t}=await w({aptosConfig:n});if(t<e.expiryDateSecs-h())throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${t}`);let a={jwt_b64:s,epk:e.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:p.fromHexInput(e.blinder).toStringWithoutPrefix(),exp_date_secs:e.expiryDateSecs,exp_horizon_secs:t,pepper:p.fromHexInput(r).toStringWithoutPrefix(),uid_key:i},{data:f}=await y({aptosConfig:n,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),c=f.proof,u=new m({a:c.a,b:c.b,c:c.c});return new K({proof:new x(u,0),trainingWheelsSignature:l.fromHex(f.training_wheels_signature),expHorizonSecs:t})}async function W(o){let{aptosConfig:n,jwt:s,uidKey:e,proofFetchCallback:r,pepper:i=await A(o)}=o,t=E({...o,pepper:i}),a=r?t:await t,f=d.fromJwtAndPepper({jwt:s,pepper:i,uidKey:e}),c=await b({aptosConfig:n,authenticationKey:f.authKey().derivedAddress()});return P.create({...o,address:c,proof:a,pepper:i,proofFetchCallback:r})}export{A as a,E as b,W as c};
2
- //# sourceMappingURL=chunk-LJZPPBTH.mjs.map
@@ -1 +0,0 @@
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 {\n EphemeralSignature,\n Groth16Zkp,\n Hex,\n KeylessPublicKey,\n ZeroKnowledgeSig,\n ZkProof,\n getKeylessConfig,\n} 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\";\nimport { lookupOriginalAccountAddress } from \"./account\";\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 = await getPepper(args), uidKey = \"sub\" } = args;\n if (Hex.fromHexInput(pepper).toUint8Array().length !== KeylessAccount.PEPPER_LENGTH) {\n throw new Error(`Pepper needs to be ${KeylessAccount.PEPPER_LENGTH} bytes`);\n }\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 { aptosConfig, jwt, uidKey, proofFetchCallback, pepper = await getPepper(args) } = args;\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 // Look up the original address to handle key rotations\n const publicKey = KeylessPublicKey.fromJwtAndPepper({ jwt, pepper, uidKey });\n const address = await lookupOriginalAccountAddress({\n aptosConfig,\n authenticationKey: publicKey.authKey().derivedAddress(),\n });\n\n const keylessAccount = KeylessAccount.create({ ...args, address, proof, pepper, proofFetchCallback });\n\n return keylessAccount;\n}\n"],"mappings":"kUA0BA,eAAsBA,EAAUC,EAMR,CACtB,GAAM,CAAE,YAAAC,EAAa,IAAAC,EAAK,iBAAAC,EAAkB,OAAAC,EAAS,MAAO,eAAAC,CAAe,EAAIL,EAEzEM,EAAO,CACX,QAASJ,EACT,IAAKC,EAAiB,aAAa,EAAE,SAAS,EAAE,sBAAsB,EACtE,cAAeA,EAAiB,eAChC,YAAaI,EAAI,aAAaJ,EAAiB,OAAO,EAAE,sBAAsB,EAC9E,QAASC,EACT,gBAAiBC,CACnB,EACM,CAAE,KAAAG,CAAK,EAAI,MAAMC,EAAgE,CACrF,YAAAR,EACA,KAAM,QACN,KAAAK,EACA,aAAc,YACd,UAAW,CAAE,iBAAkB,EAAM,CACvC,CAAC,EACD,OAAOC,EAAI,aAAaC,EAAK,MAAM,EAAE,aAAa,CACpD,CAEA,eAAsBE,EAASV,EAMD,CAC5B,GAAM,CAAE,YAAAC,EAAa,IAAAC,EAAK,iBAAAC,EAAkB,OAAAQ,EAAS,MAAMZ,EAAUC,CAAI,EAAG,OAAAI,EAAS,KAAM,EAAIJ,EAC/F,GAAIO,EAAI,aAAaI,CAAM,EAAE,aAAa,EAAE,SAAWC,EAAe,cACpE,MAAM,IAAI,MAAM,sBAAsBA,EAAe,aAAa,QAAQ,EAE5E,GAAM,CAAE,kBAAAC,CAAkB,EAAI,MAAMC,EAAiB,CAAE,YAAAb,CAAY,CAAC,EACpE,GAAIY,EAAoBV,EAAiB,eAAiBY,EAAa,EACrE,MAAM,MAAM,4EAA4EF,CAAiB,EAAE,EAE7G,IAAMG,EAAO,CACX,QAASd,EACT,IAAKC,EAAiB,aAAa,EAAE,SAAS,EAAE,sBAAsB,EACtE,YAAaI,EAAI,aAAaJ,EAAiB,OAAO,EAAE,sBAAsB,EAC9E,cAAeA,EAAiB,eAChC,iBAAkBU,EAClB,OAAQN,EAAI,aAAaI,CAAM,EAAE,sBAAsB,EACvD,QAASP,CACX,EAEM,CAAE,KAAAI,CAAK,EAAI,MAAMS,EAAuD,CAC5E,YAAAhB,EACA,KAAM,QACN,KAAMe,EACN,aAAc,WACd,UAAW,CAAE,iBAAkB,EAAM,CACvC,CAAC,EAEKE,EAAcV,EAAK,MACnBW,EAAa,IAAIC,EAAW,CAChC,EAAGF,EAAY,EACf,EAAGA,EAAY,EACf,EAAGA,EAAY,CACjB,CAAC,EAOD,OALoB,IAAIG,EAAiB,CACvC,MAAO,IAAIC,EAAQH,GAA8B,EACjD,wBAAyBI,EAAmB,QAAQf,EAAK,yBAAyB,EAClF,eAAgBK,CAClB,CAAC,CAEH,CAEA,eAAsBW,EAAqBxB,EAOf,CAC1B,GAAM,CAAE,YAAAC,EAAa,IAAAC,EAAK,OAAAE,EAAQ,mBAAAqB,EAAoB,OAAAd,EAAS,MAAMZ,EAAUC,CAAI,CAAE,EAAIA,EACnF0B,EAAehB,EAAS,CAAE,GAAGV,EAAM,OAAAW,CAAO,CAAC,EAM3CgB,EAAQF,EAAqBC,EAAe,MAAMA,EAGlDE,EAAYC,EAAiB,iBAAiB,CAAE,IAAA3B,EAAK,OAAAS,EAAQ,OAAAP,CAAO,CAAC,EACrE0B,EAAU,MAAMC,EAA6B,CACjD,YAAA9B,EACA,kBAAmB2B,EAAU,QAAQ,EAAE,eAAe,CACxD,CAAC,EAID,OAFuBhB,EAAe,OAAO,CAAE,GAAGZ,EAAM,QAAA8B,EAAS,MAAAH,EAAO,OAAAhB,EAAQ,mBAAAc,CAAmB,CAAC,CAGtG","names":["getPepper","args","aptosConfig","jwt","ephemeralKeyPair","uidKey","derivationPath","body","Hex","data","postAptosPepperService","getProof","pepper","KeylessAccount","maxExpHorizonSecs","getKeylessConfig","nowInSeconds","json","postAptosProvingService","proofPoints","groth16Zkp","Groth16Zkp","ZeroKnowledgeSig","ZkProof","EphemeralSignature","deriveKeylessAccount","proofFetchCallback","proofPromise","proof","publicKey","KeylessPublicKey","address","lookupOriginalAccountAddress"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/account/EphemeralKeyPair.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { randomBytes } from \"@noble/hashes/utils\";\n\nimport { Ed25519PrivateKey, EphemeralPublicKey, EphemeralSignature, PrivateKey } from \"../core/crypto\";\nimport { Hex } from \"../core/hex\";\nimport { bytesToBigIntLE, padAndPackBytesWithLen, poseidonHash } from \"../core/crypto/poseidon\";\nimport { EphemeralPublicKeyVariant, HexInput } from \"../types\";\nimport { Deserializer, Serializable, Serializer } from \"../bcs\";\nimport { floorToWholeHour, nowInSeconds } from \"../utils/helpers\";\n\nconst TWO_WEEKS_IN_SECONDS = 1_209_600;\n\n/**\n * A class which contains a key pair that is used in signing transactions via the Keyless authentication scheme. This key pair\n * is ephemeral and has an expiration time. For more details on how this class is used -\n * https://aptos.dev/guides/keyless-accounts/#1-present-the-user-with-a-sign-in-with-idp-button-on-the-ui\n */\nexport class EphemeralKeyPair extends Serializable {\n static readonly BLINDER_LENGTH: number = 31;\n\n /**\n * A byte array of length BLINDER_LENGTH used to obfuscate the public key from the IdP.\n * Used in calculating the nonce passed to the IdP and as a secret witness in proof generation.\n */\n readonly blinder: Uint8Array;\n\n /**\n * A timestamp in seconds indicating when the ephemeral key pair is expired. After expiry, a new\n * EphemeralKeyPair must be generated and a new JWT needs to be created.\n */\n readonly expiryDateSecs: number;\n\n /**\n * The value passed to the IdP when the user authenticates. It comprises of a hash of the\n * ephermeral public key, expiry date, and blinder.\n */\n readonly nonce: string;\n\n /**\n * A private key used to sign transactions. This private key is not tied to any account on the chain as it\n * is ephemeral (not permanent) in nature.\n */\n private privateKey: PrivateKey;\n\n /**\n * A public key used to verify transactions. This public key is not tied to any account on the chain as it\n * is ephemeral (not permanent) in nature.\n */\n private publicKey: EphemeralPublicKey;\n\n constructor(args: { privateKey: PrivateKey; expiryDateSecs?: number; blinder?: HexInput }) {\n super();\n const { privateKey, expiryDateSecs, blinder } = args;\n this.privateKey = privateKey;\n this.publicKey = new EphemeralPublicKey(privateKey.publicKey());\n // By default, we set the expiry date to be two weeks in the future floored to the nearest hour\n this.expiryDateSecs = expiryDateSecs || floorToWholeHour(nowInSeconds() + TWO_WEEKS_IN_SECONDS);\n // Generate the blinder if not provided\n this.blinder = blinder !== undefined ? Hex.fromHexInput(blinder).toUint8Array() : generateBlinder();\n // Calculate the nonce\n const fields = padAndPackBytesWithLen(this.publicKey.bcsToBytes(), 93);\n fields.push(BigInt(this.expiryDateSecs));\n fields.push(bytesToBigIntLE(this.blinder));\n const nonceHash = poseidonHash(fields);\n this.nonce = nonceHash.toString();\n }\n\n /**\n * Returns the public key of the key pair.\n * @return EphemeralPublicKey\n */\n getPublicKey(): EphemeralPublicKey {\n return this.publicKey;\n }\n\n /**\n * Returns the public key of the key pair.\n * @return boolean\n */\n isExpired(): boolean {\n const currentTimeSecs: number = Math.floor(Date.now() / 1000);\n return currentTimeSecs > this.expiryDateSecs;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.publicKey.variant);\n serializer.serializeBytes(this.privateKey.toUint8Array());\n serializer.serializeU64(this.expiryDateSecs);\n serializer.serializeFixedBytes(this.blinder);\n }\n\n static deserialize(deserializer: Deserializer): EphemeralKeyPair {\n const variantIndex = deserializer.deserializeUleb128AsU32();\n let privateKey: PrivateKey;\n switch (variantIndex) {\n case EphemeralPublicKeyVariant.Ed25519:\n privateKey = Ed25519PrivateKey.deserialize(deserializer);\n break;\n default:\n throw new Error(`Unknown variant index for EphemeralPublicKey: ${variantIndex}`);\n }\n const expiryDateSecs = deserializer.deserializeU64();\n const blinder = deserializer.deserializeFixedBytes(31);\n return new EphemeralKeyPair({ privateKey, expiryDateSecs: Number(expiryDateSecs), blinder });\n }\n\n static fromBytes(bytes: Uint8Array): EphemeralKeyPair {\n return EphemeralKeyPair.deserialize(new Deserializer(bytes));\n }\n\n /**\n * Returns the public key of the key pair.\n * @param scheme the type of keypair to use for the EphemeralKeyPair. Only Ed25519 supported for now.\n * @param expiryDateSecs the date of expiry.\n * @return boolean\n */\n static generate(args?: { scheme?: EphemeralPublicKeyVariant; expiryDateSecs?: number }): EphemeralKeyPair {\n let privateKey: PrivateKey;\n\n switch (args?.scheme) {\n case EphemeralPublicKeyVariant.Ed25519:\n default:\n privateKey = Ed25519PrivateKey.generate();\n }\n\n return new EphemeralKeyPair({ privateKey, expiryDateSecs: args?.expiryDateSecs });\n }\n\n /**\n * Sign the given message with the private key.\n * @param data in HexInput format\n * @returns EphemeralSignature\n */\n sign(data: HexInput): EphemeralSignature {\n if (this.isExpired()) {\n throw new Error(\"EphemeralKeyPair has expired\");\n }\n return new EphemeralSignature(this.privateKey.sign(data));\n }\n}\n\n/**\n * Generates a random byte array of length EphemeralKeyPair.BLINDER_LENGTH\n * @returns Uint8Array\n */\nfunction generateBlinder(): Uint8Array {\n return randomBytes(EphemeralKeyPair.BLINDER_LENGTH);\n}\n"],"mappings":"sTAGA,OAAS,eAAAA,MAAmB,sBAS5B,IAAMC,EAAuB,QAOhBC,EAAN,MAAMA,UAAyBC,CAAa,CAiCjD,YAAYC,EAA+E,CACzF,MAAM,EACN,GAAM,CAAE,WAAAC,EAAY,eAAAC,EAAgB,QAAAC,CAAQ,EAAIH,EAChD,KAAK,WAAaC,EAClB,KAAK,UAAY,IAAIG,EAAmBH,EAAW,UAAU,CAAC,EAE9D,KAAK,eAAiBC,GAAkBG,EAAiBC,EAAa,EAAIT,CAAoB,EAE9F,KAAK,QAAUM,IAAY,OAAYI,EAAI,aAAaJ,CAAO,EAAE,aAAa,EAAIK,EAAgB,EAElG,IAAMC,EAASC,EAAuB,KAAK,UAAU,WAAW,EAAG,EAAE,EACrED,EAAO,KAAK,OAAO,KAAK,cAAc,CAAC,EACvCA,EAAO,KAAKE,EAAgB,KAAK,OAAO,CAAC,EACzC,IAAMC,EAAYC,EAAaJ,CAAM,EACrC,KAAK,MAA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_SECONDS","_EphemeralKeyPair","Serializable","args","privateKey","expiryDateSecs","blinder","EphemeralPublicKey","floorToWholeHour","nowInSeconds","Hex","generateBlinder","fields","padAndPackBytesWithLen","bytesToBigIntLE","nonceHash","poseidonHash","serializer","deserializer","variantIndex","Ed25519PrivateKey","bytes","Deserializer","data","EphemeralSignature","EphemeralKeyPair","randomBytes"]}
@@ -1,2 +0,0 @@
1
- import{a as r,b as o,c as t}from"./chunk-LJZPPBTH.mjs";var i=class{constructor(e){this.config=e}async getPepper(e){return r({aptosConfig:this.config,...e})}async getProof(e){return o({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return t({aptosConfig:this.config,...e})}};export{i as a};
2
- //# sourceMappingURL=chunk-SCYGW3VV.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/api/keyless.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { EphemeralKeyPair, KeylessAccount, ProofFetchCallback } from \"../account\";\nimport { ZeroKnowledgeSig } from \"../core\";\nimport { deriveKeylessAccount, getPepper, getProof } from \"../internal/keyless\";\nimport { HexInput } from \"../types\";\nimport { AptosConfig } from \"./aptosConfig\";\n\n/**\n * A class to query all `Keyless` related queries on Aptos.\n *\n * More documentation on how to integrate Keyless Accounts see the below\n * https://aptos.dev/guides/keyless-accounts/#aptos-keyless-integration-guide\n */\nexport class Keyless {\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Fetches the pepper from the Aptos pepper service API.\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @param args.derivationPath a derivation path used for creating multiple accounts per user via the BIP-44 standard. Defaults\n * to \"m/44'/637'/0'/0'/0\".\n * @returns The pepper which is a Uint8Array of length 31.\n */\n async getPepper(args: {\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n derivationPath?: string;\n }): Promise<Uint8Array> {\n return getPepper({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches a proof from the Aptos prover service API.\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment\n * @param args.pepper the pepper used for the account. If not provided it will be fetched from the Aptos pepper service\n *\n * @returns The proof which is represented by a ZeroKnowledgeSig.\n */\n async getProof(args: {\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n pepper?: HexInput;\n uidKey?: string;\n }): Promise<ZeroKnowledgeSig> {\n return getProof({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Derives the Keyless Account from the JWT token and corresponding EphemeralKeyPair. It will lookup the pepper from\n * the pepper service if not explicitly provided. It will compute the proof via the proving service. It will ch\n *\n * @param args.jwt JWT token\n * @param args.ephemeralKeyPair the EphemeralKeyPair used to generate the nonce in the JWT token\n * @param args.uidKey a key in the JWT token to use to set the uidVal in the IdCommitment\n * @param args.pepper the pepper\n * @param args.proofFetchCallback a callback function that if set, the fetch of the proof will be done in the background. Once\n * fetching finishes the callback function will be called. This should be used to provide a more responsive user experience as now\n * they are not blocked on fetching the proof. Thus the function will return much more quickly.\n *\n * @returns A KeylessAccount that can be used to sign transactions\n */\n async deriveKeylessAccount(args: {\n jwt: string;\n ephemeralKeyPair: EphemeralKeyPair;\n uidKey?: string;\n pepper?: HexInput;\n proofFetchCallback?: ProofFetchCallback;\n }): Promise<KeylessAccount> {\n return deriveKeylessAccount({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"uDAeO,IAAMA,EAAN,KAAc,CACnB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAW3C,MAAM,UAAUC,EAIQ,CACtB,OAAOC,EAAU,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CACxD,CAYA,MAAM,SAASA,EAKe,CAC5B,OAAOE,EAAS,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CACvD,CAgBA,MAAM,qBAAqBA,EAMC,CAC1B,OAAOG,EAAqB,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CACnE,CACF","names":["Keyless","config","args","getPepper","getProof","deriveKeylessAccount"]}
@@ -1,2 +0,0 @@
1
- import{a as T,c as en,d as an,e as R}from"./chunk-DVIRUFCY.mjs";import{r as tn,u as f}from"./chunk-3HTSCV3R.mjs";import{a as Y}from"./chunk-XSTCHOUI.mjs";import{b as nn}from"./chunk-F5PNGH44.mjs";import{a as Q}from"./chunk-OTNGLTKS.mjs";import{a as y}from"./chunk-GKERWKMB.mjs";import{a as j}from"./chunk-HBQLX5QF.mjs";import{b as E,d as B,e as F,f as D}from"./chunk-GR4PHW7K.mjs";import{a as J}from"./chunk-53DBMWMU.mjs";import{a as z,c as L,d as Z}from"./chunk-MNVDBUF3.mjs";import{c as K,d as O,e as V,f as x,g as q,h as H,i as X}from"./chunk-Z2AJWV6D.mjs";import{a as v}from"./chunk-BOYYQAB4.mjs";import{a as k,b as l,d as A}from"./chunk-2XYA7NOU.mjs";import{a as b,b as p}from"./chunk-ZWX3NHGU.mjs";import{a as N}from"./chunk-O4BBULNE.mjs";import{i as S,j as _}from"./chunk-VYXS7TLB.mjs";import{b as $,d as M}from"./chunk-Q7MD4V7H.mjs";import{b as u}from"./chunk-OHRL766V.mjs";import{a as C}from"./chunk-AH44UPM4.mjs";import{a as U}from"./chunk-BSUYPXRD.mjs";import{b as I}from"./chunk-BCUSI3N6.mjs";import{g as P}from"./chunk-SCHZ67F3.mjs";import{b as W,c as G}from"./chunk-EXP5STXZ.mjs";import{sha3_256 as dn}from"@noble/hashes/sha3";async function vn(n){if(tn(n))return yn(n);let{moduleAddress:t,moduleName:e,functionName:i}=f(n.function),a=await on({key:"entry-function",moduleAddress:t,moduleName:e,functionName:i,aptosConfig:n.aptosConfig,abi:n.abi,fetch:en});return mn({...n,abi:a})}function mn(n){let t=n.abi,{moduleAddress:e,moduleName:i,functionName:a}=f(n.function),r=T(n.typeArguments);if(r.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${r.length}`);let o=n.functionArguments.map((s,d)=>R(n.function,t,s,d,r));if(o.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${i}::${a}', expected ${t.parameters.length} but got ${o.length}`);let c=x.build(`${e}::${i}`,a,r,o);if("multisigAddress"in n){let s=u.from(n.multisigAddress);return new V(new H(s,new X(c)))}return new O(c)}async function Kn(n){let{moduleAddress:t,moduleName:e,functionName:i}=f(n.function),a=await on({key:"view-function",moduleAddress:t,moduleName:e,functionName:i,aptosConfig:n.aptosConfig,abi:n.abi,fetch:an});return An({abi:a,...n})}function An(n){let t=n.abi,{moduleAddress:e,moduleName:i,functionName:a}=f(n.function),r=T(n.typeArguments);if(r.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${r.length}`);let o=n?.functionArguments?.map((c,s)=>R(n.function,t,c,s,r))??[];if(o.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${i}::${a}', expected ${t.parameters.length} but got ${o.length}`);return x.build(`${e}::${i}`,a,r,o)}function yn(n){return new K(new q(I.fromHexInput(n.bytecode).toUint8Array(),T(n.typeArguments),n.functionArguments))}async function fn(n){let{aptosConfig:t,sender:e,payload:i,options:a,feePayerAddress:r}=n,o=async()=>P[t.network]?{chainId:P[t.network]}:{chainId:(await Q({aptosConfig:t})).chain_id},c=async()=>a?.gasUnitPrice?{gasEstimate:a.gasUnitPrice}:{gasEstimate:(await nn({aptosConfig:t})).gas_estimate},s=async()=>{let g=async()=>a?.accountSequenceNumber!==void 0?a.accountSequenceNumber:(await Y({aptosConfig:t,accountAddress:e})).sequence_number;if(r&&u.from(r).equals(u.ZERO))try{return await g()}catch{return 0}else return g()},[{chainId:d},{gasEstimate:m},w]=await Promise.all([o(),c(),s()]),{maxGasAmount:sn,gasUnitPrice:cn,expireTimestamp:un}={maxGasAmount:a?.maxGasAmount?BigInt(a.maxGasAmount):BigInt(2e5),gasUnitPrice:a?.gasUnitPrice??BigInt(m),expireTimestamp:a?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+20)};return new z(u.from(e),BigInt(w),i,BigInt(sn),BigInt(cn),BigInt(un),new v(d))}async function On(n){let{aptosConfig:t,sender:e,payload:i,options:a,feePayerAddress:r}=n,o=await fn({aptosConfig:t,sender:e,payload:i,options:a,feePayerAddress:r});if("secondarySignerAddresses"in n){let c=n.secondarySignerAddresses?.map(s=>u.from(s))??[];return new J(o,c,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new j(o,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Vn(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:i,feePayerPublicKey:a}=n,r=h(t);if(e.feePayerAddress){let c=new Z(e.rawTransaction,e.secondarySignerAddresses??[],e.feePayerAddress),s=[];i&&(s=i.map(w=>h(w)));let d=h(a),m=new F(r,e.secondarySignerAddresses??[],s,{address:e.feePayerAddress,authenticator:d});return new y(c.raw_txn,m).bcsToBytes()}if(e.secondarySignerAddresses){let c=new L(e.rawTransaction,e.secondarySignerAddresses),s=[];s=i.map(m=>h(m));let d=new B(r,e.secondarySignerAddresses,s);return new y(c.raw_txn,d).bcsToBytes()}let o;if(r instanceof l)o=new E(r.public_key,r.signature);else if(r instanceof A)o=new D(r);else throw new Error("Invalid public key");return new y(e.rawTransaction,o).bcsToBytes()}function h(n){let t=new M(new Uint8Array(64));if($.isInstance(n))return new l(n,t);if(b.isInstance(n))return S.isInstance(n.publicKey)?new A(n,new p(_.getSimulationSignature())):new A(n,new p(t));if(S.isInstance(n)||N.isInstance(n))return console.warn("Expected AccountPublicKey, but got PublicKey. Please wrap your public key with AnyPublicKey."),new A(new b(n),new p(t));throw new Error("Unsupported public key")}function gn(n){let{transaction:t,feePayerAuthenticator:e,additionalSignersAuthenticators:i}=n,a=U(k,n.senderAuthenticator),r;if(t.feePayerAddress){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");r=new F(a,t.secondarySignerAddresses??[],i??[],{address:t.feePayerAddress,authenticator:e})}else if(t.secondarySignerAddresses){if(!i)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");r=new B(a,t.secondarySignerAddresses,i)}else a instanceof l?r=new E(a.public_key,a.signature):r=new D(a);return new y(t.rawTransaction,r).bcsToBytes()}function rn(n){let t=dn.create();for(let e of n)t.update(e);return t.digest()}var pn=rn(["APTOS::Transaction"]);function qn(n){let t=gn(n);return new I(rn([pn,new Uint8Array([0]),t])).toString()}async function on({key:n,moduleAddress:t,moduleName:e,functionName:i,aptosConfig:a,abi:r,fetch:o}){return r!==void 0?r:C(async()=>o(t,e,i,a),`${n}-${a.network}-${t}-${e}-${i}`,1e3*60*5)()}export{vn as a,mn as b,Kn as c,An as d,fn as e,On as f,Vn as g,h,gn as i,rn as j,qn as k};
2
- //# sourceMappingURL=chunk-T53MZO2U.mjs.map