@aptos-labs/ts-sdk 1.30.0 → 1.32.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.
- package/README.md +1 -1
- package/dist/common/{accountAddress-DnSqjhSl.d.ts → accountAddress-6RqI8Aam.d.ts} +144 -63
- package/dist/common/chunk-F43XVDYJ.js +2 -0
- package/dist/common/chunk-F43XVDYJ.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +546 -112
- package/dist/common/index.js +37 -28
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-DpH9qAcg.d.mts → Ed25519Account-B3xHXAQe.d.mts} +2 -2
- package/dist/esm/account/AbstractKeylessAccount.d.mts +86 -14
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +5 -4
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +5 -4
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +4 -3
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +57 -8
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +29 -11
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +23 -10
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +5 -4
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +6 -5
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/api/account.d.mts +9 -6
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +4 -3
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +6 -4
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +2 -1
- package/dist/esm/api/coin.d.mts +6 -5
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +7 -6
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +4 -3
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +3 -2
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +6 -5
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +6 -5
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +6 -4
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +11 -9
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +5 -4
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +5 -4
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +4 -3
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +5 -3
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +69 -3
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +5 -4
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +5 -4
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +4 -3
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +4 -3
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +3 -2
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +3 -2
- package/dist/esm/bcs/deserializer.d.mts +36 -27
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.d.mts +3 -2
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +3 -2
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +3 -2
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +3 -2
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +12 -12
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +14 -13
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-OV5UQ75K.mjs → chunk-2NHQQQZK.mjs} +2 -2
- package/dist/esm/{chunk-EF2PUPUH.mjs → chunk-2QBCTW67.mjs} +2 -2
- package/dist/esm/chunk-2QBCTW67.mjs.map +1 -0
- package/dist/esm/{chunk-JY3JJ55D.mjs → chunk-37Y54PJ5.mjs} +2 -2
- package/dist/esm/chunk-3DQVGPFE.mjs +2 -0
- package/dist/esm/chunk-3DQVGPFE.mjs.map +1 -0
- package/dist/esm/{chunk-XHCALZ7X.mjs → chunk-3XCYCFYI.mjs} +2 -2
- package/dist/esm/{chunk-6FLHGOKP.mjs → chunk-42H7WETG.mjs} +2 -2
- package/dist/esm/{chunk-RNAKZVRN.mjs → chunk-46L6BAJG.mjs} +2 -2
- package/dist/esm/{chunk-EN2HDNFE.mjs → chunk-4DNCQM3S.mjs} +2 -2
- package/dist/esm/chunk-4O5XDQDO.mjs +2 -0
- package/dist/esm/chunk-4PBXTMN3.mjs +2 -0
- package/dist/esm/chunk-4PBXTMN3.mjs.map +1 -0
- package/dist/esm/chunk-4YEOOZ2N.mjs +4 -0
- package/dist/esm/{chunk-KFSVKIFO.mjs.map → chunk-4YEOOZ2N.mjs.map} +1 -1
- package/dist/esm/{chunk-D3KBNFZR.mjs → chunk-5AKSORBJ.mjs} +2 -2
- package/dist/esm/chunk-5B3SMBXQ.mjs +2 -0
- package/dist/esm/{chunk-EKZQ3EYX.mjs → chunk-5NJWJXSS.mjs} +2 -2
- package/dist/esm/{chunk-2QRWGJJA.mjs → chunk-6K4TOFCO.mjs} +2 -2
- package/dist/esm/{chunk-OLPI7QAH.mjs → chunk-6LLGRGCN.mjs} +2 -2
- package/dist/esm/chunk-6LLGRGCN.mjs.map +1 -0
- package/dist/esm/{chunk-R3Y6WH2U.mjs → chunk-6PJH53CK.mjs} +2 -2
- package/dist/esm/{chunk-PCLU4KLY.mjs → chunk-6ZOVTYLJ.mjs} +2 -2
- package/dist/esm/chunk-7ECCT6PK.mjs +1 -0
- package/dist/esm/chunk-7WXDXBXK.mjs +2 -0
- package/dist/esm/{chunk-UKAXCARD.mjs.map → chunk-7WXDXBXK.mjs.map} +1 -1
- package/dist/esm/{chunk-JNHFQTFC.mjs → chunk-AAATWCJT.mjs} +2 -2
- package/dist/esm/{chunk-NODYW7DM.mjs → chunk-ACVIE7IE.mjs} +2 -2
- package/dist/esm/chunk-AHWZA3GD.mjs +2 -0
- package/dist/esm/chunk-AHWZA3GD.mjs.map +1 -0
- package/dist/esm/chunk-AITN3DO4.mjs +2 -0
- package/dist/esm/chunk-AITN3DO4.mjs.map +1 -0
- package/dist/esm/{chunk-QQIVWB6G.mjs → chunk-AJ5JHBAE.mjs} +2 -2
- package/dist/esm/{chunk-QQIVWB6G.mjs.map → chunk-AJ5JHBAE.mjs.map} +1 -1
- package/dist/esm/{chunk-PRZ7AIGA.mjs → chunk-AKIO3OIT.mjs} +2 -2
- package/dist/esm/chunk-AMCJQIOT.mjs +2 -0
- package/dist/esm/{chunk-UI3AKMZX.mjs.map → chunk-AMCJQIOT.mjs.map} +1 -1
- package/dist/esm/{chunk-KRVLR3L4.mjs → chunk-AOROYJ74.mjs} +2 -2
- package/dist/esm/chunk-AVPQOD67.mjs +2 -0
- package/dist/esm/chunk-AVPQOD67.mjs.map +1 -0
- package/dist/esm/chunk-AVZYJAXR.mjs +2 -0
- package/dist/esm/chunk-AVZYJAXR.mjs.map +1 -0
- package/dist/esm/{chunk-6AGTDRNM.mjs → chunk-BLLHTGAP.mjs} +2 -2
- package/dist/esm/{chunk-JGNMNCQB.mjs → chunk-BRV3RLKW.mjs} +2 -2
- package/dist/esm/{chunk-GIQQF2PD.mjs → chunk-CA3Q2X6B.mjs} +2 -2
- package/dist/esm/chunk-D52UKPQF.mjs +2 -0
- package/dist/esm/chunk-D52UKPQF.mjs.map +1 -0
- package/dist/esm/{chunk-FPF4KZ5M.mjs → chunk-DDVOBEJA.mjs} +2 -2
- package/dist/esm/chunk-DDVOBEJA.mjs.map +1 -0
- package/dist/esm/{chunk-QRTZYRH2.mjs → chunk-DP3YPGIK.mjs} +2 -2
- package/dist/esm/{chunk-DXQT55L3.mjs → chunk-DSKAMBBL.mjs} +2 -2
- package/dist/esm/{chunk-RAXP3STS.mjs → chunk-E2NYQVP3.mjs} +2 -2
- package/dist/esm/chunk-EEB7EZFO.mjs +2 -0
- package/dist/esm/chunk-EEB7EZFO.mjs.map +1 -0
- package/dist/esm/{chunk-WUCPTRXU.mjs → chunk-F2AIWA7L.mjs} +2 -2
- package/dist/esm/chunk-F45G3GP3.mjs +7 -0
- package/dist/esm/chunk-F45G3GP3.mjs.map +1 -0
- package/dist/esm/{chunk-VQTEGTUQ.mjs → chunk-FXUI3SSD.mjs} +2 -2
- package/dist/esm/chunk-G2GN4LH5.mjs +2 -0
- package/dist/esm/chunk-G2GN4LH5.mjs.map +1 -0
- package/dist/esm/chunk-GBVRCWCD.mjs +2 -0
- package/dist/esm/chunk-GBVRCWCD.mjs.map +1 -0
- package/dist/esm/chunk-H457BI3I.mjs +2 -0
- package/dist/esm/chunk-H457BI3I.mjs.map +1 -0
- package/dist/esm/{chunk-5AAFF2PV.mjs → chunk-HEHVWRMO.mjs} +2 -2
- package/dist/esm/{chunk-ZUTOMGB7.mjs → chunk-HFWFDS6Y.mjs} +2 -2
- package/dist/esm/{chunk-QBWGWHJK.mjs → chunk-HXXELLHN.mjs} +2 -2
- package/dist/esm/{chunk-LD5MUWGW.mjs → chunk-IBMZYDAR.mjs} +2 -2
- package/dist/esm/{chunk-QBP4XJT5.mjs → chunk-IDNDUJOK.mjs} +2 -2
- package/dist/esm/{chunk-HCV3NGLS.mjs → chunk-II654QZU.mjs} +2 -2
- package/dist/esm/{chunk-XIY2VORC.mjs → chunk-JDNI5VIJ.mjs} +2 -2
- package/dist/esm/{chunk-HAMXSLWF.mjs → chunk-JJUINAQE.mjs} +2 -2
- package/dist/esm/{chunk-K6MZXKVV.mjs → chunk-JLD7DLKM.mjs} +2 -2
- package/dist/esm/chunk-JNO7KPMG.mjs +4 -0
- package/dist/esm/chunk-JNO7KPMG.mjs.map +1 -0
- package/dist/esm/chunk-K4TJRYGQ.mjs +2 -0
- package/dist/esm/chunk-K4TJRYGQ.mjs.map +1 -0
- package/dist/esm/{chunk-NV6DHDM3.mjs → chunk-KA5FX53Q.mjs} +2 -2
- package/dist/esm/{chunk-CRL4WGOH.mjs → chunk-KT3DT5GV.mjs} +2 -2
- package/dist/esm/chunk-KT3DT5GV.mjs.map +1 -0
- package/dist/esm/chunk-KUL55M2H.mjs +2 -0
- package/dist/esm/chunk-KUL55M2H.mjs.map +1 -0
- package/dist/esm/{chunk-JDYASF3E.mjs → chunk-L2QVUMBV.mjs} +2 -2
- package/dist/esm/chunk-L2SDI7PI.mjs +2 -0
- package/dist/esm/chunk-L2SDI7PI.mjs.map +1 -0
- package/dist/esm/chunk-L56DQ4N3.mjs +2 -0
- package/dist/esm/chunk-L56DQ4N3.mjs.map +1 -0
- package/dist/esm/{chunk-S3FVA55H.mjs → chunk-LAAFLCDM.mjs} +2 -2
- package/dist/esm/{chunk-AGBA3Y7A.mjs → chunk-LGTOOAQI.mjs} +2 -2
- package/dist/esm/chunk-MHN6XY4Z.mjs +2 -0
- package/dist/esm/{chunk-PHG2IWZW.mjs → chunk-MOGPSSTD.mjs} +2 -2
- package/dist/esm/{chunk-KSKQVOBA.mjs → chunk-NARS3JDH.mjs} +2 -2
- package/dist/esm/{chunk-KSUZS6EL.mjs → chunk-NHKAQRJB.mjs} +2 -2
- package/dist/esm/{chunk-PHP47DI4.mjs → chunk-OIOGOW6I.mjs} +1 -1
- package/dist/esm/{chunk-PHP47DI4.mjs.map → chunk-OIOGOW6I.mjs.map} +1 -1
- package/dist/esm/{chunk-DCUVV3VY.mjs → chunk-OJBMR5CT.mjs} +2 -2
- package/dist/esm/chunk-OJBMR5CT.mjs.map +1 -0
- package/dist/esm/{chunk-TIZL5YVP.mjs → chunk-OKE3FXIP.mjs} +2 -2
- package/dist/esm/chunk-ONFKJ57C.mjs +2 -0
- package/dist/esm/chunk-ONFKJ57C.mjs.map +1 -0
- package/dist/esm/{chunk-ZINOJTLU.mjs → chunk-OPO5EYF7.mjs} +2 -2
- package/dist/esm/{chunk-HDTKBFRX.mjs → chunk-PW3ISXPN.mjs} +2 -2
- package/dist/esm/{chunk-WIXNX7HY.mjs → chunk-QQM47PHZ.mjs} +2 -2
- package/dist/esm/{chunk-5XXIIWG7.mjs → chunk-SBCLBDCP.mjs} +2 -2
- package/dist/esm/chunk-SPRNSFUV.mjs +2 -0
- package/dist/esm/chunk-SPRNSFUV.mjs.map +1 -0
- package/dist/esm/{chunk-Z36WHOZV.mjs → chunk-SU2WB34N.mjs} +2 -2
- package/dist/esm/{chunk-OTY3NO7Q.mjs → chunk-T6ADNZE5.mjs} +2 -2
- package/dist/esm/{chunk-IECDO22V.mjs → chunk-TM7OZT3W.mjs} +2 -2
- package/dist/esm/chunk-TM7OZT3W.mjs.map +1 -0
- package/dist/esm/chunk-UGTIALNW.mjs +2 -0
- package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
- package/dist/esm/chunk-UZTJWOLS.mjs +2 -0
- package/dist/esm/chunk-V4FKFCBL.mjs +2 -0
- package/dist/esm/chunk-V4FKFCBL.mjs.map +1 -0
- package/dist/esm/{chunk-7V6RL27I.mjs → chunk-VCY3JGZM.mjs} +2 -2
- package/dist/esm/{chunk-XOCRDV2V.mjs → chunk-VQZMI3EZ.mjs} +2 -2
- package/dist/esm/chunk-WGIYSLH6.mjs +2 -0
- package/dist/esm/chunk-WGIYSLH6.mjs.map +1 -0
- package/dist/esm/{chunk-WOOH5MMX.mjs → chunk-WKNX43KN.mjs} +2 -2
- package/dist/esm/chunk-WKNX43KN.mjs.map +1 -0
- package/dist/esm/chunk-WQF3IOXC.mjs +2 -0
- package/dist/esm/chunk-WQF3IOXC.mjs.map +1 -0
- package/dist/esm/{chunk-N3OYD6VZ.mjs → chunk-WSFHH3BK.mjs} +2 -2
- package/dist/esm/{chunk-7PVIWKGT.mjs → chunk-X3JPX7T6.mjs} +2 -2
- package/dist/esm/{chunk-HGVZ7ULA.mjs → chunk-XKOSS5KC.mjs} +2 -2
- package/dist/esm/{chunk-TRU3EK64.mjs → chunk-XT5T5LAP.mjs} +2 -2
- package/dist/esm/chunk-XUP6VABV.mjs +2 -0
- package/dist/esm/chunk-XUP6VABV.mjs.map +1 -0
- package/dist/esm/{chunk-FO4F3OJJ.mjs → chunk-YNT7JHMS.mjs} +2 -2
- package/dist/esm/{chunk-37UZKMJI.mjs → chunk-YPBNYKOD.mjs} +2 -2
- package/dist/esm/{chunk-IFHQSZLK.mjs → chunk-YZ3YPLEU.mjs} +2 -2
- package/dist/esm/{chunk-OZN3OOJV.mjs → chunk-ZMBXHMVQ.mjs} +2 -2
- package/dist/esm/{chunk-BQXVHY7J.mjs → chunk-ZRWZIAF5.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +3 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +2 -1
- package/dist/esm/cli/move.mjs +1 -1
- package/dist/esm/client/core.d.mts +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +2 -2
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +3 -3
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +2 -2
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +3 -2
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +3 -2
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +3 -2
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +20 -10
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +4 -3
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +27 -12
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +4 -3
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +5 -4
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/hdKey.d.mts +0 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +5 -4
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +73 -11
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +4 -3
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +4 -3
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +38 -10
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +3 -2
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +4 -3
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +24 -9
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +3 -2
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +4 -3
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.d.mts +3 -2
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +40 -3
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +6 -5
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +123 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/index.d.mts +13 -11
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +5 -4
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +5 -4
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +3 -2
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +5 -4
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +3 -2
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +2 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +5 -4
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +3 -2
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +13 -7
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +3 -2
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +2 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +3 -2
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +2 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +4 -3
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +4 -3
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/{publicKey-_tPa99ea.d.mts → publicKey-BVXX1nVl.d.mts} +2 -2
- package/dist/esm/transactions/authenticator/account.d.mts +4 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +4 -3
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +10 -4
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +7 -5
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +3 -2
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +3 -2
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +4 -3
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +3 -2
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +3 -2
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +3 -2
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +4 -3
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +4 -3
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +3 -2
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +3 -2
- package/dist/esm/transactions/instances/transactionPayload.d.mts +3 -2
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +5 -4
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +5 -4
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +5 -4
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/script-composer/index.d.mts +44 -0
- package/dist/esm/transactions/script-composer/index.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -2
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +5 -4
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +26 -5
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +4 -3
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +4 -3
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +3 -2
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +3 -2
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +12 -3
- package/dist/esm/types/index.d.mts +4 -1260
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/keyless.d.mts +22 -1
- package/dist/esm/types/types.d.mts +1290 -0
- package/dist/esm/types/types.mjs +2 -0
- package/dist/esm/types/types.mjs.map +1 -0
- package/dist/esm/utils/helpers.d.mts +11 -3
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +3 -2
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +3 -2
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +3 -2
- package/src/account/AbstractKeylessAccount.ts +203 -10
- package/src/account/FederatedKeylessAccount.ts +83 -35
- package/src/account/KeylessAccount.ts +44 -37
- package/src/account/MultiKeyAccount.ts +18 -5
- package/src/api/account.ts +12 -2
- package/src/api/keyless.ts +4 -3
- package/src/api/transactionSubmission/build.ts +82 -1
- package/src/bcs/deserializer.ts +53 -30
- package/src/bcs/serializable/moveStructs.ts +16 -17
- package/src/bcs/serializer.ts +22 -12
- package/src/cli/move.ts +20 -5
- package/src/client/core.ts +2 -2
- package/src/client/get.ts +1 -2
- package/src/client/index.ts +0 -1
- package/src/client/post.ts +1 -2
- package/src/core/accountAddress.ts +36 -9
- package/src/core/crypto/ed25519.ts +34 -14
- package/src/core/crypto/hdKey.ts +0 -1
- package/src/core/crypto/keyless.ts +245 -38
- package/src/core/crypto/privateKey.ts +81 -5
- package/src/core/crypto/secp256k1.ts +31 -11
- package/src/core/hex.ts +47 -0
- package/src/errors/index.ts +406 -0
- package/src/index.ts +1 -0
- package/src/internal/account.ts +6 -6
- package/src/internal/ans.ts +2 -1
- package/src/internal/keyless.ts +50 -20
- package/src/internal/transaction.ts +2 -1
- package/src/internal/transactionSubmission.ts +36 -18
- package/src/transactions/authenticator/transaction.ts +20 -0
- package/src/transactions/index.ts +1 -0
- package/src/transactions/script-composer/index.ts +76 -0
- package/src/transactions/transactionBuilder/remoteAbi.ts +55 -1
- package/src/transactions/types.ts +11 -0
- package/src/types/index.ts +2 -1483
- package/src/types/keyless.ts +19 -0
- package/src/types/types.ts +1512 -0
- package/src/utils/helpers.ts +10 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-7IYTZDXV.js +0 -2
- package/dist/common/chunk-7IYTZDXV.js.map +0 -1
- package/dist/esm/chunk-2I56E4T2.mjs +0 -2
- package/dist/esm/chunk-2I56E4T2.mjs.map +0 -1
- package/dist/esm/chunk-4CDDWSKZ.mjs +0 -2
- package/dist/esm/chunk-4OV7QU2U.mjs +0 -2
- package/dist/esm/chunk-5CCHECTE.mjs +0 -2
- package/dist/esm/chunk-5CCHECTE.mjs.map +0 -1
- package/dist/esm/chunk-5ZBHIUWG.mjs +0 -2
- package/dist/esm/chunk-5ZBHIUWG.mjs.map +0 -1
- package/dist/esm/chunk-7D3RY73L.mjs +0 -2
- package/dist/esm/chunk-7D3RY73L.mjs.map +0 -1
- package/dist/esm/chunk-7XS45O6M.mjs +0 -2
- package/dist/esm/chunk-7XS45O6M.mjs.map +0 -1
- package/dist/esm/chunk-CRL4WGOH.mjs.map +0 -1
- package/dist/esm/chunk-DCUVV3VY.mjs.map +0 -1
- package/dist/esm/chunk-DZJXOL64.mjs +0 -2
- package/dist/esm/chunk-DZJXOL64.mjs.map +0 -1
- package/dist/esm/chunk-EF2PUPUH.mjs.map +0 -1
- package/dist/esm/chunk-FPF4KZ5M.mjs.map +0 -1
- package/dist/esm/chunk-FY7TSOUU.mjs +0 -2
- package/dist/esm/chunk-FY7TSOUU.mjs.map +0 -1
- package/dist/esm/chunk-GPZRGLU2.mjs +0 -2
- package/dist/esm/chunk-GPZRGLU2.mjs.map +0 -1
- package/dist/esm/chunk-GQABU3RQ.mjs +0 -2
- package/dist/esm/chunk-GQABU3RQ.mjs.map +0 -1
- package/dist/esm/chunk-I5OYNCZS.mjs +0 -1
- package/dist/esm/chunk-IBLZ6MZU.mjs +0 -2
- package/dist/esm/chunk-IECDO22V.mjs.map +0 -1
- package/dist/esm/chunk-KFNDDPOW.mjs +0 -2
- package/dist/esm/chunk-KFNDDPOW.mjs.map +0 -1
- package/dist/esm/chunk-KFSVKIFO.mjs +0 -2
- package/dist/esm/chunk-KIW54KWR.mjs +0 -2
- package/dist/esm/chunk-KM6UXNC7.mjs +0 -2
- package/dist/esm/chunk-KM6UXNC7.mjs.map +0 -1
- package/dist/esm/chunk-KUX6GQ2E.mjs +0 -1
- package/dist/esm/chunk-L5I7F3NZ.mjs +0 -2
- package/dist/esm/chunk-L5I7F3NZ.mjs.map +0 -1
- package/dist/esm/chunk-LEKBJ2EG.mjs +0 -2
- package/dist/esm/chunk-LEKBJ2EG.mjs.map +0 -1
- package/dist/esm/chunk-LZS7BQ2B.mjs +0 -2
- package/dist/esm/chunk-LZS7BQ2B.mjs.map +0 -1
- package/dist/esm/chunk-N2FKVZ4D.mjs +0 -1
- package/dist/esm/chunk-N47FTRYO.mjs +0 -2
- package/dist/esm/chunk-N47FTRYO.mjs.map +0 -1
- package/dist/esm/chunk-OLPI7QAH.mjs.map +0 -1
- package/dist/esm/chunk-ONBFUPEC.mjs +0 -2
- package/dist/esm/chunk-OS2EG6AE.mjs +0 -2
- package/dist/esm/chunk-OS2EG6AE.mjs.map +0 -1
- package/dist/esm/chunk-PGZWRY7A.mjs +0 -2
- package/dist/esm/chunk-PGZWRY7A.mjs.map +0 -1
- package/dist/esm/chunk-RUDS7RSB.mjs +0 -2
- package/dist/esm/chunk-RUDS7RSB.mjs.map +0 -1
- package/dist/esm/chunk-UI3AKMZX.mjs +0 -2
- package/dist/esm/chunk-UKAXCARD.mjs +0 -2
- package/dist/esm/chunk-WOOH5MMX.mjs.map +0 -1
- package/dist/esm/chunk-WSVOJSAC.mjs +0 -2
- package/dist/esm/chunk-WSVOJSAC.mjs.map +0 -1
- package/dist/esm/chunk-ZS3EWM5A.mjs +0 -2
- package/dist/esm/chunk-ZS3EWM5A.mjs.map +0 -1
- package/dist/esm/client/types.d.mts +0 -66
- package/dist/esm/client/types.mjs +0 -2
- package/src/client/types.ts +0 -138
- /package/dist/esm/{chunk-OV5UQ75K.mjs.map → chunk-2NHQQQZK.mjs.map} +0 -0
- /package/dist/esm/{chunk-JY3JJ55D.mjs.map → chunk-37Y54PJ5.mjs.map} +0 -0
- /package/dist/esm/{chunk-XHCALZ7X.mjs.map → chunk-3XCYCFYI.mjs.map} +0 -0
- /package/dist/esm/{chunk-6FLHGOKP.mjs.map → chunk-42H7WETG.mjs.map} +0 -0
- /package/dist/esm/{chunk-RNAKZVRN.mjs.map → chunk-46L6BAJG.mjs.map} +0 -0
- /package/dist/esm/{chunk-EN2HDNFE.mjs.map → chunk-4DNCQM3S.mjs.map} +0 -0
- /package/dist/esm/{chunk-IBLZ6MZU.mjs.map → chunk-4O5XDQDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-D3KBNFZR.mjs.map → chunk-5AKSORBJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-KIW54KWR.mjs.map → chunk-5B3SMBXQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-EKZQ3EYX.mjs.map → chunk-5NJWJXSS.mjs.map} +0 -0
- /package/dist/esm/{chunk-2QRWGJJA.mjs.map → chunk-6K4TOFCO.mjs.map} +0 -0
- /package/dist/esm/{chunk-R3Y6WH2U.mjs.map → chunk-6PJH53CK.mjs.map} +0 -0
- /package/dist/esm/{chunk-PCLU4KLY.mjs.map → chunk-6ZOVTYLJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-I5OYNCZS.mjs.map → chunk-7ECCT6PK.mjs.map} +0 -0
- /package/dist/esm/{chunk-JNHFQTFC.mjs.map → chunk-AAATWCJT.mjs.map} +0 -0
- /package/dist/esm/{chunk-NODYW7DM.mjs.map → chunk-ACVIE7IE.mjs.map} +0 -0
- /package/dist/esm/{chunk-PRZ7AIGA.mjs.map → chunk-AKIO3OIT.mjs.map} +0 -0
- /package/dist/esm/{chunk-KRVLR3L4.mjs.map → chunk-AOROYJ74.mjs.map} +0 -0
- /package/dist/esm/{chunk-6AGTDRNM.mjs.map → chunk-BLLHTGAP.mjs.map} +0 -0
- /package/dist/esm/{chunk-JGNMNCQB.mjs.map → chunk-BRV3RLKW.mjs.map} +0 -0
- /package/dist/esm/{chunk-GIQQF2PD.mjs.map → chunk-CA3Q2X6B.mjs.map} +0 -0
- /package/dist/esm/{chunk-QRTZYRH2.mjs.map → chunk-DP3YPGIK.mjs.map} +0 -0
- /package/dist/esm/{chunk-DXQT55L3.mjs.map → chunk-DSKAMBBL.mjs.map} +0 -0
- /package/dist/esm/{chunk-RAXP3STS.mjs.map → chunk-E2NYQVP3.mjs.map} +0 -0
- /package/dist/esm/{chunk-WUCPTRXU.mjs.map → chunk-F2AIWA7L.mjs.map} +0 -0
- /package/dist/esm/{chunk-VQTEGTUQ.mjs.map → chunk-FXUI3SSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-5AAFF2PV.mjs.map → chunk-HEHVWRMO.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZUTOMGB7.mjs.map → chunk-HFWFDS6Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-QBWGWHJK.mjs.map → chunk-HXXELLHN.mjs.map} +0 -0
- /package/dist/esm/{chunk-LD5MUWGW.mjs.map → chunk-IBMZYDAR.mjs.map} +0 -0
- /package/dist/esm/{chunk-QBP4XJT5.mjs.map → chunk-IDNDUJOK.mjs.map} +0 -0
- /package/dist/esm/{chunk-HCV3NGLS.mjs.map → chunk-II654QZU.mjs.map} +0 -0
- /package/dist/esm/{chunk-XIY2VORC.mjs.map → chunk-JDNI5VIJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-HAMXSLWF.mjs.map → chunk-JJUINAQE.mjs.map} +0 -0
- /package/dist/esm/{chunk-K6MZXKVV.mjs.map → chunk-JLD7DLKM.mjs.map} +0 -0
- /package/dist/esm/{chunk-NV6DHDM3.mjs.map → chunk-KA5FX53Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-JDYASF3E.mjs.map → chunk-L2QVUMBV.mjs.map} +0 -0
- /package/dist/esm/{chunk-S3FVA55H.mjs.map → chunk-LAAFLCDM.mjs.map} +0 -0
- /package/dist/esm/{chunk-AGBA3Y7A.mjs.map → chunk-LGTOOAQI.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OV7QU2U.mjs.map → chunk-MHN6XY4Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-PHG2IWZW.mjs.map → chunk-MOGPSSTD.mjs.map} +0 -0
- /package/dist/esm/{chunk-KSKQVOBA.mjs.map → chunk-NARS3JDH.mjs.map} +0 -0
- /package/dist/esm/{chunk-KSUZS6EL.mjs.map → chunk-NHKAQRJB.mjs.map} +0 -0
- /package/dist/esm/{chunk-TIZL5YVP.mjs.map → chunk-OKE3FXIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZINOJTLU.mjs.map → chunk-OPO5EYF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-HDTKBFRX.mjs.map → chunk-PW3ISXPN.mjs.map} +0 -0
- /package/dist/esm/{chunk-WIXNX7HY.mjs.map → chunk-QQM47PHZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-5XXIIWG7.mjs.map → chunk-SBCLBDCP.mjs.map} +0 -0
- /package/dist/esm/{chunk-Z36WHOZV.mjs.map → chunk-SU2WB34N.mjs.map} +0 -0
- /package/dist/esm/{chunk-OTY3NO7Q.mjs.map → chunk-T6ADNZE5.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONBFUPEC.mjs.map → chunk-UGTIALNW.mjs.map} +0 -0
- /package/dist/esm/{chunk-KUX6GQ2E.mjs.map → chunk-UIRAXHDH.mjs.map} +0 -0
- /package/dist/esm/{chunk-4CDDWSKZ.mjs.map → chunk-UZTJWOLS.mjs.map} +0 -0
- /package/dist/esm/{chunk-7V6RL27I.mjs.map → chunk-VCY3JGZM.mjs.map} +0 -0
- /package/dist/esm/{chunk-XOCRDV2V.mjs.map → chunk-VQZMI3EZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-N3OYD6VZ.mjs.map → chunk-WSFHH3BK.mjs.map} +0 -0
- /package/dist/esm/{chunk-7PVIWKGT.mjs.map → chunk-X3JPX7T6.mjs.map} +0 -0
- /package/dist/esm/{chunk-HGVZ7ULA.mjs.map → chunk-XKOSS5KC.mjs.map} +0 -0
- /package/dist/esm/{chunk-TRU3EK64.mjs.map → chunk-XT5T5LAP.mjs.map} +0 -0
- /package/dist/esm/{chunk-FO4F3OJJ.mjs.map → chunk-YNT7JHMS.mjs.map} +0 -0
- /package/dist/esm/{chunk-37UZKMJI.mjs.map → chunk-YPBNYKOD.mjs.map} +0 -0
- /package/dist/esm/{chunk-IFHQSZLK.mjs.map → chunk-YZ3YPLEU.mjs.map} +0 -0
- /package/dist/esm/{chunk-OZN3OOJV.mjs.map → chunk-ZMBXHMVQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-BQXVHY7J.mjs.map → chunk-ZRWZIAF5.mjs.map} +0 -0
- /package/dist/esm/{chunk-N2FKVZ4D.mjs.map → errors/index.mjs.map} +0 -0
- /package/dist/esm/{client/types.mjs.map → transactions/script-composer/index.mjs.map} +0 -0
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{decode as c}from"js-base64";async function m(e){return new Promise(n=>{setTimeout(n,e)})}var u=()=>Math.floor(Date.now()/1e3);function i(e){let n=new Date(e*1e3);return n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0),Math.floor(n.getTime()/1e3)}function l(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n+"==".substring(0,(3-n.length%3)%3);return c(t)}var g=(e,n)=>e*10**n,p=(e,n)=>e/10**n,r=e=>{let n="";for(let t=2;t<e.length;t+=2)n+=String.fromCharCode(parseInt(e.substring(t,t+2),16));return n},_=e=>{let{account_address:n,module_name:t,struct_name:o}=e,s=r(t),a=r(o);return`${n}::${s}::${a}`},f=e=>typeof e=="object"&&!Array.isArray(e)&&e!==null&&"account_address"in e&&"module_name"in e&&"struct_name"in e&&typeof e.account_address=="string"&&typeof e.module_name=="string"&&typeof e.struct_name=="string";export{m as a,u as b,i as c,l as d,g as e,p as f,_ as g,f as h};
|
|
2
|
-
//# sourceMappingURL=chunk-LEKBJ2EG.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/helpers.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { decode } from \"js-base64\";\nimport { MoveStructId } from \"../types\";\n\n/**\n * Sleep for the specified amount of time in milliseconds.\n * This function can be used to introduce delays in asynchronous operations.\n *\n * @param timeMs - The time in milliseconds to sleep.\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\nexport const nowInSeconds = () => Math.floor(Date.now() / 1000);\n\n/**\n * Floors the given timestamp to the nearest whole hour.\n * This function is useful for normalizing timestamps to hourly intervals.\n *\n * @param timestampInSeconds - The timestamp in seconds to be floored.\n */\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\n/**\n * Decodes a base64 URL-encoded string into its original form.\n * This function is useful for converting base64 URL-encoded data back to a readable format.\n *\n * @param base64Url - The base64 URL-encoded string to decode.\n * @returns The decoded string.\n */\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * a human-readable amount format to the smallest unit format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n */\nexport const convertAmountFromHumanReadableToOnChain = (value: number, decimal: number) => value * 10 ** decimal;\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * the smallest unit format to a human-readable amount format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n */\nexport const convertAmountFromOnChainToHumanReadable = (value: number, decimal: number) => value / 10 ** decimal;\n\n/**\n * Convert a hex string to an ascii string with the `0x` prefix.\n *\n * `0x6170746f735f636f696e` --> `aptos_coin`\n *\n * @param hex The hex string to convert (e.g. `0x6170746f735f636f696e`)\n * @returns The ascii string\n */\nconst hexToAscii = (hex: string) => {\n let str = \"\";\n for (let n = 2; n < hex.length; n += 2) {\n str += String.fromCharCode(parseInt(hex.substring(n, n + 2), 16));\n }\n return str;\n};\n\n/**\n * Convert an encoded struct to a MoveStructId.\n *\n * @example\n * const structObj = {\n * account_address: \"0x1\",\n * module_name: \"0x6170746f735f636f696e\",\n * struct_name: \"0x4170746f73436f696e\",\n * };\n * // structId is \"0x1::aptos_coin::AptosCoin\"\n * const structId = parseEncodedStruct(structObj);\n *\n * @param structObj The struct with account_address, module_name, and struct_name properties\n * @returns The MoveStructId\n */\nexport const parseEncodedStruct = (structObj: {\n account_address: string;\n module_name: string;\n struct_name: string;\n}): MoveStructId => {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { account_address, module_name, struct_name } = structObj;\n const moduleName = hexToAscii(module_name);\n const structName = hexToAscii(struct_name);\n return `${account_address}::${moduleName}::${structName}`;\n};\n\n/**\n * Determines whether the given object is an encoded struct type with the following properties:\n * - account_address: string\n * - module_name: string\n * - struct_name: string\n *\n * @param structObj The object to check\n * @returns Whether the object is an encoded struct type\n */\nexport const isEncodedStruct = (\n structObj: any,\n): structObj is {\n account_address: string;\n module_name: string;\n struct_name: string;\n} =>\n typeof structObj === \"object\" &&\n !Array.isArray(structObj) &&\n structObj !== null &&\n \"account_address\" in structObj &&\n \"module_name\" in structObj &&\n \"struct_name\" in structObj &&\n typeof structObj.account_address === \"string\" &&\n typeof structObj.module_name === \"string\" &&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,GACrB,gBAAiBA,GACjB,gBAAiBA,GACjB,OAAOA,EAAU,iBAAoB,UACrC,OAAOA,EAAU,aAAgB,UACjC,OAAOA,EAAU,aAAgB","names":["decode","sleep","timeMs","resolve","nowInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64","convertAmountFromHumanReadableToOnChain","value","decimal","convertAmountFromOnChainToHumanReadable","hexToAscii","hex","str","n","parseEncodedStruct","structObj","account_address","module_name","struct_name","moduleName","structName","isEncodedStruct"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as w}from"./chunk-5ZBHIUWG.mjs";import{a as f}from"./chunk-UKAXCARD.mjs";import{a as y}from"./chunk-37UZKMJI.mjs";import{n as u}from"./chunk-5CCHECTE.mjs";import{a as l}from"./chunk-N47FTRYO.mjs";import{b as c}from"./chunk-KM6UXNC7.mjs";import{jwtDecode as A}from"jwt-decode";var K=class o extends w{constructor(e){let r=y.create(e);super({publicKey:r,...e}),this.publicKey=r}serialize(e){if(this.proof===void 0)throw new Error("Cannot serialize - proof undefined");e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.publicKey.jwkAddress.serialize(e),this.ephemeralKeyPair.serialize(e),this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeStr(),s=e.deserializeFixedBytes(31),a=c.deserialize(e),d=f.deserialize(e),n=u.deserialize(e);return o.create({proof:n,pepper:s,jwkAddress:a,uidKey:i,jwt:r,ephemeralKeyPair:d})}static fromBytes(e){return o.deserialize(new l(e))}static create(e){let{address:r,proof:i,jwt:s,ephemeralKeyPair:a,pepper:d,jwkAddress:n,uidKey:p="sub",proofFetchCallback:m}=e,t=A(s);if(typeof t.iss!="string")throw new Error("iss was not found");if(typeof t.aud!="string")throw new Error("aud was not found or an array of values");let h=t[p];return new o({address:r,proof:i,ephemeralKeyPair:a,iss:t.iss,uidKey:p,uidVal:h,aud:t.aud,pepper:d,jwkAddress:c.from(n),jwt:s,proofFetchCallback:m})}};export{K as a};
|
|
2
|
-
//# sourceMappingURL=chunk-LZS7BQ2B.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/account/FederatedKeylessAccount.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { HexInput } from \"../types\";\nimport { AccountAddress, AccountAddressInput } from \"../core/accountAddress\";\nimport { ZeroKnowledgeSig } from \"../core/crypto\";\n\nimport { EphemeralKeyPair } from \"./EphemeralKeyPair\";\nimport { Deserializer, Serializer } from \"../bcs\";\nimport { FederatedKeylessPublicKey } from \"../core/crypto/federatedKeyless\";\nimport { AbstractKeylessAccount, ProofFetchCallback } from \"./AbstractKeylessAccount\";\n\n/**\n * Account implementation for the FederatedKeyless authentication scheme.\n *\n * Used to represent a FederatedKeyless based account and sign transactions with it.\n *\n * Use `FederatedKeylessAccount.create()` to instantiate a KeylessAccount with a JWT, proof, EphemeralKeyPair and the\n * address the JWKs are installed that will be used to verify the JWT.\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 FederatedKeylessAccount extends AbstractKeylessAccount {\n /**\n * The FederatedKeylessPublicKey associated with the account\n */\n readonly publicKey: FederatedKeylessPublicKey;\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 jwkAddress: AccountAddress;\n proof: ZeroKnowledgeSig | Promise<ZeroKnowledgeSig>;\n proofFetchCallback?: ProofFetchCallback;\n jwt: string;\n }) {\n const publicKey = FederatedKeylessPublicKey.create(args);\n super({ publicKey, ...args });\n this.publicKey = publicKey;\n }\n\n serialize(serializer: Serializer): void {\n if (this.proof === undefined) {\n throw new Error(\"Cannot serialize - proof undefined\");\n }\n serializer.serializeStr(this.jwt);\n serializer.serializeStr(this.uidKey);\n serializer.serializeFixedBytes(this.pepper);\n this.publicKey.jwkAddress.serialize(serializer);\n this.ephemeralKeyPair.serialize(serializer);\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): FederatedKeylessAccount {\n const jwt = deserializer.deserializeStr();\n const uidKey = deserializer.deserializeStr();\n const pepper = deserializer.deserializeFixedBytes(31);\n const jwkAddress = AccountAddress.deserialize(deserializer);\n const ephemeralKeyPair = EphemeralKeyPair.deserialize(deserializer);\n const proof = ZeroKnowledgeSig.deserialize(deserializer);\n return FederatedKeylessAccount.create({\n proof,\n pepper,\n jwkAddress,\n uidKey,\n jwt,\n ephemeralKeyPair,\n });\n }\n\n static fromBytes(bytes: Uint8Array): FederatedKeylessAccount {\n return FederatedKeylessAccount.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 jwkAddress: AccountAddressInput;\n uidKey?: string;\n proofFetchCallback?: ProofFetchCallback;\n }): FederatedKeylessAccount {\n const { address, proof, jwt, ephemeralKeyPair, pepper, jwkAddress, uidKey = \"sub\", proofFetchCallback } = args;\n\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n if (typeof jwtPayload.iss !== \"string\") {\n throw new Error(\"iss was not found\");\n }\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const uidVal = jwtPayload[uidKey];\n return new FederatedKeylessAccount({\n address,\n proof,\n ephemeralKeyPair,\n iss: jwtPayload.iss,\n uidKey,\n uidVal,\n aud: jwtPayload.aud,\n pepper,\n jwkAddress: AccountAddress.from(jwkAddress),\n jwt,\n proofFetchCallback,\n });\n }\n}\n"],"mappings":"sPAGA,OAAqB,aAAAA,MAAiB,a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C,EAE3D,IAAME,EAASF,EAAWZ,CAAM,EAChC,OAAO,IAAIR,EAAwB,CACjC,QAAAkB,EACA,MAAAJ,EACA,iBAAAF,EACA,IAAKQ,EAAW,IAChB,OAAAZ,EACA,OAAAc,EACA,IAAKF,EAAW,IAChB,OAAAX,EACA,WAAYE,EAAe,KAAKD,CAAU,EAC1C,IAAAH,EACA,mBAAAY,CACF,CAAC,CACH,CACF","names":["jwtDecode","FederatedKeylessAccount","_FederatedKeylessAccount","AbstractKeylessAccount","args","publicKey","FederatedKeylessPublicKey","serializer","deserializer","jwt","uidKey","pepper","jwkAddress","AccountAddress","ephemeralKeyPair","EphemeralKeyPair","proof","ZeroKnowledgeSig","bytes","Deserializer","address","proofFetchCallback","jwtPayload","jwtDecode","uidVal"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=chunk-N2FKVZ4D.mjs.map
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as r}from"./chunk-56CNRT2K.mjs";var n=class{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let i=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,i}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeBool()?this.deserializeStr():void 0}deserializeOption(e){return this.deserializeBool()?this.deserialize(e):void 0}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),i=this.deserializeU32();return BigInt(BigInt(i)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),i=this.deserializeU64();return BigInt(i<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),i=this.deserializeU128();return BigInt(i<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),i=0;for(;e<r;){let t=this.deserializeU8();if(e|=BigInt(t&127)<<BigInt(i),!(t&128))break;i+=7}if(e>r)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let i=this.deserializeUleb128AsU32(),t=new Array;for(let s=0;s<i;s+=1)t.push(this.deserialize(e));return t}};export{n as a};
|
|
2
|
-
//# sourceMappingURL=chunk-N47FTRYO.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bcs/deserializer.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport { MAX_U32_NUMBER } from \"./consts\";\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256 } from \"../types\";\n\n/**\n * This interface exists to define Deserializable<T> inputs for functions that\n * deserialize a byte buffer into a type T.\n * It is not intended to be implemented or extended, because Typescript has no support\n * for static methods in interfaces.\n *\n * @template T - The type that this will deserialize into.\n */\nexport interface Deserializable<T> {\n /**\n * Deserializes the buffered bytes into an instance of the specified class type.\n * This function provides an alternative syntax for deserialization, allowing users to call\n * `deserializer.deserialize(MyClass)` instead of `MyClass.deserialize(deserializer)`.\n *\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @returns The deserialized value of class type T.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * ```\n */\n deserialize(deserializer: Deserializer): T;\n}\n\n/**\n * A class that provides methods for deserializing various data types from a byte buffer.\n * It supports deserialization of primitive types, strings, and complex objects using a BCS (Binary Common Serialization) layout.\n */\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Creates a new instance of the class with a copy of the provided data buffer.\n * This prevents outside mutation of the buffer.\n *\n * @param data - The data to be copied into the internal buffer as a Uint8Array.\n */\n constructor(data: Uint8Array) {\n // copies data to prevent outside mutation of buffer.\n this.buffer = new ArrayBuffer(data.length);\n new Uint8Array(this.buffer).set(data, 0);\n this.offset = 0;\n }\n\n /**\n * Reads a specified number of bytes from the buffer and advances the offset.\n *\n * @param length - The number of bytes to read from the buffer.\n * @throws Throws an error if the read operation exceeds the buffer's length.\n */\n private read(length: number): ArrayBuffer {\n if (this.offset + length > this.buffer.byteLength) {\n throw new Error(\"Reached to the end of buffer\");\n }\n\n const bytes = this.buffer.slice(this.offset, this.offset + length);\n this.offset += length;\n return bytes;\n }\n\n /**\n * Returns the number of bytes remaining in the buffer.\n *\n * This information is useful to determine if there's more data to be read.\n *\n * @returns The number of bytes remaining in the buffer.\n */\n remaining(): number {\n return this.buffer.byteLength - this.offset;\n }\n\n /**\n * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes,\n * followed by the actual byte content, and decodes it into a string.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeStr() === \"1234abcd\");\n * ```\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * Deserializes an optional string.\n *\n * The BCS layout for Optional<String> is 0 if none, else 1 followed by the string length and string content.\n * @returns The deserialized string if it exists, otherwise undefined.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00]));\n * assert(deserializer.deserializeOptionStr() === undefined);\n * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeOptionStr() === \"1234abcd\");\n * ```\n */\n deserializeOptionStr(): string | undefined {\n const exists = this.deserializeBool();\n return exists ? this.deserializeStr() : undefined;\n }\n\n /**\n * Deserializes an optional deserializable class.\n *\n * BCS layout for Optional<T>: 0 if none, else 1 | BCS representation of class.\n *\n * @example\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n *\n * const deserializer = new Deserializer(new Uint8Array([0]));\n * const value = deserializer.deserializeOption(MyClass); // where MyClass has a `deserialize` function\n * // value is undefined\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns The deserialized value of class type T or undefined if no value exists.\n */\n deserializeOption<T>(cls: Deserializable<T>): T | undefined {\n const exists = this.deserializeBool();\n return exists ? this.deserialize(cls) : undefined;\n }\n\n /**\n * Deserializes an array of bytes.\n *\n * The BCS layout for \"bytes\" consists of a bytes_length followed by the bytes themselves, where bytes_length is a u32 integer\n * encoded as a uleb128 integer, indicating the length of the bytes array.\n *\n * @returns {Uint8Array} The deserialized array of bytes.\n */\n deserializeBytes(): Uint8Array {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes of a specified length.\n *\n * @param len - The number of bytes to read from the source.\n */\n deserializeFixedBytes(len: number): Uint8Array {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value from a byte stream.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n * An error is thrown if the byte value is not valid.\n *\n * @returns The deserialized boolean value.\n * @throws Throws an error if the boolean value is invalid.\n */\n deserializeBool(): boolean {\n const bool = new Uint8Array(this.read(1))[0];\n if (bool !== 1 && bool !== 0) {\n throw new Error(\"Invalid boolean value\");\n }\n return bool === 1;\n }\n\n /**\n * Deserializes a uint8 number from the binary data.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @returns {number} The deserialized uint8 number.\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint16\": Two bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint32\": Four bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * This function combines two 32-bit values to return a 64-bit unsigned integer in little-endian representation.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\n */\n deserializeU64(): Uint64 {\n const low = this.deserializeU32();\n const high = this.deserializeU32();\n\n // combine the two 32-bit values and return (little endian)\n return BigInt((BigInt(high) << BigInt(32)) | BigInt(low));\n }\n\n /**\n * Deserializes a uint128 number from its binary representation.\n * This function combines two 64-bit values to return a single uint128 value in little-endian format.\n *\n * @returns {BigInt} The deserialized uint128 number.\n */\n deserializeU128(): Uint128 {\n const low = this.deserializeU64();\n const high = this.deserializeU64();\n\n // combine the two 64-bit values and return (little endian)\n return BigInt((high << BigInt(64)) | low);\n }\n\n /**\n * Deserializes a uint256 number from its binary representation.\n *\n * The BCS layout for \"uint256\" consists of thirty-two bytes in little-endian format.\n *\n * @returns {BigInt} The deserialized uint256 number.\n */\n deserializeU256(): Uint256 {\n const low = this.deserializeU128();\n const high = this.deserializeU128();\n\n // combine the two 128-bit values and return (little endian)\n return BigInt((high << BigInt(128)) | low);\n }\n\n /**\n * Deserializes a uleb128 encoded uint32 number.\n *\n * This function is used for interpreting lengths of variable-length sequences and tags of enum values in BCS encoding.\n *\n * @throws {Error} Throws an error if the parsed value exceeds the maximum uint32 number.\n * @returns {number} The deserialized uint32 value.\n */\n deserializeUleb128AsU32(): Uint32 {\n let value: bigint = BigInt(0);\n let shift = 0;\n\n while (value < MAX_U32_NUMBER) {\n const byte = this.deserializeU8();\n value |= BigInt(byte & 0x7f) << BigInt(shift);\n\n if ((byte & 0x80) === 0) {\n break;\n }\n shift += 7;\n }\n\n if (value > MAX_U32_NUMBER) {\n throw new Error(\"Overflow while parsing uleb128-encoded uint32 value\");\n }\n\n return Number(value);\n }\n\n /**\n * Helper function that primarily exists to support alternative syntax for deserialization.\n * That is, if we have a `const deserializer: new Deserializer(...)`, instead of having to use\n * `MyClass.deserialize(deserializer)`, we can call `deserializer.deserialize(MyClass)`.\n *\n * @example const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns the deserialized value of class type T\n */\n deserialize<T>(cls: Deserializable<T>): T {\n // NOTE: `deserialize` in `cls.deserialize(this)` here is a static method defined in `cls`,\n // It is separate from the `deserialize` instance method defined here in Deserializer.\n return cls.deserialize(this);\n }\n\n /**\n * Deserializes an array of BCS Deserializable values given an existing Deserializer instance with a loaded byte buffer.\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n * @returns An array of deserialized values of type T.\n * @example\n * // serialize a vector of addresses\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n *\n * // deserialize the bytes into an array of addresses\n * const deserializer = new Deserializer(serializedBytes);\n * const deserializedAddresses = deserializer.deserializeVector(AccountAddress);\n * // deserializedAddresses is now an array of AccountAddress instances\n */\n deserializeVector<T>(cls: Deserializable<T>): Array<T> {\n const length = this.deserializeUleb128AsU32();\n const vector = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n vector.push(this.deserialize(cls));\n }\n return vector;\n }\n}\n"],"mappings":"yCAsCO,IAAMA,EAAN,KAAmB,CAWxB,YAAYC,EAAkB,CAE5B,KAAK,OAAS,IAAI,YAAYA,EAAK,MAAM,EACzC,IAAI,WAAW,KAAK,MAAM,EAAE,IAAIA,EAAM,CAAC,EACvC,KAAK,OAAS,CAChB,CAQQ,KAAKC,EAA6B,CACxC,GAAI,KAAK,OAASA,EAAS,KAAK,OAAO,WACrC,MAAM,IAAI,MAAM,8BAA8B,EAGhD,IAAMC,EAAQ,KAAK,OAAO,MAAM,KAAK,OAAQ,KAAK,OAASD,CAAM,EACjE,YAAK,QAAUA,EACRC,CACT,CASA,WAAoB,CAClB,OAAO,KAAK,OAAO,WAAa,KAAK,MACvC,CAeA,gBAAyB,CACvB,IAAMC,EAAQ,KAAK,iBAAiB,EAEpC,OADoB,IAAI,YAAY,EACjB,OAAOA,CAAK,CACjC,CAeA,sBAA2C,CAEzC,OADe,KAAK,gBAAgB,EACpB,KAAK,eAAe,EAAI,MAC1C,CAoBA,kBAAqBC,EAAuC,CAE1D,OADe,KAAK,gBAAgB,EACpB,KAAK,YAAYA,CAAG,EAAI,MAC1C,CAUA,kBAA+B,CAC7B,IAAMC,EAAM,KAAK,wBAAwB,EACzC,OAAO,IAAI,WAAW,KAAK,KAAKA,CAAG,CAAC,CACtC,CA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OAAO,OAAOP,CAAK,CACrB,CAeA,YAAeC,EAA2B,CAGxC,OAAOA,EAAI,YAAY,IAAI,CAC7B,CAwBA,kBAAqBA,EAAkC,CACrD,IAAMH,EAAS,KAAK,wBAAwB,EACtCW,EAAS,IAAI,MACnB,QAASC,EAAI,EAAGA,EAAIZ,EAAQY,GAAK,EAC/BD,EAAO,KAAK,KAAK,YAAYR,CAAG,CAAC,EAEnC,OAAOQ,CACT,CACF","names":["Deserializer","data","length","bytes","value","cls","len","bool","low","high","shift","MAX_U32_NUMBER","byte","vector","i"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/get.ts"],"sourcesContent":["import { AptosConfig } from \"../api/aptosConfig\";\nimport { aptosRequest } from \"./core\";\nimport { AptosResponse } from \"./types\";\nimport { AnyNumber, ClientConfig, MimeType } from \"../types\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * Options for making a GET request, including configuration for the API client.\n */\nexport type GetRequestOptions = {\n /**\n * The config for the API client\n */\n aptosConfig: AptosConfig;\n /**\n * The type of API endpoint to call e.g. fullnode, indexer, etc\n */\n type: AptosApiType;\n /**\n * The name of the API method\n */\n originMethod: string;\n /**\n * The URL path to the API method\n */\n path: string;\n /**\n * The content type of the request body\n */\n contentType?: MimeType;\n /**\n * The accepted content type of the response of the API\n */\n acceptType?: MimeType;\n /**\n * The query parameters for the request\n */\n params?: Record<string, string | AnyNumber | boolean | undefined>;\n /**\n * Specific client overrides for this request to override aptosConfig\n */\n overrides?: ClientConfig;\n};\n\n/**\n * Options for making a request to the Aptos API, excluding the \"type\" field.\n */\nexport type GetAptosRequestOptions = Omit<GetRequestOptions, \"type\">;\n\n/**\n * Executes a GET request to retrieve data based on the provided options.\n *\n * @param options - The options for the GET request.\n * @param options.aptosConfig - The configuration object for Aptos requests.\n * @param options.overrides - Optional overrides for the request configuration.\n * @param options.params - Query parameters to include in the request.\n * @param options.contentType - The content type of the request.\n * @param options.acceptType - The accepted response type.\n * @param options.path - The specific path for the request.\n * @param options.originMethod - The original method of the request.\n * @param options.type - The type of request being made.\n * @returns The response from the GET request.\n */\nexport async function get<Req extends {}, Res extends {}>(\n options: GetRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig, overrides, params, contentType, acceptType, path, originMethod, type } = options;\n const url = aptosConfig.getRequestUrl(type);\n\n return aptosRequest<Req, Res>(\n {\n url,\n method: \"GET\",\n originMethod,\n path,\n contentType,\n acceptType,\n params,\n overrides: {\n ...aptosConfig.clientConfig,\n ...overrides,\n },\n },\n aptosConfig,\n options.type,\n );\n}\n\n/**\n * Retrieves data from the Aptos full node using the provided options.\n *\n * @param options - The options for the request to the Aptos full node.\n * @param options.aptosConfig - Configuration settings specific to the Aptos client and full node.\n * @param options.aptosConfig.clientConfig - The client configuration settings.\n * @param options.aptosConfig.fullnodeConfig - The full node configuration settings.\n * @param options.overrides - Additional overrides for the request.\n * @param options.type - The type of API request being made.\n *\n * @returns A promise that resolves with the response from the Aptos full node.\n */\nexport async function getAptosFullNode<Req extends {}, Res extends {}>(\n options: GetAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n\n return get<Req, Res>({\n ...options,\n type: AptosApiType.FULLNODE,\n overrides: {\n ...aptosConfig.clientConfig,\n ...aptosConfig.fullnodeConfig,\n ...options.overrides,\n HEADERS: { ...aptosConfig.clientConfig?.HEADERS, ...aptosConfig.fullnodeConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Makes a GET request to the Aptos Pepper service to retrieve data.\n *\n * @param options - The options for the request.\n * @param options.param1 - Description of param1.\n * @param options.param2 - Description of param2.\n * @returns AptosResponse - The response from the Aptos Pepper service.\n */\nexport async function getAptosPepperService<Req extends {}, Res extends {}>(\n options: GetAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n return get<Req, Res>({ ...options, type: AptosApiType.PEPPER });\n}\n\n/// This function is a helper for paginating using a function wrapping an API\nexport async function paginateWithCursor<Req extends Record<string, any>, Res extends Array<{}>>(\n options: GetAptosRequestOptions,\n): Promise<Res> {\n const out: any[] = [];\n let cursor: string | undefined;\n const requestParams = options.params as { start?: string; limit?: number };\n do {\n // eslint-disable-next-line no-await-in-loop\n const response = await get<Req, Res>({\n type: AptosApiType.FULLNODE,\n aptosConfig: options.aptosConfig,\n originMethod: options.originMethod,\n path: options.path,\n params: requestParams,\n overrides: options.overrides,\n });\n /**\n * the cursor is a \"state key\" from the API perspective. Client\n * should not need to \"care\" what it represents but just use it\n * to query the next chunk of data.\n */\n cursor = response.headers[\"x-aptos-cursor\"];\n // Now that we have the cursor (if any), we remove the headers before\n // adding these to the output of this function.\n delete response.headers;\n out.push(...response.data);\n requestParams.start = cursor;\n } while (cursor !== null && cursor !== undefined);\n return out as Res;\n}\n"],"mappings":"yCA+DA,eAAsBA,EACpBC,EACkC,CAClC,GAAM,CAAE,YAAAC,EAAa,UAAAC,EAAW,OAAAC,EAAQ,YAAAC,EAAa,WAAAC,EAAY,KAAAC,EAAM,aAAAC,EAAc,KAAAC,CAAK,EAAIR,EACxFS,EAAMR,EAAY,cAAcO,CAAI,EAE1C,OAAOE,EACL,CACE,IAAAD,EACA,OAAQ,MACR,aAAAF,EACA,KAAAD,EACA,YAAAF,EACA,WAAAC,EACA,OAAAF,EACA,UAAW,CACT,GAAGF,EAAY,aACf,GAAGC,CACL,CACF,EACAD,EACAD,EAAQ,IACV,CACF,CAcA,eAAsBW,EACpBX,EACkC,CAClC,GAAM,CAAE,YAAAC,CAAY,EAAID,EAExB,OAAOD,EAAc,CACnB,GAAGC,EACH,gBACA,UAAW,CACT,GAAGC,EAAY,aACf,GAAGA,EAAY,eACf,GAAGD,EAAQ,UACX,QAAS,CAAE,GAAGC,EAAY,cAAc,QAAS,GAAGA,EAAY,gBAAgB,OAAQ,CAC1F,CACF,CAAC,CACH,CAUA,eAAsBW,EACpBZ,EACkC,CAClC,OAAOD,EAAc,CAAE,GAAGC,EAAS,aAA0B,CAAC,CAChE,CAGA,eAAsBa,EACpBb,EACc,CACd,IAAMc,EAAa,CAAC,EAChBC,EACEC,EAAgBhB,EAAQ,OAC9B,EAAG,CAED,IAAMiB,EAAW,MAAMlB,EAAc,CACnC,gBACA,YAAaC,EAAQ,YACrB,aAAcA,EAAQ,aACtB,KAAMA,EAAQ,KACd,OAAQgB,EACR,UAAWhB,EAAQ,SACrB,CAAC,EAMDe,EAASE,EAAS,QAAQ,gBAAgB,EAG1C,OAAOA,EAAS,QAChBH,EAAI,KAAK,GAAGG,EAAS,IAAI,EACzBD,EAAc,MAAQD,CACxB,OAASA,GAAW,MACpB,OAAOD,CACT","names":["get","options","aptosConfig","overrides","params","contentType","acceptType","path","originMethod","type","url","aptosRequest","getAptosFullNode","getAptosPepperService","paginateWithCursor","out","cursor","requestParams","response"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-IFHQSZLK.mjs";import{a as b,b as g}from"./chunk-WIXNX7HY.mjs";import{b as h,d as p}from"./chunk-WSVOJSAC.mjs";import{b as a}from"./chunk-KM6UXNC7.mjs";import{a as y}from"./chunk-QQIVWB6G.mjs";var n=class extends y{static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return o.load(e);case 1:return d.load(e);case 2:return u.load(e);case 3:return l.load(e);case 4:return A.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${r}`)}}},o=class s extends n{constructor(e,r){super(),this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=h.deserialize(e),t=p.deserialize(e);return new s(r,t)}},d=class s extends n{constructor(e,r){super(),this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=b.deserialize(e),t=g.deserialize(e);return new s(r,t)}},u=class s extends n{constructor(e,r,t){super(),this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=t}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=i.deserialize(e),t=e.deserializeVector(a),c=e.deserializeVector(i);return new s(r,t,c)}},l=class s extends n{constructor(e,r,t,c){super(),this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=t,this.fee_payer=c}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let r=i.deserialize(e),t=e.deserializeVector(a),c=e.deserializeVector(i),_=a.deserialize(e),z=i.deserialize(e),S={address:_,authenticator:z};return new s(r,t,c,S)}},A=class s extends n{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=i.deserialize(e);return new s(r)}};export{n as a,o as b,d as c,u as d,l as e,A as f};
|
|
2
|
-
//# sourceMappingURL=chunk-OS2EG6AE.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/authenticator/transaction.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable @typescript-eslint/naming-convention */\n\nimport { AccountAuthenticator } from \"./account\";\nimport { Deserializer, Serializable, Serializer } from \"../../bcs\";\nimport { AccountAddress } from \"../../core\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"../../core/crypto/ed25519\";\nimport { MultiEd25519PublicKey, MultiEd25519Signature } from \"../../core/crypto/multiEd25519\";\nimport { TransactionAuthenticatorVariant } from \"../../types\";\n\n/**\n * Represents an abstract base class for transaction authenticators.\n * This class provides methods for serializing and deserializing different types of transaction authenticators.\n *\n * @extends Serializable\n */\nexport abstract class TransactionAuthenticator extends Serializable {\n abstract serialize(serializer: Serializer): void;\n\n /**\n * Deserializes a TransactionAuthenticator from the provided deserializer.\n * This function helps in reconstructing the TransactionAuthenticator based on the variant index found in the serialized data.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n */\n static deserialize(deserializer: Deserializer): TransactionAuthenticator {\n const index = deserializer.deserializeUleb128AsU32();\n switch (index) {\n case TransactionAuthenticatorVariant.Ed25519:\n return TransactionAuthenticatorEd25519.load(deserializer);\n case TransactionAuthenticatorVariant.MultiEd25519:\n return TransactionAuthenticatorMultiEd25519.load(deserializer);\n case TransactionAuthenticatorVariant.MultiAgent:\n return TransactionAuthenticatorMultiAgent.load(deserializer);\n case TransactionAuthenticatorVariant.FeePayer:\n return TransactionAuthenticatorFeePayer.load(deserializer);\n case TransactionAuthenticatorVariant.SingleSender:\n return TransactionAuthenticatorSingleSender.load(deserializer);\n default:\n throw new Error(`Unknown variant index for TransactionAuthenticator: ${index}`);\n }\n }\n}\n\n/**\n * Represents a transaction authenticator using Ed25519 for a single signer transaction.\n * This class encapsulates the client's public key and the Ed25519 signature of a raw transaction.\n *\n * @param public_key - The client's public key.\n * @param signature - The Ed25519 signature of a raw transaction.\n * @see {@link https://aptos.dev/integration/creating-a-signed-transaction | Creating a Signed Transaction}\n * for details about generating a signature.\n */\nexport class TransactionAuthenticatorEd25519 extends TransactionAuthenticator {\n public readonly public_key: Ed25519PublicKey;\n\n public readonly signature: Ed25519Signature;\n\n /**\n * Creates an instance of the class with the specified account authenticator.\n *\n * @param public_key - The Ed25519PublicKey that will be used for authentication.\n * @param signature - The Ed25519Signature that will be used for authentication.\n */\n constructor(public_key: Ed25519PublicKey, signature: Ed25519Signature) {\n super();\n this.public_key = public_key;\n this.signature = signature;\n }\n\n /**\n * Serializes the transaction authenticator by encoding the sender information.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(TransactionAuthenticatorVariant.Ed25519);\n this.public_key.serialize(serializer);\n this.signature.serialize(serializer);\n }\n\n /**\n * Loads a TransactionAuthenticatorSingleSender instance from the provided deserializer.\n * This function helps in deserializing the sender information to create a transaction authenticator.\n *\n * @param deserializer - The deserializer used to extract the sender data.\n */\n static load(deserializer: Deserializer): TransactionAuthenticatorEd25519 {\n const public_key = Ed25519PublicKey.deserialize(deserializer);\n const signature = Ed25519Signature.deserialize(deserializer);\n return new TransactionAuthenticatorEd25519(public_key, signature);\n }\n}\n\n/**\n * Represents a transaction authenticator for multi-signature transactions using Ed25519.\n * This class is used to validate transactions that require multiple signatures from different signers.\n *\n * @param public_key - The public key of the client involved in the transaction.\n * @param signature - The multi-signature of the raw transaction.\n */\nexport class TransactionAuthenticatorMultiEd25519 extends TransactionAuthenticator {\n public readonly public_key: MultiEd25519PublicKey;\n\n public readonly signature: MultiEd25519Signature;\n\n constructor(public_key: MultiEd25519PublicKey, signature: MultiEd25519Signature) {\n super();\n this.public_key = public_key;\n this.signature = signature;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(TransactionAuthenticatorVariant.MultiEd25519);\n this.public_key.serialize(serializer);\n this.signature.serialize(serializer);\n }\n\n static load(deserializer: Deserializer): TransactionAuthenticatorMultiEd25519 {\n const public_key = MultiEd25519PublicKey.deserialize(deserializer);\n const signature = MultiEd25519Signature.deserialize(deserializer);\n return new TransactionAuthenticatorMultiEd25519(public_key, signature);\n }\n}\n\n/**\n * Represents a transaction authenticator for a multi-agent transaction.\n *\n * This class manages the authentication process involving a primary sender and multiple secondary signers.\n *\n * @param sender - The authenticator for the sender account.\n * @param secondary_signer_addresses - An array of addresses for the secondary signers.\n * @param secondary_signers - An array of authenticators for the secondary signer accounts.\n */\nexport class TransactionAuthenticatorMultiAgent extends TransactionAuthenticator {\n public readonly sender: AccountAuthenticator;\n\n public readonly secondary_signer_addresses: Array<AccountAddress>;\n\n public readonly secondary_signers: Array<AccountAuthenticator>;\n\n constructor(\n sender: AccountAuthenticator,\n secondary_signer_addresses: Array<AccountAddress>,\n secondary_signers: Array<AccountAuthenticator>,\n ) {\n super();\n this.sender = sender;\n this.secondary_signer_addresses = secondary_signer_addresses;\n this.secondary_signers = secondary_signers;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(TransactionAuthenticatorVariant.MultiAgent);\n this.sender.serialize(serializer);\n serializer.serializeVector<AccountAddress>(this.secondary_signer_addresses);\n serializer.serializeVector<AccountAuthenticator>(this.secondary_signers);\n }\n\n static load(deserializer: Deserializer): TransactionAuthenticatorMultiAgent {\n const sender = AccountAuthenticator.deserialize(deserializer);\n const secondary_signer_addresses = deserializer.deserializeVector(AccountAddress);\n const secondary_signers = deserializer.deserializeVector(AccountAuthenticator);\n return new TransactionAuthenticatorMultiAgent(sender, secondary_signer_addresses, secondary_signers);\n }\n}\n\n/**\n * Represents a transaction authenticator specifically for fee payer transactions.\n * It encapsulates the sender's account authenticator, addresses of secondary signers,\n * their respective authenticators, and the fee payer's account information.\n *\n * @param sender - The authenticator for the sender's account.\n * @param secondary_signer_addresses - An array of addresses for secondary signers.\n * @param secondary_signers - An array of authenticators for secondary signers' accounts.\n * @param fee_payer - An object containing the fee payer's account address and authenticator.\n */\nexport class TransactionAuthenticatorFeePayer extends TransactionAuthenticator {\n public readonly sender: AccountAuthenticator;\n\n public readonly secondary_signer_addresses: Array<AccountAddress>;\n\n public readonly secondary_signers: Array<AccountAuthenticator>;\n\n public readonly fee_payer: {\n address: AccountAddress;\n authenticator: AccountAuthenticator;\n };\n\n constructor(\n sender: AccountAuthenticator,\n secondary_signer_addresses: Array<AccountAddress>,\n secondary_signers: Array<AccountAuthenticator>,\n fee_payer: { address: AccountAddress; authenticator: AccountAuthenticator },\n ) {\n super();\n this.sender = sender;\n this.secondary_signer_addresses = secondary_signer_addresses;\n this.secondary_signers = secondary_signers;\n this.fee_payer = fee_payer;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(TransactionAuthenticatorVariant.FeePayer);\n this.sender.serialize(serializer);\n serializer.serializeVector<AccountAddress>(this.secondary_signer_addresses);\n serializer.serializeVector<AccountAuthenticator>(this.secondary_signers);\n this.fee_payer.address.serialize(serializer);\n this.fee_payer.authenticator.serialize(serializer);\n }\n\n static load(deserializer: Deserializer): TransactionAuthenticatorMultiAgent {\n const sender = AccountAuthenticator.deserialize(deserializer);\n const secondary_signer_addresses = deserializer.deserializeVector(AccountAddress);\n const secondary_signers = deserializer.deserializeVector(AccountAuthenticator);\n const address = AccountAddress.deserialize(deserializer);\n const authenticator = AccountAuthenticator.deserialize(deserializer);\n const fee_payer = { address, authenticator };\n return new TransactionAuthenticatorFeePayer(sender, secondary_signer_addresses, secondary_signers, fee_payer);\n }\n}\n\n/**\n * Represents a single sender authenticator for transactions that require a single signer.\n * This class is responsible for managing the authentication of a transaction initiated by a single sender.\n *\n * @param sender - An instance of AccountAuthenticator that represents the account of the sender.\n */\nexport class TransactionAuthenticatorSingleSender extends TransactionAuthenticator {\n public readonly sender: AccountAuthenticator;\n\n constructor(sender: AccountAuthenticator) {\n super();\n this.sender = sender;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(TransactionAuthenticatorVariant.SingleSender);\n this.sender.serialize(serializer);\n }\n\n static load(deserializer: Deserializer): TransactionAuthenticatorSingleSender {\n const sender = AccountAuthenticator.deserialize(deserializer);\n return new TransactionAuthenticatorSingleSender(sender);\n }\n}\n"],"mappings":"2NAkBO,IAAeA,EAAf,cAAgDC,CAAa,CASlE,OAAO,YAAYC,EAAsD,CACvE,IAAMC,EAAQD,EAAa,wBAAwB,EACnD,OAAQC,EAAO,CACb,OACE,OAAOC,EAAgC,KAAKF,CAAY,EAC1D,OACE,OAAOG,EAAqC,KAAKH,CAAY,EAC/D,OACE,OAAOI,EAAmC,KAAKJ,CAAY,EAC7D,OACE,OAAOK,EAAiC,KAAKL,CAAY,EAC3D,OACE,OAAOM,EAAqC,KAAKN,CAAY,EAC/D,QACE,MAAM,IAAI,MAAM,uDAAuDC,CAAK,EAAE,CAClF,CACF,CACF,EAWaC,EAAN,MAAMK,UAAwCT,CAAyB,CAW5E,YAAYU,EAA8BC,EAA6B,CACrE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,EAAN,MAAMiB,UAAyCxB,CAAyB,CAY7E,YACEmB,EACAC,EACAC,EACAI,EACA,CACA,MAAM,EACN,KAAK,OAASN,EACd,KAAK,2BAA6BC,EAClC,KAAK,kBAAoBC,EACzB,KAAK,UAAYI,CACnB,CAEA,UAAUb,EAA8B,CACtCA,EAAW,uBAA8D,EACzE,KAAK,OAAO,UAAUA,CAAU,EAChCA,EAAW,gBAAgC,KAAK,0BAA0B,EAC1EA,EAAW,gBAAsC,KAAK,iBAAiB,EACvE,KAAK,UAAU,QAAQ,UAAUA,CAAU,EAC3C,KAAK,UAAU,cAAc,UAAUA,CAAU,CACnD,CAEA,OAAO,KAAKV,EAAgE,CAC1E,IAAMiB,EAASG,EAAqB,YAAYpB,CAAY,EACtDkB,EAA6BlB,EAAa,kBAAkBqB,CAAc,EAC1EF,EAAoBnB,EAAa,kBAAkBoB,CAAoB,EACvEI,EAAUH,EAAe,YAAYrB,CAAY,EACjDyB,EAAgBL,EAAqB,YAAYpB,CAAY,EAC7DuB,EAAY,CAAE,QAAAC,EAAS,cAAAC,CAAc,EAC3C,OAAO,IAAIH,EAAiCL,EAAQC,EAA4BC,EAAmBI,CAAS,CAC9G,CACF,EAQajB,EAAN,MAAMoB,UAA6C5B,CAAyB,CAGjF,YAAYmB,EAA8B,CACxC,MAAM,EACN,KAAK,OAASA,CAChB,CAEA,UAAUP,EAA8B,CACtCA,EAAW,uBAAkE,EAC7E,KAAK,OAAO,UAAUA,CAAU,CAClC,CAEA,OAAO,KAAKV,EAAkE,CAC5E,IAAMiB,EAASG,EAAqB,YAAYpB,CAAY,EAC5D,OAAO,IAAI0B,EAAqCT,CAAM,CACxD,CACF","names":["TransactionAuthenticator","Serializable","deserializer","index","TransactionAuthenticatorEd25519","TransactionAuthenticatorMultiEd25519","TransactionAuthenticatorMultiAgent","TransactionAuthenticatorFeePayer","TransactionAuthenticatorSingleSender","_TransactionAuthenticatorEd25519","public_key","signature","serializer","Ed25519PublicKey","Ed25519Signature","_TransactionAuthenticatorMultiEd25519","MultiEd25519PublicKey","MultiEd25519Signature","_TransactionAuthenticatorMultiAgent","sender","secondary_signer_addresses","secondary_signers","AccountAuthenticator","AccountAddress","_TransactionAuthenticatorFeePayer","fee_payer","address","authenticator","_TransactionAuthenticatorSingleSender"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/transactionSubmission/build.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AccountAddressInput } from \"../../core\";\nimport { generateTransaction } from \"../../internal/transactionSubmission\";\nimport { InputGenerateTransactionPayloadData, InputGenerateTransactionOptions } from \"../../transactions\";\nimport { MultiAgentTransaction } from \"../../transactions/instances/multiAgentTransaction\";\nimport { SimpleTransaction } from \"../../transactions/instances/simpleTransaction\";\nimport { AptosConfig } from \"../aptosConfig\";\n\n/**\n * A class to handle all `Build` transaction operations.\n */\nexport class Build {\n readonly config: AptosConfig;\n\n /**\n * Initializes a new instance of the Aptos client with the specified configuration.\n * This allows you to interact with the Aptos blockchain using the provided settings.\n *\n * @param config - The configuration settings for the Aptos client.\n * @param config.network - The network to connect to (e.g., TESTNET, MAINNET).\n * @param config.nodeUrl - The URL of the Aptos node to connect to.\n * @param config.account - The account details for authentication.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for the Aptos client\n * const config = new AptosConfig({\n * network: Network.TESTNET, // specify the network\n * nodeUrl: \"https://testnet.aptos.dev\", // specify the node URL\n * });\n *\n * // Initialize the Aptos client\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n */\n constructor(config: AptosConfig) {\n this.config = config;\n }\n\n /**\n * Build a simple transaction.\n *\n * This function allows you to create a transaction with specified sender and data.\n *\n * @param args.sender - The sender account address.\n * @param args.data - The transaction data.\n * @param args.options - Optional transaction configurations.\n * @param args.withFeePayer - Whether there is a fee payer for the transaction.\n *\n * @returns SimpleTransaction\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Build a simple transaction\n * const transaction = await aptos.transaction.simple({\n * sender: \"0x1\", // replace with a real sender account address\n * data: {\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [\"0x2\", 100], // replace with a real destination account address\n * },\n * options: {\n * gasUnitPrice: 100, // specify your own gas unit price if needed\n * maxGasAmount: 1000, // specify your own max gas amount if needed\n * },\n * });\n *\n * console.log(transaction);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async simple(args: {\n sender: AccountAddressInput;\n data: InputGenerateTransactionPayloadData;\n options?: InputGenerateTransactionOptions;\n withFeePayer?: boolean;\n }): Promise<SimpleTransaction> {\n return generateTransaction({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Build a multi-agent transaction that allows multiple signers to authorize a transaction.\n *\n * @param args - The parameters for creating the multi-agent transaction.\n * @param args.sender - The sender account address.\n * @param args.data - The transaction data.\n * @param args.secondarySignerAddresses - An array of the secondary signers' account addresses.\n * @param args.options - Optional transaction configurations.\n * @param args.withFeePayer - Whether there is a fee payer for the transaction.\n *\n * @returns MultiAgentTransaction\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Build a multi-agent transaction\n * const transaction = await aptos.multiAgent({\n * sender: \"0x1\", // replace with a real sender account address\n * data: {\n * // Transaction data structure\n * function: \"0x1::aptos_account::transfer\",\n * functionArguments: [\"0x2\", 100], // replace with a real destination account address and amount\n * },\n * secondarySignerAddresses: [\"0x3\", \"0x4\"], // replace with real secondary signer addresses\n * options: {\n * // Optional transaction configurations\n * maxGasAmount: \"1000\",\n * gasUnitPrice: \"1\",\n * },\n * });\n *\n * console.log(transaction);\n * }\n * runExample().catch(console.error);\n * ```\n */\n async multiAgent(args: {\n sender: AccountAddressInput;\n data: InputGenerateTransactionPayloadData;\n secondarySignerAddresses: AccountAddressInput[];\n options?: InputGenerateTransactionOptions;\n withFeePayer?: boolean;\n }): Promise<MultiAgentTransaction> {\n return generateTransaction({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"yCAaO,IAAMA,EAAN,KAAY,CA+BjB,YAAYC,EAAqB,CAC/B,KAAK,OAASA,CAChB,CAwCA,MAAM,OAAOC,EAKkB,CAC7B,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CA2CA,MAAM,WAAWA,EAMkB,CACjC,OAAOC,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAClE,CACF","names":["Build","config","args","generateTransaction"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as l}from"./chunk-KRVLR3L4.mjs";import{a as k,b as c,d as A,e as g,f as P,g as z,h as D,i as m,j as L,l as R,m as X,n as q,o as H,p as J,q as K,s as i,t as Q}from"./chunk-N3OYD6VZ.mjs";import{c as j}from"./chunk-7D3RY73L.mjs";import{b as S,c as I,d as x,e as M,f as O,g as C,h as _,i as V,n as G}from"./chunk-OTY3NO7Q.mjs";import{a as y,c as F,d as s}from"./chunk-IECDO22V.mjs";import{a as w,b as h,c as B,d as E,e as v,f as $,g as b}from"./chunk-6FLHGOKP.mjs";import{b as d}from"./chunk-KM6UXNC7.mjs";var Y=new TextEncoder;function sn(n){return n?.map(e=>c(e)?l(e):e)??[]}async function W(n,e,t,u){let r=await j({aptosConfig:u,accountAddress:n,moduleName:e});if(r.abi)return r.abi.exposed_functions.find(o=>o.name===t)}async function fn(n,e,t,u){let r=await W(n,e,t,u);if(!r)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!r.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=Q(r),T=[];for(let f=o;f<r.params.length;f+=1)T.push(l(r.params[f],{allowGenerics:!0}));return{signers:o,typeParameters:r.generic_type_params,parameters:T}}async function on(n,e,t,u){let r=await W(n,e,t,u);if(!r)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!r.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let f=0;f<r.params.length;f+=1)o.push(l(r.params[f],{allowGenerics:!0}));let T=[];for(let f=0;f<r.return.length;f+=1)T.push(l(r.return[f],{allowGenerics:!0}));return{typeParameters:r.generic_type_params,parameters:o,returnTypes:T}}function cn(n,e,t,u,r){if(u>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);let o=e.parameters[u];return U(t,o,u,r)}function U(n,e,t,u){return z(n)?(p(e,n,t),n):Z(n,e,t,u)}function Z(n,e,t,u){if(e.isBool()){if(k(n))return new w(n);if(c(n)){if(n==="true")return new w(!0);if(n==="false")return new w(!1)}i("boolean",t)}if(e.isAddress()){if(c(n))return d.fromString(n);i("string | AccountAddress",t)}if(e.isU8()){let r=A(n);if(r!==void 0)return new h(r);i("number | string",t)}if(e.isU16()){let r=A(n);if(r!==void 0)return new B(r);i("number | string",t)}if(e.isU32()){let r=A(n);if(r!==void 0)return new E(r);i("number | string",t)}if(e.isU64()){if(g(n))return new v(BigInt(n));i("bigint | number | string",t)}if(e.isU128()){if(g(n))return new $(BigInt(n));i("bigint | number | string",t)}if(e.isU256()){if(g(n))return new b(BigInt(n));i("bigint | number | string",t)}if(e.isGeneric()){let r=e.value;if(r<0||r>=u.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return U(n,u[r],t,u)}if(e.isVector()){if(e.value.isU8()){if(c(n))return y.U8(Y.encode(n));if(n instanceof Uint8Array)return y.U8(n);if(n instanceof ArrayBuffer)return y.U8(new Uint8Array(n))}if(Array.isArray(n))return new y(n.map(r=>U(r,e.value,t,u)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(c(n))return new F(n);i("string",t)}if(e.isObject()){if(c(n))return d.fromString(n);i("string | AccountAddress",t)}if(e.isOption()){if(P(n)){let r=e.value.typeArgs[0];return r instanceof S?new s(null):r instanceof V?new s(null):r instanceof I?new s(null):r instanceof x?new s(null):r instanceof M?new s(null):r instanceof O?new s(null):r instanceof C?new s(null):r instanceof _?new s(null):new s(null)}return new s(U(n,e.value.typeArgs[0],t,u))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function p(n,e,t){if(n.isBool()){if(D(e))return;i("Bool",t)}if(n.isAddress()){if(m(e))return;i("AccountAddress",t)}if(n.isU8()){if(R(e))return;i("U8",t)}if(n.isU16()){if(X(e))return;i("U16",t)}if(n.isU32()){if(q(e))return;i("U32",t)}if(n.isU64()){if(H(e))return;i("U64",t)}if(n.isU128()){if(J(e))return;i("U128",t)}if(n.isU256()){if(K(e))return;i("U256",t)}if(n.isVector()){if(e instanceof y){e.values.length>0&&p(n.value,e.values[0],t);return}i("MoveVector",t)}if(n instanceof G){if(n.isString()){if(L(e))return;i("MoveString",t)}if(n.isObject()){if(m(e))return;i("AccountAddress",t)}if(n.isOption()){if(e instanceof s){e.value!==void 0&&p(n.value.typeArgs[0],e.value,t);return}i("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}export{sn as a,W as b,fn as c,on as d,cn as e,U as f};
|
|
2
|
-
//# sourceMappingURL=chunk-RUDS7RSB.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/transactionBuilder/remoteAbi.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { parseTypeTag } from \"../typeTag/parser\";\nimport {\n TypeTag,\n TypeTagAddress,\n TypeTagBool,\n TypeTagStruct,\n TypeTagU128,\n TypeTagU16,\n TypeTagU256,\n TypeTagU32,\n TypeTagU64,\n TypeTagU8,\n} from \"../typeTag\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport {\n EntryFunctionArgumentTypes,\n SimpleEntryFunctionArgumentTypes,\n EntryFunctionABI,\n ViewFunctionABI,\n FunctionABI,\n TypeArgument,\n} from \"../types\";\nimport { Bool, MoveOption, MoveString, MoveVector, U128, U16, U256, U32, U64, U8 } from \"../../bcs\";\nimport { AccountAddress } from \"../../core\";\nimport { getModule } from \"../../internal/account\";\nimport {\n findFirstNonSignerArg,\n isBcsAddress,\n isBcsBool,\n isBcsString,\n isBcsU128,\n isBcsU16,\n isBcsU256,\n isBcsU32,\n isBcsU64,\n isBcsU8,\n isBool,\n isEncodedEntryFunctionArgument,\n isLargeNumber,\n isEmptyOption,\n isString,\n throwTypeMismatch,\n convertNumber,\n} from \"./helpers\";\nimport { MoveFunction } from \"../../types\";\n\nconst TEXT_ENCODER = new TextEncoder();\n\n/**\n * Convert type arguments to only type tags, allowing for string representations of type tags.\n *\n * @param typeArguments - An optional array of type arguments that may include string representations.\n * @returns An array of TypeTag objects derived from the provided type arguments.\n */\nexport function standardizeTypeTags(typeArguments?: Array<TypeArgument>): Array<TypeTag> {\n return (\n typeArguments?.map((typeArg: TypeArgument): TypeTag => {\n // Convert to TypeTag if it's a string representation\n if (isString(typeArg)) {\n return parseTypeTag(typeArg);\n }\n return typeArg;\n }) ?? []\n );\n}\n\n/**\n * Fetches the ABI of a specified function from the on-chain module ABI. This function allows you to access the details of a\n * specific function within a module.\n *\n * @param moduleAddress - The address of the module from which to fetch the function ABI.\n * @param moduleName - The name of the module containing the function.\n * @param functionName - The name of the function whose ABI is to be fetched.\n * @param aptosConfig - The configuration settings for Aptos.\n */\nexport async function fetchFunctionAbi(\n moduleAddress: string,\n moduleName: string,\n functionName: string,\n aptosConfig: AptosConfig,\n): Promise<MoveFunction | undefined> {\n // This fetch from the API is currently cached\n const module = await getModule({ aptosConfig, accountAddress: moduleAddress, moduleName });\n\n if (module.abi) {\n return module.abi.exposed_functions.find((func) => func.name === functionName);\n }\n\n return undefined;\n}\n\n/**\n * Fetches the ABI for an entry function from the specified module address.\n * This function validates if the ABI corresponds to an entry function and retrieves its parameters.\n *\n * @param moduleAddress - The address of the module containing the entry function.\n * @param moduleName - The name of the module containing the entry function.\n * @param functionName - The name of the entry function to fetch the ABI for.\n * @param aptosConfig - The configuration settings for Aptos.\n * @returns An object containing the number of signers, type parameters, and function parameters.\n * @throws Error if the ABI cannot be found or if the function is not an entry function.\n */\nexport async function fetchEntryFunctionAbi(\n moduleAddress: string,\n moduleName: string,\n functionName: string,\n aptosConfig: AptosConfig,\n): Promise<EntryFunctionABI> {\n const functionAbi = await fetchFunctionAbi(moduleAddress, moduleName, functionName, aptosConfig);\n\n // If there's no ABI, then the function is invalid\n if (!functionAbi) {\n throw new Error(`Could not find entry function ABI for '${moduleAddress}::${moduleName}::${functionName}'`);\n }\n\n // Non-entry functions also can't be used\n if (!functionAbi.is_entry) {\n throw new Error(`'${moduleAddress}::${moduleName}::${functionName}' is not an entry function`);\n }\n\n // Remove the signer arguments\n const numSigners = findFirstNonSignerArg(functionAbi);\n const params: TypeTag[] = [];\n for (let i = numSigners; i < functionAbi.params.length; i += 1) {\n params.push(parseTypeTag(functionAbi.params[i], { allowGenerics: true }));\n }\n\n return {\n signers: numSigners,\n typeParameters: functionAbi.generic_type_params,\n parameters: params,\n };\n}\n\n/**\n * Fetches the ABI for a view function from the specified module address.\n * This function ensures that the ABI is valid and retrieves the type parameters, parameters, and return types for the view function.\n *\n * @param moduleAddress - The address of the module containing the view function.\n * @param moduleName - The name of the module containing the view function.\n * @param functionName - The name of the view function for which to fetch the ABI.\n * @param aptosConfig - The configuration settings for Aptos.\n * @returns An object containing the type parameters, parameters, and return types of the view function.\n * @throws Error if the ABI cannot be found or if the function is not a view function.\n */\nexport async function fetchViewFunctionAbi(\n moduleAddress: string,\n moduleName: string,\n functionName: string,\n aptosConfig: AptosConfig,\n): Promise<ViewFunctionABI> {\n const functionAbi = await fetchFunctionAbi(moduleAddress, moduleName, functionName, aptosConfig);\n\n // If there's no ABI, then the function is invalid\n if (!functionAbi) {\n throw new Error(`Could not find view function ABI for '${moduleAddress}::${moduleName}::${functionName}'`);\n }\n\n // Non-view functions can't be used\n if (!functionAbi.is_view) {\n throw new Error(`'${moduleAddress}::${moduleName}::${functionName}' is not an view function`);\n }\n\n // Type tag parameters for the function\n const params: TypeTag[] = [];\n for (let i = 0; i < functionAbi.params.length; i += 1) {\n params.push(parseTypeTag(functionAbi.params[i], { allowGenerics: true }));\n }\n\n // The return types of the view function\n const returnTypes: TypeTag[] = [];\n for (let i = 0; i < functionAbi.return.length; i += 1) {\n returnTypes.push(parseTypeTag(functionAbi.return[i], { allowGenerics: true }));\n }\n\n return {\n typeParameters: functionAbi.generic_type_params,\n parameters: params,\n returnTypes,\n };\n}\n\n/**\n * Converts a non-BCS encoded argument into BCS encoded, if necessary.\n * This function checks the provided argument against the expected parameter type and converts it accordingly.\n *\n * @param functionName - The name of the function for which the argument is being converted.\n * @param functionAbi - The ABI (Application Binary Interface) of the function, which defines its parameters.\n * @param arg - The argument to be converted, which can be of various types.\n * @param position - The index of the argument in the function's parameter list.\n * @param genericTypeParams - An array of type tags for any generic type parameters.\n */\nexport function convertArgument(\n functionName: string,\n functionAbi: FunctionABI,\n arg: EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes,\n position: number,\n genericTypeParams: Array<TypeTag>,\n) {\n // Ensure not too many arguments\n if (position >= functionAbi.parameters.length) {\n throw new Error(`Too many arguments for '${functionName}', expected ${functionAbi.parameters.length}`);\n }\n\n const param = functionAbi.parameters[position];\n return checkOrConvertArgument(arg, param, position, genericTypeParams);\n}\n\n/**\n * Checks if the provided argument is BCS encoded and converts it if necessary, ensuring type compatibility with the ABI.\n * This function helps in validating and converting arguments for entry functions based on their expected types.\n *\n * @param arg - The argument to check or convert, which can be either a simple or entry function argument type.\n * @param param - The expected type tag for the argument.\n * @param position - The position of the argument in the function call.\n * @param genericTypeParams - An array of generic type parameters that may be used for conversion.\n */\nexport function checkOrConvertArgument(\n arg: SimpleEntryFunctionArgumentTypes | EntryFunctionArgumentTypes,\n param: TypeTag,\n position: number,\n genericTypeParams: Array<TypeTag>,\n) {\n // If the argument is bcs encoded, we can just use it directly\n if (isEncodedEntryFunctionArgument(arg)) {\n // Ensure the type matches the ABI\n\n /**\n * Checks the type of the provided argument against the expected type.\n * This function helps validate that the argument conforms to the specified type requirements.\n *\n * @param typeArgs - The expected type arguments.\n * @param arg - The argument to be checked.\n * @param position - The position of the argument in the context of the check.\n */\n checkType(param, arg, position);\n return arg;\n }\n\n // If it is not BCS encoded, we will need to convert it with the ABI\n return parseArg(arg, param, position, genericTypeParams);\n}\n\n/**\n * Parses a non-BCS encoded argument into a BCS encoded argument recursively.\n * This function helps convert various types of input arguments into their corresponding BCS encoded formats based on the\n * specified parameter type.\n *\n * @param arg - The argument to be parsed, which can be of various types.\n * @param param - The type tag that defines the expected type of the argument.\n * @param position - The position of the argument in the function call, used for error reporting.\n * @param genericTypeParams - An array of type tags for generic type parameters, used when the parameter type is generic.\n */\nfunction parseArg(\n arg: SimpleEntryFunctionArgumentTypes,\n param: TypeTag,\n position: number,\n genericTypeParams: Array<TypeTag>,\n): EntryFunctionArgumentTypes {\n if (param.isBool()) {\n if (isBool(arg)) {\n return new Bool(arg);\n }\n if (isString(arg)) {\n if (arg === \"true\") return new Bool(true);\n if (arg === \"false\") return new Bool(false);\n }\n\n /**\n * Throws a type mismatch error for the specified move option.\n *\n * @param moveOption - The name of the move option that caused the type mismatch.\n * @param position - The position where the error occurred.\n */\n throwTypeMismatch(\"boolean\", position);\n }\n // TODO: support uint8array?\n if (param.isAddress()) {\n if (isString(arg)) {\n return AccountAddress.fromString(arg);\n }\n throwTypeMismatch(\"string | AccountAddress\", position);\n }\n if (param.isU8()) {\n const num = convertNumber(arg);\n if (num !== undefined) {\n return new U8(num);\n }\n throwTypeMismatch(\"number | string\", position);\n }\n if (param.isU16()) {\n const num = convertNumber(arg);\n if (num !== undefined) {\n return new U16(num);\n }\n throwTypeMismatch(\"number | string\", position);\n }\n if (param.isU32()) {\n const num = convertNumber(arg);\n if (num !== undefined) {\n return new U32(num);\n }\n throwTypeMismatch(\"number | string\", position);\n }\n if (param.isU64()) {\n if (isLargeNumber(arg)) {\n return new U64(BigInt(arg));\n }\n throwTypeMismatch(\"bigint | number | string\", position);\n }\n if (param.isU128()) {\n if (isLargeNumber(arg)) {\n return new U128(BigInt(arg));\n }\n throwTypeMismatch(\"bigint | number | string\", position);\n }\n if (param.isU256()) {\n if (isLargeNumber(arg)) {\n return new U256(BigInt(arg));\n }\n throwTypeMismatch(\"bigint | number | string\", position);\n }\n\n // Generic needs to use the subtype\n if (param.isGeneric()) {\n const genericIndex = param.value;\n if (genericIndex < 0 || genericIndex >= genericTypeParams.length) {\n throw new Error(`Generic argument ${param.toString()} is invalid for argument ${position}`);\n }\n\n return checkOrConvertArgument(arg, genericTypeParams[genericIndex], position, genericTypeParams);\n }\n\n // We have to special case some vectors for Vector<u8>\n if (param.isVector()) {\n // Check special case for Vector<u8>\n if (param.value.isU8()) {\n // We don't allow vector<u8>, but we convert strings to UTF8 Uint8Array\n // This is legacy behavior from the original SDK\n if (isString(arg)) {\n return MoveVector.U8(TEXT_ENCODER.encode(arg));\n }\n if (arg instanceof Uint8Array) {\n return MoveVector.U8(arg);\n }\n if (arg instanceof ArrayBuffer) {\n return MoveVector.U8(new Uint8Array(arg));\n }\n }\n\n // TODO: Support Uint16Array, Uint32Array, BigUint64Array?\n\n if (Array.isArray(arg)) {\n return new MoveVector(arg.map((item) => checkOrConvertArgument(item, param.value, position, genericTypeParams)));\n }\n\n throw new Error(`Type mismatch for argument ${position}, type '${param.toString()}'`);\n }\n\n // Handle structs as they're more complex\n if (param.isStruct()) {\n if (param.isString()) {\n if (isString(arg)) {\n return new MoveString(arg);\n }\n throwTypeMismatch(\"string\", position);\n }\n if (param.isObject()) {\n // The inner type of Object doesn't matter, since it's just syntactic sugar\n if (isString(arg)) {\n return AccountAddress.fromString(arg);\n }\n throwTypeMismatch(\"string | AccountAddress\", position);\n }\n\n if (param.isOption()) {\n if (isEmptyOption(arg)) {\n // Here we attempt to reconstruct the underlying type\n // Note, for some reason the `isBool` etc. does not work with the compiler\n const innerParam = param.value.typeArgs[0];\n if (innerParam instanceof TypeTagBool) {\n return new MoveOption<Bool>(null);\n }\n if (innerParam instanceof TypeTagAddress) {\n return new MoveOption<AccountAddress>(null);\n }\n if (innerParam instanceof TypeTagU8) {\n return new MoveOption<U8>(null);\n }\n if (innerParam instanceof TypeTagU16) {\n return new MoveOption<U16>(null);\n }\n if (innerParam instanceof TypeTagU32) {\n return new MoveOption<U32>(null);\n }\n if (innerParam instanceof TypeTagU64) {\n return new MoveOption<U64>(null);\n }\n if (innerParam instanceof TypeTagU128) {\n return new MoveOption<U128>(null);\n }\n if (innerParam instanceof TypeTagU256) {\n return new MoveOption<U256>(null);\n }\n\n // In all other cases, we will use a placeholder, it doesn't actually matter what the type is, but it will be obvious\n // Note: This is a placeholder U8 type, and does not match the actual type, as that can't be dynamically grabbed\n return new MoveOption<MoveString>(null);\n }\n\n return new MoveOption(checkOrConvertArgument(arg, param.value.typeArgs[0], position, genericTypeParams));\n }\n\n throw new Error(`Unsupported struct input type for argument ${position}, type '${param.toString()}'`);\n }\n\n throw new Error(`Type mismatch for argument ${position}, type '${param.toString()}'`);\n}\n\n/**\n * Checks that the type of the BCS encoded argument matches the ABI\n * @param param\n * @param arg\n * @param position\n */\nfunction checkType(param: TypeTag, arg: EntryFunctionArgumentTypes, position: number) {\n if (param.isBool()) {\n if (isBcsBool(arg)) {\n return;\n }\n throwTypeMismatch(\"Bool\", position);\n }\n if (param.isAddress()) {\n if (isBcsAddress(arg)) {\n return;\n }\n throwTypeMismatch(\"AccountAddress\", position);\n }\n if (param.isU8()) {\n if (isBcsU8(arg)) {\n return;\n }\n throwTypeMismatch(\"U8\", position);\n }\n if (param.isU16()) {\n if (isBcsU16(arg)) {\n return;\n }\n throwTypeMismatch(\"U16\", position);\n }\n if (param.isU32()) {\n if (isBcsU32(arg)) {\n return;\n }\n throwTypeMismatch(\"U32\", position);\n }\n if (param.isU64()) {\n if (isBcsU64(arg)) {\n return;\n }\n throwTypeMismatch(\"U64\", position);\n }\n if (param.isU128()) {\n if (isBcsU128(arg)) {\n return;\n }\n throwTypeMismatch(\"U128\", position);\n }\n if (param.isU256()) {\n if (isBcsU256(arg)) {\n return;\n }\n throwTypeMismatch(\"U256\", position);\n }\n if (param.isVector()) {\n if (arg instanceof MoveVector) {\n // If there's anything in it, check that the inner types match\n // Note that since it's typed, the first item should be the same as the rest\n if (arg.values.length > 0) {\n checkType(param.value, arg.values[0], position);\n }\n\n return;\n }\n throwTypeMismatch(\"MoveVector\", position);\n }\n\n // Handle structs as they're more complex\n if (param instanceof TypeTagStruct) {\n if (param.isString()) {\n if (isBcsString(arg)) {\n return;\n }\n throwTypeMismatch(\"MoveString\", position);\n }\n if (param.isObject()) {\n if (isBcsAddress(arg)) {\n return;\n }\n throwTypeMismatch(\"AccountAddress\", position);\n }\n if (param.isOption()) {\n if (arg instanceof MoveOption) {\n // If there's a value, we can check the inner type (otherwise it doesn't really matter)\n if (arg.value !== undefined) {\n checkType(param.value.typeArgs[0], arg.value, position);\n }\n return;\n }\n throwTypeMismatch(\"MoveOption\", position);\n }\n }\n\n throw new Error(`Type mismatch for argument ${position}, expected '${param.toString()}'`);\n}\n"],"mappings":"+fAiDA,IAAMA,EAAe,IAAI,YAQlB,SAASC,GAAoBC,EAAqD,CACvF,OACEA,GAAe,IAAKC,GAEdC,EAASD,CAAO,EACXE,EAAaF,CAAO,EAEtBA,CACR,GAAK,CAAC,CAEX,CAWA,eAAsBG,EACpBC,EACAC,EACAC,EACAC,EACmC,CAEnC,IAAMC,EAAS,MAAMC,EAAU,CAAE,YAAAF,EAAa,eAAgBH,EAAe,WAAA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OAEFU,EAAkB,iBAAkBT,CAAQ,CAC9C,CACA,GAAIE,EAAM,SAAS,EAAG,CACpB,GAAIH,aAAe4B,EAAY,CAEzB5B,EAAI,QAAU,QAChBM,EAAUH,EAAM,MAAM,SAAS,CAAC,EAAGH,EAAI,MAAOC,CAAQ,EAExD,MACF,CACAS,EAAkB,aAAcT,CAAQ,CAC1C,CACF,CAEA,MAAM,IAAI,MAAM,8BAA8BA,CAAQ,eAAeE,EAAM,SAAS,CAAC,GAAG,CAC1F","names":["TEXT_ENCODER","standardizeTypeTags","typeArguments","typeArg","isString","parseTypeTag","fetchFunctionAbi","moduleAddress","moduleName","functionName","aptosConfig","module","getModule","func","fetchEntryFunctionAbi","functionAbi","numSigners","findFirstNonSignerArg","params","i","fetchViewFunctionAbi","returnTypes","convertArgument","arg","position","genericTypeParams","param","checkOrConvertArgument","isEncodedEntryFunctionArgument","checkType","parseArg","isBool","Bool","throwTypeMismatch","AccountAddress","num","convertNumber","U8","U16","U32","isLargeNumber","U64","U128","U256","genericIndex","MoveVector","item","MoveString","isEmptyOption","innerParam","TypeTagBool","MoveOption","TypeTagAddress","TypeTagU8","TypeTagU16","TypeTagU32","TypeTagU64","TypeTagU128","TypeTagU256","isBcsBool","isBcsAddress","isBcsU8","isBcsU16","isBcsU32","isBcsU64","isBcsU128","isBcsU256","TypeTagStruct","isBcsString"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as p,b as u}from"./chunk-XHCALZ7X.mjs";import{b as h,c as d,e as m}from"./chunk-GMKKHGXK.mjs";import{c as s}from"./chunk-WSVOJSAC.mjs";import{b,c as K}from"./chunk-LEKBJ2EG.mjs";import{a as l}from"./chunk-N47FTRYO.mjs";import{a as c}from"./chunk-QQIVWB6G.mjs";import{b as y}from"./chunk-KFNDDPOW.mjs";import{randomBytes as E}from"@noble/hashes/utils";var S=1209600,i=class i extends c{constructor(e){super();let{privateKey:r,expiryDateSecs:a,blinder:n}=e;this.privateKey=r,this.publicKey=new p(r.publicKey()),this.expiryDateSecs=a||K(b()+S),this.blinder=n!==void 0?y.fromHexInput(n).toUint8Array():v();let t=h(this.publicKey.bcsToBytes(),93);t.push(BigInt(this.expiryDateSecs)),t.push(d(this.blinder));let x=m(t);this.nonce=x.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let r=e.deserializeUleb128AsU32(),a;switch(r){case 0:a=s.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}let n=e.deserializeU64(),t=e.deserializeFixedBytes(31);return new i({privateKey:a,expiryDateSecs:Number(n),blinder:t})}static fromBytes(e){return i.deserialize(new l(e))}static generate(e){let r;switch(e?.scheme){case 0:default:r=s.generate()}return new i({privateKey:r,expiryDateSecs:e?.expiryDateSecs})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new u(this.privateKey.sign(e))}};i.BLINDER_LENGTH=31;var o=i;function v(){return E(o.BLINDER_LENGTH)}export{o as a};
|
|
2
|
-
//# sourceMappingURL=chunk-UKAXCARD.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/client/post.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { aptosRequest } from \"./core\";\nimport { AptosResponse } from \"./types\";\nimport { AnyNumber, ClientConfig, MimeType } from \"../types\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * Options for making a POST request, including the API client configuration.\n */\nexport type PostRequestOptions = {\n /**\n * The config for the API client\n */\n aptosConfig: AptosConfig;\n /**\n * The type of API endpoint to call e.g. fullnode, indexer, etc\n */\n type: AptosApiType;\n /**\n * The name of the API method\n */\n originMethod: string;\n /**\n * The URL path to the API method\n */\n path: string;\n /**\n * The content type of the request body\n */\n contentType?: MimeType;\n /**\n * The accepted content type of the response of the API\n */\n acceptType?: MimeType;\n /**\n * The query parameters for the request\n */\n params?: Record<string, string | AnyNumber | boolean | undefined>;\n /**\n * The body of the request, should match the content type of the request\n */\n body?: any;\n /**\n * Specific client overrides for this request to override aptosConfig\n */\n overrides?: ClientConfig;\n};\n\n/**\n * Options for posting a request to Aptos, excluding the type field.\n */\nexport type PostAptosRequestOptions = Omit<PostRequestOptions, \"type\">;\n\n/**\n * Executes a POST request to the specified URL with the provided options.\n *\n * @param options - The options for the POST request.\n * @param options.type - The type of the request.\n * @param options.originMethod - The original method that initiated the request.\n * @param options.path - The path for the request.\n * @param options.body - The body content to be sent with the request.\n * @param options.acceptType - The type of response expected from the server.\n * @param options.contentType - The content type of the request body.\n * @param options.params - Additional parameters to include in the request.\n * @param options.aptosConfig - Configuration settings for the Aptos request.\n * @param options.overrides - Any overrides for the default request behavior.\n * @returns The response from the POST request.\n */\nexport async function post<Req extends {}, Res extends {}>(\n options: PostRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { type, originMethod, path, body, acceptType, contentType, params, aptosConfig, overrides } = options;\n const url = aptosConfig.getRequestUrl(type);\n\n return aptosRequest<Req, Res>(\n {\n url,\n method: \"POST\",\n originMethod,\n path,\n body,\n contentType,\n acceptType,\n params,\n overrides,\n },\n aptosConfig,\n options.type,\n );\n}\n\n/**\n * Sends a request to the Aptos full node using the specified options.\n * This function allows you to interact with the Aptos blockchain by sending requests to the full node.\n *\n * @param options - The options for the request.\n * @param options.aptosConfig - Configuration settings for the Aptos client.\n * @param options.aptosConfig.clientConfig - Client-specific configuration settings.\n * @param options.aptosConfig.fullnodeConfig - Full node-specific configuration settings.\n * @param options.overrides - Additional overrides for the request.\n */\nexport async function postAptosFullNode<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n\n return post<Req, Res>({\n ...options,\n type: AptosApiType.FULLNODE,\n overrides: {\n ...aptosConfig.clientConfig,\n ...aptosConfig.fullnodeConfig,\n ...options.overrides,\n HEADERS: { ...aptosConfig.clientConfig?.HEADERS, ...aptosConfig.fullnodeConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Sends a request to the Aptos indexer with the specified options.\n * This function allows you to interact with the Aptos indexer and customize the request using various configurations.\n *\n * @param options - The options for the request to the Aptos indexer.\n * @param options.aptosConfig - Configuration settings specific to the Aptos client and indexer.\n * @param options.aptosConfig.clientConfig - The client configuration settings.\n * @param options.aptosConfig.indexerConfig - The indexer configuration settings.\n * @param options.overrides - Additional overrides for the request.\n * @param options.overrides.HEADERS - Custom headers to include in the request.\n */\nexport async function postAptosIndexer<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n\n return post<Req, Res>({\n ...options,\n type: AptosApiType.INDEXER,\n overrides: {\n ...aptosConfig.clientConfig,\n ...aptosConfig.indexerConfig,\n ...options.overrides,\n HEADERS: { ...aptosConfig.clientConfig?.HEADERS, ...aptosConfig.indexerConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Sends a request to the Aptos faucet to obtain test tokens.\n * This function modifies the provided configuration to ensure that the API_KEY is not included in the request.\n *\n * @param options - The options for the request.\n * @param options.aptosConfig - The configuration settings for the Aptos client.\n * @param options.aptosConfig.clientConfig - The client-specific configuration settings.\n * @param options.aptosConfig.clientConfig.HEADERS - Optional headers to include in the request.\n * @param options.aptosConfig.faucetConfig - The configuration settings specific to the faucet.\n * @param options.overrides - Additional overrides for the request configuration.\n */\nexport async function postAptosFaucet<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n const { aptosConfig } = options;\n // Faucet does not support API_KEY\n // Create a new object with the desired modification\n const modifiedAptosConfig = {\n ...aptosConfig,\n clientConfig: { ...aptosConfig.clientConfig },\n };\n // Delete API_KEY config\n delete modifiedAptosConfig?.clientConfig?.API_KEY;\n\n return post<Req, Res>({\n ...options,\n type: AptosApiType.FAUCET,\n overrides: {\n ...modifiedAptosConfig.clientConfig,\n ...modifiedAptosConfig.faucetConfig,\n ...options.overrides,\n HEADERS: { ...modifiedAptosConfig.clientConfig?.HEADERS, ...modifiedAptosConfig.faucetConfig?.HEADERS },\n },\n });\n}\n\n/**\n * Makes a post request to the pepper service.\n *\n * @param options - The options for the request.\n * @param options.url - The URL to which the request is sent.\n * @param options.headers - The headers to include in the request.\n * @param options.body - The body of the request.\n * @returns A promise that resolves to the response from the pepper service.\n */\nexport async function postAptosPepperService<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n return post<Req, Res>({ ...options, type: AptosApiType.PEPPER });\n}\n\n/**\n * Sends a request to the Aptos proving service with the specified options.\n *\n * @param options - The options for the request to the Aptos proving service.\n * @param options.type - The type of the request, which should be set to AptosApiType.PROVER.\n * @param options.data - The data to be included in the request.\n */\nexport async function postAptosProvingService<Req extends {}, Res extends {}>(\n options: PostAptosRequestOptions,\n): Promise<AptosResponse<Req, Res>> {\n return post<Req, Res>({ ...options, type: AptosApiType.PROVER });\n}\n"],"mappings":"yCAuEA,eAAsBA,EACpBC,EACkC,CAClC,GAAM,CAAE,KAAAC,EAAM,aAAAC,EAAc,KAAAC,EAAM,KAAAC,EAAM,WAAAC,EAAY,YAAAC,EAAa,OAAAC,EAAQ,YAAAC,EAAa,UAAAC,CAAU,EAAIT,EAC9FU,EAAMF,EAAY,cAAcP,CAAI,EAE1C,OAAOU,EACL,CACE,IAAAD,EACA,OAAQ,OACR,aAAAR,EACA,KAAAC,EACA,KAAAC,EACA,YAAAE,EACA,WAAAD,EACA,OAAAE,EACA,UAAAE,CACF,EACAD,EACAR,EAAQ,IACV,CACF,CAYA,eAAsBY,EACpBZ,EACkC,CAClC,GAAM,CAAE,YAAAQ,CAAY,EAAIR,EAExB,OAAOD,EAAe,CACpB,GAAGC,EACH,gBACA,UAAW,CACT,GAAGQ,EAAY,aACf,GAAGA,EAAY,eACf,GAAGR,EAAQ,UACX,QAAS,CAAE,GAAGQ,EAAY,cAAc,QAAS,GAAGA,EAAY,gBAAgB,OAAQ,CAC1F,CACF,CAAC,CACH,CAaA,eAAsBK,EACpBb,EACkC,CAClC,GAAM,CAAE,YAAAQ,CAAY,EAAIR,EAExB,OAAOD,EAAe,CACpB,GAAGC,EACH,eACA,UAAW,CACT,GAAGQ,EAAY,aACf,GAAGA,EAAY,cACf,GAAGR,EAAQ,UACX,QAAS,CAAE,GAAGQ,EAAY,cAAc,QAAS,GAAGA,EAAY,eAAe,OAAQ,CACzF,CACF,CAAC,CACH,CAaA,eAAsBM,EACpBd,EACkC,CAClC,GAAM,CAAE,YAAAQ,CAAY,EAAIR,EAGlBe,EAAsB,CAC1B,GAAGP,EACH,aAAc,CAAE,GAAGA,EAAY,YAAa,CAC9C,EAEA,cAAOO,GAAqB,cAAc,QAEnChB,EAAe,CACpB,GAAGC,EACH,cACA,UAAW,CACT,GAAGe,EAAoB,aACvB,GAAGA,EAAoB,aACvB,GAAGf,EAAQ,UACX,QAAS,CAAE,GAAGe,EAAoB,cAAc,QAAS,GAAGA,EAAoB,cAAc,OAAQ,CACxG,CACF,CAAC,CACH,CAWA,eAAsBC,EACpBhB,EACkC,CAClC,OAAOD,EAAe,CAAE,GAAGC,EAAS,aAA0B,CAAC,CACjE,CASA,eAAsBiB,EACpBjB,EACkC,CAClC,OAAOD,EAAe,CAAE,GAAGC,EAAS,aAA0B,CAAC,CACjE","names":["post","options","type","originMethod","path","body","acceptType","contentType","params","aptosConfig","overrides","url","aptosRequest","postAptosFullNode","postAptosIndexer","postAptosFaucet","modifiedAptosConfig","postAptosPepperService","postAptosProvingService"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as S}from"./chunk-4OV7QU2U.mjs";import{a as b}from"./chunk-IBLZ6MZU.mjs";import{a as g}from"./chunk-KIW54KWR.mjs";import{d as K,f as A,g as v,h as E,i as H,j as P}from"./chunk-PHP47DI4.mjs";import{a as p}from"./chunk-PRZ7AIGA.mjs";import{a as f}from"./chunk-QQIVWB6G.mjs";import{b as s}from"./chunk-KFNDDPOW.mjs";import{ed25519 as y}from"@noble/curves/ed25519";var d=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function w(z){let e=z.toUint8Array().slice(32);for(let t=d.length-1;t>=0;t-=1){if(e[t]<d[t])return!0;if(e[t]>d[t])return!1}return!1}var i=class i extends S{constructor(e){super();let t=s.fromHexInput(e);if(t.toUint8Array().length!==i.LENGTH)throw new Error(`PublicKey length should be ${i.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e;if(!w(n))return!1;let o=g(t),c=s.fromHexInput(o).toUint8Array(),u=n.toUint8Array(),l=this.key.toUint8Array();return y.verify(u,c,l)}authKey(){return p.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new i(t)}static isPublicKey(e){return e instanceof i}static isInstance(e){return"key"in e&&e.key?.data?.length===i.LENGTH}};i.LENGTH=32;var m=i,r=class r extends f{constructor(e){super();let t=s.fromHexInput(e);if(t.toUint8Array().length!==r.LENGTH)throw new Error(`PrivateKey length should be ${r.LENGTH}`);this.signingKey=t}static generate(){let e=y.utils.randomPrivateKey();return new r(e)}static fromDerivationPath(e,t){if(!A(e))throw new Error(`Invalid derivation path ${e}`);return r.fromDerivationPathInner(e,P(t))}static fromDerivationPathInner(e,t,n=K){let{key:o,chainCode:c}=v(r.SLIP_0010_SEED,t),u=H(e).map(x=>parseInt(x,10)),{key:l}=u.reduce((x,I)=>E(x,I+n),{key:o,chainCode:c});return new r(l)}publicKey(){let e=y.getPublicKey(this.signingKey.toUint8Array());return new m(e)}sign(e){let t=g(e),n=s.fromHexInput(t).toUint8Array(),o=y.sign(n,this.signingKey.toUint8Array());return new h(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new r(t)}static isPrivateKey(e){return e instanceof r}};r.LENGTH=32,r.SLIP_0010_SEED="ed25519 seed";var U=r,a=class a extends b{constructor(e){super();let t=s.fromHexInput(e);if(t.toUint8Array().length!==a.LENGTH)throw new Error(`Signature length should be ${a.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new a(t)}};a.LENGTH=64;var h=a;export{w as a,m as b,U as c,h as d};
|
|
2
|
-
//# sourceMappingURL=chunk-WSVOJSAC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/crypto/ed25519.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ed25519 } from \"@noble/curves/ed25519\";\nimport { Deserializer } from \"../../bcs/deserializer\";\nimport { Serializable, Serializer } from \"../../bcs/serializer\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { HexInput, SigningScheme as AuthenticationKeyScheme } from \"../../types\";\nimport { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSeed, splitPath } from \"./hdKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { AccountPublicKey, PublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { convertSigningMessage } from \"./utils\";\n\n/**\n * L is the value that greater than or equal to will produce a non-canonical signature, and must be rejected\n */\nconst L: number[] = [\n 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\n];\n\n/**\n * Checks if an ED25519 signature is non-canonical.\n * This function helps determine the validity of a signature by verifying its canonical form.\n *\n * @param signature - The signature to be checked for canonicality.\n * @returns A boolean indicating whether the signature is non-canonical.\n *\n * Comes from Aptos Core\n * https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos-crypto/src/ed25519/ed25519_sigs.rs#L47-L85\n */\nexport function isCanonicalEd25519Signature(signature: Signature): boolean {\n const s = signature.toUint8Array().slice(32);\n for (let i = L.length - 1; i >= 0; i -= 1) {\n if (s[i] < L[i]) {\n return true;\n }\n if (s[i] > L[i]) {\n return false;\n }\n }\n // As this stage S == L which implies a non-canonical S.\n return false;\n}\n\n/**\n * Represents the public key of an Ed25519 key pair.\n *\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n *\n * Ed25519 scheme is represented in the SDK as `Legacy authentication key` and also\n * as `AnyPublicKey` that represents any `Unified authentication key`.\n */\nexport class Ed25519PublicKey extends AccountPublicKey {\n /**\n * Length of an Ed25519 public key\n */\n static readonly LENGTH: number = 32;\n\n /**\n * Bytes of the public key\n * @private\n */\n private readonly key: Hex;\n\n /**\n * Creates an instance of the Ed25519Signature class from a hex input.\n * This constructor validates the length of the signature to ensure it meets the required specifications.\n *\n * @param hexInput - The hex input representing the Ed25519 signature.\n * @throws Error if the signature length is not equal to Ed25519Signature.LENGTH.\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n if (hex.toUint8Array().length !== Ed25519PublicKey.LENGTH) {\n throw new Error(`PublicKey length should be ${Ed25519PublicKey.LENGTH}`);\n }\n this.key = hex;\n }\n\n // region AccountPublicKey\n\n /**\n * Verifies a signed message using a public key.\n *\n * @param args - The arguments for verification.\n * @param args.message - A signed message as a Hex string or Uint8Array.\n * @param args.signature - The signature of the message.\n */\n verifySignature(args: VerifySignatureArgs): boolean {\n const { message, signature } = args;\n // Verify malleability\n if (!isCanonicalEd25519Signature(signature)) {\n return false;\n }\n\n const messageToVerify = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();\n const signatureBytes = signature.toUint8Array();\n const publicKeyBytes = this.key.toUint8Array();\n return ed25519.verify(signatureBytes, messageBytes, publicKeyBytes);\n }\n\n /**\n * Generates an authentication key from the public key using the Ed25519 scheme.\n * This function is essential for creating a secure authentication key that can be used for further cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.Ed25519,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Convert the internal data representation to a Uint8Array.\n *\n * @returns Uint8Array representation of the data.\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This allows for the conversion of data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserialize bytes into an Ed25519Signature object.\n * This function is used to convert serialized byte data into a usable Ed25519Signature instance.\n *\n * @param deserializer - The deserializer instance used to read the byte data.\n */\n static deserialize(deserializer: Deserializer): Ed25519PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519PublicKey(bytes);\n }\n\n // endregion\n\n /**\n * Determine if the provided public key is an instance of Ed25519PublicKey.\n *\n * @param publicKey - The public key to check.\n * @returns True if the public key is an instance of Ed25519PublicKey, otherwise false.\n * @deprecated use `instanceof Ed25519PublicKey` instead.\n */\n static isPublicKey(publicKey: AccountPublicKey): publicKey is Ed25519PublicKey {\n return publicKey instanceof Ed25519PublicKey;\n }\n\n /**\n * Determines if the provided public key is a valid Ed25519 public key.\n * This function checks for the presence of the \"key\" property and verifies that its data length matches the expected length\n * for Ed25519 public keys.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Ed25519 public key.\n */\n static isInstance(publicKey: PublicKey): publicKey is Ed25519PublicKey {\n return \"key\" in publicKey && (publicKey.key as any)?.data?.length === Ed25519PublicKey.LENGTH;\n }\n}\n\n/**\n * Represents the private key of an Ed25519 key pair.\n *\n * @static\n * @readonly LENGTH - Length of an Ed25519 private key.\n * @static\n * @readonly SLIP_0010_SEED - The Ed25519 key seed to use for BIP-32 compatibility.\n */\nexport class Ed25519PrivateKey extends Serializable implements PrivateKey {\n /**\n * Length of an Ed25519 private key\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The Ed25519 key seed to use for BIP-32 compatibility\n * See more {@link https://github.com/satoshilabs/slips/blob/master/slip-0010.md}\n */\n static readonly SLIP_0010_SEED = \"ed25519 seed\";\n\n /**\n * The Ed25519 signing key\n * @private\n */\n private readonly signingKey: Hex;\n\n // region Constructors\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * @param hexInput HexInput (string or Uint8Array)\n */\n constructor(hexInput: HexInput) {\n super();\n\n const privateKeyHex = Hex.fromHexInput(hexInput);\n if (privateKeyHex.toUint8Array().length !== Ed25519PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Ed25519PrivateKey.LENGTH}`);\n }\n\n // Create keyPair from Private key in Uint8Array format\n this.signingKey = privateKeyHex;\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Ed25519PrivateKey A newly generated Ed25519 private key.\n */\n static generate(): Ed25519PrivateKey {\n const keyPair = ed25519.utils.randomPrivateKey();\n return new Ed25519PrivateKey(keyPair);\n }\n\n /**\n * Derives a private key from a mnemonic seed phrase using a specified BIP44 path.\n * To derive multiple keys from the same phrase, change the path\n *\n * IMPORTANT: Ed25519 supports hardened derivation only, as it lacks a key homomorphism, making non-hardened derivation impossible.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param mnemonics - The mnemonic seed phrase from which the key will be derived.\n * @throws Error if the provided path is not a valid hardened path.\n */\n static fromDerivationPath(path: string, mnemonics: string): Ed25519PrivateKey {\n if (!isValidHardenedPath(path)) {\n throw new Error(`Invalid derivation path ${path}`);\n }\n return Ed25519PrivateKey.fromDerivationPathInner(path, mnemonicToSeed(mnemonics));\n }\n\n /**\n * Derives a child private key from a given BIP44 path and seed.\n * A private inner function so we can separate from the main fromDerivationPath() method\n * to add tests to verify we create the keys correctly.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param seed - The seed phrase created by the mnemonics, represented as a Uint8Array.\n * @param offset - The offset used for key derivation, defaults to HARDENED_OFFSET.\n * @returns An instance of Ed25519PrivateKey derived from the specified path and seed.\n */\n private static fromDerivationPathInner(path: string, seed: Uint8Array, offset = HARDENED_OFFSET): Ed25519PrivateKey {\n const { key, chainCode } = deriveKey(Ed25519PrivateKey.SLIP_0010_SEED, seed);\n\n const segments = splitPath(path).map((el) => parseInt(el, 10));\n\n // Derive the child key based on the path\n const { key: privateKey } = segments.reduce((parentKeys, segment) => CKDPriv(parentKeys, segment + offset), {\n key,\n chainCode,\n });\n return new Ed25519PrivateKey(privateKey);\n }\n\n // endregion\n\n // region PrivateKey\n\n /**\n * Derive the Ed25519PublicKey for this private key.\n *\n * @returns Ed25519PublicKey - The derived public key corresponding to the private key.\n */\n publicKey(): Ed25519PublicKey {\n const bytes = ed25519.getPublicKey(this.signingKey.toUint8Array());\n return new Ed25519PublicKey(bytes);\n }\n\n /**\n * Sign the given message with the private key.\n * This function generates a digital signature for the specified message, ensuring its authenticity and integrity.\n *\n * @param message - A message as a string or Uint8Array in HexInput format.\n * @returns A digital signature for the provided message.\n */\n sign(message: HexInput): Ed25519Signature {\n const messageToSign = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToSign).toUint8Array();\n const signatureBytes = ed25519.sign(messageBytes, this.signingKey.toUint8Array());\n return new Ed25519Signature(signatureBytes);\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the private key\n */\n toUint8Array(): Uint8Array {\n return this.signingKey.toUint8Array();\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toString(): string {\n return this.signingKey.toString();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Ed25519PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519PrivateKey(bytes);\n }\n\n // endregion\n\n /**\n * Determines if the provided private key is an instance of Ed25519PrivateKey.\n *\n * @param privateKey - The private key to check.\n * @returns A boolean indicating whether the private key is an Ed25519PrivateKey.\n *\n * @deprecated Use `instanceof Ed25519PrivateKey` instead.\n */\n static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey {\n return privateKey instanceof Ed25519PrivateKey;\n }\n}\n\n/**\n * Represents a signature of a message signed using an Ed25519 private key.\n *\n * @static LENGTH - Length of an Ed25519 signature, which is 64 bytes.\n */\nexport class Ed25519Signature extends Signature {\n /**\n * Length of an Ed25519 signature\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n */\n private readonly data: Hex;\n\n // region Constructors\n\n constructor(hexInput: HexInput) {\n super();\n const data = Hex.fromHexInput(hexInput);\n if (data.toUint8Array().length !== Ed25519Signature.LENGTH) {\n throw new Error(`Signature length should be ${Ed25519Signature.LENGTH}`);\n }\n this.data = data;\n }\n\n // endregion\n\n // region Signature\n\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Ed25519Signature {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519Signature(bytes);\n }\n\n // endregion\n}\n"],"mappings":"kUAGA,OAAS,WAAAA,MAAe,wBAexB,IAAMC,EAAc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,GAJpB,IAAMF,EAANE","names":["ed25519","L","isCanonicalEd25519Signature","signature","s","i","_Ed25519PublicKey","AccountPublicKey","hexInput","hex","Hex","args","message","messageToVerify","convertSigningMessage","messageBytes","signatureBytes","publicKeyBytes","ed25519","AuthenticationKey","serializer","deserializer","bytes","publicKey","Ed25519PublicKey","_Ed25519PrivateKey","Serializable","privateKeyHex","keyPair","path","mnemonics","isValidHardenedPath","mnemonicToSeed","seed","offset","HARDENED_OFFSET","key","chainCode","deriveKey","segments","splitPath","el","privateKey","parentKeys","segment","CKDPriv","messageToSign","Ed25519Signature","Ed25519PrivateKey","_Ed25519Signature","Signature","data"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./chunk-5ZBHIUWG.mjs";import{e as a}from"./chunk-IFHQSZLK.mjs";import{a as l,b as o}from"./chunk-6AGTDRNM.mjs";import{b as y}from"./chunk-KM6UXNC7.mjs";var p=class g{constructor(i){let{multiKey:t,signers:e,address:c}=i;this.publicKey=t,this.signingScheme=3,this.accountAddress=c?y.from(c):this.publicKey.authKey().derivedAddress();let s=[];for(let n of e)s.push(this.publicKey.getIndex(n.publicKey));let r=e.map((n,u)=>[n,s[u]]);r.sort((n,u)=>n[1]-u[1]),this.signers=r.map(n=>n[0]),this.signerIndicies=r.map(n=>n[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:s})}static fromPublicKeysAndSigners(i){let{publicKeys:t,signaturesRequired:e,signers:c}=i,s=new l({publicKeys:t,signaturesRequired:e});return new g({multiKey:s,signers:c})}static isMultiKeySigner(i){return i instanceof g}signWithAuthenticator(i){return new a(this.publicKey,this.sign(i))}signTransactionWithAuthenticator(i){return new a(this.publicKey,this.signTransaction(i))}async waitForProofFetch(){let t=this.signers.filter(e=>e instanceof m).map(async e=>e.waitForProofFetch());await Promise.all(t)}sign(i){let t=[];for(let e of this.signers)t.push(e.sign(i));return new o({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(i){let t=[];for(let e of this.signers)t.push(e.signTransaction(i));return new o({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(i){let{message:t,signature:e}=i;if(!this.signerIndicies.every((s,r)=>r===0||s>=this.signerIndicies[r-1]))return!1;for(let s=0;s<e.signatures.length;s+=1){let r=e.signatures[s];if(!this.publicKey.publicKeys[this.signerIndicies[s]].verifySignature({message:t,signature:r}))return!1}return!0}};export{p as a};
|
|
2
|
-
//# sourceMappingURL=chunk-ZS3EWM5A.mjs.map
|
|
@@ -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 { AbstractKeylessAccount } from \"./AbstractKeylessAccount\";\n\n/**\n * Arguments required to verify a multi-key signature against a given message.\n *\n * @param message - The original message that was signed.\n * @param signature - The multi-key signature to be verified.\n */\nexport interface VerifyMultiKeySignatureArgs {\n message: HexInput;\n signature: MultiKeySignature;\n}\n\n/**\n * Signer implementation for the MultiKey authentication scheme.\n *\n * This account utilizes an M of N signing scheme, where M and N are specified in the {@link MultiKey}.\n * It signs messages using an array of M accounts, each corresponding 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 indices 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 // TODO: Rename Indicies to Indices\n readonly signerIndicies: number[];\n\n readonly signaturesBitmap: Uint8Array;\n\n /**\n * Constructs a MultiKeyAccount instance, which requires multiple signatures for transactions.\n *\n * @param args - The arguments for creating a MultiKeyAccount.\n * @param args.multiKey - The multikey of the account consisting of N public keys and a number M representing the required signatures.\n * @param args.signers - An array of M signers that will be used to sign the transaction.\n * @param args.address - An optional account address input. If not provided, the derived address from the public key will be used.\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 to create a MultiKeyAccount using the provided public keys and signers.\n *\n * @param args - The arguments for creating a MultiKeyAccount.\n * @param args.publicKeys - The N public keys of the MultiKeyAccount.\n * @param args.signaturesRequired - The number of signatures required to authorize a transaction.\n * @param args.signers - An array of M signers that will be used to sign the transaction.\n * @returns MultiKeyAccount - The newly created 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 /**\n * Determines if the provided account is a multi-key account.\n *\n * @param account - The account to check.\n * @returns A boolean indicating whether the account is a multi-key account.\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 and return an AccountAuthenticator containing the signature along with the\n * account's public key.\n * @param message - The signing message, represented as binary input in hexadecimal format.\n * @returns An instance of AccountAuthenticatorMultiKey that includes the signature and the 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, returning an AccountAuthenticator that contains the signature and the\n * account's public key.\n * @param transaction - The raw transaction to be signed.\n * @returns An AccountAuthenticatorMultiKey containing the signature of the transaction along 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 KeylessAccount signers to be fetched. This ensures that signing with the KeylessAccount does not\n * fail due to missing proofs.\n * @return {Promise<void>} A promise that resolves when all proofs have been fetched.\n */\n async waitForProofFetch(): Promise<void> {\n const keylessSigners = this.signers.filter(\n (signer) => signer instanceof AbstractKeylessAccount,\n ) as AbstractKeylessAccount[];\n const promises = keylessSigners.map(async (signer) => signer.waitForProofFetch());\n await Promise.all(promises);\n }\n\n /**\n * Sign the given data using the MultiKeyAccount's signers.\n * @param data - The data to be signed in HexInput format.\n * @returns MultiKeySignature - The resulting multi-key signature.\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 * This function aggregates signatures from all signers associated with the MultiKeyAccount.\n *\n * @param transaction - The transaction to be signed.\n * @returns MultiKeySignature - An object containing the aggregated signatures and a bitmap of the signatures.\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 keys.\n *\n * This function checks if the provided signatures are valid for the given message using the corresponding public keys.\n *\n * @param args - The arguments for verifying the signature.\n * @param args.message - The raw message data in HexInput format.\n * @param args.signature - The signed message MultiKeySignature containing multiple signatures.\n * @returns A boolean indicating whether the signatures are valid for the message.\n */\n verifySignature(args: VerifyMultiKeySignatureArgs): boolean {\n const { message, signature } = args;\n const isSignerIndicesSorted = this.signerIndicies.every(\n (value, i) => i === 0 || value >= this.signerIndicies[i - 1],\n );\n if (!isSignerIndicesSorted) {\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":"2KA8BO,IAAMA,EAAN,MAAMC,CAAmC,CAwC9C,YAAYC,EAAiF,CAC3F,GAAM,CAAE,SAAAC,EAAU,QAAAC,EAAS,QAAAC,CAAQ,EAAIH,EAEvC,KAAK,UAAYC,EACjB,KAAK,cAAgB,EAErB,KAAK,eAAiBE,EAAUC,EAAe,KAAKD,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,EAGvG,IAAME,EAAyB,CAAC,EAChC,QAAWC,KAAUJ,EACnBG,EAAa,KAAK,KAAK,UAAU,SAASC,EAAO,SAAS,CAAC,EAK7D,IAAMC,EAA6CL,EAAQ,IAAI,CAACI,EAAQE,IAAU,CAACF,EAAQD,EAAaG,CAAK,CAAC,CA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B,EAAO,gBAAgBY,CAAW,CAAC,EAErD,OAAO,IAAIK,EAAkB,CAAE,WAAAD,EAAY,OAAQ,KAAK,gBAAiB,CAAC,CAC5E,CAYA,gBAAgBtB,EAA4C,CAC1D,GAAM,CAAE,QAAAgB,EAAS,UAAAQ,CAAU,EAAIxB,EAI/B,GAAI,CAH0B,KAAK,eAAe,MAChD,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","AbstractKeylessAccount","data","signatures","MultiKeySignature","signature","i","singleSignature"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { AptosRequest } from '../types/index.mjs';
|
|
2
|
-
import { AptosApiType } from '../utils/const.mjs';
|
|
3
|
-
import '../utils/apiEndpoints.mjs';
|
|
4
|
-
import '../types/indexer.mjs';
|
|
5
|
-
import '../types/generated/operations.mjs';
|
|
6
|
-
import '../types/generated/types.mjs';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The API response type
|
|
10
|
-
*
|
|
11
|
-
* @param status - the response status. i.e. 200
|
|
12
|
-
* @param statusText - the response message
|
|
13
|
-
* @param data the response data
|
|
14
|
-
* @param url the url the request was made to
|
|
15
|
-
* @param headers the response headers
|
|
16
|
-
* @param config (optional) - the request object
|
|
17
|
-
* @param request (optional) - the request object
|
|
18
|
-
*/
|
|
19
|
-
interface AptosResponse<Req, Res> {
|
|
20
|
-
status: number;
|
|
21
|
-
statusText: string;
|
|
22
|
-
data: Res;
|
|
23
|
-
url: string;
|
|
24
|
-
headers: any;
|
|
25
|
-
config?: any;
|
|
26
|
-
request?: Req;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Options for handling errors in the Aptos API.
|
|
30
|
-
*/
|
|
31
|
-
type AptosApiErrorOpts = {
|
|
32
|
-
apiType: AptosApiType;
|
|
33
|
-
aptosRequest: AptosRequest;
|
|
34
|
-
aptosResponse: AptosResponse<any, any>;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Represents an error returned from the Aptos API.
|
|
38
|
-
* This class encapsulates the details of the error, including the request URL, response status, and additional data.
|
|
39
|
-
*
|
|
40
|
-
* @param name - The name of the error, which is always "AptosApiError".
|
|
41
|
-
* @param url - The URL to which the request was made.
|
|
42
|
-
* @param status - The HTTP response status code (e.g., 400).
|
|
43
|
-
* @param statusText - The message associated with the response status.
|
|
44
|
-
* @param data - The response data returned from the API.
|
|
45
|
-
* @param request - The original AptosRequest that triggered the error.
|
|
46
|
-
*/
|
|
47
|
-
declare class AptosApiError extends Error {
|
|
48
|
-
readonly url: string;
|
|
49
|
-
readonly status: number;
|
|
50
|
-
readonly statusText: string;
|
|
51
|
-
readonly data: any;
|
|
52
|
-
readonly request: AptosRequest;
|
|
53
|
-
/**
|
|
54
|
-
* Constructs an instance of AptosApiError with relevant error details.
|
|
55
|
-
*
|
|
56
|
-
* @param opts - The options for creating the AptosApiError.
|
|
57
|
-
* @param opts.apiType - The type of API that generated the error.
|
|
58
|
-
* @param opts.aptosRequest - The request object that caused the error.
|
|
59
|
-
* @param opts.aptosResponse - The response object containing error details.
|
|
60
|
-
*
|
|
61
|
-
* @internal This constructor is for SDK internal use - do not instantiate outside the SDK codebase.
|
|
62
|
-
*/
|
|
63
|
-
constructor({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { AptosApiError, type AptosResponse };
|