@aptos-labs/ts-sdk 1.13.0 → 1.13.1-zeta.1
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/dist/common/index.d.ts +1775 -1351
- package/dist/common/index.js +26 -26
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account--qjfup2u.d.mts → Ed25519Account-8gJF5t3F.d.mts} +10 -12
- package/dist/esm/account/Account.d.mts +34 -0
- package/dist/esm/account/Account.mjs +2 -0
- package/dist/esm/account/Ed25519Account.d.mts +34 -0
- package/dist/esm/account/Ed25519Account.mjs +2 -0
- package/dist/esm/account/EphemeralKeyPair.d.mts +44 -0
- package/dist/esm/account/EphemeralKeyPair.mjs +2 -0
- package/dist/esm/account/KeylessAccount.d.mts +87 -0
- package/dist/esm/account/KeylessAccount.mjs +2 -0
- package/dist/esm/account/MultiKeyAccount.d.mts +99 -0
- package/dist/esm/account/MultiKeyAccount.mjs +2 -0
- package/dist/esm/account/SingleKeyAccount.d.mts +34 -0
- package/dist/esm/account/SingleKeyAccount.mjs +2 -0
- package/dist/esm/account/index.d.mts +39 -0
- package/dist/esm/account/index.mjs +2 -0
- package/dist/esm/api/account.d.mts +14 -2
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +2 -2
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +14 -8
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +20 -0
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +7 -7
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +3 -3
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +6 -6
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +9 -9
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +13 -8
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +67 -0
- package/dist/esm/api/keyless.mjs +2 -0
- package/dist/esm/api/keyless.mjs.map +1 -0
- package/dist/esm/api/staking.d.mts +2 -2
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +8 -8
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +1 -1
- 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 +6 -6
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +2 -0
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-HB6T27S2.mjs → chunk-2OTMSEHI.mjs} +2 -2
- package/dist/esm/{chunk-FS3NSGBF.mjs → chunk-35ZI4WOQ.mjs} +2 -2
- package/dist/esm/{chunk-ONDQ4MK7.mjs → chunk-3FL3NLZ6.mjs} +2 -2
- package/dist/esm/chunk-3OA7CG6N.mjs +2 -0
- package/dist/esm/chunk-3OA7CG6N.mjs.map +1 -0
- package/dist/esm/{chunk-52C73T26.mjs → chunk-52DBSOFA.mjs} +2 -2
- package/dist/esm/{chunk-52C73T26.mjs.map → chunk-52DBSOFA.mjs.map} +1 -1
- package/dist/esm/{chunk-A7MSW6OL.mjs → chunk-534GCQ37.mjs} +2 -2
- package/dist/esm/chunk-5GIWRESN.mjs +2 -0
- package/dist/esm/{chunk-KUOIRTNL.mjs → chunk-5TNUDFLP.mjs} +2 -2
- package/dist/esm/{chunk-V4YBGBCN.mjs → chunk-6DA64TSG.mjs} +2 -2
- package/dist/esm/{chunk-H4UVHJ3M.mjs → chunk-6YDD6LGX.mjs} +2 -2
- package/dist/esm/chunk-6YDD6LGX.mjs.map +1 -0
- package/dist/esm/{chunk-TBMAJ6AW.mjs → chunk-7EQOLMEJ.mjs} +2 -2
- package/dist/esm/chunk-7YMBWSKN.mjs +2 -0
- package/dist/esm/chunk-7YMBWSKN.mjs.map +1 -0
- package/dist/esm/chunk-7Z6DYLCA.mjs +1 -0
- package/dist/esm/chunk-7Z6DYLCA.mjs.map +1 -0
- package/dist/esm/chunk-AE7X4LVG.mjs +2 -0
- package/dist/esm/chunk-AE7X4LVG.mjs.map +1 -0
- package/dist/esm/chunk-AQ4I7VVB.mjs +1 -0
- package/dist/esm/chunk-AQ4I7VVB.mjs.map +1 -0
- package/dist/esm/chunk-ASRAJ24P.mjs +2 -0
- package/dist/esm/{chunk-OKCU4GHN.mjs → chunk-B645DPPF.mjs} +2 -2
- package/dist/esm/chunk-BIU5KNPT.mjs +2 -0
- package/dist/esm/chunk-C2HDZYYQ.mjs +2 -0
- package/dist/esm/chunk-C2HDZYYQ.mjs.map +1 -0
- package/dist/esm/chunk-CFJEOZMV.mjs +2 -0
- package/dist/esm/{chunk-WEZXFWPR.mjs.map → chunk-CFJEOZMV.mjs.map} +1 -1
- package/dist/esm/chunk-COLCWAPL.mjs +2 -0
- package/dist/esm/chunk-COLCWAPL.mjs.map +1 -0
- package/dist/esm/chunk-CW7JVCSV.mjs +2 -0
- package/dist/esm/chunk-CW7JVCSV.mjs.map +1 -0
- package/dist/esm/chunk-D2DIZHP3.mjs +2 -0
- package/dist/esm/chunk-D2DIZHP3.mjs.map +1 -0
- package/dist/esm/{chunk-L4Q2XTHT.mjs → chunk-ED6PYTNG.mjs} +2 -2
- package/dist/esm/chunk-EGTGR3R4.mjs +2 -0
- package/dist/esm/{chunk-KVIVMWN5.mjs → chunk-FB6T6ZQP.mjs} +2 -2
- package/dist/esm/chunk-FLYEALDB.mjs +2 -0
- package/dist/esm/chunk-FLYEALDB.mjs.map +1 -0
- package/dist/esm/{chunk-SDUIZ3FY.mjs → chunk-G4QU37E6.mjs} +2 -2
- package/dist/esm/chunk-G4QU37E6.mjs.map +1 -0
- package/dist/esm/{chunk-QW3VNZJ7.mjs → chunk-GVZZTEYV.mjs} +2 -2
- package/dist/esm/{chunk-WFZDFFBM.mjs → chunk-HZC6A3QL.mjs} +2 -2
- package/dist/esm/{chunk-IA6XM7QE.mjs → chunk-HZFOKUQZ.mjs} +2 -2
- package/dist/esm/chunk-HZFOKUQZ.mjs.map +1 -0
- package/dist/esm/{chunk-647IOEXV.mjs → chunk-I657KZIO.mjs} +2 -2
- package/dist/esm/chunk-IO2NZ5PR.mjs +2 -0
- package/dist/esm/chunk-IO2NZ5PR.mjs.map +1 -0
- package/dist/esm/{chunk-U43IJHQN.mjs → chunk-IVBYTTN7.mjs} +2 -2
- package/dist/esm/chunk-JP6UNRLO.mjs +2 -0
- package/dist/esm/{chunk-TLKV4NHK.mjs.map → chunk-JP6UNRLO.mjs.map} +1 -1
- package/dist/esm/chunk-JXCZTOYC.mjs +1 -0
- package/dist/esm/chunk-JXCZTOYC.mjs.map +1 -0
- package/dist/esm/{chunk-NPFNYP75.mjs → chunk-JYFKKB34.mjs} +2 -2
- package/dist/esm/{chunk-2M6OT6DU.mjs → chunk-KFKE46CF.mjs} +2 -2
- package/dist/esm/{chunk-R5QUBEH6.mjs → chunk-KX5ESZO7.mjs} +2 -2
- package/dist/esm/{chunk-7PYFGGHM.mjs → chunk-LB4KMZNQ.mjs} +2 -2
- package/dist/esm/chunk-LB4KMZNQ.mjs.map +1 -0
- package/dist/esm/chunk-M3VGAYMW.mjs +2 -0
- package/dist/esm/chunk-M3VGAYMW.mjs.map +1 -0
- package/dist/esm/{chunk-BWFJHFBQ.mjs → chunk-MRCVSUJQ.mjs} +2 -2
- package/dist/esm/{chunk-HXN2WRUX.mjs → chunk-MUEDPI2Z.mjs} +2 -2
- package/dist/esm/{chunk-3F6EYD5O.mjs → chunk-N35ARFH3.mjs} +2 -2
- package/dist/esm/chunk-N35ARFH3.mjs.map +1 -0
- package/dist/esm/chunk-ND5A52N4.mjs +2 -0
- package/dist/esm/chunk-ND5A52N4.mjs.map +1 -0
- package/dist/esm/{chunk-XYLYHSEI.mjs → chunk-NKSAU5OX.mjs} +2 -2
- package/dist/esm/chunk-NKSAU5OX.mjs.map +1 -0
- package/dist/esm/chunk-NMYQ2LMC.mjs +2 -0
- package/dist/esm/chunk-NMYQ2LMC.mjs.map +1 -0
- package/dist/esm/chunk-OF256KD5.mjs +2 -0
- package/dist/esm/chunk-OF256KD5.mjs.map +1 -0
- package/dist/esm/chunk-OKRUEVF3.mjs +2 -0
- package/dist/esm/chunk-OKRUEVF3.mjs.map +1 -0
- package/dist/esm/{chunk-7CAEMK4R.mjs → chunk-OQKD5SSG.mjs} +2 -2
- package/dist/esm/chunk-ORMDVSRG.mjs +2 -0
- package/dist/esm/chunk-ORMDVSRG.mjs.map +1 -0
- package/dist/esm/{chunk-IS3OLRMB.mjs → chunk-P2JP6PSD.mjs} +2 -2
- package/dist/esm/{chunk-TR2YS7DT.mjs → chunk-PCLBZIT4.mjs} +2 -2
- package/dist/esm/chunk-PSTPEDI3.mjs +2 -0
- package/dist/esm/chunk-PSTPEDI3.mjs.map +1 -0
- package/dist/esm/{chunk-DMKUAQB7.mjs → chunk-Q225PZMV.mjs} +2 -2
- package/dist/esm/{chunk-6CBPMYW5.mjs → chunk-QBWI223M.mjs} +2 -2
- package/dist/esm/chunk-QEKSGA7S.mjs +2 -0
- package/dist/esm/chunk-QEKSGA7S.mjs.map +1 -0
- package/dist/esm/{chunk-VBTJVPAM.mjs → chunk-QFK75K2K.mjs} +2 -2
- package/dist/esm/{chunk-TGLSJGFO.mjs → chunk-RBDX3YWC.mjs} +2 -2
- package/dist/esm/chunk-RFSO3JRG.mjs +1 -0
- package/dist/esm/chunk-RFSO3JRG.mjs.map +1 -0
- package/dist/esm/{chunk-DSTKXJMA.mjs → chunk-RM7D2ITN.mjs} +2 -2
- package/dist/esm/chunk-S5HG2QUD.mjs +2 -0
- package/dist/esm/chunk-S5HG2QUD.mjs.map +1 -0
- package/dist/esm/chunk-S5YUB2BI.mjs +2 -0
- package/dist/esm/chunk-S5YUB2BI.mjs.map +1 -0
- package/dist/esm/{chunk-MIEV7J74.mjs → chunk-SC7NXRMV.mjs} +2 -2
- package/dist/esm/chunk-SC7NXRMV.mjs.map +1 -0
- package/dist/esm/chunk-SQNDWIVJ.mjs +2 -0
- package/dist/esm/chunk-SQNDWIVJ.mjs.map +1 -0
- package/dist/esm/chunk-T7TIIAWK.mjs +2 -0
- package/dist/esm/{chunk-KOAUBVO6.mjs.map → chunk-T7TIIAWK.mjs.map} +1 -1
- package/dist/esm/chunk-TCMSBGBS.mjs +2 -0
- package/dist/esm/chunk-TCMSBGBS.mjs.map +1 -0
- package/dist/esm/{chunk-IOSQVDZI.mjs → chunk-U7EZI5D5.mjs} +2 -2
- package/dist/esm/chunk-UAFAZSOH.mjs +2 -0
- package/dist/esm/chunk-UAFAZSOH.mjs.map +1 -0
- package/dist/esm/chunk-UMFYNNCG.mjs +2 -0
- package/dist/esm/{chunk-YWQLLV2R.mjs.map → chunk-UMFYNNCG.mjs.map} +1 -1
- package/dist/esm/{chunk-ZYYK3UXP.mjs → chunk-UZHVGPGH.mjs} +2 -2
- package/dist/esm/chunk-VG2J3UTS.mjs +2 -0
- package/dist/esm/chunk-VG2J3UTS.mjs.map +1 -0
- package/dist/esm/chunk-VSPQRNEG.mjs +2 -0
- package/dist/esm/chunk-VSPQRNEG.mjs.map +1 -0
- package/dist/esm/chunk-VSWIMQAB.mjs +2 -0
- package/dist/esm/chunk-VSWIMQAB.mjs.map +1 -0
- package/dist/esm/{chunk-QIAHBEEW.mjs → chunk-VVJEWB26.mjs} +2 -2
- package/dist/esm/chunk-W2MKEIHI.mjs +2 -0
- package/dist/esm/chunk-W2MKEIHI.mjs.map +1 -0
- package/dist/esm/{chunk-Y5M5DD64.mjs → chunk-WAWBXQ6B.mjs} +2 -2
- package/dist/esm/{chunk-TBFLWWV4.mjs → chunk-WR5L4STD.mjs} +2 -2
- package/dist/esm/{chunk-RHBCVCOS.mjs → chunk-WZCUABDL.mjs} +2 -2
- package/dist/esm/{chunk-UML2VQZT.mjs → chunk-XI4LX4EC.mjs} +2 -2
- package/dist/esm/chunk-Y4VKIX2V.mjs +2 -0
- package/dist/esm/chunk-Y4VKIX2V.mjs.map +1 -0
- package/dist/esm/{chunk-I7YI22IW.mjs → chunk-Y5DMKMLF.mjs} +2 -2
- package/dist/esm/chunk-YE5B2S5L.mjs +2 -0
- package/dist/esm/chunk-YE5B2S5L.mjs.map +1 -0
- package/dist/esm/{chunk-ZKNM27TR.mjs → chunk-YGWIVUJP.mjs} +2 -2
- package/dist/esm/chunk-YGWIVUJP.mjs.map +1 -0
- package/dist/esm/{chunk-QVKMFPAV.mjs → chunk-YIIDPNGQ.mjs} +2 -2
- package/dist/esm/{chunk-G2QII3AT.mjs → chunk-YMVFNEBO.mjs} +2 -2
- package/dist/esm/chunk-YMVFNEBO.mjs.map +1 -0
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +2 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +2 -2
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +3 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +5 -14
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +0 -10
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +77 -0
- package/dist/esm/core/crypto/ephemeral.mjs +2 -0
- package/dist/esm/core/crypto/ephemeral.mjs.map +1 -0
- package/dist/esm/core/crypto/hdKey.d.mts +15 -1
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +7 -5
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +217 -0
- package/dist/esm/core/crypto/keyless.mjs +2 -0
- package/dist/esm/core/crypto/keyless.mjs.map +1 -0
- 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/poseidon.d.mts +7 -0
- package/dist/esm/core/crypto/poseidon.mjs +2 -0
- package/dist/esm/core/crypto/poseidon.mjs.map +1 -0
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.d.mts +6 -7
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +15 -9
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +14 -2
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +7 -7
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +2 -2
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +6 -6
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +66 -0
- package/dist/esm/internal/keyless.mjs +2 -0
- package/dist/esm/internal/keyless.mjs.map +1 -0
- package/dist/esm/internal/staking.d.mts +3 -3
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +5 -5
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +7 -7
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +3 -4
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +2 -2
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +13 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +2 -2
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +6 -6
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +47 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +2 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +6 -28
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +6 -6
- package/dist/esm/types/index.d.mts +17 -3
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/keyless.d.mts +14 -0
- package/dist/esm/types/keyless.mjs +1 -0
- package/dist/esm/types/keyless.mjs.map +1 -0
- package/dist/esm/utils/apiEndpoints.d.mts +3 -1
- package/dist/esm/utils/apiEndpoints.mjs +1 -1
- package/dist/esm/utils/const.d.mts +3 -1
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +7 -2
- package/src/{core/account → account}/Account.ts +12 -16
- package/src/{core/account → account}/Ed25519Account.ts +13 -7
- package/src/account/EphemeralKeyPair.ts +107 -0
- package/src/account/KeylessAccount.ts +250 -0
- package/src/account/MultiKeyAccount.ts +119 -0
- package/src/{core/account → account}/SingleKeyAccount.ts +13 -8
- package/src/account/index.ts +6 -0
- package/src/api/account.ts +2 -1
- package/src/api/ans.ts +2 -1
- package/src/api/aptos.ts +6 -0
- package/src/api/aptosConfig.ts +46 -1
- package/src/api/digitalAsset.ts +2 -1
- package/src/api/fungibleAsset.ts +2 -1
- package/src/api/keyless.ts +36 -0
- package/src/api/transaction.ts +2 -1
- package/src/api/transactionSubmission/management.ts +1 -1
- package/src/api/transactionSubmission/sign.ts +1 -1
- package/src/bcs/serializer.ts +18 -0
- package/src/client/core.ts +8 -0
- package/src/client/get.ts +6 -0
- package/src/client/post.ts +12 -0
- package/src/core/account/index.ts +1 -3
- package/src/core/crypto/ed25519.ts +4 -24
- package/src/core/crypto/ephemeral.ts +149 -0
- package/src/core/crypto/hdKey.ts +31 -0
- package/src/core/crypto/index.ts +2 -0
- package/src/core/crypto/keyless.ts +508 -0
- package/src/core/crypto/multiKey.ts +21 -11
- package/src/core/crypto/poseidon.ts +134 -0
- package/src/core/crypto/singleKey.ts +11 -0
- package/src/core/index.ts +0 -1
- package/src/index.ts +1 -0
- package/src/internal/account.ts +1 -1
- package/src/internal/ans.ts +2 -1
- package/src/internal/digitalAsset.ts +2 -1
- package/src/internal/fungibleAsset.ts +2 -1
- package/src/internal/keyless.ts +189 -0
- package/src/internal/transactionSubmission.ts +11 -8
- package/src/transactions/authenticator/account.ts +6 -11
- package/src/transactions/management/accountSequenceNumber.ts +1 -1
- package/src/transactions/management/transactionWorker.ts +8 -2
- package/src/transactions/transactionBuilder/index.ts +1 -0
- package/src/transactions/transactionBuilder/signingMessage.ts +70 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +51 -117
- package/src/types/index.ts +19 -0
- package/src/types/keyless.ts +6 -0
- package/src/utils/apiEndpoints.ts +15 -0
- package/src/utils/const.ts +2 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-3CLYWZYZ.mjs +0 -2
- package/dist/esm/chunk-3F6EYD5O.mjs.map +0 -1
- package/dist/esm/chunk-54BANKLA.mjs +0 -2
- package/dist/esm/chunk-54BANKLA.mjs.map +0 -1
- package/dist/esm/chunk-5AQEETAC.mjs +0 -2
- package/dist/esm/chunk-5AQEETAC.mjs.map +0 -1
- package/dist/esm/chunk-63AIRYJX.mjs +0 -2
- package/dist/esm/chunk-7PYFGGHM.mjs.map +0 -1
- package/dist/esm/chunk-AP7UZTPZ.mjs +0 -2
- package/dist/esm/chunk-AP7UZTPZ.mjs.map +0 -1
- package/dist/esm/chunk-BMKDEIRL.mjs +0 -2
- package/dist/esm/chunk-BMKDEIRL.mjs.map +0 -1
- package/dist/esm/chunk-BSEQPVD6.mjs +0 -2
- package/dist/esm/chunk-BSEQPVD6.mjs.map +0 -1
- package/dist/esm/chunk-C67BKZND.mjs +0 -2
- package/dist/esm/chunk-C67BKZND.mjs.map +0 -1
- package/dist/esm/chunk-CYNQRMO5.mjs +0 -2
- package/dist/esm/chunk-CYNQRMO5.mjs.map +0 -1
- package/dist/esm/chunk-E7FWVXGX.mjs +0 -1
- package/dist/esm/chunk-G2QII3AT.mjs.map +0 -1
- package/dist/esm/chunk-GMVVQD72.mjs +0 -2
- package/dist/esm/chunk-GMVVQD72.mjs.map +0 -1
- package/dist/esm/chunk-GXVUN32G.mjs +0 -2
- package/dist/esm/chunk-GXVUN32G.mjs.map +0 -1
- package/dist/esm/chunk-H4UVHJ3M.mjs.map +0 -1
- package/dist/esm/chunk-IA6XM7QE.mjs.map +0 -1
- package/dist/esm/chunk-KL6VJ3UK.mjs +0 -2
- package/dist/esm/chunk-KL6VJ3UK.mjs.map +0 -1
- package/dist/esm/chunk-KOAUBVO6.mjs +0 -2
- package/dist/esm/chunk-LR65XHSF.mjs +0 -2
- package/dist/esm/chunk-LR65XHSF.mjs.map +0 -1
- package/dist/esm/chunk-MIEV7J74.mjs.map +0 -1
- package/dist/esm/chunk-MLWIHWNH.mjs +0 -1
- package/dist/esm/chunk-OWW6SIDP.mjs +0 -2
- package/dist/esm/chunk-OWW6SIDP.mjs.map +0 -1
- package/dist/esm/chunk-QK4P26SH.mjs +0 -2
- package/dist/esm/chunk-QTSECE7R.mjs +0 -2
- package/dist/esm/chunk-QTSECE7R.mjs.map +0 -1
- package/dist/esm/chunk-R7G3CLRI.mjs +0 -1
- package/dist/esm/chunk-RAYJRFIG.mjs +0 -2
- package/dist/esm/chunk-RAYJRFIG.mjs.map +0 -1
- package/dist/esm/chunk-SDUIZ3FY.mjs.map +0 -1
- package/dist/esm/chunk-TLKV4NHK.mjs +0 -2
- package/dist/esm/chunk-UVSRX4SV.mjs +0 -1
- package/dist/esm/chunk-V6SPPOWX.mjs +0 -2
- package/dist/esm/chunk-VM3EJYJU.mjs +0 -2
- package/dist/esm/chunk-VM3EJYJU.mjs.map +0 -1
- package/dist/esm/chunk-VX6LTXGB.mjs +0 -2
- package/dist/esm/chunk-VX6LTXGB.mjs.map +0 -1
- package/dist/esm/chunk-WEZXFWPR.mjs +0 -2
- package/dist/esm/chunk-XYLYHSEI.mjs.map +0 -1
- package/dist/esm/chunk-Y2VA7F5D.mjs +0 -2
- package/dist/esm/chunk-Y2VA7F5D.mjs.map +0 -1
- package/dist/esm/chunk-YWQLLV2R.mjs +0 -2
- package/dist/esm/chunk-ZEXZ4CX5.mjs +0 -2
- package/dist/esm/chunk-ZEXZ4CX5.mjs.map +0 -1
- package/dist/esm/chunk-ZKNM27TR.mjs.map +0 -1
- package/dist/esm/chunk-ZPNCA4C7.mjs +0 -2
- package/dist/esm/chunk-ZPNCA4C7.mjs.map +0 -1
- package/dist/esm/core/account/Account.d.mts +0 -20
- package/dist/esm/core/account/Account.mjs +0 -2
- package/dist/esm/core/account/Ed25519Account.d.mts +0 -20
- package/dist/esm/core/account/Ed25519Account.mjs +0 -2
- package/dist/esm/core/account/SingleKeyAccount.d.mts +0 -20
- package/dist/esm/core/account/SingleKeyAccount.mjs +0 -2
- /package/dist/esm/{core/account → account}/Account.mjs.map +0 -0
- /package/dist/esm/{core/account → account}/Ed25519Account.mjs.map +0 -0
- /package/dist/esm/{chunk-E7FWVXGX.mjs.map → account/EphemeralKeyPair.mjs.map} +0 -0
- /package/dist/esm/{chunk-MLWIHWNH.mjs.map → account/KeylessAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-R7G3CLRI.mjs.map → account/MultiKeyAccount.mjs.map} +0 -0
- /package/dist/esm/{core/account → account}/SingleKeyAccount.mjs.map +0 -0
- /package/dist/esm/{chunk-UVSRX4SV.mjs.map → account/index.mjs.map} +0 -0
- /package/dist/esm/{chunk-HB6T27S2.mjs.map → chunk-2OTMSEHI.mjs.map} +0 -0
- /package/dist/esm/{chunk-FS3NSGBF.mjs.map → chunk-35ZI4WOQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONDQ4MK7.mjs.map → chunk-3FL3NLZ6.mjs.map} +0 -0
- /package/dist/esm/{chunk-A7MSW6OL.mjs.map → chunk-534GCQ37.mjs.map} +0 -0
- /package/dist/esm/{chunk-V6SPPOWX.mjs.map → chunk-5GIWRESN.mjs.map} +0 -0
- /package/dist/esm/{chunk-KUOIRTNL.mjs.map → chunk-5TNUDFLP.mjs.map} +0 -0
- /package/dist/esm/{chunk-V4YBGBCN.mjs.map → chunk-6DA64TSG.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBMAJ6AW.mjs.map → chunk-7EQOLMEJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-63AIRYJX.mjs.map → chunk-ASRAJ24P.mjs.map} +0 -0
- /package/dist/esm/{chunk-OKCU4GHN.mjs.map → chunk-B645DPPF.mjs.map} +0 -0
- /package/dist/esm/{chunk-QK4P26SH.mjs.map → chunk-BIU5KNPT.mjs.map} +0 -0
- /package/dist/esm/{chunk-L4Q2XTHT.mjs.map → chunk-ED6PYTNG.mjs.map} +0 -0
- /package/dist/esm/{chunk-3CLYWZYZ.mjs.map → chunk-EGTGR3R4.mjs.map} +0 -0
- /package/dist/esm/{chunk-KVIVMWN5.mjs.map → chunk-FB6T6ZQP.mjs.map} +0 -0
- /package/dist/esm/{chunk-QW3VNZJ7.mjs.map → chunk-GVZZTEYV.mjs.map} +0 -0
- /package/dist/esm/{chunk-WFZDFFBM.mjs.map → chunk-HZC6A3QL.mjs.map} +0 -0
- /package/dist/esm/{chunk-647IOEXV.mjs.map → chunk-I657KZIO.mjs.map} +0 -0
- /package/dist/esm/{chunk-U43IJHQN.mjs.map → chunk-IVBYTTN7.mjs.map} +0 -0
- /package/dist/esm/{chunk-NPFNYP75.mjs.map → chunk-JYFKKB34.mjs.map} +0 -0
- /package/dist/esm/{chunk-2M6OT6DU.mjs.map → chunk-KFKE46CF.mjs.map} +0 -0
- /package/dist/esm/{chunk-R5QUBEH6.mjs.map → chunk-KX5ESZO7.mjs.map} +0 -0
- /package/dist/esm/{chunk-BWFJHFBQ.mjs.map → chunk-MRCVSUJQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-HXN2WRUX.mjs.map → chunk-MUEDPI2Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-7CAEMK4R.mjs.map → chunk-OQKD5SSG.mjs.map} +0 -0
- /package/dist/esm/{chunk-IS3OLRMB.mjs.map → chunk-P2JP6PSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-TR2YS7DT.mjs.map → chunk-PCLBZIT4.mjs.map} +0 -0
- /package/dist/esm/{chunk-DMKUAQB7.mjs.map → chunk-Q225PZMV.mjs.map} +0 -0
- /package/dist/esm/{chunk-6CBPMYW5.mjs.map → chunk-QBWI223M.mjs.map} +0 -0
- /package/dist/esm/{chunk-VBTJVPAM.mjs.map → chunk-QFK75K2K.mjs.map} +0 -0
- /package/dist/esm/{chunk-TGLSJGFO.mjs.map → chunk-RBDX3YWC.mjs.map} +0 -0
- /package/dist/esm/{chunk-DSTKXJMA.mjs.map → chunk-RM7D2ITN.mjs.map} +0 -0
- /package/dist/esm/{chunk-IOSQVDZI.mjs.map → chunk-U7EZI5D5.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZYYK3UXP.mjs.map → chunk-UZHVGPGH.mjs.map} +0 -0
- /package/dist/esm/{chunk-QIAHBEEW.mjs.map → chunk-VVJEWB26.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y5M5DD64.mjs.map → chunk-WAWBXQ6B.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBFLWWV4.mjs.map → chunk-WR5L4STD.mjs.map} +0 -0
- /package/dist/esm/{chunk-RHBCVCOS.mjs.map → chunk-WZCUABDL.mjs.map} +0 -0
- /package/dist/esm/{chunk-UML2VQZT.mjs.map → chunk-XI4LX4EC.mjs.map} +0 -0
- /package/dist/esm/{chunk-I7YI22IW.mjs.map → chunk-Y5DMKMLF.mjs.map} +0 -0
- /package/dist/esm/{chunk-QVKMFPAV.mjs.map → chunk-YIIDPNGQ.mjs.map} +0 -0
|
@@ -9,20 +9,13 @@
|
|
|
9
9
|
import { sha3_256 as sha3Hash } from "@noble/hashes/sha3";
|
|
10
10
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
11
11
|
import { AccountAddress, AccountAddressInput, Hex, PublicKey } from "../../core";
|
|
12
|
-
import { Account } from "../../core/account";
|
|
13
12
|
import { AnyPublicKey, AnySignature } from "../../core/crypto";
|
|
14
13
|
import { Ed25519PublicKey, Ed25519Signature } from "../../core/crypto/ed25519";
|
|
15
|
-
import { Secp256k1PublicKey, Secp256k1Signature } from "../../core/crypto/secp256k1";
|
|
16
14
|
import { getInfo } from "../../internal/account";
|
|
17
15
|
import { getLedgerInfo } from "../../internal/general";
|
|
18
16
|
import { getGasPriceEstimation } from "../../internal/transaction";
|
|
19
17
|
import { NetworkToChainId } from "../../utils/apiEndpoints";
|
|
20
|
-
import {
|
|
21
|
-
DEFAULT_MAX_GAS_AMOUNT,
|
|
22
|
-
DEFAULT_TXN_EXP_SEC_FROM_NOW,
|
|
23
|
-
RAW_TRANSACTION_SALT,
|
|
24
|
-
RAW_TRANSACTION_WITH_DATA_SALT,
|
|
25
|
-
} from "../../utils/const";
|
|
18
|
+
import { DEFAULT_MAX_GAS_AMOUNT, DEFAULT_TXN_EXP_SEC_FROM_NOW } from "../../utils/const";
|
|
26
19
|
import {
|
|
27
20
|
AccountAuthenticator,
|
|
28
21
|
AccountAuthenticatorEd25519,
|
|
@@ -52,7 +45,6 @@ import { SignedTransaction } from "../instances/signedTransaction";
|
|
|
52
45
|
import {
|
|
53
46
|
AnyRawTransaction,
|
|
54
47
|
AnyTransactionPayloadInstance,
|
|
55
|
-
AnyRawTransactionInstance,
|
|
56
48
|
EntryFunctionArgumentTypes,
|
|
57
49
|
InputGenerateMultiAgentRawTransactionArgs,
|
|
58
50
|
InputGenerateRawTransactionArgs,
|
|
@@ -73,10 +65,10 @@ import {
|
|
|
73
65
|
} from "../types";
|
|
74
66
|
import { convertArgument, fetchEntryFunctionAbi, fetchViewFunctionAbi, standardizeTypeTags } from "./remoteAbi";
|
|
75
67
|
import { memoizeAsync } from "../../utils/memoize";
|
|
76
|
-
import { AnyNumber } from "../../types";
|
|
77
68
|
import { getFunctionParts, isScriptDataInput } from "./helpers";
|
|
78
69
|
import { SimpleTransaction } from "../instances/simpleTransaction";
|
|
79
70
|
import { MultiAgentTransaction } from "../instances/multiAgentTransaction";
|
|
71
|
+
import { deriveTransactionType } from "./signingMessage";
|
|
80
72
|
|
|
81
73
|
/**
|
|
82
74
|
* We are defining function signatures, each with its specific input and output.
|
|
@@ -121,7 +113,7 @@ export async function generateTransactionPayload(
|
|
|
121
113
|
});
|
|
122
114
|
|
|
123
115
|
// Fill in the ABI
|
|
124
|
-
return generateTransactionPayloadWithABI({ abi: functionAbi
|
|
116
|
+
return generateTransactionPayloadWithABI({ ...args, abi: functionAbi });
|
|
125
117
|
}
|
|
126
118
|
|
|
127
119
|
export function generateTransactionPayloadWithABI(args: InputEntryFunctionDataWithABI): TransactionPayloadEntryFunction;
|
|
@@ -246,41 +238,53 @@ export async function generateRawTransaction(args: {
|
|
|
246
238
|
}): Promise<RawTransaction> {
|
|
247
239
|
const { aptosConfig, sender, payload, options, feePayerAddress } = args;
|
|
248
240
|
|
|
249
|
-
const getChainId =
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const getGasUnitPrice = options?.gasUnitPrice
|
|
254
|
-
? Promise.resolve({ gas_estimate: options.gasUnitPrice })
|
|
255
|
-
: getGasPriceEstimation({ aptosConfig });
|
|
256
|
-
|
|
257
|
-
const [{ chain_id: chainId }, { gas_estimate: gasEstimate }] = await Promise.all([getChainId, getGasUnitPrice]);
|
|
258
|
-
|
|
259
|
-
const getSequenceNumber =
|
|
260
|
-
options?.accountSequenceNumber !== undefined
|
|
261
|
-
? Promise.resolve({ sequence_number: options.accountSequenceNumber })
|
|
262
|
-
: getInfo({ aptosConfig, accountAddress: sender });
|
|
263
|
-
|
|
264
|
-
let sequenceNumber: string | AnyNumber;
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Check if is sponsored transaction to honor AIP-52
|
|
268
|
-
* {@link https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-52.md}
|
|
269
|
-
*/
|
|
270
|
-
if (feePayerAddress && AccountAddress.from(feePayerAddress).equals(AccountAddress.ZERO)) {
|
|
271
|
-
// Handle sponsored transaction generation with the option that
|
|
272
|
-
// the main signer has not been created on chain
|
|
273
|
-
try {
|
|
274
|
-
// Check if main signer has been created on chain, if not assign sequence number 0
|
|
275
|
-
const { sequence_number: seqNumber } = await getSequenceNumber;
|
|
276
|
-
sequenceNumber = seqNumber;
|
|
277
|
-
} catch (e: any) {
|
|
278
|
-
sequenceNumber = "0";
|
|
241
|
+
const getChainId = async () => {
|
|
242
|
+
if (NetworkToChainId[aptosConfig.network]) {
|
|
243
|
+
return { chainId: NetworkToChainId[aptosConfig.network] };
|
|
279
244
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
245
|
+
const info = await getLedgerInfo({ aptosConfig });
|
|
246
|
+
return { chainId: info.chain_id };
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
const getGasUnitPrice = async () => {
|
|
250
|
+
if (options?.gasUnitPrice) {
|
|
251
|
+
return { gasEstimate: options.gasUnitPrice };
|
|
252
|
+
}
|
|
253
|
+
const estimation = await getGasPriceEstimation({ aptosConfig });
|
|
254
|
+
return { gasEstimate: estimation.gas_estimate };
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const getSequenceNumberForAny = async () => {
|
|
258
|
+
const getSequenceNumber = async () => {
|
|
259
|
+
if (options?.accountSequenceNumber !== undefined) {
|
|
260
|
+
return options.accountSequenceNumber;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return (await getInfo({ aptosConfig, accountAddress: sender })).sequence_number;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Check if is sponsored transaction to honor AIP-52
|
|
268
|
+
* {@link https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-52.md}
|
|
269
|
+
*/
|
|
270
|
+
if (feePayerAddress && AccountAddress.from(feePayerAddress).equals(AccountAddress.ZERO)) {
|
|
271
|
+
// Handle sponsored transaction generation with the option that
|
|
272
|
+
// the main signer has not been created on chain
|
|
273
|
+
try {
|
|
274
|
+
// Check if main signer has been created on chain, if not assign sequence number 0
|
|
275
|
+
return await getSequenceNumber();
|
|
276
|
+
} catch (e: any) {
|
|
277
|
+
return 0;
|
|
278
|
+
}
|
|
279
|
+
} else {
|
|
280
|
+
return getSequenceNumber();
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const [{ chainId }, { gasEstimate }, sequenceNumber] = await Promise.all([
|
|
284
|
+
getChainId(),
|
|
285
|
+
getGasUnitPrice(),
|
|
286
|
+
getSequenceNumberForAny(),
|
|
287
|
+
]);
|
|
284
288
|
|
|
285
289
|
const { maxGasAmount, gasUnitPrice, expireTimestamp } = {
|
|
286
290
|
maxGasAmount: options?.maxGasAmount ? BigInt(options.maxGasAmount) : BigInt(DEFAULT_MAX_GAS_AMOUNT),
|
|
@@ -440,12 +444,7 @@ export function generateSignedTransactionForSimulation(args: InputSimulateTransa
|
|
|
440
444
|
export function getAuthenticatorForSimulation(publicKey: PublicKey) {
|
|
441
445
|
// TODO add support for AnyMultiKey
|
|
442
446
|
if (publicKey instanceof AnyPublicKey) {
|
|
443
|
-
|
|
444
|
-
return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Ed25519Signature(new Uint8Array(64))));
|
|
445
|
-
}
|
|
446
|
-
if (publicKey.publicKey instanceof Secp256k1PublicKey) {
|
|
447
|
-
return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Secp256k1Signature(new Uint8Array(64))));
|
|
448
|
-
}
|
|
447
|
+
return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Ed25519Signature(new Uint8Array(64))));
|
|
449
448
|
}
|
|
450
449
|
|
|
451
450
|
// legacy code
|
|
@@ -455,24 +454,6 @@ export function getAuthenticatorForSimulation(publicKey: PublicKey) {
|
|
|
455
454
|
);
|
|
456
455
|
}
|
|
457
456
|
|
|
458
|
-
/**
|
|
459
|
-
* Sign a transaction that can later be submitted to chain
|
|
460
|
-
*
|
|
461
|
-
* @param args.signer The signer account to sign the transaction
|
|
462
|
-
* @param args.transaction A aptos transaction type to sign
|
|
463
|
-
*
|
|
464
|
-
* @return The signer AccountAuthenticator
|
|
465
|
-
*/
|
|
466
|
-
export function sign(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {
|
|
467
|
-
const { signer, transaction } = args;
|
|
468
|
-
|
|
469
|
-
// get the signing message
|
|
470
|
-
const message = generateSigningMessage(transaction);
|
|
471
|
-
|
|
472
|
-
// account.signMessage
|
|
473
|
-
return signer.signWithAuthenticator(message);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
457
|
/**
|
|
477
458
|
* Prepare a transaction to be submitted to chain
|
|
478
459
|
*
|
|
@@ -554,28 +535,6 @@ export function generateUserTransactionHash(args: InputSubmitTransactionData): s
|
|
|
554
535
|
return new Hex(hashValues([TRANSACTION_PREFIX, new Uint8Array([0]), signedTransaction])).toString();
|
|
555
536
|
}
|
|
556
537
|
|
|
557
|
-
/**
|
|
558
|
-
* Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction
|
|
559
|
-
*
|
|
560
|
-
* @param transaction A aptos transaction type
|
|
561
|
-
*
|
|
562
|
-
* @returns FeePayerRawTransaction | MultiAgentRawTransaction | RawTransaction
|
|
563
|
-
*/
|
|
564
|
-
export function deriveTransactionType(transaction: AnyRawTransaction): AnyRawTransactionInstance {
|
|
565
|
-
if (transaction.feePayerAddress) {
|
|
566
|
-
return new FeePayerRawTransaction(
|
|
567
|
-
transaction.rawTransaction,
|
|
568
|
-
transaction.secondarySignerAddresses ?? [],
|
|
569
|
-
transaction.feePayerAddress,
|
|
570
|
-
);
|
|
571
|
-
}
|
|
572
|
-
if (transaction.secondarySignerAddresses) {
|
|
573
|
-
return new MultiAgentRawTransaction(transaction.rawTransaction, transaction.secondarySignerAddresses);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
return transaction.rawTransaction;
|
|
577
|
-
}
|
|
578
|
-
|
|
579
538
|
/**
|
|
580
539
|
* Generate a multi signers signed transaction that can be submitted to chain
|
|
581
540
|
*
|
|
@@ -625,31 +584,6 @@ export function generateMultiSignersSignedTransaction(
|
|
|
625
584
|
);
|
|
626
585
|
}
|
|
627
586
|
|
|
628
|
-
export function generateSigningMessage(transaction: AnyRawTransaction): Uint8Array {
|
|
629
|
-
const rawTxn = deriveTransactionType(transaction);
|
|
630
|
-
const hash = sha3Hash.create();
|
|
631
|
-
|
|
632
|
-
if (rawTxn instanceof RawTransaction) {
|
|
633
|
-
hash.update(RAW_TRANSACTION_SALT);
|
|
634
|
-
} else if (rawTxn instanceof MultiAgentRawTransaction) {
|
|
635
|
-
hash.update(RAW_TRANSACTION_WITH_DATA_SALT);
|
|
636
|
-
} else if (rawTxn instanceof FeePayerRawTransaction) {
|
|
637
|
-
hash.update(RAW_TRANSACTION_WITH_DATA_SALT);
|
|
638
|
-
} else {
|
|
639
|
-
throw new Error(`Unknown transaction type to sign on: ${rawTxn}`);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
const prefix = hash.digest();
|
|
643
|
-
|
|
644
|
-
const body = rawTxn.bcsToBytes();
|
|
645
|
-
|
|
646
|
-
const mergedArray = new Uint8Array(prefix.length + body.length);
|
|
647
|
-
mergedArray.set(prefix);
|
|
648
|
-
mergedArray.set(body, prefix.length);
|
|
649
|
-
|
|
650
|
-
return mergedArray;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
587
|
/**
|
|
654
588
|
* Fetches and caches ABIs with allowing for pass-through on provided ABIs
|
|
655
589
|
* @param key
|
|
@@ -677,7 +611,7 @@ async function fetchAbi<T extends FunctionABI>({
|
|
|
677
611
|
abi?: T;
|
|
678
612
|
fetch: (moduleAddress: string, moduleName: string, functionName: string, aptosConfig: AptosConfig) => Promise<T>;
|
|
679
613
|
}): Promise<T> {
|
|
680
|
-
if (abi) {
|
|
614
|
+
if (abi !== undefined) {
|
|
681
615
|
return abi;
|
|
682
616
|
}
|
|
683
617
|
|
package/src/types/index.ts
CHANGED
|
@@ -108,11 +108,26 @@ export enum AccountAuthenticatorVariant {
|
|
|
108
108
|
export enum AnyPublicKeyVariant {
|
|
109
109
|
Ed25519 = 0,
|
|
110
110
|
Secp256k1 = 1,
|
|
111
|
+
Keyless = 3,
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
export enum AnySignatureVariant {
|
|
114
115
|
Ed25519 = 0,
|
|
115
116
|
Secp256k1 = 1,
|
|
117
|
+
Keyless = 3,
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export enum EphemeralPublicKeyVariant {
|
|
121
|
+
Ed25519 = 0,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export enum EphemeralSignatureVariant {
|
|
125
|
+
Ed25519 = 0,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export enum EphemeralCertificate {
|
|
129
|
+
ZkProof = 0,
|
|
130
|
+
OpenIdSignature = 1,
|
|
116
131
|
}
|
|
117
132
|
|
|
118
133
|
/**
|
|
@@ -140,6 +155,10 @@ export type AptosSettings = {
|
|
|
140
155
|
|
|
141
156
|
readonly indexer?: string;
|
|
142
157
|
|
|
158
|
+
readonly pepper?: string;
|
|
159
|
+
|
|
160
|
+
readonly prover?: string;
|
|
161
|
+
|
|
143
162
|
readonly clientConfig?: ClientConfig;
|
|
144
163
|
|
|
145
164
|
readonly client?: Client;
|
|
@@ -25,6 +25,20 @@ export const NetworkToFaucetAPI: Record<string, string> = {
|
|
|
25
25
|
local: "http://127.0.0.1:8081",
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
export const NetworkToPepperAPI: Record<string, string> = {
|
|
29
|
+
mainnet: "mainnet not yet ready, requires sdk upgrade",
|
|
30
|
+
testnet: "https://api.testnet.aptoslabs.com/keyless/pepper/v0",
|
|
31
|
+
devnet: "https://api.devnet.aptoslabs.com/keyless/pepper/v0",
|
|
32
|
+
local: "https://api.devnet.aptoslabs.com/keyless/pepper/v0",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const NetworkToProverAPI: Record<string, string> = {
|
|
36
|
+
mainnet: "mainnet not yet ready, requires sdk upgrade",
|
|
37
|
+
testnet: "https://api.testnet.aptoslabs.com/keyless/prover/v0",
|
|
38
|
+
devnet: "https://prover.keyless.devnet.aptoslabs.com/v0",
|
|
39
|
+
local: "https://api.devnet.aptoslabs.com/keyless/prover/v0",
|
|
40
|
+
};
|
|
41
|
+
|
|
28
42
|
export enum Network {
|
|
29
43
|
MAINNET = "mainnet",
|
|
30
44
|
TESTNET = "testnet",
|
|
@@ -38,6 +52,7 @@ export const NetworkToChainId: Record<string, number> = {
|
|
|
38
52
|
mainnet: 1,
|
|
39
53
|
testnet: 2,
|
|
40
54
|
randomnet: 70,
|
|
55
|
+
local: 4,
|
|
41
56
|
};
|
|
42
57
|
|
|
43
58
|
export const NetworkToNetworkName: Record<string, Network> = {
|
package/src/utils/const.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-L4Q2XTHT.mjs";import{a as i}from"./chunk-KVIVMWN5.mjs";import{a as r}from"./chunk-52C73T26.mjs";var n=class o extends r{constructor(t,a){super();this.raw_txn=t,this.authenticator=a}serialize(t){this.raw_txn.serialize(t),this.authenticator.serialize(t)}static deserialize(t){let a=e.deserialize(t),s=i.deserialize(t);return new o(a,s)}};export{n as a};
|
|
2
|
-
//# sourceMappingURL=chunk-3CLYWZYZ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/management/accountSequenceNumber.ts"],"sourcesContent":["/**\n * A wrapper that handles and manages an account sequence number.\n *\n * Submit up to `maximumInFlight` transactions per account in parallel with a timeout of `sleepTime`\n * If local assumes `maximumInFlight` are in flight, determine the actual committed state from the network\n * If there are less than `maximumInFlight` due to some being committed, adjust the window\n * If `maximumInFlight` are in flight, wait `sleepTime` seconds before re-evaluating\n * If ever waiting more than `maxWaitTime` restart the sequence number to the current on-chain state\n *\n * Assumptions:\n * Accounts are expected to be managed by a single AccountSequenceNumber and not used otherwise.\n * They are initialized to the current on-chain state, so if there are already transactions in\n * flight, they may take some time to reset.\n * Accounts are automatically initialized if not explicitly\n *\n * Notes:\n * This is co-routine safe, that is many async tasks can be reading from this concurrently.\n * The state of an account cannot be used across multiple AccountSequenceNumber services.\n * The synchronize method will create a barrier that prevents additional nextSequenceNumber\n * calls until it is complete.\n * This only manages the distribution of sequence numbers it does not help handle transaction\n * failures.\n * If a transaction fails, you should call synchronize and wait for timeouts.\n */\n\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { Account } from \"../../core\";\nimport { getInfo } from \"../../internal/account\";\nimport { sleep } from \"../../utils/helpers\";\n\n// returns `now` time in seconds\nconst now = () => Math.floor(Date.now() / 1000);\n\nexport class AccountSequenceNumber {\n readonly aptosConfig: AptosConfig;\n\n readonly account: Account;\n\n // sequence number on chain\n lastUncommintedNumber: bigint | null = null;\n\n // local sequence number\n currentNumber: bigint | null = null;\n\n /**\n * We want to guarantee that we preserve ordering of workers to requests.\n *\n * `lock` is used to try to prevent multiple coroutines from accessing a shared resource at the same time,\n * which can result in race conditions and data inconsistency.\n * This code actually doesn't do it though, since we aren't giving out a slot, it is still somewhat a race condition.\n *\n * The ideal solution is likely that each thread grabs the next number from a incremental integer.\n * When they complete, they increment that number and that entity is able to enter the `lock`.\n * That would guarantee ordering.\n */\n lock = false;\n\n maxWaitTime: number;\n\n maximumInFlight: number;\n\n sleepTime: number;\n\n constructor(\n aptosConfig: AptosConfig,\n account: Account,\n maxWaitTime: number,\n maximumInFlight: number,\n sleepTime: number,\n ) {\n this.aptosConfig = aptosConfig;\n this.account = account;\n this.maxWaitTime = maxWaitTime;\n this.maximumInFlight = maximumInFlight;\n this.sleepTime = sleepTime;\n }\n\n /**\n * Returns the next available sequence number for this account\n *\n * @returns next available sequence number\n */\n async nextSequenceNumber(): Promise<bigint | null> {\n /* eslint-disable no-await-in-loop */\n while (this.lock) {\n await sleep(this.sleepTime);\n }\n\n this.lock = true;\n let nextNumber = BigInt(0);\n try {\n if (this.lastUncommintedNumber === null || this.currentNumber === null) {\n await this.initialize();\n }\n\n if (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {\n await this.update();\n\n const startTime = now();\n while (this.currentNumber! - this.lastUncommintedNumber! >= this.maximumInFlight) {\n await sleep(this.sleepTime);\n if (now() - startTime > this.maxWaitTime) {\n /* eslint-disable no-console */\n console.warn(\n `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,\n );\n await this.initialize();\n } else {\n await this.update();\n }\n }\n }\n nextNumber = this.currentNumber!;\n this.currentNumber! += BigInt(1);\n } catch (e) {\n console.error(\"error in getting next sequence number for this account\", e);\n } finally {\n this.lock = false;\n }\n return nextNumber;\n }\n\n /**\n * Initializes this account with the sequence number on chain\n */\n async initialize(): Promise<void> {\n const { sequence_number: sequenceNumber } = await getInfo({\n aptosConfig: this.aptosConfig,\n accountAddress: this.account.accountAddress,\n });\n this.currentNumber = BigInt(sequenceNumber);\n this.lastUncommintedNumber = BigInt(sequenceNumber);\n }\n\n /**\n * Updates this account sequence number with the one on-chain\n *\n * @returns on-chain sequence number for this account\n */\n async update(): Promise<bigint> {\n const { sequence_number: sequenceNumber } = await getInfo({\n aptosConfig: this.aptosConfig,\n accountAddress: this.account.accountAddress,\n });\n this.lastUncommintedNumber = BigInt(sequenceNumber);\n return this.lastUncommintedNumber;\n }\n\n /**\n * Synchronizes local sequence number with the seqeunce number on chain for this account.\n *\n * Poll the network until all submitted transactions have either been committed or until\n * the maximum wait time has elapsed\n */\n async synchronize(): Promise<void> {\n if (this.lastUncommintedNumber === this.currentNumber) return;\n\n /* eslint-disable no-await-in-loop */\n while (this.lock) {\n await sleep(this.sleepTime);\n }\n\n this.lock = true;\n\n try {\n await this.update();\n const startTime = now();\n while (this.lastUncommintedNumber !== this.currentNumber) {\n if (now() - startTime > this.maxWaitTime) {\n /* eslint-disable no-console */\n console.warn(\n `Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`,\n );\n await this.initialize();\n } else {\n await sleep(this.sleepTime);\n await this.update();\n }\n }\n } catch (e) {\n console.error(\"error in synchronizing this account sequence number with the one on chain\", e);\n } finally {\n this.lock = false;\n }\n }\n}\n"],"mappings":"kFA+BA,IAAMA,EAAM,IAAM,KAAK,MAAM,KAAK,IAAI,EAAI,GAAI,EAEjCC,EAAN,KAA4B,CA8BjC,YACEC,EACAC,EACAC,EACAC,EACAC,EACA,CA9BF,2BAAuC,KAGvC,mBAA+B,KAa/B,UAAO,GAeL,KAAK,YAAcJ,EACnB,KAAK,QAAUC,EACf,KAAK,YAAcC,EACnB,KAAK,gB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GAEZ,GAAI,CACF,MAAM,KAAK,OAAO,EAClB,IAAME,EAAYT,EAAI,EACtB,KAAO,KAAK,wBAA0B,KAAK,eACrCA,EAAI,EAAIS,EAAY,KAAK,aAE3B,QAAQ,KACN,iEAAiE,KAAK,QAAQ,eAAe,SAAS,CAAC,EACzG,EACA,MAAM,KAAK,WAAW,IAEtB,MAAMF,EAAM,KAAK,SAAS,EAC1B,MAAM,KAAK,OAAO,EAGxB,OAASG,EAAG,CACV,QAAQ,MAAM,4EAA6EA,CAAC,CAC9F,QAAE,CACA,KAAK,KAAO,EACd,EACF,CACF","names":["now","AccountSequenceNumber","aptosConfig","account","maxWaitTime","maximumInFlight","sleepTime","sleep","nextNumber","startTime","e","sequenceNumber","getInfo"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as $,c as tn,d as en,e as M}from"./chunk-VBTJVPAM.mjs";import{q as nn,t as T}from"./chunk-KOAUBVO6.mjs";import{a as A}from"./chunk-3CLYWZYZ.mjs";import{a as Y}from"./chunk-ONDQ4MK7.mjs";import{a as rn}from"./chunk-KUOIRTNL.mjs";import{a as l,c as f,d as g}from"./chunk-L4Q2XTHT.mjs";import{c as X,d as z,e as Z,f as N,g as j,h as J,i as Q}from"./chunk-TGLSJGFO.mjs";import{a as L}from"./chunk-BWFJHFBQ.mjs";import{b as R,d as F,e as _,f as D}from"./chunk-KVIVMWN5.mjs";import{b as H}from"./chunk-7CAEMK4R.mjs";import{a as K}from"./chunk-MIEV7J74.mjs";import{a as V}from"./chunk-AH44UPM4.mjs";import{a as O}from"./chunk-Y5M5DD64.mjs";import{e as P}from"./chunk-C67BKZND.mjs";import{b as W,c as U,f as C,g as S}from"./chunk-CYNQRMO5.mjs";import{b as h,d as p,e as q}from"./chunk-ZEXZ4CX5.mjs";import{a as v,b as E}from"./chunk-RAYJRFIG.mjs";import{a as G,c as k}from"./chunk-OKCU4GHN.mjs";import{a as x,c as B}from"./chunk-Y2VA7F5D.mjs";import{b as u}from"./chunk-IOSQVDZI.mjs";import{b}from"./chunk-AOCNYMMX.mjs";import{sha3_256 as an}from"@noble/hashes/sha3";async function On(n){if(nn(n))return fn(n);let{moduleAddress:e,moduleName:t,functionName:o}=T(n.function),a=await cn({key:"entry-function",moduleAddress:e,moduleName:t,functionName:o,aptosConfig:n.aptosConfig,abi:n.abi,fetch:tn});return mn({abi:a,...n})}function mn(n){let e=n.abi,{moduleAddress:t,moduleName:o,functionName:a}=T(n.function),r=$(n.typeArguments);if(r.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${r.length}`);let i=n.functionArguments.map((s,d)=>M(n.function,e,s,d,r));if(i.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${o}::${a}', expected ${e.parameters.length} but got ${i.length}`);let c=N.build(`${t}::${o}`,a,r,i);if("multisigAddress"in n){let s=u.from(n.multisigAddress);return new Z(new J(s,new Q(c)))}return new z(c)}async function Vn(n){let{moduleAddress:e,moduleName:t,functionName:o}=T(n.function),a=await cn({key:"view-function",moduleAddress:e,moduleName:t,functionName:o,aptosConfig:n.aptosConfig,abi:n.abi,fetch:en});return yn({abi:a,...n})}function yn(n){let e=n.abi,{moduleAddress:t,moduleName:o,functionName:a}=T(n.function),r=$(n.typeArguments);if(r.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${r.length}`);let i=n?.functionArguments?.map((c,s)=>M(n.function,e,c,s,r))??[];if(i.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${o}::${a}', expected ${e.parameters.length} but got ${i.length}`);return N.build(`${t}::${o}`,a,r,i)}function fn(n){return new X(new j(b.fromHexInput(n.bytecode).toUint8Array(),n.typeArguments??[],n.functionArguments))}async function gn(n){let{aptosConfig:e,sender:t,payload:o,options:a,feePayerAddress:r}=n,i=P[e.network]?Promise.resolve({chain_id:P[e.network]}):O({aptosConfig:e}),c=a?.gasUnitPrice?Promise.resolve({gas_estimate:a.gasUnitPrice}):H({aptosConfig:e}),[{chain_id:s},{gas_estimate:d}]=await Promise.all([i,c]),m=a?.accountSequenceNumber!==void 0?Promise.resolve({sequence_number:a.accountSequenceNumber}):K({aptosConfig:e,accountAddress:t}),y;if(r&&u.from(r).equals(u.ZERO))try{let{sequence_number:w}=await m;y=w}catch{y="0"}else{let{sequence_number:w}=await m;y=w}let{maxGasAmount:un,gasUnitPrice:An,expireTimestamp:dn}={maxGasAmount:a?.maxGasAmount?BigInt(a.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(d),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...a};return new l(u.from(t),BigInt(y),o,BigInt(un),BigInt(An),BigInt(dn),new L(s))}async function Kn(n){let{aptosConfig:e,sender:t,payload:o,options:a,feePayerAddress:r}=n,i=await gn({aptosConfig:e,sender:t,payload:o,options:a,feePayerAddress:r});if("secondarySignerAddresses"in n){let c=n.secondarySignerAddresses?.map(s=>u.from(s))??[];return new rn(i,c,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Y(i,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Hn(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:o,feePayerPublicKey:a}=n,r=I(e);if(t.feePayerAddress){let c=new g(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),s=[];o&&(s=o.map(y=>I(y)));let d=I(a),m=new _(r,t.secondarySignerAddresses??[],s,{address:t.feePayerAddress,authenticator:d});return new A(c.raw_txn,m).bcsToBytes()}if(t.secondarySignerAddresses){let c=new f(t.rawTransaction,t.secondarySignerAddresses),s=[];s=o.map(m=>I(m));let d=new F(r,t.secondarySignerAddresses,s);return new A(c.raw_txn,d).bcsToBytes()}let i;if(r instanceof h)i=new R(r.public_key,r.signature);else if(r instanceof p)i=new D(r);else throw new Error("Invalid public key");return new A(t.rawTransaction,i).bcsToBytes()}function I(n){if(n instanceof v){if(n.publicKey instanceof x)return new p(n,new E(new B(new Uint8Array(64))));if(n.publicKey instanceof G)return new p(n,new E(new k(new Uint8Array(64))))}return new h(new x(n.toUint8Array()),new B(new Uint8Array(64)))}function Ln(n){let{signer:e,transaction:t}=n,o=wn(t);return e.signWithAuthenticator(o)}function pn(n){let{transaction:e,senderAuthenticator:t,feePayerAuthenticator:o,additionalSignersAuthenticators:a}=n,r=sn(e);if((o||a)&&(r instanceof f||r instanceof g))return Tn(r,t,o,a);if(t instanceof h&&r instanceof l){let i=new R(t.public_key,t.signature);return new A(r,i).bcsToBytes()}if((t instanceof p||t instanceof q)&&r instanceof l){let i=new D(t);return new A(r,i).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${t} is not a supported account authentication scheme`)}function on(n){let e=an.create();for(let t of n)e.update(t);return e.digest()}var ln=on(["APTOS::Transaction"]);function Xn(n){let e=pn(n);return new b(on([ln,new Uint8Array([0]),e])).toString()}function sn(n){return n.feePayerAddress?new g(n.rawTransaction,n.secondarySignerAddresses??[],n.feePayerAddress):n.secondarySignerAddresses?new f(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Tn(n,e,t,o){if(n instanceof g){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let a=new _(e,n.secondary_signer_addresses,o??[],{address:n.fee_payer_address,authenticator:t});return new A(n.raw_txn,a).bcsToBytes()}if(n instanceof f){if(!o)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let a=new F(e,n.secondary_signer_addresses,o??[]);return new A(n.raw_txn,a).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}function wn(n){let e=sn(n),t=an.create();if(e instanceof l)t.update(C);else if(e instanceof f)t.update(S);else if(e instanceof g)t.update(S);else throw new Error(`Unknown transaction type to sign on: ${e}`);let o=t.digest(),a=e.bcsToBytes(),r=new Uint8Array(o.length+a.length);return r.set(o),r.set(a,o.length),r}async function cn({key:n,moduleAddress:e,moduleName:t,functionName:o,aptosConfig:a,abi:r,fetch:i}){return r||V(async()=>i(e,t,o,a),`${n}-${a.network}-${e}-${t}-${o}`,1e3*60*5)()}export{On as a,mn as b,Vn as c,yn as d,gn as e,Kn as f,Hn as g,I as h,Ln as i,pn as j,on as k,Xn as l,sn as m,Tn as n,wn as o};
|
|
2
|
-
//# sourceMappingURL=chunk-54BANKLA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/transactionBuilder/transactionBuilder.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file handles the transaction creation lifecycle.\n * It holds different operations to generate a transaction payload, a raw transaction,\n * and a signed transaction that can be simulated, signed and submitted to chain.\n */\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { AccountAddress, AccountAddressInput, Hex, PublicKey } from \"../../core\";\nimport { Account } from \"../../core/account\";\nimport { AnyPublicKey, AnySignature } from \"../../core/crypto\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"../../core/crypto/ed25519\";\nimport { Secp256k1PublicKey, Secp256k1Signature } from \"../../core/crypto/secp256k1\";\nimport { getInfo } from \"../../internal/account\";\nimport { getLedgerInfo } from \"../../internal/general\";\nimport { getGasPriceEstimation } from \"../../internal/transaction\";\nimport { NetworkToChainId } from \"../../utils/apiEndpoints\";\nimport {\n DEFAULT_MAX_GAS_AMOUNT,\n DEFAULT_TXN_EXP_SEC_FROM_NOW,\n RAW_TRANSACTION_SALT,\n RAW_TRANSACTION_WITH_DATA_SALT,\n} from \"../../utils/const\";\nimport {\n AccountAuthenticator,\n AccountAuthenticatorEd25519,\n AccountAuthenticatorMultiKey,\n AccountAuthenticatorSingleKey,\n} from \"../authenticator/account\";\nimport {\n TransactionAuthenticatorEd25519,\n TransactionAuthenticatorFeePayer,\n TransactionAuthenticatorMultiAgent,\n TransactionAuthenticatorSingleSender,\n} from \"../authenticator/transaction\";\nimport {\n ChainId,\n EntryFunction,\n FeePayerRawTransaction,\n MultiAgentRawTransaction,\n MultiSig,\n MultiSigTransactionPayload,\n RawTransaction,\n Script,\n TransactionPayloadEntryFunction,\n TransactionPayloadMultiSig,\n TransactionPayloadScript,\n} from \"../instances\";\nimport { SignedTransaction } from \"../instances/signedTransaction\";\nimport {\n AnyRawTransaction,\n AnyTransactionPayloadInstance,\n AnyRawTransactionInstance,\n EntryFunctionArgumentTypes,\n InputGenerateMultiAgentRawTransactionArgs,\n InputGenerateRawTransactionArgs,\n InputGenerateSingleSignerRawTransactionArgs,\n InputGenerateTransactionOptions,\n InputScriptData,\n InputSimulateTransactionData,\n InputMultiSigDataWithRemoteABI,\n InputEntryFunctionDataWithRemoteABI,\n InputGenerateTransactionPayloadDataWithRemoteABI,\n InputSubmitTransactionData,\n InputGenerateTransactionPayloadDataWithABI,\n InputEntryFunctionDataWithABI,\n InputMultiSigDataWithABI,\n InputViewFunctionDataWithRemoteABI,\n InputViewFunctionDataWithABI,\n FunctionABI,\n} from \"../types\";\nimport { convertArgument, fetchEntryFunctionAbi, fetchViewFunctionAbi, standardizeTypeTags } from \"./remoteAbi\";\nimport { memoizeAsync } from \"../../utils/memoize\";\nimport { AnyNumber } from \"../../types\";\nimport { getFunctionParts, isScriptDataInput } from \"./helpers\";\nimport { SimpleTransaction } from \"../instances/simpleTransaction\";\nimport { MultiAgentTransaction } from \"../instances/multiAgentTransaction\";\n\n/**\n * We are defining function signatures, each with its specific input and output.\n * These are the possible function signature for our `generateTransactionPayload` function.\n * When we call our `generateTransactionPayload` function with the relevant type properties,\n * Typescript can infer the return type based on the appropriate function overload.\n */\nexport async function generateTransactionPayload(args: InputScriptData): Promise<TransactionPayloadScript>;\nexport async function generateTransactionPayload(\n args: InputEntryFunctionDataWithRemoteABI,\n): Promise<TransactionPayloadEntryFunction>;\nexport async function generateTransactionPayload(\n args: InputMultiSigDataWithRemoteABI,\n): Promise<TransactionPayloadMultiSig>;\n\n/**\n * Builds a transaction payload based on the data argument and returns\n * a transaction payload - TransactionPayloadScript | TransactionPayloadMultiSig | TransactionPayloadEntryFunction\n *\n * This uses the RemoteABI by default, and the remote ABI can be skipped by using generateTransactionPayloadWithABI\n *\n * @param args.data GenerateTransactionPayloadData\n *\n * @return TransactionPayload\n */\nexport async function generateTransactionPayload(\n args: InputGenerateTransactionPayloadDataWithRemoteABI,\n): Promise<AnyTransactionPayloadInstance> {\n if (isScriptDataInput(args)) {\n return generateTransactionPayloadScript(args);\n }\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n const functionAbi = await fetchAbi({\n key: \"entry-function\",\n moduleAddress,\n moduleName,\n functionName,\n aptosConfig: args.aptosConfig,\n abi: args.abi,\n fetch: fetchEntryFunctionAbi,\n });\n\n // Fill in the ABI\n return generateTransactionPayloadWithABI({ abi: functionAbi, ...args });\n}\n\nexport function generateTransactionPayloadWithABI(args: InputEntryFunctionDataWithABI): TransactionPayloadEntryFunction;\nexport function generateTransactionPayloadWithABI(args: InputMultiSigDataWithABI): TransactionPayloadMultiSig;\nexport function generateTransactionPayloadWithABI(\n args: InputGenerateTransactionPayloadDataWithABI,\n): AnyTransactionPayloadInstance {\n const functionAbi = args.abi;\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n // Ensure that all type arguments are typed properly\n const typeArguments = standardizeTypeTags(args.typeArguments);\n\n // Check the type argument count against the ABI\n if (typeArguments.length !== functionAbi.typeParameters.length) {\n throw new Error(\n `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`,\n );\n }\n\n // Check all BCS types, and convert any non-BCS types\n const functionArguments: Array<EntryFunctionArgumentTypes> = args.functionArguments.map((arg, i) =>\n convertArgument(args.function, functionAbi, arg, i, typeArguments),\n );\n\n // Check that all arguments are accounted for\n if (functionArguments.length !== functionAbi.parameters.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`,\n );\n }\n\n // Generate entry function payload\n const entryFunctionPayload = EntryFunction.build(\n `${moduleAddress}::${moduleName}`,\n functionName,\n typeArguments,\n functionArguments,\n );\n\n // Send it as multi sig if it's a multisig payload\n if (\"multisigAddress\" in args) {\n const multisigAddress = AccountAddress.from(args.multisigAddress);\n return new TransactionPayloadMultiSig(\n new MultiSig(multisigAddress, new MultiSigTransactionPayload(entryFunctionPayload)),\n );\n }\n\n // Otherwise send as an entry function\n return new TransactionPayloadEntryFunction(entryFunctionPayload);\n}\n\nexport async function generateViewFunctionPayload(args: InputViewFunctionDataWithRemoteABI): Promise<EntryFunction> {\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n const functionAbi = await fetchAbi({\n key: \"view-function\",\n moduleAddress,\n moduleName,\n functionName,\n aptosConfig: args.aptosConfig,\n abi: args.abi,\n fetch: fetchViewFunctionAbi,\n });\n\n // Fill in the ABI\n return generateViewFunctionPayloadWithABI({ abi: functionAbi, ...args });\n}\n\nexport function generateViewFunctionPayloadWithABI(args: InputViewFunctionDataWithABI): EntryFunction {\n const functionAbi = args.abi;\n const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);\n\n // Ensure that all type arguments are typed properly\n const typeArguments = standardizeTypeTags(args.typeArguments);\n\n // Check the type argument count against the ABI\n if (typeArguments.length !== functionAbi.typeParameters.length) {\n throw new Error(\n `Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`,\n );\n }\n\n // Check all BCS types, and convert any non-BCS types\n const functionArguments: Array<EntryFunctionArgumentTypes> =\n args?.functionArguments?.map((arg, i) => convertArgument(args.function, functionAbi, arg, i, typeArguments)) ?? [];\n\n // Check that all arguments are accounted for\n if (functionArguments.length !== functionAbi.parameters.length) {\n throw new Error(\n // eslint-disable-next-line max-len\n `Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`,\n );\n }\n\n // Generate entry function payload\n return EntryFunction.build(`${moduleAddress}::${moduleName}`, functionName, typeArguments, functionArguments);\n}\n\nfunction generateTransactionPayloadScript(args: InputScriptData) {\n return new TransactionPayloadScript(\n new Script(Hex.fromHexInput(args.bytecode).toUint8Array(), args.typeArguments ?? [], args.functionArguments),\n );\n}\n\n/**\n * Generates a raw transaction\n *\n * @param args.aptosConfig AptosConfig\n * @param args.sender The transaction's sender account address as a hex input\n * @param args.payload The transaction payload - can create by using generateTransactionPayload()\n *\n * @returns RawTransaction\n */\nexport async function generateRawTransaction(args: {\n aptosConfig: AptosConfig;\n sender: AccountAddressInput;\n payload: AnyTransactionPayloadInstance;\n options?: InputGenerateTransactionOptions;\n feePayerAddress?: AccountAddressInput;\n}): Promise<RawTransaction> {\n const { aptosConfig, sender, payload, options, feePayerAddress } = args;\n\n const getChainId = NetworkToChainId[aptosConfig.network]\n ? Promise.resolve({ chain_id: NetworkToChainId[aptosConfig.network] })\n : getLedgerInfo({ aptosConfig });\n\n const getGasUnitPrice = options?.gasUnitPrice\n ? Promise.resolve({ gas_estimate: options.gasUnitPrice })\n : getGasPriceEstimation({ aptosConfig });\n\n const [{ chain_id: chainId }, { gas_estimate: gasEstimate }] = await Promise.all([getChainId, getGasUnitPrice]);\n\n const getSequenceNumber =\n options?.accountSequenceNumber !== undefined\n ? Promise.resolve({ sequence_number: options.accountSequenceNumber })\n : getInfo({ aptosConfig, accountAddress: sender });\n\n let sequenceNumber: string | AnyNumber;\n\n /**\n * Check if is sponsored transaction to honor AIP-52\n * {@link https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-52.md}\n */\n if (feePayerAddress && AccountAddress.from(feePayerAddress).equals(AccountAddress.ZERO)) {\n // Handle sponsored transaction generation with the option that\n // the main signer has not been created on chain\n try {\n // Check if main signer has been created on chain, if not assign sequence number 0\n const { sequence_number: seqNumber } = await getSequenceNumber;\n sequenceNumber = seqNumber;\n } catch (e: any) {\n sequenceNumber = \"0\";\n }\n } else {\n const { sequence_number: seqNumber } = await getSequenceNumber;\n sequenceNumber = seqNumber;\n }\n\n const { maxGasAmount, gasUnitPrice, expireTimestamp } = {\n maxGasAmount: options?.maxGasAmount ? BigInt(options.maxGasAmount) : BigInt(DEFAULT_MAX_GAS_AMOUNT),\n gasUnitPrice: BigInt(gasEstimate),\n expireTimestamp: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_TXN_EXP_SEC_FROM_NOW),\n ...options,\n };\n\n return new RawTransaction(\n AccountAddress.from(sender),\n BigInt(sequenceNumber),\n payload,\n BigInt(maxGasAmount),\n BigInt(gasUnitPrice),\n BigInt(expireTimestamp),\n new ChainId(chainId),\n );\n}\n\n/**\n * We are defining function signatures, each with its specific input and output.\n * These are the possible function signature for our `generateTransaction` function.\n * When we call our `generateTransaction` function with the relevant type properties,\n * Typescript can infer the return type based on the appropriate function overload.\n */\nexport async function buildTransaction(args: InputGenerateSingleSignerRawTransactionArgs): Promise<SimpleTransaction>;\nexport async function buildTransaction(args: InputGenerateMultiAgentRawTransactionArgs): Promise<MultiAgentTransaction>;\n\n/**\n * Generates a transaction based on the provided arguments\n *\n * Note: we can start with one function to support all different payload/transaction types,\n * and if to complex to use, we could have function for each type\n *\n * @param args.aptosConfig AptosConfig\n * @param args.sender The transaction's sender account address as a hex input\n * @param args.payload The transaction payload - can create by using generateTransactionPayload()\n * @param args.options optional. Transaction options object\n * @param args.secondarySignerAddresses optional. For when want to create a multi signers transaction\n * @param args.feePayerAddress optional. For when want to create a fee payer (aka sponsored) transaction\n *\n * @return An instance of a RawTransaction, plus optional secondary/fee payer addresses\n * ```\n * {\n * rawTransaction: RawTransaction,\n * secondarySignerAddresses? : Array<AccountAddress>,\n * feePayerAddress?: AccountAddress\n * }\n * ```\n */\nexport async function buildTransaction(args: InputGenerateRawTransactionArgs): Promise<AnyRawTransaction> {\n const { aptosConfig, sender, payload, options, feePayerAddress } = args;\n // generate raw transaction\n const rawTxn = await generateRawTransaction({\n aptosConfig,\n sender,\n payload,\n options,\n feePayerAddress,\n });\n\n // if multi agent transaction\n if (\"secondarySignerAddresses\" in args) {\n const signers: Array<AccountAddress> =\n args.secondarySignerAddresses?.map((signer) => AccountAddress.from(signer)) ?? [];\n\n return new MultiAgentTransaction(\n rawTxn,\n signers,\n args.feePayerAddress ? AccountAddress.from(args.feePayerAddress) : undefined,\n );\n }\n // return the raw transaction\n return new SimpleTransaction(rawTxn, args.feePayerAddress ? AccountAddress.from(args.feePayerAddress) : undefined);\n}\n\n/**\n * Simulate a transaction before signing and submit to chain\n *\n * @param args.transaction A aptos transaction type to sign\n * @param args.signerPublicKey The signer public key\n * @param args.secondarySignersPublicKeys optional. The secondary signers public keys if multi signers transaction\n * @param args.feePayerPublicKey optional. The fee payer public key is a fee payer (aka sponsored) transaction\n * @param args.options optional. SimulateTransactionOptions\n *\n * @returns A signed serialized transaction that can be simulated\n */\nexport function generateSignedTransactionForSimulation(args: InputSimulateTransactionData): Uint8Array {\n const { signerPublicKey, transaction, secondarySignersPublicKeys, feePayerPublicKey } = args;\n\n const accountAuthenticator = getAuthenticatorForSimulation(signerPublicKey);\n\n // fee payer transaction\n if (transaction.feePayerAddress) {\n const transactionToSign = new FeePayerRawTransaction(\n transaction.rawTransaction,\n transaction.secondarySignerAddresses ?? [],\n transaction.feePayerAddress,\n );\n let secondaryAccountAuthenticators: Array<AccountAuthenticator> = [];\n if (secondarySignersPublicKeys) {\n secondaryAccountAuthenticators = secondarySignersPublicKeys.map((publicKey) =>\n getAuthenticatorForSimulation(publicKey),\n );\n }\n const feePayerAuthenticator = getAuthenticatorForSimulation(feePayerPublicKey!);\n\n const transactionAuthenticator = new TransactionAuthenticatorFeePayer(\n accountAuthenticator,\n transaction.secondarySignerAddresses ?? [],\n secondaryAccountAuthenticators,\n {\n address: transaction.feePayerAddress,\n authenticator: feePayerAuthenticator,\n },\n );\n return new SignedTransaction(transactionToSign.raw_txn, transactionAuthenticator).bcsToBytes();\n }\n\n // multi agent transaction\n if (transaction.secondarySignerAddresses) {\n const transactionToSign = new MultiAgentRawTransaction(\n transaction.rawTransaction,\n transaction.secondarySignerAddresses,\n );\n\n let secondaryAccountAuthenticators: Array<AccountAuthenticator> = [];\n\n secondaryAccountAuthenticators = secondarySignersPublicKeys!.map((publicKey) =>\n getAuthenticatorForSimulation(publicKey),\n );\n\n const transactionAuthenticator = new TransactionAuthenticatorMultiAgent(\n accountAuthenticator,\n transaction.secondarySignerAddresses,\n secondaryAccountAuthenticators,\n );\n\n return new SignedTransaction(transactionToSign.raw_txn, transactionAuthenticator).bcsToBytes();\n }\n\n // single signer raw transaction\n let transactionAuthenticator;\n if (accountAuthenticator instanceof AccountAuthenticatorEd25519) {\n transactionAuthenticator = new TransactionAuthenticatorEd25519(\n accountAuthenticator.public_key,\n accountAuthenticator.signature,\n );\n } else if (accountAuthenticator instanceof AccountAuthenticatorSingleKey) {\n transactionAuthenticator = new TransactionAuthenticatorSingleSender(accountAuthenticator);\n } else {\n throw new Error(\"Invalid public key\");\n }\n return new SignedTransaction(transaction.rawTransaction, transactionAuthenticator).bcsToBytes();\n}\n\nexport function getAuthenticatorForSimulation(publicKey: PublicKey) {\n // TODO add support for AnyMultiKey\n if (publicKey instanceof AnyPublicKey) {\n if (publicKey.publicKey instanceof Ed25519PublicKey) {\n return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Ed25519Signature(new Uint8Array(64))));\n }\n if (publicKey.publicKey instanceof Secp256k1PublicKey) {\n return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Secp256k1Signature(new Uint8Array(64))));\n }\n }\n\n // legacy code\n return new AccountAuthenticatorEd25519(\n new Ed25519PublicKey(publicKey.toUint8Array()),\n new Ed25519Signature(new Uint8Array(64)),\n );\n}\n\n/**\n * Sign a transaction that can later be submitted to chain\n *\n * @param args.signer The signer account to sign the transaction\n * @param args.transaction A aptos transaction type to sign\n *\n * @return The signer AccountAuthenticator\n */\nexport function sign(args: { signer: Account; transaction: AnyRawTransaction }): AccountAuthenticator {\n const { signer, transaction } = args;\n\n // get the signing message\n const message = generateSigningMessage(transaction);\n\n // account.signMessage\n return signer.signWithAuthenticator(message);\n}\n\n/**\n * Prepare a transaction to be submitted to chain\n *\n * @param args.transaction A aptos transaction type\n * @param args.senderAuthenticator The account authenticator of the transaction sender\n * @param args.secondarySignerAuthenticators optional. For when the transaction is a multi signers transaction\n *\n * @returns A SignedTransaction\n */\nexport function generateSignedTransaction(args: InputSubmitTransactionData): Uint8Array {\n const { transaction, senderAuthenticator, feePayerAuthenticator, additionalSignersAuthenticators } = args;\n\n const transactionToSubmit = deriveTransactionType(transaction);\n\n if (\n (feePayerAuthenticator || additionalSignersAuthenticators) &&\n (transactionToSubmit instanceof MultiAgentRawTransaction || transactionToSubmit instanceof FeePayerRawTransaction)\n ) {\n return generateMultiSignersSignedTransaction(\n transactionToSubmit,\n senderAuthenticator,\n feePayerAuthenticator,\n additionalSignersAuthenticators,\n );\n }\n\n // submit single signer transaction\n\n // check what instance is accountAuthenticator\n if (senderAuthenticator instanceof AccountAuthenticatorEd25519 && transactionToSubmit instanceof RawTransaction) {\n const transactionAuthenticator = new TransactionAuthenticatorEd25519(\n senderAuthenticator.public_key,\n senderAuthenticator.signature,\n );\n return new SignedTransaction(transactionToSubmit, transactionAuthenticator).bcsToBytes();\n }\n\n if (\n (senderAuthenticator instanceof AccountAuthenticatorSingleKey ||\n senderAuthenticator instanceof AccountAuthenticatorMultiKey) &&\n transactionToSubmit instanceof RawTransaction\n ) {\n const transactionAuthenticator = new TransactionAuthenticatorSingleSender(senderAuthenticator);\n return new SignedTransaction(transactionToSubmit, transactionAuthenticator).bcsToBytes();\n }\n\n throw new Error(\n `Cannot generate a signed transaction, ${senderAuthenticator} is not a supported account authentication scheme`,\n );\n}\n\n/**\n * Hashes the set of values with a SHA-3 256 hash\n * @param input array of UTF-8 strings or Uint8array byte arrays\n */\nexport function hashValues(input: (Uint8Array | string)[]): Uint8Array {\n const hash = sha3Hash.create();\n for (const item of input) {\n hash.update(item);\n }\n return hash.digest();\n}\n\n/**\n * The domain separated prefix for hashing transacitons\n */\nconst TRANSACTION_PREFIX = hashValues([\"APTOS::Transaction\"]);\n\n/**\n * Generates a user transaction hash for the given transaction payload. It must already have an authenticator\n * @param args InputSubmitTransactionData\n */\nexport function generateUserTransactionHash(args: InputSubmitTransactionData): string {\n const signedTransaction = generateSignedTransaction(args);\n\n // Transaction signature is defined as, the domain separated prefix based on struct (Transaction)\n // Then followed by the type of the transaction for the enum, UserTransaction is 0\n // Then followed by BCS encoded bytes of the signed transaction\n return new Hex(hashValues([TRANSACTION_PREFIX, new Uint8Array([0]), signedTransaction])).toString();\n}\n\n/**\n * Derive the raw transaction type - FeePayerRawTransaction or MultiAgentRawTransaction or RawTransaction\n *\n * @param transaction A aptos transaction type\n *\n * @returns FeePayerRawTransaction | MultiAgentRawTransaction | RawTransaction\n */\nexport function deriveTransactionType(transaction: AnyRawTransaction): AnyRawTransactionInstance {\n if (transaction.feePayerAddress) {\n return new FeePayerRawTransaction(\n transaction.rawTransaction,\n transaction.secondarySignerAddresses ?? [],\n transaction.feePayerAddress,\n );\n }\n if (transaction.secondarySignerAddresses) {\n return new MultiAgentRawTransaction(transaction.rawTransaction, transaction.secondarySignerAddresses);\n }\n\n return transaction.rawTransaction;\n}\n\n/**\n * Generate a multi signers signed transaction that can be submitted to chain\n *\n * @param transaction MultiAgentRawTransaction | FeePayerRawTransaction\n * @param senderAuthenticator The account authenticator of the transaction sender\n * @param secondarySignerAuthenticators The extra signers account Authenticators\n *\n * @returns A SignedTransaction\n */\nexport function generateMultiSignersSignedTransaction(\n transaction: MultiAgentRawTransaction | FeePayerRawTransaction,\n senderAuthenticator: AccountAuthenticator,\n feePayerAuthenticator?: AccountAuthenticator,\n additionalSignersAuthenticators?: Array<AccountAuthenticator>,\n) {\n if (transaction instanceof FeePayerRawTransaction) {\n if (!feePayerAuthenticator) {\n throw new Error(\"Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction\");\n }\n const txAuthenticatorFeePayer = new TransactionAuthenticatorFeePayer(\n senderAuthenticator,\n transaction.secondary_signer_addresses,\n additionalSignersAuthenticators ?? [],\n {\n address: transaction.fee_payer_address,\n authenticator: feePayerAuthenticator,\n },\n );\n return new SignedTransaction(transaction.raw_txn, txAuthenticatorFeePayer).bcsToBytes();\n }\n if (transaction instanceof MultiAgentRawTransaction) {\n if (!additionalSignersAuthenticators) {\n throw new Error(\n \"Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction\",\n );\n }\n const multiAgentAuthenticator = new TransactionAuthenticatorMultiAgent(\n senderAuthenticator,\n transaction.secondary_signer_addresses,\n additionalSignersAuthenticators ?? [],\n );\n return new SignedTransaction(transaction.raw_txn, multiAgentAuthenticator).bcsToBytes();\n }\n\n throw new Error(\n `Cannot prepare multi signers transaction to submission, ${typeof transaction} transaction is not supported`,\n );\n}\n\nexport function generateSigningMessage(transaction: AnyRawTransaction): Uint8Array {\n const rawTxn = deriveTransactionType(transaction);\n const hash = sha3Hash.create();\n\n if (rawTxn instanceof RawTransaction) {\n hash.update(RAW_TRANSACTION_SALT);\n } else if (rawTxn instanceof MultiAgentRawTransaction) {\n hash.update(RAW_TRANSACTION_WITH_DATA_SALT);\n } else if (rawTxn instanceof FeePayerRawTransaction) {\n hash.update(RAW_TRANSACTION_WITH_DATA_SALT);\n } else {\n throw new Error(`Unknown transaction type to sign on: ${rawTxn}`);\n }\n\n const prefix = hash.digest();\n\n const body = rawTxn.bcsToBytes();\n\n const mergedArray = new Uint8Array(prefix.length + body.length);\n mergedArray.set(prefix);\n mergedArray.set(body, prefix.length);\n\n return mergedArray;\n}\n\n/**\n * Fetches and caches ABIs with allowing for pass-through on provided ABIs\n * @param key\n * @param moduleAddress\n * @param moduleName\n * @param functionName\n * @param aptosConfig\n * @param abi\n * @param fetch\n */\nasync function fetchAbi<T extends FunctionABI>({\n key,\n moduleAddress,\n moduleName,\n functionName,\n aptosConfig,\n abi,\n fetch,\n}: {\n key: string;\n moduleAddress: string;\n moduleName: string;\n functionName: string;\n aptosConfig: AptosConfig;\n abi?: T;\n fetch: (moduleAddress: string, moduleName: string, functionName: string, aptosConfig: AptosConfig) => Promise<T>;\n}): Promise<T> {\n if (abi) {\n return abi;\n }\n\n // We fetch the entry function ABI, and then pretend that we already had the ABI\n return memoizeAsync(\n async () => fetch(moduleAddress, moduleName, functionName, aptosConfig),\n `${key}-${aptosConfig.network}-${moduleAddress}-${moduleName}-${functionName}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n"],"mappings":"6/BAQA,OAAS,YAAYA,OAAgB,qBAgGrC,eAAsBC,GACpBC,EACwC,CACxC,GAAIC,GAAkBD,CAAI,EACxB,OAAOE,GAAiCF,CAAI,EAE9C,GAAM,CAAE,cAAAG,EAAe,WAAAC,EAAY,aAAAC,CAAa,EAAIC,EAAiBN,EAAK,QAAQ,EAE5EO,EAAc,MAAMC,GAAS,CACjC,IAAK,iBACL,cAAAL,EACA,WAAAC,EACA,aAAAC,EACA,YAAaL,EAAK,YAClB,IAAKA,EAAK,IACV,MAAOS,EACT,CAAC,EAGD,OAAOC,GAAkC,CAAE,IAAKH,EAAa,GAAGP,CAAK,CAAC,CACxE,CAIO,SAASU,GACdV,EAC+B,CAC/B,IAAMO,EAAcP,EAAK,IACnB,CAAE,cAAAG,EAAe,WAAAC,EAAY,aAAAC,CAAa,EAAIC,EAAiBN,EAAK,QAAQ,EAG5EW,EAAgBC,EAAoBZ,EAAK,aAAa,EAG5D,GAAIW,EAAc,SAAWJ,EAAY,eAAe,OACtD,MAAM,IAAI,MACR,0CAA0CA,EAAY,eAAe,MAAM,cAAcI,EAAc,MAAM,EAC/G,EAIF,IAAME,EAAuDb,EAAK,kBAAkB,IAAI,CAACc,EAAKC,IAC5FC,EAAgBhB,EAAK,SAAUO,EAAaO,EAAKC,EAAGJ,CAAa,CACnE,EAGA,GAAIE,EAAkB,SAAWN,EAAY,WAAW,OACtD,MAAM,IAAI,MAER,0BAA0BJ,CAAa,KAAKC,CAAU,KAAKC,CAAY,eAAeE,EAAY,WAAW,MAAM,YAAYM,EAAkB,M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AetG,GAAgC,CAC7C,IAAAuG,EACA,cAAA5G,EACA,WAAAC,EACA,aAAAC,EACA,YAAA2B,EACA,IAAAgF,EACA,MAAAC,CACF,EAQe,CACb,OAAID,GAKGE,EACL,SAAYD,EAAM9G,EAAeC,EAAYC,EAAc2B,CAAW,EACtE,GAAG+E,CAAG,IAAI/E,EAAY,OAAO,IAAI7B,CAAa,IAAIC,CAAU,IAAIC,CAAY,GAC5E,IAAO,GAAK,CACd,EAAE,CACJ","names":["sha3Hash","generateTransactionPayload","args","isScriptDataInput","generateTransactionPayloadScript","moduleAddress","moduleName","functionName","getFunctionParts","functionAbi","fetchAbi","fetchEntryFunctionAbi","generateTransactionPayloadWithABI","typeArguments","standardizeTypeTags","functionArguments","arg","i","convertArgument","entryFunctionPayload","EntryFunction","multisigAddress","AccountAddress","TransactionPayloadMultiSig","MultiSig","MultiSigTransactionPayload","TransactionPayloadEntryFunction","generateViewFunctionPayload","fetchViewFunctionAbi","generateViewFunctionPayloadWithABI","TransactionPayloadScript","Script","Hex","generateRawTransaction","aptosConfig","sender","payload","options","feePayerAddress","getChainId","NetworkToChainId","getLedgerInfo","getGasUnitPrice","getGasPriceEstimation","chainId","gasEstimate","getSequenceNumber","getInfo","sequenceNumber","seqNumber","maxGasAmount","gasUnitPrice","expireTimestamp","RawTransaction","ChainId","buildTransaction","rawTxn","signers","signer","MultiAgentTransaction","SimpleTransaction","generateSignedTransactionForSimulation","signerPublicKey","transaction","secondarySignersPublicKeys","feePayerPublicKey","accountAuthenticator","getAuthenticatorForSimulation","transactionToSign","FeePayerRawTransaction","secondaryAccountAuthenticators","publicKey","feePayerAuthenticator","transactionAuthenticator","TransactionAuthenticatorFeePayer","SignedTransaction","MultiAgentRawTransaction","TransactionAuthenticatorMultiAgent","AccountAuthenticatorEd25519","TransactionAuthenticatorEd25519","AccountAuthenticatorSingleKey","TransactionAuthenticatorSingleSender","AnyPublicKey","Ed25519PublicKey","AnySignature","Ed25519Signature","Secp256k1PublicKey","Secp256k1Signature","sign","message","generateSigningMessage","generateSignedTransaction","senderAuthenticator","additionalSignersAuthenticators","transactionToSubmit","deriveTransactionType","generateMultiSignersSignedTransaction","AccountAuthenticatorMultiKey","hashValues","input","hash","sha3Hash","item","TRANSACTION_PREFIX","generateUserTransactionHash","signedTransaction","txAuthenticatorFeePayer","multiAgentAuthenticator","RAW_TRANSACTION_SALT","RAW_TRANSACTION_WITH_DATA_SALT","prefix","body","mergedArray","key","abi","fetch","memoizeAsync"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as o,b as r,c as n}from"./chunk-C67BKZND.mjs";import i from"@aptos-labs/aptos-client";var t=class{constructor(e){this.network=e?.network??"devnet",this.fullnode=e?.fullnode,this.faucet=e?.faucet,this.indexer=e?.indexer,this.client=e?.client??{provider:i},this.clientConfig=e?.clientConfig??{},this.fullnodeConfig=e?.fullnodeConfig??{},this.indexerConfig=e?.indexerConfig??{},this.faucetConfig=e?.faucetConfig??{}}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return r[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return n[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return o[this.network];default:throw Error(`apiType ${e} is not supported`)}}};export{t as a};
|
|
2
|
-
//# sourceMappingURL=chunk-5AQEETAC.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/aptosConfig.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport aptosClient from \"@aptos-labs/aptos-client\";\nimport { AptosSettings, ClientConfig, Client, FullNodeConfig, IndexerConfig, FaucetConfig } from \"../types\";\nimport { NetworkToNodeAPI, NetworkToFaucetAPI, NetworkToIndexerAPI, Network } from \"../utils/apiEndpoints\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * This class holds the config information for the SDK client instance.\n *\n * @example\n *\n * const aptosConfig = new AptosConfig({network:Network.TESTNET})\n */\nexport class AptosConfig {\n /**\n * The Network that this SDK is associated with. Defaults to DEVNET\n */\n readonly network: Network;\n\n /**\n * The client instance the SDK uses. Defaults to `@aptos-labs/aptos-client\n */\n readonly client: Client;\n\n /**\n * The optional hardcoded fullnode URL to send requests to instead of using the network\n */\n readonly fullnode?: string;\n\n /**\n * The optional hardcoded faucet URL to send requests to instead of using the network\n */\n readonly faucet?: string;\n\n /**\n * The optional hardcoded indexer URL to send requests to instead of using the network\n */\n readonly indexer?: string;\n\n /**\n * Optional client configurations\n */\n readonly clientConfig?: ClientConfig;\n\n /**\n * Optional specific Fullnode configurations\n */\n readonly fullnodeConfig?: FullNodeConfig;\n\n /**\n * Optional specific Indexer configurations\n */\n readonly indexerConfig?: IndexerConfig;\n\n /**\n * Optional specific Faucet configurations\n */\n readonly faucetConfig?: FaucetConfig;\n\n constructor(settings?: AptosSettings) {\n this.network = settings?.network ?? Network.DEVNET;\n this.fullnode = settings?.fullnode;\n this.faucet = settings?.faucet;\n this.indexer = settings?.indexer;\n this.client = settings?.client ?? { provider: aptosClient };\n this.clientConfig = settings?.clientConfig ?? {};\n this.fullnodeConfig = settings?.fullnodeConfig ?? {};\n this.indexerConfig = settings?.indexerConfig ?? {};\n this.faucetConfig = settings?.faucetConfig ?? {};\n }\n\n /**\n * Returns the URL endpoint to send the request to.\n * If a custom URL was provided in the config, that URL is returned.\n * If a custom URL was provided but not URL endpoints, an error is thrown.\n * Otherwise, the URL endpoint is derived from the network.\n *\n * @param apiType - The type of Aptos API to get the URL for.\n *\n * @internal\n */\n getRequestUrl(apiType: AptosApiType): string {\n switch (apiType) {\n case AptosApiType.FULLNODE:\n if (this.fullnode !== undefined) return this.fullnode;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom full node url\");\n return NetworkToNodeAPI[this.network];\n case AptosApiType.FAUCET:\n if (this.faucet !== undefined) return this.faucet;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom faucet url\");\n return NetworkToFaucetAPI[this.network];\n case AptosApiType.INDEXER:\n if (this.indexer !== undefined) return this.indexer;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom indexer url\");\n return NetworkToIndexerAPI[this.network];\n default:\n throw Error(`apiType ${apiType} is not supported`);\n }\n }\n}\n"],"mappings":"uDAGA,OAAOA,MAAiB,2BAYjB,IAAMC,EAAN,KAAkB,CA8CvB,YAAYC,EAA0B,CACpC,KAAK,QAAUA,GAAU,kBACzB,KAAK,SAAWA,GAAU,SAC1B,KAAK,OAASA,GAAU,OACxB,KAAK,QAAUA,GAAU,QACzB,KAAK,OAASA,GAAU,QAAU,CAAE,SAAUC,CAAY,EAC1D,KAAK,aAAeD,GAAU,cAAgB,CAAC,EAC/C,KAAK,eAAiBA,GAAU,gBAAkB,CAAC,EACnD,KAAK,cAAgBA,GAAU,eAAiB,CAAC,EACjD,KAAK,aAAeA,GAAU,cAAgB,CAAC,CACjD,CAYA,cAAcE,EAA+B,CAC3C,OAAQA,EAAS,CACf,eACE,GAAI,KAAK,WAAa,OAAW,OAAO,KAAK,SAC7C,GAAI,KAAK,mBAA4B,MAAM,IAAI,MAAM,uCAAuC,EAC5F,OAAOC,EAAiB,KAAK,OAAO,EACtC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,mBAA4B,MAAM,IAAI,MAAM,oCAAoC,EACzF,OAAOC,EAAmB,KAAK,OAAO,EACxC,cACE,GAAI,KAAK,UAAY,OAAW,OAAO,KAAK,QAC5C,GAAI,KAAK,mBAA4B,MAAM,IAAI,MAAM,qCAAqC,EAC1F,OAAOC,EAAoB,KAAK,OAAO,EACzC,QACE,MAAM,MAAM,WAAWH,CAAO,mBAAmB,CACrD,CACF,CACF","names":["aptosClient","AptosConfig","settings","aptosClient","apiType","NetworkToNodeAPI","NetworkToFaucetAPI","NetworkToIndexerAPI"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{g as e}from"./chunk-7CAEMK4R.mjs";import{d as r}from"./chunk-YWQLLV2R.mjs";import{d as s}from"./chunk-CYNQRMO5.mjs";import{b as c}from"./chunk-IOSQVDZI.mjs";async function x(a){let{aptosConfig:t,accountAddress:i,amount:p,options:n}=a,u=n?.timeoutSecs||20,{data:d}=await r({aptosConfig:t,path:"fund",body:{address:c.from(i).toString(),amount:p},originMethod:"fundAccount"}),m=d.txn_hashes[0],o=await e({aptosConfig:t,transactionHash:m,options:{timeoutSecs:u,checkSuccess:n?.checkSuccess}});if(o.type==="user_transaction")return o;throw new Error(`Unexpected transaction received for fund account: ${o.type}`)}export{x as a};
|
|
2
|
-
//# sourceMappingURL=chunk-63AIRYJX.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/fungibleAsset.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n AnyNumber,\n GetCurrentFungibleAssetBalancesResponse,\n GetFungibleAssetActivitiesResponse,\n GetFungibleAssetMetadataResponse,\n PaginationArgs,\n WhereArg,\n} from \"../types\";\nimport {\n getCurrentFungibleAssetBalances,\n getFungibleAssetActivities,\n getFungibleAssetMetadata,\n transferFungibleAsset,\n} from \"../internal/fungibleAsset\";\nimport {\n CurrentFungibleAssetBalancesBoolExp,\n FungibleAssetActivitiesBoolExp,\n FungibleAssetMetadataBoolExp,\n} from \"../types/generated/types\";\nimport { ProcessorType } from \"../utils/const\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { waitForIndexerOnVersion } from \"./utils\";\nimport { Account, AccountAddressInput } from \"../core\";\nimport { InputGenerateTransactionOptions } from \"../transactions\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\n\n/**\n * A class to query all `FungibleAsset` related queries on Aptos.\n */\nexport class FungibleAsset {\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Queries all fungible asset metadata.\n *\n * @example\n * const fungibleAsset = await aptos.getFungibleAssetMetadata()\n *\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options Optional configuration for pagination and filtering\n *\n * @returns A list of fungible asset metadata\n */\n async getFungibleAssetMetadata(args?: {\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs & WhereArg<FungibleAssetMetadataBoolExp>;\n }): Promise<GetFungibleAssetMetadataResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args?.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getFungibleAssetMetadata({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries a fungible asset metadata\n *\n * This query returns the fungible asset metadata for a specific fungible asset.\n *\n * @example\n * const fungibleAsset = await aptos.getFungibleAssetMetadataByAssetType({assetType:\"0x123::test_coin::TestCoin\"})\n *\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.assetType The asset type of the fungible asset.\n * e.g\n * \"0x1::aptos_coin::AptosCoin\" for Aptos Coin\n * \"0xc2948283c2ce03aafbb294821de7ee684b06116bb378ab614fa2de07a99355a8\" - address format if this is fungible asset\n *\n * @returns A fungible asset metadata item\n */\n async getFungibleAssetMetadataByAssetType(args: {\n assetType: string;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<GetFungibleAssetMetadataResponse[0]> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args?.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n const data = await getFungibleAssetMetadata({\n aptosConfig: this.config,\n options: {\n where: {\n asset_type: { _eq: args.assetType },\n },\n },\n });\n\n return data[0];\n }\n\n /**\n * Queries all fungible asset activities\n *\n * @example\n * const fungibleAssetActivities = await aptos.getFungibleAssetActivities()\n *\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options Optional configuration for pagination and filtering\n *\n * @returns A list of fungible asset metadata\n */\n async getFungibleAssetActivities(args?: {\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs & WhereArg<FungibleAssetActivitiesBoolExp>;\n }): Promise<GetFungibleAssetActivitiesResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args?.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getFungibleAssetActivities({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries all fungible asset balances\n *\n * @example\n * const fungibleAssetBalances = await aptos.getCurrentFungibleAssetBalances()\n *\n * @param args.minimumLedgerVersion Optional ledger version to sync up to, before querying\n * @param args.options Optional configuration for pagination and filtering\n *\n * @returns A list of fungible asset metadata\n */\n async getCurrentFungibleAssetBalances(args?: {\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs & WhereArg<CurrentFungibleAssetBalancesBoolExp>;\n }): Promise<GetCurrentFungibleAssetBalancesResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args?.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getCurrentFungibleAssetBalances({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Transfer `amount` of fungible asset from sender's primary store to recipient's primary store.\n *\n * Use this method to transfer any fungible asset including fungible token.\n *\n * @example\n * const transaction = await aptos.transferFungibleAsset({\n * sender: alice,\n * fungibleAssetMetadataAddress: \"0x123\",\n * recipient: \"0x456\",\n * amount: 5\n * })\n *\n * @param sender The sender account\n * @param fungibleAssetMetadataAddress The fungible asset account address.\n * For example if you’re transferring USDT this would be the USDT address\n * @param recipient The recipient account address\n * @param amount Number of assets to transfer\n *\n * @returns A SimpleTransaction that can be simulated or submitted to chain.\n */\n async transferFungibleAsset(args: {\n sender: Account;\n fungibleAssetMetadataAddress: AccountAddressInput;\n recipient: AccountAddressInput;\n amount: AnyNumber;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return transferFungibleAsset({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"uGAgCO,IAAMA,EAAN,KAAoB,CACzB,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAa3C,MAAM,yBAAyBC,EAGe,CAC5C,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,wCACF,CAAC,EACME,EAAyB,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CACvE,CAkBA,MAAM,oCAAoCA,EAGO,CAC/C,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,wCACF,CAAC,GACY,MAAME,EAAyB,CAC1C,YAAa,KAAK,OAClB,QAAS,CACP,MAAO,CACL,WAAY,CAAE,IAAKF,EAAK,SAAU,CACpC,CACF,CACF,CAAC,GAEW,CAAC,CACf,CAaA,MAAM,2BAA2BA,EAGe,CAC9C,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,wCACF,CAAC,EACMG,EAA2B,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CACzE,CAaA,MAAM,gCAAgCA,EAGe,CACnD,aAAMC,EAAwB,CAC5B,OAAQ,KAAK,OACb,qBAAsBD,GAAM,qBAC5B,wCACF,CAAC,EACMI,EAAgC,CAAE,YAAa,KAAK,OAAQ,GAAGJ,CAAK,CAAC,CAC9E,CAuBA,MAAM,sBAAsBA,EAMG,CAC7B,OAAOK,EAAsB,CAAE,YAAa,KAAK,OAAQ,GAAGL,CAAK,CAAC,CACpE,CACF","names":["FungibleAsset","config","args","waitForIndexerOnVersion","getFungibleAssetMetadata","getFungibleAssetActivities","getCurrentFungibleAssetBalances","transferFungibleAsset"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{d as y}from"./chunk-ZEXZ4CX5.mjs";import{a as g,b as u}from"./chunk-RAYJRFIG.mjs";import{b as s}from"./chunk-OKCU4GHN.mjs";import{b as i}from"./chunk-Y2VA7F5D.mjs";import{b as o}from"./chunk-IOSQVDZI.mjs";var p=class a{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new g(t.publicKey()),this.accountAddress=r?o.from(r):this.publicKey.authKey().derivedAddress()}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=i.generate();break;case 2:r=s.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new a({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:c}=e,n;switch(t){case 0:n=i.fromDerivationPath(r,c);break;case 2:n=s.fromDerivationPath(r,c);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new a({privateKey:n})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){let t=this.privateKey.sign(e),r=new u(t);return new y(this.publicKey,r)}sign(e){return this.signWithAuthenticator(e).signature}};export{p as a};
|
|
2
|
-
//# sourceMappingURL=chunk-AP7UZTPZ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/account/SingleKeyAccount.ts"],"sourcesContent":["import { AccountAuthenticatorSingleKey } from \"../../transactions/authenticator/account\";\nimport { type HexInput, SigningScheme, SigningSchemeInput } from \"../../types\";\nimport { AccountAddress, AccountAddressInput } from \"../accountAddress\";\nimport { AnyPublicKey, AnySignature, Ed25519PrivateKey, PrivateKey, Secp256k1PrivateKey } from \"../crypto\";\nimport type { Account } from \"./Account\";\n\nexport interface SingleKeySignerConstructorArgs {\n privateKey: PrivateKey;\n address?: AccountAddressInput;\n}\n\nexport interface SingleKeySignerGenerateArgs {\n scheme?: SigningSchemeInput;\n}\n\nexport type SingleKeySignerFromDerivationPathArgs = SingleKeySignerGenerateArgs & {\n path: string;\n mnemonic: string;\n};\n\nexport interface VerifySingleKeySignatureArgs {\n message: HexInput;\n signature: AnySignature;\n}\n\n/**\n * Signer implementation for the SingleKey authentication scheme.\n * This extends a SingleKeyAccount by adding signing capabilities through a valid private key.\n * Currently, the only supported signature schemes are Ed25519 and Secp256k1.\n *\n * Note: Generating a signer instance does not create the account on-chain.\n */\nexport class SingleKeyAccount implements Account {\n /**\n * Private key associated with the account\n */\n readonly privateKey: PrivateKey;\n\n readonly publicKey: AnyPublicKey;\n\n readonly accountAddress: AccountAddress;\n\n readonly signingScheme = SigningScheme.SingleKey;\n\n // region Constructors\n\n constructor(args: SingleKeySignerConstructorArgs) {\n const { privateKey, address } = args;\n this.privateKey = privateKey;\n this.publicKey = new AnyPublicKey(privateKey.publicKey());\n this.accountAddress = address ? AccountAddress.from(address) : this.publicKey.authKey().derivedAddress();\n }\n\n /**\n * Derives an account from a randomly generated private key.\n * Default generation is using an Ed25519 key\n * @returns Account with the given signature scheme\n */\n static generate(args: SingleKeySignerGenerateArgs = {}) {\n const { scheme = SigningSchemeInput.Ed25519 } = args;\n let privateKey: PrivateKey;\n switch (scheme) {\n case SigningSchemeInput.Ed25519:\n privateKey = Ed25519PrivateKey.generate();\n break;\n case SigningSchemeInput.Secp256k1Ecdsa:\n privateKey = Secp256k1PrivateKey.generate();\n break;\n default:\n throw new Error(`Unsupported signature scheme ${scheme}`);\n }\n return new SingleKeyAccount({ privateKey });\n }\n\n /**\n * Derives an account with bip44 path and mnemonics,\n * Default to using an Ed25519 signature scheme.\n *\n * @param args.scheme The signature scheme to derive the private key with\n * @param args.path the BIP44 derive hardened path (e.g. m/44'/637'/0'/0'/0') for Ed25519,\n * or non-hardened path (e.g. m/44'/637'/0'/0/0) for secp256k1\n * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}\n * @param args.mnemonic the mnemonic seed phrase of the account\n */\n static fromDerivationPath(args: SingleKeySignerFromDerivationPathArgs) {\n const { scheme = SigningSchemeInput.Ed25519, path, mnemonic } = args;\n let privateKey: PrivateKey;\n switch (scheme) {\n case SigningSchemeInput.Ed25519:\n privateKey = Ed25519PrivateKey.fromDerivationPath(path, mnemonic);\n break;\n case SigningSchemeInput.Secp256k1Ecdsa:\n privateKey = Secp256k1PrivateKey.fromDerivationPath(path, mnemonic);\n break;\n default:\n throw new Error(`Unsupported signature scheme ${scheme}`);\n }\n return new SingleKeyAccount({ privateKey });\n }\n\n // endregion\n\n // region Account\n\n verifySignature(args: VerifySingleKeySignatureArgs): boolean {\n return this.publicKey.verifySignature(args);\n }\n\n signWithAuthenticator(message: HexInput) {\n const innerSignature = this.privateKey.sign(message);\n const signature = new AnySignature(innerSignature);\n return new AccountAuthenticatorSingleKey(this.publicKey, signature);\n }\n\n sign(message: HexInput) {\n return this.signWithAuthenticator(message).signature;\n }\n\n // endregion\n}\n"],"mappings":"oNAgCO,IAAMA,EAAN,MAAMC,CAAoC,CAc/C,YAAYC,EAAsC,CAJlD,KAAS,cAAgB,EAKvB,GAAM,CAAE,WAAAC,EAAY,QAAAC,CAAQ,EAAIF,EAChC,KAAK,WAAaC,EAClB,KAAK,UAAY,IAAIE,EAAaF,EAAW,UAAU,CAAC,EACxD,KAAK,eAAiBC,EAAUE,EAAe,KAAKF,CAAO,EAAI,KAAK,UAAU,QAAQ,EAAE,eAAe,CACzG,CAOA,OAAO,SAASF,EAAoC,CAAC,EAAG,CACtD,GAAM,CAAE,OAAAK,GAAoC,EAAIL,EAC5CC,EACJ,OAAQI,EAAQ,CACd,OACEJ,EAAaK,EAAkB,SAAS,EACxC,MACF,OACEL,EAAaM,EAAoB,SAAS,EAC1C,MACF,QACE,MAAM,IAAI,MAAM,gCAAgCF,CAAM,EAAE,CAC5D,CACA,OAAO,IAAIN,EAAiB,CAAE,WAAAE,CAAW,CAAC,CAC5C,CAYA,OAAO,mBAAmBD,EAA6C,CACrE,GAAM,CAAE,OAAAK,IAAqC,KAAAG,EAAM,SAAAC,CAAS,EAAIT,EAC5DC,EACJ,OAAQI,EAAQ,CACd,OACEJ,EAAaK,EAAkB,mBAAmBE,EAAMC,CAAQ,EAChE,MACF,OACER,EAAaM,EAAoB,mBAAmBC,EAAMC,CAAQ,EAClE,MACF,QACE,MAAM,IAAI,MAAM,gCAAgCJ,CAAM,EAAE,CAC5D,CACA,OAAO,IAAIN,EAAiB,CAAE,WAAAE,CAAW,CAAC,CAC5C,CAMA,gBAAgBD,EAA6C,CAC3D,OAAO,KAAK,UAAU,gBAAgBA,CAAI,CAC5C,CAEA,sBAAsBU,EAAmB,CACvC,IAAMC,EAAiB,KAAK,WAAW,KAAKD,CAAO,EAC7CE,EAAY,IAAIC,EAAaF,CAAc,EACjD,OAAO,IAAIG,EAA8B,KAAK,UAAWF,CAAS,CACpE,CAEA,KAAKF,EAAmB,CACtB,OAAO,KAAK,sBAAsBA,CAAO,EAAE,SAC7C,CAGF","names":["SingleKeyAccount","_SingleKeyAccount","args","privateKey","address","AnyPublicKey","AccountAddress","scheme","Ed25519PrivateKey","Secp256k1PrivateKey","path","mnemonic","message","innerSignature","signature","AnySignature","AccountAuthenticatorSingleKey"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f as e,g as s,h as t,i as o,j as r,k as i,l as a,m as c,n as m,o as g,p as u,q as d,r as p}from"./chunk-H4UVHJ3M.mjs";var A=class{constructor(n){this.config=n}async getOwnerAddress(n){return e({aptosConfig:this.config,...n})}async getExpiration(n){return t({aptosConfig:this.config,...n})}async getTargetAddress(n){return i({aptosConfig:this.config,...n})}async setTargetAddress(n){return a({aptosConfig:this.config,...n})}async getPrimaryName(n){return o({aptosConfig:this.config,...n})}async setPrimaryName(n){return r({aptosConfig:this.config,...n})}async registerName(n){return s({aptosConfig:this.config,...n})}async renewDomain(n){return p({aptosConfig:this.config,...n})}async getName(n){return c({aptosConfig:this.config,...n})}async getAccountNames(n){return m({aptosConfig:this.config,...n})}async getAccountDomains(n){return g({aptosConfig:this.config,...n})}async getAccountSubdomains(n){return u({aptosConfig:this.config,...n})}async getDomainSubdomains(n){return d({aptosConfig:this.config,...n})}};export{A as a};
|
|
2
|
-
//# sourceMappingURL=chunk-BMKDEIRL.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ans.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account, AccountAddress, AccountAddressInput } from \"../core\";\nimport {\n RegisterNameParameters,\n getExpiration,\n getOwnerAddress,\n registerName,\n getPrimaryName,\n setPrimaryName,\n getTargetAddress,\n setTargetAddress,\n renewDomain,\n getName,\n getAccountDomains,\n GetAccountDomainsArgs,\n GetAccountSubdomainsArgs,\n getAccountSubdomains,\n getAccountNames,\n GetAccountNamesArgs,\n getDomainSubdomains,\n GetDomainSubdomainsArgs,\n} from \"../internal/ans\";\nimport { GetANSNameResponse } from \"../types\";\nimport { InputGenerateTransactionOptions } from \"../transactions/types\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\n\n/**\n * A class to handle all `ANS` operations\n */\nexport class ANS {\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Retrieve the owner address of a domain name or subdomain name from the contract.\n *\n * @example\n * // Will return the owner address of \"test.aptos.apt\" or undefined\n * const owner = await aptos.getOwnerAddress({name: \"test.aptos\"})\n * // owner = 0x123...\n *\n * @param args.name - A string of the name to retrieve\n *\n * @returns AccountAddress if the name is owned, undefined otherwise\n */\n async getOwnerAddress(args: { name: string }): Promise<AccountAddress | undefined> {\n return getOwnerAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieve the expiration time of a domain name or subdomain name from the contract.\n *\n * @example\n * // Will return the expiration of \"test.aptos.apt\" or undefined\n * const exp = await aptos.getExpiration({name: \"test.aptos\"})\n * // new Date(exp) would give you the date in question: 2021-01-01T00:00:00.000Z\n *\n * @param args.name - A string of the name to retrieve\n *\n * @returns number as a unix timestamp in milliseconds.\n */\n async getExpiration(args: { name: string }): Promise<number | undefined> {\n return getExpiration({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieve the target address of a domain or subdomain name. This is the\n * address the name points to for use on chain. Note, the target address can\n * point to addresses that are not the owner of the name\n *\n * @example\n * const targetAddr = await aptos.getTargetAddress({name: \"test.aptos\"})\n * // targetAddr = 0x123...\n *\n * @param args.name - A string of the name: primary, primary.apt, secondary.primary, secondary.primary.apt, etc.\n *\n * @returns AccountAddress if the name has a target, undefined otherwise\n */\n async getTargetAddress(args: { name: string }): Promise<AccountAddress | undefined> {\n return getTargetAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sets the target address of a domain or subdomain name. This is the\n * address the name points to for use on chain. Note, the target address can\n * point to addresses that are not the owner of the name\n *\n * @example\n * await aptos.setTargetAddress({sender: alice, name: \"test.aptos\", address: bob.accountAddress})\n * const address = await aptos.getTargetAddress({name: \"test.aptos\"})\n * // address = bob.accountAddress\n *\n * @param args.name - A string of the name: test.aptos.apt, test.apt, test, test.aptos, etc.\n * @param args.address - A AccountAddressInput of the address to set the domain or subdomain to\n *\n * @returns SimpleTransaction\n */\n async setTargetAddress(args: {\n sender: Account;\n name: string;\n address: AccountAddressInput;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return setTargetAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieve the primary name for an account. An account can have\n * multiple names that target it, but only a single name that is primary. An\n * account also may not have a primary name.\n *\n * @example\n * const name = await aptos.getPrimaryName({address: alice.accountAddress})\n * // name = test.aptos\n *\n * @param args.address - A AccountAddressInput (address) of the account\n *\n * @returns a string if the account has a primary name, undefined otherwise\n */\n async getPrimaryName(args: { address: AccountAddressInput }): Promise<string | undefined> {\n return getPrimaryName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Sets the primary name for the sender. An account can have\n * multiple names that target it, but only a single name that is primary. An\n * account also may not have a primary name.\n *\n * @example\n * await aptos.setPrimaryName({sender: alice, name: \"test.aptos\"})\n * const primaryName = await aptos.getPrimaryName({address: alice.accountAddress})\n * // primaryName = test.aptos\n *\n * @param args.sender - The sender account\n * @param args.name - A string of the name: test, test.apt, test.aptos, test.aptos.apt, etc.\n *\n * @returns SimpleTransaction\n */\n async setPrimaryName(args: {\n sender: Account;\n name?: string;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return setPrimaryName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Registers a new name\n *\n * @example\n * // An example of registering a subdomain name assuming def.apt is already registered\n * // and belongs to the sender alice.\n * const txn = aptos.registerName({\n * sender: alice,\n * name: \"test.aptos.apt\",\n * expiration: {\n * policy: \"subdomain:independent\",\n * expirationDate: Date.now() + 30 * 24 * 60 * 60 * 1000,\n * },\n * });\n *\n * @param args.sender - The sender account\n * @param args.name - A string of the name to register. This can be inclusive or exclusive of the .apt suffix.\n * Examples include: \"test\", \"test.apt\", \"test.aptos.apt\", etc.\n * @param args.expiration - An object with the expiration policy of the name.\n * @param args.expiration.policy - 'domain' | 'subdomain:follow-domain' | 'subdomain:independent'\n * - domain: Years is required and the name will expire after the given number of years.\n * - subdomain:follow-domain: The name will expire at the same time as the domain name.\n * - subdomain:independent: The name will expire at the given date.\n * @param args.expiration.expirationDate - An epoch number in milliseconds of\n * the date when the subdomain will expire. Only applicable when the policy is\n * set to 'subdomain:independent'.\n * @param args.transferable - Determines if the subdomain being minted is soul-bound. Applicable only to subdomains.\n * @param args.targetAddress optional - The address the domain name will resolve to. If not provided,\n * the sender's address will be used.\n * @param args.toAddress optional - The address to send the domain name to. If not provided,\n * the transaction will be sent to the router.\n *\n * @returns SimpleTransaction\n */\n async registerName(args: Omit<RegisterNameParameters, \"aptosConfig\">): Promise<SimpleTransaction> {\n return registerName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Renews a domain name\n *\n * Note: If a domain name was minted with V1 of the contract, it will automatically be upgraded to V2 via this transaction.\n *\n * @example\n * await aptos.renewDomain({sender: alice, name: \"test\"})\n * // test.apt will be renewed for one year\n *\n * @param args.sender - The sender account\n * @param args.name - A string of the domain the subdomain will be under. The signer must be the domain owner.\n * Subdomains cannot be renewed.\n * @param args.years - The number of years to renew the name. Currently only one year is permitted.\n *\n * @returns SimpleTransaction\n */\n async renewDomain(args: {\n sender: Account;\n name: string;\n years?: 1;\n options?: InputGenerateTransactionOptions;\n }): Promise<SimpleTransaction> {\n return renewDomain({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches a single name from the indexer\n * @param args.name - A string of the name to retrieve, e.g. \"test.aptos.apt\"\n * or \"test.apt\" or \"test\". Can be inclusive or exclusive of the .apt suffix.\n * Can be a subdomain.\n *\n * @returns A promise of an ANSName or undefined\n */\n async getName(args: { name: string }): Promise<GetANSNameResponse[0] | undefined> {\n return getName({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all names for an account (both top level domains and subdomains)\n *\n * @param args\n * @param args.accountAddress - A AccountAddressInput of the address to retrieve names for.\n * @param args.options.offset - Optional, the offset to start from when fetching names\n * @param args.options.limit - Optional, A number of the names to fetch per request\n * @param args.options.orderBy - The order to sort the names by\n * @param args.options.where - Additional filters to apply to the query\n *\n * @returns a promise of an array of ANSName\n */\n async getAccountNames(args: GetAccountNamesArgs): Promise<GetANSNameResponse> {\n return getAccountNames({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all top level domain names for an account\n *\n * @param args\n * @param args.accountAddress - A AccountAddressInput of the address to retrieve domain names for.\n * @param args.options.offset - Optional, the offset to start from when fetching names\n * @param args.options.limit - Optional, A number of the names to fetch per request\n * @param args.options.orderBy - The order to sort the names by\n * @param args.options.where - Additional filters to apply to the query\n *\n * @returns a promise of an array of ANSName\n */\n async getAccountDomains(args: GetAccountDomainsArgs): Promise<GetANSNameResponse> {\n return getAccountDomains({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all subdomains names for an account\n *\n * @param args\n * @param args.accountAddress - A AccountAddressInput of the address to retrieve subdomains names for.\n * @param args.options.offset - Optional, the offset to start from when fetching names\n * @param args.options.limit - Optional, A number of the names to fetch per request\n * @param args.options.orderBy - The order to sort the names by\n * @param args.options.where - Additional filters to apply to the query\n *\n * @returns a promise of an array of ANSName\n */\n async getAccountSubdomains(args: GetAccountSubdomainsArgs): Promise<GetANSNameResponse> {\n return getAccountSubdomains({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Fetches all subdomains names for a given domain. Note, this will not return the domain itself.\n *\n * @param args\n * @param args.domain - A string of the domain name: eg. \"test.apt\" or \"test\" (without the suffix of .apt)\n * @param args.options.offset - Optional, the offset to start from when fetching names\n * @param args.options.limit - Optional, A number of the names to fetch per request\n * @param args.options.orderBy - The order to sort the names by\n * @param args.options.where - Additional filters to apply to the query\n *\n * @returns a promise of an array of ANSName\n */\n async getDomainSubdomains(args: GetDomainSubdomainsArgs): Promise<GetANSNameResponse> {\n return getDomainSubdomains({ aptosConfig: this.config, ...args });\n }\n}\n"],"mappings":"6HAgCO,IAAMA,EAAN,KAAU,CACf,YAAqBC,EAAqB,CAArB,YAAAA,CAAsB,CAc3C,MAAM,gBAAgBC,EAA6D,CACjF,OAAOC,EAAgB,CAAE,YAAa,KAAK,OAAQ,GAAGD,CAAK,CAAC,CAC9D,CAcA,MAAM,cAAcA,EAAqD,CACvE,OAAOE,EAAc,CAAE,YAAa,KAAK,OAAQ,GAAGF,CAAK,CAAC,CAC5D,CAeA,MAAM,iBAAiBA,EAA6D,CAClF,OAAOG,EAAiB,CAAE,YAAa,KAAK,OAAQ,GAAGH,CAAK,CAAC,CAC/D,CAiBA,MAAM,iBAAiBA,EAKQ,CAC7B,OAAOI,EAAiB,CAAE,YAAa,KAAK,OAAQ,GAAGJ,CAAK,CAAC,CAC/D,CAeA,MAAM,eAAeA,EAAqE,CACxF,OAAOK,EAAe,CAAE,YAAa,KAAK,OAAQ,GAAGL,CAAK,CAAC,CAC7D,CAiBA,MAAM,eAAeA,EAIU,CAC7B,OAAOM,EAAe,CAAE,YAAa,KAAK,OAAQ,GAAGN,CAAK,CAAC,CAC7D,CAoCA,MAAM,aAAaA,EAA+E,CAChG,OAAOO,EAAa,CAAE,YAAa,KAAK,OAAQ,GAAGP,CAAK,CAAC,CAC3D,CAkBA,MAAM,YAAYA,EAKa,CAC7B,OAAOQ,EAAY,CAAE,YAAa,KAAK,OAAQ,GAAGR,CAAK,CAAC,CAC1D,CAUA,MAAM,QAAQA,EAAoE,CAChF,OAAOS,EAAQ,CAAE,YAAa,KAAK,OAAQ,GAAGT,CAAK,CAAC,CACtD,CAcA,MAAM,gBAAgBA,EAAwD,CAC5E,OAAOU,EAAgB,CAAE,YAAa,KAAK,OAAQ,GAAGV,CAAK,CAAC,CAC9D,CAcA,MAAM,kBAAkBA,EAA0D,CAChF,OAAOW,EAAkB,CAAE,YAAa,KAAK,OAAQ,GAAGX,CAAK,CAAC,CAChE,CAcA,MAAM,qBAAqBA,EAA6D,CACtF,OAAOY,EAAqB,CAAE,YAAa,KAAK,OAAQ,GAAGZ,CAAK,CAAC,CACnE,CAcA,MAAM,oBAAoBA,EAA4D,CACpF,OAAOa,EAAoB,CAAE,YAAa,KAAK,OAAQ,GAAGb,CAAK,CAAC,CAClE,CACF","names":["ANS","config","args","getOwnerAddress","getExpiration","getTargetAddress","setTargetAddress","getPrimaryName","setPrimaryName","registerName","renewDomain","getName","getAccountNames","getAccountDomains","getAccountSubdomains","getDomainSubdomains"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as h,b as l}from"./chunk-RAYJRFIG.mjs";import{b as g}from"./chunk-WFZDFFBM.mjs";import{a as p}from"./chunk-R5QUBEH6.mjs";import{a as m}from"./chunk-NPFNYP75.mjs";function f(y){let o=y;return o-=o>>1&1431655765,o=(o&858993459)+(o>>2&858993459),(o+(o>>4)&252645135)*16843009>>24}var A=class y extends g{constructor(e){super();let{publicKeys:s,signaturesRequired:t}=e;if(t<1)throw new Error("The number of required signatures needs to be greater than 0");if(s.length<t)throw new Error(`Provided ${s.length} public keys is smaller than the ${t} required signatures`);this.publicKeys=s.map(r=>r instanceof h?r:new h(r)),this.signaturesRequired=t}verifySignature(e){throw new Error("not implemented")}authKey(){return m.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let s=e.deserializeVector(h),t=e.deserializeU8();return new y({publicKeys:s,signaturesRequired:t})}createBitmap(e){let{bits:s}=e,t=128,r=new Uint8Array([0,0,0,0]),n=new Set;return s.forEach((i,u)=>{if(u+1>this.publicKeys.length)throw new Error(`Signature index ${u+1} is out of public keys range, ${this.publicKeys.length}.`);if(n.has(i))throw new Error(`Duplicate bit ${i} detected.`);n.add(i);let c=Math.floor(i/8),b=r[c];b|=t>>i%8,r[c]=b}),r}},a=class a extends p{constructor(e){super();let{signatures:s,bitmap:t}=e;if(s.length>a.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${a.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=s.map(n=>n instanceof l?n:new l(n)),!(t instanceof Uint8Array))this.bitmap=a.createBitmap({bits:t});else{if(t.length!==a.BITMAP_LEN)throw new Error(`"bitmap" length should be ${a.BITMAP_LEN}`);this.bitmap=t}let r=this.bitmap.reduce((n,i)=>n+f(i),0);if(r!==this.signatures.length)throw new Error(`Expecting ${r} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:s}=e,t=128,r=new Uint8Array([0,0,0,0]),n=new Set;return s.forEach(i=>{if(i>=a.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${a.MAX_SIGNATURES_SUPPORTED-1}.`);if(n.has(i))throw new Error("Duplicate bits detected.");n.add(i);let u=Math.floor(i/8),c=r[u];c|=t>>i%8,r[u]=c}),r}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let s=e.deserializeBytes(),t=s.reduce((n,i)=>n+f(i),0),r=[];for(let n=0;n<t;n+=1){let i=l.deserialize(e);r.push(i)}return new a({signatures:r,bitmap:s})}};a.BITMAP_LEN=4,a.MAX_SIGNATURES_SUPPORTED=a.BITMAP_LEN*8;var d=a;export{A as a,d as b};
|
|
2
|
-
//# sourceMappingURL=chunk-BSEQPVD6.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/crypto/multiKey.ts"],"sourcesContent":["import { SigningScheme as AuthenticationKeyScheme } from \"../../types\";\nimport { Deserializer } from \"../../bcs/deserializer\";\nimport { Serializer } from \"../../bcs/serializer\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { AccountPublicKey, PublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { AnyPublicKey, AnySignature } from \"./singleKey\";\n\n/* eslint-disable no-bitwise */\n\nfunction bitCount(byte: number) {\n let n = byte;\n n -= (n >> 1) & 0x55555555;\n n = (n & 0x33333333) + ((n >> 2) & 0x33333333);\n return (((n + (n >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;\n}\n\n/* eslint-enable no-bitwise */\n\n/**\n * Represents the public key of a multi-agent account.\n *\n * The public keys of each individual agent can be any type of public key supported by Aptos.\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n */\nexport class MultiKey extends AccountPublicKey {\n /**\n * List of any public keys\n */\n public readonly publicKeys: AnyPublicKey[];\n\n /**\n * The minimum number of valid signatures required, for the number of public keys specified\n */\n public readonly signaturesRequired: number;\n\n // region Constructors\n\n constructor(args: { publicKeys: Array<PublicKey>; signaturesRequired: number }) {\n super();\n const { publicKeys, signaturesRequired } = args;\n\n // Validate number of public keys is greater than signature required\n if (signaturesRequired < 1) {\n throw new Error(\"The number of required signatures needs to be greater than 0\");\n }\n\n // Validate number of public keys is greater than signature required\n if (publicKeys.length < signaturesRequired) {\n throw new Error(\n `Provided ${publicKeys.length} public keys is smaller than the ${signaturesRequired} required signatures`,\n );\n }\n\n // Make sure that all keys are normalized to the SingleKey authentication scheme\n this.publicKeys = publicKeys.map((publicKey) =>\n publicKey instanceof AnyPublicKey ? publicKey : new AnyPublicKey(publicKey),\n );\n\n this.signaturesRequired = signaturesRequired;\n }\n\n // endregion\n\n // region AccountPublicKey\n\n // eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars\n verifySignature(args: VerifySignatureArgs): boolean {\n throw new Error(\"not implemented\");\n }\n\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.MultiKey,\n input: this.toUint8Array(),\n });\n }\n\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeVector(this.publicKeys);\n serializer.serializeU8(this.signaturesRequired);\n }\n\n static deserialize(deserializer: Deserializer): MultiKey {\n const keys = deserializer.deserializeVector(AnyPublicKey);\n const signaturesRequired = deserializer.deserializeU8();\n\n return new MultiKey({ publicKeys: keys, signaturesRequired });\n }\n\n // endregion\n\n /**\n * Create a bitmap that holds the mapping from the original public keys\n * to the signatures passed in\n *\n * @param args.bits array of the index mapping to the matching public keys\n * @returns Uint8array bit map\n */\n createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number, idx: number) => {\n if (idx + 1 > this.publicKeys.length) {\n throw new Error(`Signature index ${idx + 1} is out of public keys range, ${this.publicKeys.length}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(`Duplicate bit ${bit} detected.`);\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n}\n\nexport class MultiKeySignature extends Signature {\n /**\n * Number of bytes in the bitmap representing who signed the transaction (32-bits)\n */\n static BITMAP_LEN: number = 4;\n\n /**\n * Maximum number of Ed25519 signatures supported\n */\n static MAX_SIGNATURES_SUPPORTED = MultiKeySignature.BITMAP_LEN * 8;\n\n /**\n * The list of underlying Ed25519 signatures\n */\n public readonly signatures: AnySignature[];\n\n /**\n * 32-bit Bitmap representing who signed the transaction\n *\n * This is represented where each public key can be masked to determine whether the message was signed by that key.\n */\n public readonly bitmap: Uint8Array;\n\n /**\n * Signature for a K-of-N multi-sig transaction.\n *\n * @see {@link\n * https://aptos.dev/integration/creating-a-signed-transaction/#multisignature-transactions | Creating a Signed Transaction}\n *\n * @param args.signatures A list of signatures\n * @param args.bitmap 4 bytes, at most 32 signatures are supported. If Nth bit value is `1`, the Nth\n * signature should be provided in `signatures`. Bits are read from left to right\n */\n constructor(args: { signatures: Array<Signature | AnySignature>; bitmap: Uint8Array | number[] }) {\n super();\n const { signatures, bitmap } = args;\n\n if (signatures.length > MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`The number of signatures cannot be greater than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED}`);\n }\n\n // Make sure that all signatures are normalized to the SingleKey authentication scheme\n this.signatures = signatures.map((signature) =>\n signature instanceof AnySignature ? signature : new AnySignature(signature),\n );\n\n if (!(bitmap instanceof Uint8Array)) {\n this.bitmap = MultiKeySignature.createBitmap({ bits: bitmap });\n } else if (bitmap.length !== MultiKeySignature.BITMAP_LEN) {\n throw new Error(`\"bitmap\" length should be ${MultiKeySignature.BITMAP_LEN}`);\n } else {\n this.bitmap = bitmap;\n }\n\n const nSignatures = this.bitmap.reduce((acc, byte) => acc + bitCount(byte), 0);\n if (nSignatures !== this.signatures.length) {\n throw new Error(`Expecting ${nSignatures} signatures from the bitmap, but got ${this.signatures.length}`);\n }\n }\n\n /**\n * Helper method to create a bitmap out of the specified bit positions\n * @param args.bits The bitmap positions that should be set. A position starts at index 0.\n * Valid position should range between 0 and 31.\n * @example\n * Here's an example of valid `bits`\n * ```\n * [0, 2, 31]\n * ```\n * `[0, 2, 31]` means the 1st, 3rd and 32nd bits should be set in the bitmap.\n * The result bitmap should be 0b1010000000000000000000000000001\n *\n * @returns bitmap that is 32bit long\n */\n static createBitmap(args: { bits: number[] }): Uint8Array {\n const { bits } = args;\n // Bits are read from left to right. e.g. 0b10000000 represents the first bit is set in one byte.\n // The decimal value of 0b10000000 is 128.\n const firstBitInByte = 128;\n const bitmap = new Uint8Array([0, 0, 0, 0]);\n\n // Check if duplicates exist in bits\n const dupCheckSet = new Set();\n\n bits.forEach((bit: number) => {\n if (bit >= MultiKeySignature.MAX_SIGNATURES_SUPPORTED) {\n throw new Error(`Cannot have a signature larger than ${MultiKeySignature.MAX_SIGNATURES_SUPPORTED - 1}.`);\n }\n\n if (dupCheckSet.has(bit)) {\n throw new Error(\"Duplicate bits detected.\");\n }\n\n dupCheckSet.add(bit);\n\n const byteOffset = Math.floor(bit / 8);\n\n let byte = bitmap[byteOffset];\n\n // eslint-disable-next-line no-bitwise\n byte |= firstBitInByte >> bit % 8;\n\n bitmap[byteOffset] = byte;\n });\n\n return bitmap;\n }\n\n // region Signature\n\n toUint8Array(): Uint8Array {\n return this.bcsToBytes();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n // Note: we should not need to serialize the vector length, as it can be derived from the bitmap\n serializer.serializeVector(this.signatures);\n serializer.serializeBytes(this.bitmap);\n }\n\n static deserialize(deserializer: Deserializer): MultiKeySignature {\n const bitmap = deserializer.deserializeBytes();\n const nSignatures = bitmap.reduce((acc, byte) => acc + bitCount(byte), 0);\n const signatures: AnySignature[] = [];\n for (let i = 0; i < nSignatures; i += 1) {\n const signature = AnySignature.deserialize(deserializer);\n signatures.push(signature);\n }\n return new MultiKeySignature({ signatures, bitmap });\n }\n\n // endregion\n}\n"],"mappings":"2KA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I,IAExB,OAAAH,EAAK,QAASI,GAAgB,CAC5B,GAAIA,GAAOG,EAAkB,yBAC3B,MAAM,IAAI,MAAM,uCAAuCA,EAAkB,yBAA2B,CAAC,GAAG,EAG1G,GAAIJ,EAAY,IAAIC,CAAG,EACrB,MAAM,IAAI,MAAM,0BAA0B,EAG5CD,EAAY,IAAIC,CAAG,EAEnB,IAAME,EAAa,KAAK,MAAMF,EAAM,CAAC,EAEjClB,EAAOgB,EAAOI,CAAU,EAG5BpB,GAAQe,GAAkBG,EAAM,EAEhCF,EAAOI,CAAU,EAAIpB,CACvB,CAAC,EAEMgB,CACT,CAIA,cAA2B,CACzB,OAAO,KAAK,WAAW,CACzB,CAMA,UAAUL,EAA8B,CAEtCA,EAAW,gBAAgB,KAAK,UAAU,EAC1CA,EAAW,eAAe,KAAK,MAAM,CACvC,CAEA,OAAO,YAAYC,EAA+C,CAChE,IAAMI,EAASJ,EAAa,iBAAiB,EACvCc,EAAcV,EAAO,OAAO,CAACW,EAAK3B,IAAS2B,EAAM5B,EAASC,CAAI,EAAG,CAAC,EAClEuB,EAA6B,CAAC,EACpC,QAASK,EAAI,EAAGA,EAAIF,EAAaE,GAAK,EAAG,CACvC,IAAMJ,EAAYC,EAAa,YAAYb,CAAY,EACvDW,EAAW,KAAKC,CAAS,CAC3B,CACA,OAAO,IAAIH,EAAkB,CAAE,WAAAE,EAAY,OAAAP,CAAO,CAAC,CACrD,CAGF,EAxIaK,EAIJ,WAAqB,EAJjBA,EASJ,yBAA2BA,EAAkB,WAAa,EAT5D,IAAMQ,EAANR","names":["bitCount","byte","n","MultiKey","_MultiKey","AccountPublicKey","args","publicKeys","signaturesRequired","publicKey","AnyPublicKey","AuthenticationKey","serializer","deserializer","keys","bits","firstBitInByte","bitmap","dupCheckSet","bit","idx","byteOffset","_MultiKeySignature","Signature","signatures","signature","AnySignature","nSignatures","acc","i","MultiKeySignature"]}
|