@aptos-labs/ts-sdk 1.33.2 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/common/{accountAddress-Cf1amU98.d.ts → accountAddress-CDtCLtJA.d.ts} +3 -2
- package/dist/common/chunk-ZYPBABLQ.js +4 -0
- package/dist/common/chunk-ZYPBABLQ.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +2631 -2273
- package/dist/common/index.js +28 -30
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +1 -0
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +91 -0
- package/dist/esm/account/AbstractedAccount.mjs +2 -0
- package/dist/esm/account/Account.d.mts +1 -0
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +17 -16
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +1 -0
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +1 -0
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +1 -0
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +1 -0
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +1 -0
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +1 -0
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +3 -0
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.d.mts +1 -0
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.d.mts +209 -0
- package/dist/esm/api/account/abstraction.mjs +2 -0
- package/dist/esm/api/account.d.mts +3 -0
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +1 -0
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +3 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -0
- package/dist/esm/api/coin.d.mts +1 -0
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +1 -0
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +1 -0
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +1 -0
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +1 -0
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +1 -0
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +3 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +2 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +1 -0
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +1 -0
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -0
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -0
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +66 -0
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +1 -0
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +1 -0
- 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 +1 -0
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +1 -0
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +1 -0
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +1 -0
- package/dist/esm/bcs/deserializer.d.mts +1 -0
- package/dist/esm/bcs/index.d.mts +1 -0
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -0
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -0
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -0
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -0
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +1 -0
- package/dist/esm/{chunk-OEQ2U7GK.mjs → chunk-2FNFUTFJ.mjs} +2 -2
- package/dist/esm/{chunk-DOQV5BSA.mjs → chunk-2GIPNLDO.mjs} +2 -2
- package/dist/esm/{chunk-6YHDZLRN.mjs → chunk-33CBJFX2.mjs} +2 -2
- package/dist/esm/{chunk-WUWPN7XV.mjs → chunk-3EY7MT2M.mjs} +2 -2
- package/dist/esm/{chunk-2UXW3EB7.mjs → chunk-3HFZN7L5.mjs} +2 -2
- package/dist/esm/chunk-3OLFJ65O.mjs +2 -0
- package/dist/esm/chunk-3OLFJ65O.mjs.map +1 -0
- package/dist/esm/chunk-42T3UGSW.mjs +2 -0
- package/dist/esm/chunk-42T3UGSW.mjs.map +1 -0
- package/dist/esm/chunk-4776UXL6.mjs +2 -0
- package/dist/esm/chunk-4776UXL6.mjs.map +1 -0
- package/dist/esm/{chunk-QQEK7WVP.mjs → chunk-4T75XRI2.mjs} +2 -2
- package/dist/esm/{chunk-MCLYDS3O.mjs → chunk-4UK4MUSD.mjs} +2 -2
- package/dist/esm/{chunk-FIEMUPXF.mjs → chunk-5BSMF22B.mjs} +2 -2
- package/dist/esm/chunk-66HHRRIX.mjs +2 -0
- package/dist/esm/chunk-66HHRRIX.mjs.map +1 -0
- package/dist/esm/{chunk-XYB6KYKW.mjs → chunk-6JTNS5O6.mjs} +2 -2
- package/dist/esm/{chunk-E7JDVKFY.mjs → chunk-6LGXFXXR.mjs} +2 -2
- package/dist/esm/{chunk-43GCGE6C.mjs → chunk-6PBMD2BQ.mjs} +2 -2
- package/dist/esm/chunk-7C2RDOWS.mjs +1 -0
- package/dist/esm/{chunk-OROPNHRY.mjs → chunk-7CYCKCVU.mjs} +2 -2
- package/dist/esm/chunk-7DPHPPMG.mjs +2 -0
- package/dist/esm/chunk-7DPHPPMG.mjs.map +1 -0
- package/dist/esm/chunk-ABXES4FS.mjs +2 -0
- package/dist/esm/chunk-ABXES4FS.mjs.map +1 -0
- package/dist/esm/{chunk-VV4HCOJQ.mjs → chunk-AC3BISWL.mjs} +2 -2
- package/dist/esm/chunk-BBUN4IO4.mjs +2 -0
- package/dist/esm/chunk-BBUN4IO4.mjs.map +1 -0
- package/dist/esm/{chunk-QHEKBHNU.mjs → chunk-BUTMGMSD.mjs} +2 -2
- package/dist/esm/{chunk-V6VPMNWJ.mjs → chunk-BYHCW7MI.mjs} +2 -2
- package/dist/esm/{chunk-M77M6NSB.mjs → chunk-CRFLR3ZY.mjs} +2 -2
- package/dist/esm/chunk-CSG67JHZ.mjs +2 -0
- package/dist/esm/chunk-CSG67JHZ.mjs.map +1 -0
- package/dist/esm/{chunk-5VMAJTTV.mjs → chunk-CXNF73OX.mjs} +2 -2
- package/dist/esm/{chunk-4EUS4E6S.mjs → chunk-D6T3NYOA.mjs} +2 -2
- package/dist/esm/chunk-DBIZE7G6.mjs +2 -0
- package/dist/esm/chunk-DBIZE7G6.mjs.map +1 -0
- package/dist/esm/{chunk-X6UNY6YM.mjs → chunk-DLLDRANJ.mjs} +2 -2
- package/dist/esm/{chunk-ZAIVZDOL.mjs → chunk-DMS7K76O.mjs} +2 -2
- package/dist/esm/chunk-DNJQWGB7.mjs +2 -0
- package/dist/esm/chunk-DNJQWGB7.mjs.map +1 -0
- package/dist/esm/{chunk-BGSEBFFC.mjs → chunk-DNWFDS7F.mjs} +2 -2
- package/dist/esm/{chunk-OHZURQPY.mjs → chunk-DWJ3PGWE.mjs} +2 -2
- package/dist/esm/chunk-EGZI6EJ2.mjs +2 -0
- package/dist/esm/chunk-EGZI6EJ2.mjs.map +1 -0
- package/dist/esm/chunk-EY2JUXEC.mjs +2 -0
- package/dist/esm/{chunk-77AEKF7K.mjs.map → chunk-EY2JUXEC.mjs.map} +1 -1
- package/dist/esm/{chunk-IEUEMBFD.mjs → chunk-G6RLN6ET.mjs} +2 -2
- package/dist/esm/{chunk-NBNZ53ZV.mjs → chunk-GQX5KMF7.mjs} +2 -2
- package/dist/esm/{chunk-2FBJWTJD.mjs → chunk-H4GZWYIG.mjs} +2 -2
- package/dist/esm/chunk-HEAWDTLG.mjs +2 -0
- package/dist/esm/chunk-HEAWDTLG.mjs.map +1 -0
- package/dist/esm/{chunk-2N5KYALM.mjs → chunk-HFCWJ6QL.mjs} +2 -2
- package/dist/esm/{chunk-2TJ6OTVD.mjs → chunk-HL2O3T57.mjs} +2 -2
- package/dist/esm/chunk-HLJE5XGE.mjs +2 -0
- package/dist/esm/chunk-HLJE5XGE.mjs.map +1 -0
- package/dist/esm/{chunk-5EYTHMRZ.mjs → chunk-HT2WC3QV.mjs} +2 -2
- package/dist/esm/{chunk-VVXBVJXD.mjs → chunk-I7YHK6ZF.mjs} +2 -2
- package/dist/esm/chunk-IMTC3J2M.mjs +2 -0
- package/dist/esm/chunk-IMTC3J2M.mjs.map +1 -0
- package/dist/esm/{chunk-ONTWK5FU.mjs → chunk-J7HRQ2IH.mjs} +2 -2
- package/dist/esm/{chunk-S7RZGC56.mjs → chunk-JF66JS2R.mjs} +2 -2
- package/dist/esm/{chunk-UC23V7PU.mjs → chunk-KEJAUCQF.mjs} +2 -2
- package/dist/esm/{chunk-6CXMDJQR.mjs → chunk-L2AQG3G3.mjs} +2 -2
- package/dist/esm/{chunk-XTJOA5QN.mjs → chunk-L6FONDPA.mjs} +2 -2
- package/dist/esm/{chunk-67ZVDKJF.mjs → chunk-N7C6LQPZ.mjs} +2 -2
- package/dist/esm/{chunk-OR6GFWLG.mjs → chunk-O37BZP2G.mjs} +2 -2
- package/dist/esm/{chunk-XZ4JRYCE.mjs → chunk-OURSLL3I.mjs} +2 -2
- package/dist/esm/{chunk-7IY3DTEF.mjs → chunk-P7SE5LQE.mjs} +2 -2
- package/dist/esm/{chunk-6YWYAVFS.mjs → chunk-PNSF3E67.mjs} +2 -2
- package/dist/esm/{chunk-E5HGSOG2.mjs → chunk-PR3W2QEH.mjs} +2 -2
- package/dist/esm/{chunk-P7A5RILV.mjs → chunk-PWYJWTEM.mjs} +2 -2
- package/dist/esm/{chunk-ZPV7HPA4.mjs → chunk-Q7RG7KQS.mjs} +2 -2
- package/dist/esm/{chunk-WQRGDSPD.mjs → chunk-QBFGY74I.mjs} +2 -2
- package/dist/esm/{chunk-XY43TPRH.mjs → chunk-S47HA7O7.mjs} +2 -2
- package/dist/esm/{chunk-5EBUWO2M.mjs → chunk-SCBYJU6K.mjs} +2 -2
- package/dist/esm/chunk-TDGUMBON.mjs +4 -0
- package/dist/esm/chunk-TDGUMBON.mjs.map +1 -0
- package/dist/esm/{chunk-FZD5RWSZ.mjs → chunk-TM6IKHMX.mjs} +2 -2
- package/dist/esm/{chunk-KOORZTHC.mjs → chunk-U2SJIG2T.mjs} +2 -2
- package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
- package/dist/esm/chunk-UIRAXHDH.mjs.map +1 -0
- package/dist/esm/{chunk-S4LZMY2L.mjs → chunk-ULHOJ2BE.mjs} +2 -2
- package/dist/esm/{chunk-VUIHJIMX.mjs → chunk-UTXEW2FT.mjs} +2 -2
- package/dist/esm/{chunk-4ZYPDCSP.mjs → chunk-V2EXS6TM.mjs} +2 -2
- package/dist/esm/{chunk-6IEZPA4H.mjs → chunk-V7G2EDNR.mjs} +2 -2
- package/dist/esm/{chunk-MWBRD43V.mjs → chunk-VKDTI6NX.mjs} +2 -2
- package/dist/esm/{chunk-NYETBDSR.mjs → chunk-VOCI2675.mjs} +2 -2
- package/dist/esm/{chunk-NWLJ6RW7.mjs → chunk-WXDA4CCR.mjs} +2 -2
- package/dist/esm/{chunk-ZGVNZE7J.mjs → chunk-X24PSWCX.mjs} +2 -2
- package/dist/esm/chunk-X2CPDUOS.mjs +2 -0
- package/dist/esm/chunk-X2CPDUOS.mjs.map +1 -0
- package/dist/esm/{chunk-YCQUYDZI.mjs → chunk-X6IHNXWY.mjs} +2 -2
- package/dist/esm/{chunk-JJM6ELMS.mjs → chunk-XAPQNCTN.mjs} +2 -2
- package/dist/esm/{chunk-5YWH3XPN.mjs → chunk-XDIX7NIP.mjs} +2 -2
- package/dist/esm/{chunk-DYATTONT.mjs → chunk-XH3BEKII.mjs} +2 -2
- package/dist/esm/{chunk-AXYARCYT.mjs → chunk-XXHZQFYW.mjs} +2 -2
- package/dist/esm/{chunk-3RCAJICY.mjs → chunk-Y3Y4DVCK.mjs} +2 -2
- package/dist/esm/{chunk-OSBRPVVI.mjs → chunk-YIF242TF.mjs} +2 -2
- package/dist/esm/{chunk-CWKNJZB6.mjs → chunk-ZCEBDPBJ.mjs} +2 -2
- package/dist/esm/{chunk-2WCATZVL.mjs → chunk-ZP5EBIBE.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +1 -0
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +1 -0
- package/dist/esm/client/core.d.mts +1 -0
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -0
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +1 -0
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -0
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +1 -0
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +1 -0
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +1 -0
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +1 -0
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +1 -0
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.d.mts +30 -0
- package/dist/esm/core/crypto/abstraction.mjs +2 -0
- package/dist/esm/core/crypto/abstraction.mjs.map +1 -0
- package/dist/esm/core/crypto/ed25519.d.mts +1 -0
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +1 -0
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +1 -0
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +1 -0
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +1 -0
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +1 -0
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +1 -0
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +1 -0
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +1 -0
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +1 -0
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +1 -0
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +1 -0
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +1 -0
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.d.mts +1 -0
- package/dist/esm/core/hex.d.mts +1 -0
- package/dist/esm/core/index.d.mts +1 -0
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +1 -0
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +10 -5
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.d.mts +55 -0
- package/dist/esm/internal/abstraction.mjs +2 -0
- package/dist/esm/internal/abstraction.mjs.map +1 -0
- package/dist/esm/internal/account.d.mts +1 -0
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -0
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +1 -0
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +1 -0
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +1 -0
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -0
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +1 -0
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +1 -0
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +1 -0
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +1 -0
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -0
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +1 -0
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -0
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +1 -0
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +1 -0
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +12 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +2 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +3 -2
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +6 -4
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +1 -0
- package/dist/esm/transactions/instances/identifier.d.mts +1 -0
- package/dist/esm/transactions/instances/index.d.mts +1 -0
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -0
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -0
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +5 -4
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -0
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -0
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +1 -0
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +1 -0
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +1 -0
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/scriptComposer/index.d.mts +53 -0
- package/dist/esm/transactions/scriptComposer/index.mjs +2 -0
- package/dist/esm/transactions/scriptComposer/index.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -17
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +3 -2
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +23 -2
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -2
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +1 -0
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +1 -0
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +10 -1
- package/dist/esm/types/abstraction.d.mts +8 -0
- package/dist/esm/types/abstraction.mjs +2 -0
- package/dist/esm/types/abstraction.mjs.map +1 -0
- package/dist/esm/types/index.d.mts +1 -0
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +3 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +19 -2
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +2 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +1 -0
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +25 -18
- package/src/account/AbstractedAccount.ts +111 -0
- package/src/account/index.ts +1 -0
- package/src/api/account/abstraction.ts +239 -0
- package/src/api/account.ts +6 -1
- package/src/api/aptos.ts +3 -0
- package/src/api/transactionSubmission/build.ts +85 -2
- package/src/core/crypto/abstraction.ts +47 -0
- package/src/internal/abstraction.ts +79 -0
- package/src/transactions/authenticator/account.ts +52 -1
- package/src/transactions/index.ts +1 -0
- package/src/transactions/scriptComposer/index.ts +87 -0
- package/src/transactions/transactionBuilder/helpers.ts +1 -22
- package/src/transactions/transactionBuilder/remoteAbi.ts +62 -1
- package/src/transactions/transactionBuilder/transactionBuilder.ts +2 -1
- package/src/transactions/types.ts +11 -0
- package/src/types/abstraction.ts +6 -0
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +1 -0
- package/src/utils/helpers.ts +28 -1
- package/src/version.ts +1 -1
- package/dist/common/chunk-IHUCZKG2.js +0 -2
- package/dist/common/chunk-IHUCZKG2.js.map +0 -1
- package/dist/esm/chunk-5PXDPMF2.mjs +0 -4
- package/dist/esm/chunk-5PXDPMF2.mjs.map +0 -1
- package/dist/esm/chunk-77AEKF7K.mjs +0 -2
- package/dist/esm/chunk-AFEHO5PP.mjs +0 -2
- package/dist/esm/chunk-AFEHO5PP.mjs.map +0 -1
- package/dist/esm/chunk-DAFSKSZ5.mjs +0 -2
- package/dist/esm/chunk-DAFSKSZ5.mjs.map +0 -1
- package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
- package/dist/esm/chunk-GP4TLDVZ.mjs +0 -1
- package/dist/esm/chunk-HBH2NQKU.mjs +0 -2
- package/dist/esm/chunk-HBH2NQKU.mjs.map +0 -1
- package/dist/esm/chunk-I5OYNCZS.mjs +0 -1
- package/dist/esm/chunk-JBEUUULP.mjs +0 -2
- package/dist/esm/chunk-JBEUUULP.mjs.map +0 -1
- package/dist/esm/chunk-KVM2SGSF.mjs +0 -2
- package/dist/esm/chunk-KVM2SGSF.mjs.map +0 -1
- package/dist/esm/chunk-MLSAZJZK.mjs +0 -2
- package/dist/esm/chunk-MLSAZJZK.mjs.map +0 -1
- package/dist/esm/chunk-QHC5DKVZ.mjs +0 -2
- package/dist/esm/chunk-QHC5DKVZ.mjs.map +0 -1
- package/dist/esm/chunk-U2PRGW4O.mjs +0 -2
- package/dist/esm/chunk-U2PRGW4O.mjs.map +0 -1
- /package/dist/esm/{chunk-FD6FGKYY.mjs.map → account/AbstractedAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-GP4TLDVZ.mjs.map → api/account/abstraction.mjs.map} +0 -0
- /package/dist/esm/{chunk-OEQ2U7GK.mjs.map → chunk-2FNFUTFJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-DOQV5BSA.mjs.map → chunk-2GIPNLDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-6YHDZLRN.mjs.map → chunk-33CBJFX2.mjs.map} +0 -0
- /package/dist/esm/{chunk-WUWPN7XV.mjs.map → chunk-3EY7MT2M.mjs.map} +0 -0
- /package/dist/esm/{chunk-2UXW3EB7.mjs.map → chunk-3HFZN7L5.mjs.map} +0 -0
- /package/dist/esm/{chunk-QQEK7WVP.mjs.map → chunk-4T75XRI2.mjs.map} +0 -0
- /package/dist/esm/{chunk-MCLYDS3O.mjs.map → chunk-4UK4MUSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-FIEMUPXF.mjs.map → chunk-5BSMF22B.mjs.map} +0 -0
- /package/dist/esm/{chunk-XYB6KYKW.mjs.map → chunk-6JTNS5O6.mjs.map} +0 -0
- /package/dist/esm/{chunk-E7JDVKFY.mjs.map → chunk-6LGXFXXR.mjs.map} +0 -0
- /package/dist/esm/{chunk-43GCGE6C.mjs.map → chunk-6PBMD2BQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-I5OYNCZS.mjs.map → chunk-7C2RDOWS.mjs.map} +0 -0
- /package/dist/esm/{chunk-OROPNHRY.mjs.map → chunk-7CYCKCVU.mjs.map} +0 -0
- /package/dist/esm/{chunk-VV4HCOJQ.mjs.map → chunk-AC3BISWL.mjs.map} +0 -0
- /package/dist/esm/{chunk-QHEKBHNU.mjs.map → chunk-BUTMGMSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-V6VPMNWJ.mjs.map → chunk-BYHCW7MI.mjs.map} +0 -0
- /package/dist/esm/{chunk-M77M6NSB.mjs.map → chunk-CRFLR3ZY.mjs.map} +0 -0
- /package/dist/esm/{chunk-5VMAJTTV.mjs.map → chunk-CXNF73OX.mjs.map} +0 -0
- /package/dist/esm/{chunk-4EUS4E6S.mjs.map → chunk-D6T3NYOA.mjs.map} +0 -0
- /package/dist/esm/{chunk-X6UNY6YM.mjs.map → chunk-DLLDRANJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZAIVZDOL.mjs.map → chunk-DMS7K76O.mjs.map} +0 -0
- /package/dist/esm/{chunk-BGSEBFFC.mjs.map → chunk-DNWFDS7F.mjs.map} +0 -0
- /package/dist/esm/{chunk-OHZURQPY.mjs.map → chunk-DWJ3PGWE.mjs.map} +0 -0
- /package/dist/esm/{chunk-IEUEMBFD.mjs.map → chunk-G6RLN6ET.mjs.map} +0 -0
- /package/dist/esm/{chunk-NBNZ53ZV.mjs.map → chunk-GQX5KMF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-2FBJWTJD.mjs.map → chunk-H4GZWYIG.mjs.map} +0 -0
- /package/dist/esm/{chunk-2N5KYALM.mjs.map → chunk-HFCWJ6QL.mjs.map} +0 -0
- /package/dist/esm/{chunk-2TJ6OTVD.mjs.map → chunk-HL2O3T57.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EYTHMRZ.mjs.map → chunk-HT2WC3QV.mjs.map} +0 -0
- /package/dist/esm/{chunk-VVXBVJXD.mjs.map → chunk-I7YHK6ZF.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONTWK5FU.mjs.map → chunk-J7HRQ2IH.mjs.map} +0 -0
- /package/dist/esm/{chunk-S7RZGC56.mjs.map → chunk-JF66JS2R.mjs.map} +0 -0
- /package/dist/esm/{chunk-UC23V7PU.mjs.map → chunk-KEJAUCQF.mjs.map} +0 -0
- /package/dist/esm/{chunk-6CXMDJQR.mjs.map → chunk-L2AQG3G3.mjs.map} +0 -0
- /package/dist/esm/{chunk-XTJOA5QN.mjs.map → chunk-L6FONDPA.mjs.map} +0 -0
- /package/dist/esm/{chunk-67ZVDKJF.mjs.map → chunk-N7C6LQPZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-OR6GFWLG.mjs.map → chunk-O37BZP2G.mjs.map} +0 -0
- /package/dist/esm/{chunk-XZ4JRYCE.mjs.map → chunk-OURSLL3I.mjs.map} +0 -0
- /package/dist/esm/{chunk-7IY3DTEF.mjs.map → chunk-P7SE5LQE.mjs.map} +0 -0
- /package/dist/esm/{chunk-6YWYAVFS.mjs.map → chunk-PNSF3E67.mjs.map} +0 -0
- /package/dist/esm/{chunk-E5HGSOG2.mjs.map → chunk-PR3W2QEH.mjs.map} +0 -0
- /package/dist/esm/{chunk-P7A5RILV.mjs.map → chunk-PWYJWTEM.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPV7HPA4.mjs.map → chunk-Q7RG7KQS.mjs.map} +0 -0
- /package/dist/esm/{chunk-WQRGDSPD.mjs.map → chunk-QBFGY74I.mjs.map} +0 -0
- /package/dist/esm/{chunk-XY43TPRH.mjs.map → chunk-S47HA7O7.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EBUWO2M.mjs.map → chunk-SCBYJU6K.mjs.map} +0 -0
- /package/dist/esm/{chunk-FZD5RWSZ.mjs.map → chunk-TM6IKHMX.mjs.map} +0 -0
- /package/dist/esm/{chunk-KOORZTHC.mjs.map → chunk-U2SJIG2T.mjs.map} +0 -0
- /package/dist/esm/{chunk-S4LZMY2L.mjs.map → chunk-ULHOJ2BE.mjs.map} +0 -0
- /package/dist/esm/{chunk-VUIHJIMX.mjs.map → chunk-UTXEW2FT.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ZYPDCSP.mjs.map → chunk-V2EXS6TM.mjs.map} +0 -0
- /package/dist/esm/{chunk-6IEZPA4H.mjs.map → chunk-V7G2EDNR.mjs.map} +0 -0
- /package/dist/esm/{chunk-MWBRD43V.mjs.map → chunk-VKDTI6NX.mjs.map} +0 -0
- /package/dist/esm/{chunk-NYETBDSR.mjs.map → chunk-VOCI2675.mjs.map} +0 -0
- /package/dist/esm/{chunk-NWLJ6RW7.mjs.map → chunk-WXDA4CCR.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZGVNZE7J.mjs.map → chunk-X24PSWCX.mjs.map} +0 -0
- /package/dist/esm/{chunk-YCQUYDZI.mjs.map → chunk-X6IHNXWY.mjs.map} +0 -0
- /package/dist/esm/{chunk-JJM6ELMS.mjs.map → chunk-XAPQNCTN.mjs.map} +0 -0
- /package/dist/esm/{chunk-5YWH3XPN.mjs.map → chunk-XDIX7NIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-DYATTONT.mjs.map → chunk-XH3BEKII.mjs.map} +0 -0
- /package/dist/esm/{chunk-AXYARCYT.mjs.map → chunk-XXHZQFYW.mjs.map} +0 -0
- /package/dist/esm/{chunk-3RCAJICY.mjs.map → chunk-Y3Y4DVCK.mjs.map} +0 -0
- /package/dist/esm/{chunk-OSBRPVVI.mjs.map → chunk-YIF242TF.mjs.map} +0 -0
- /package/dist/esm/{chunk-CWKNJZB6.mjs.map → chunk-ZCEBDPBJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2WCATZVL.mjs.map → chunk-ZP5EBIBE.mjs.map} +0 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { AccountAddress, AccountAddressInput } from "../../core";
|
|
2
|
+
import {
|
|
3
|
+
addAuthenticationFunctionTransaction,
|
|
4
|
+
removeAuthenticationFunctionTransaction,
|
|
5
|
+
removeDispatchableAuthenticatorTransaction,
|
|
6
|
+
} from "../../internal/abstraction";
|
|
7
|
+
import { view } from "../../internal/view";
|
|
8
|
+
import { InputGenerateTransactionOptions, TypeTagAddress } from "../../transactions";
|
|
9
|
+
import { MoveFunctionId } from "../../types";
|
|
10
|
+
import { getFunctionParts } from "../../utils/helpers";
|
|
11
|
+
import { AptosConfig } from "../aptosConfig";
|
|
12
|
+
|
|
13
|
+
export class AccountAbstraction {
|
|
14
|
+
constructor(readonly config: AptosConfig) {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Adds a dispatchable authentication function to the account.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const txn = await aptos.abstraction.addAuthenticationFunctionTransaction({
|
|
22
|
+
* accountAddress: alice.accountAddress,
|
|
23
|
+
* authenticationFunction: `${alice.accountAddress}::any_authenticator::authenticate`,
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const txn = await aptos.signAndSubmitTransaction({ signer: alice, transaction});
|
|
27
|
+
* await aptos.waitForTransaction({ transactionHash: txn.hash });
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param args.accountAddress - The account to add the authentication function to.
|
|
31
|
+
* @param args.authenticationFunction - The authentication function info to add.
|
|
32
|
+
* @param args.options - The options for the transaction.
|
|
33
|
+
* @returns A transaction to add the authentication function to the account.
|
|
34
|
+
*/
|
|
35
|
+
public async addAuthenticationFunctionTransaction(args: {
|
|
36
|
+
accountAddress: AccountAddressInput;
|
|
37
|
+
authenticationFunction: string;
|
|
38
|
+
options?: InputGenerateTransactionOptions;
|
|
39
|
+
}) {
|
|
40
|
+
const { accountAddress, authenticationFunction, options } = args;
|
|
41
|
+
return addAuthenticationFunctionTransaction({
|
|
42
|
+
aptosConfig: this.config,
|
|
43
|
+
authenticationFunction,
|
|
44
|
+
sender: accountAddress,
|
|
45
|
+
options,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Removes a dispatchable authentication function from the account.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* const txn = await aptos.abstraction.removeAuthenticationFunctionTransaction({
|
|
55
|
+
* accountAddress: alice.accountAddress,
|
|
56
|
+
* authenticationFunction: `${alice.accountAddress}::any_authenticator::authenticate`,
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* const txn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
|
|
60
|
+
* await aptos.waitForTransaction({ transactionHash: txn.hash });
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param args.accountAddress - The account to remove the authentication function from.
|
|
64
|
+
* @param args.authenticationFunction - The authentication function info to remove.
|
|
65
|
+
* @param args.options - The options for the transaction.
|
|
66
|
+
* @returns A transaction to remove the authentication function from the account.
|
|
67
|
+
*/
|
|
68
|
+
public async removeAuthenticationFunctionTransaction(args: {
|
|
69
|
+
accountAddress: AccountAddressInput;
|
|
70
|
+
authenticationFunction: string;
|
|
71
|
+
options?: InputGenerateTransactionOptions;
|
|
72
|
+
}) {
|
|
73
|
+
const { accountAddress, authenticationFunction, options } = args;
|
|
74
|
+
return removeAuthenticationFunctionTransaction({
|
|
75
|
+
aptosConfig: this.config,
|
|
76
|
+
sender: accountAddress,
|
|
77
|
+
authenticationFunction,
|
|
78
|
+
options,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Removes a dispatchable authenticator from the account.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* const txn = await aptos.abstraction.removeDispatchableAuthenticatorTransaction({
|
|
88
|
+
* accountAddress: alice.accountAddress,
|
|
89
|
+
* });
|
|
90
|
+
*
|
|
91
|
+
* const txn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
|
|
92
|
+
* await aptos.waitForTransaction({ transactionHash: txn.hash });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @param args.accountAddress - The account to remove the authenticator from.
|
|
96
|
+
* @param args.options - The options for the transaction.
|
|
97
|
+
* @returns A transaction to remove the authenticator from the account.
|
|
98
|
+
*/
|
|
99
|
+
public async removeDispatchableAuthenticatorTransaction(args: {
|
|
100
|
+
accountAddress: AccountAddressInput;
|
|
101
|
+
options?: InputGenerateTransactionOptions;
|
|
102
|
+
}) {
|
|
103
|
+
const { accountAddress, options } = args;
|
|
104
|
+
return removeDispatchableAuthenticatorTransaction({ aptosConfig: this.config, sender: accountAddress, options });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Gets the dispatchable authentication function for the account.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```ts
|
|
112
|
+
* const functionInfos = await aptos.abstraction.getAuthenticationFunction({
|
|
113
|
+
* accountAddress: alice.accountAddress,
|
|
114
|
+
* });
|
|
115
|
+
*
|
|
116
|
+
* if (functionInfos) {
|
|
117
|
+
* console.log(`Account ${alice.accountAddress.toString()} is using account abstraction!`);
|
|
118
|
+
* } else {
|
|
119
|
+
* console.log(`Account ${alice.accountAddress.toString()} is not using account abstraction.`);
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*
|
|
123
|
+
* @param args.accountAddress - The account to get the dispatchable authentication function for.
|
|
124
|
+
* @returns The dispatchable authentication function for the account.
|
|
125
|
+
*/
|
|
126
|
+
public async getAuthenticationFunction(args: { accountAddress: AccountAddressInput }) {
|
|
127
|
+
const { accountAddress } = args;
|
|
128
|
+
const [{ vec: functionInfoOption }] = await view<
|
|
129
|
+
[{ vec: { function_name: string; module_name: string; module_address: string }[][] }]
|
|
130
|
+
>({
|
|
131
|
+
aptosConfig: this.config,
|
|
132
|
+
payload: {
|
|
133
|
+
function: "0x1::account_abstraction::dispatchable_authenticator",
|
|
134
|
+
functionArguments: [AccountAddress.from(accountAddress)],
|
|
135
|
+
abi: { typeParameters: [], parameters: [new TypeTagAddress()], returnTypes: [] },
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
if (functionInfoOption.length === 0) return undefined;
|
|
140
|
+
|
|
141
|
+
return functionInfoOption[0].map((functionInfo) => ({
|
|
142
|
+
moduleAddress: AccountAddress.fromString(functionInfo.module_address),
|
|
143
|
+
moduleName: functionInfo.module_name,
|
|
144
|
+
functionName: functionInfo.function_name,
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Will return true if the account is abstracted, otherwise false.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* const isAccountAbstractionEnabled = await aptos.abstraction.isAccountAbstractionEnabled({
|
|
154
|
+
* accountAddress: alice.accountAddress,
|
|
155
|
+
* authenticationFunction: `${alice.accountAddress}::any_authenticator::authenticate`,
|
|
156
|
+
* });
|
|
157
|
+
* if (isAccountAbstractionEnabled) {
|
|
158
|
+
* console.log(`Account ${alice.accountAddress.toString()} is using account abstraction!`);
|
|
159
|
+
* } else {
|
|
160
|
+
* console.log(`Account ${alice.accountAddress.toString()} is not using account abstraction.`);
|
|
161
|
+
* }
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @param args.accountAddress - The account to check.
|
|
165
|
+
* @returns Whether the account is abstracted.
|
|
166
|
+
*/
|
|
167
|
+
public isAccountAbstractionEnabled = async (args: {
|
|
168
|
+
accountAddress: AccountAddressInput;
|
|
169
|
+
authenticationFunction: string;
|
|
170
|
+
}) => {
|
|
171
|
+
const functionInfos = await this.getAuthenticationFunction(args);
|
|
172
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(args.authenticationFunction as MoveFunctionId);
|
|
173
|
+
return (
|
|
174
|
+
functionInfos?.some(
|
|
175
|
+
(functionInfo) =>
|
|
176
|
+
AccountAddress.fromString(moduleAddress).equals(functionInfo.moduleAddress) &&
|
|
177
|
+
moduleName === functionInfo.moduleName &&
|
|
178
|
+
functionName === functionInfo.functionName,
|
|
179
|
+
) ?? false
|
|
180
|
+
);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Creates a transaction to enable account abstraction with the given authentication function.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```ts
|
|
188
|
+
* const txn = await aptos.abstraction.enableAccountAbstractionTransaction({
|
|
189
|
+
* accountAddress: alice.accountAddress,
|
|
190
|
+
* authenticationFunction: `{alice.accountAddress}::any_authenticator::authenticate`,
|
|
191
|
+
* });
|
|
192
|
+
*
|
|
193
|
+
* const txn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
|
|
194
|
+
* await aptos.waitForTransaction({ transactionHash: txn.hash });
|
|
195
|
+
* ```
|
|
196
|
+
*
|
|
197
|
+
* @param args.accountAddress - The account to enable account abstraction for.
|
|
198
|
+
* @param args.authenticationFunction - The authentication function info to use.
|
|
199
|
+
* @param args.options - The options for the transaction.
|
|
200
|
+
* @returns A transaction to enable account abstraction for the account.
|
|
201
|
+
*/
|
|
202
|
+
public enableAccountAbstractionTransaction = this.addAuthenticationFunctionTransaction;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Creates a transaction to disable account abstraction. If an authentication function is provided, it will specify to
|
|
206
|
+
* remove the authentication function.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const txn = await aptos.abstraction.disableAccountAbstractionTransaction({
|
|
211
|
+
* accountAddress: alice.accountAddress,
|
|
212
|
+
* authenticationFunction: `${alice.accountAddress}::any_authenticator::authenticate`,
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* const txn = await aptos.signAndSubmitTransaction({ signer: alice, transaction: txn });
|
|
216
|
+
* await aptos.waitForTransaction({ transactionHash: txn.hash });
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @param args.accountAddress - The account to disable account abstraction for.
|
|
220
|
+
* @param args.authenticationFunction - The authentication function info to remove.
|
|
221
|
+
* @param args.options - The options for the transaction.
|
|
222
|
+
* @returns A transaction to disable account abstraction for the account.
|
|
223
|
+
*/
|
|
224
|
+
public disableAccountAbstractionTransaction = async (args: {
|
|
225
|
+
accountAddress: AccountAddressInput;
|
|
226
|
+
authenticationFunction?: string;
|
|
227
|
+
options?: InputGenerateTransactionOptions;
|
|
228
|
+
}) => {
|
|
229
|
+
const { accountAddress, authenticationFunction, options } = args;
|
|
230
|
+
if (authenticationFunction) {
|
|
231
|
+
return this.removeAuthenticationFunctionTransaction({
|
|
232
|
+
accountAddress,
|
|
233
|
+
authenticationFunction,
|
|
234
|
+
options,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return this.removeDispatchableAuthenticatorTransaction({ accountAddress, options });
|
|
238
|
+
};
|
|
239
|
+
}
|
package/src/api/account.ts
CHANGED
|
@@ -47,12 +47,15 @@ import { CurrentFungibleAssetBalancesBoolExp } from "../types/generated/types";
|
|
|
47
47
|
import { view } from "../internal/view";
|
|
48
48
|
import { isEncodedStruct, parseEncodedStruct } from "../utils";
|
|
49
49
|
import { memoizeAsync } from "../utils/memoize";
|
|
50
|
+
import { AccountAbstraction } from "./account/abstraction";
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* A class to query all `Account` related queries on Aptos.
|
|
53
54
|
* @group Account
|
|
54
55
|
*/
|
|
55
56
|
export class Account {
|
|
57
|
+
abstraction: AccountAbstraction;
|
|
58
|
+
|
|
56
59
|
/**
|
|
57
60
|
* Creates an instance of the Aptos client with the provided configuration.
|
|
58
61
|
*
|
|
@@ -73,7 +76,9 @@ export class Account {
|
|
|
73
76
|
* ```
|
|
74
77
|
* @group Account
|
|
75
78
|
*/
|
|
76
|
-
constructor(readonly config: AptosConfig) {
|
|
79
|
+
constructor(readonly config: AptosConfig) {
|
|
80
|
+
this.abstraction = new AccountAbstraction(config);
|
|
81
|
+
}
|
|
77
82
|
|
|
78
83
|
/**
|
|
79
84
|
* Queries the current state for an Aptos account given its account address.
|
package/src/api/aptos.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { Transaction } from "./transaction";
|
|
|
15
15
|
import { Table } from "./table";
|
|
16
16
|
import { Keyless } from "./keyless";
|
|
17
17
|
import { AptosObject } from "./object";
|
|
18
|
+
import { AccountAbstraction } from "./account/abstraction";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* The main entry point for interacting with the Aptos APIs,
|
|
@@ -94,6 +95,7 @@ export class Aptos {
|
|
|
94
95
|
constructor(settings?: AptosConfig) {
|
|
95
96
|
this.config = new AptosConfig(settings);
|
|
96
97
|
this.account = new Account(this.config);
|
|
98
|
+
this.abstraction = new AccountAbstraction(this.config);
|
|
97
99
|
this.ans = new ANS(this.config);
|
|
98
100
|
this.coin = new Coin(this.config);
|
|
99
101
|
this.digitalAsset = new DigitalAsset(this.config);
|
|
@@ -149,6 +151,7 @@ function applyMixin(targetClass: any, baseClass: any, baseClassProp: string) {
|
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
applyMixin(Aptos, Account, "account");
|
|
154
|
+
applyMixin(Aptos, AccountAbstraction, "abstraction");
|
|
152
155
|
applyMixin(Aptos, ANS, "ans");
|
|
153
156
|
applyMixin(Aptos, Coin, "coin");
|
|
154
157
|
applyMixin(Aptos, DigitalAsset, "digitalAsset");
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { AccountAddressInput } from "../../core";
|
|
4
|
+
import { AccountAddress, AccountAddressInput } from "../../core";
|
|
5
5
|
import { generateTransaction } from "../../internal/transactionSubmission";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
InputGenerateTransactionPayloadData,
|
|
8
|
+
InputGenerateTransactionOptions,
|
|
9
|
+
AptosScriptComposer,
|
|
10
|
+
TransactionPayloadScript,
|
|
11
|
+
generateRawTransaction,
|
|
12
|
+
} from "../../transactions";
|
|
7
13
|
import { MultiAgentTransaction } from "../../transactions/instances/multiAgentTransaction";
|
|
8
14
|
import { SimpleTransaction } from "../../transactions/instances/simpleTransaction";
|
|
9
15
|
import { AptosConfig } from "../aptosConfig";
|
|
16
|
+
import { Deserializer } from "../../bcs";
|
|
10
17
|
|
|
11
18
|
/**
|
|
12
19
|
* A class to handle all `Build` transaction operations.
|
|
@@ -96,6 +103,82 @@ export class Build {
|
|
|
96
103
|
return generateTransaction({ aptosConfig: this.config, ...args });
|
|
97
104
|
}
|
|
98
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Build a transaction from a series of Move calls.
|
|
108
|
+
*
|
|
109
|
+
* This function allows you to create a transaction with a list of Move calls.
|
|
110
|
+
*
|
|
111
|
+
* Right now we only tested this logic with single signer and we will add support
|
|
112
|
+
* for mutli agent transactions if needed.
|
|
113
|
+
*
|
|
114
|
+
* @param args.sender - The sender account address.
|
|
115
|
+
* @param args.builder - The closure to construct the list of calls.
|
|
116
|
+
* @param args.options - Optional transaction configurations.
|
|
117
|
+
* @param args.withFeePayer - Whether there is a fee payer for the transaction.
|
|
118
|
+
*
|
|
119
|
+
* @returns SimpleTransaction
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* import { Aptos, AptosConfig, Network } from "@aptos-labs/ts-sdk";
|
|
124
|
+
*
|
|
125
|
+
* const config = new AptosConfig({ network: Network.TESTNET });
|
|
126
|
+
* const aptos = new Aptos(config);
|
|
127
|
+
*
|
|
128
|
+
* async function runExample() {
|
|
129
|
+
* // Build a transaction from a chained series of Move calls.
|
|
130
|
+
* const transaction = await aptos.transaction.build.scriptComposer({
|
|
131
|
+
* sender: "0x1", // replace with a real sender account address
|
|
132
|
+
* builder: builder: async (builder) => {
|
|
133
|
+
* const coin = await builder.addBatchedCalls({
|
|
134
|
+
* function: "0x1::coin::withdraw",
|
|
135
|
+
* functionArguments: [CallArgument.new_signer(0), 1],
|
|
136
|
+
* typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
137
|
+
* });
|
|
138
|
+
*
|
|
139
|
+
* // Pass the returned value from the first function call to the second call
|
|
140
|
+
* const fungibleAsset = await builder.addBatchedCalls({
|
|
141
|
+
* function: "0x1::coin::coin_to_fungible_asset",
|
|
142
|
+
* functionArguments: [coin[0]],
|
|
143
|
+
* typeArguments: ["0x1::aptos_coin::AptosCoin"],
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* await builder.addBatchedCalls({
|
|
147
|
+
* function: "0x1::primary_fungible_store::deposit",
|
|
148
|
+
* functionArguments: [singleSignerED25519SenderAccount.accountAddress, fungibleAsset[0]],
|
|
149
|
+
* typeArguments: [],
|
|
150
|
+
* });
|
|
151
|
+
* return builder;
|
|
152
|
+
* },
|
|
153
|
+
* options: {
|
|
154
|
+
* gasUnitPrice: 100, // specify your own gas unit price if needed
|
|
155
|
+
* maxGasAmount: 1000, // specify your own max gas amount if needed
|
|
156
|
+
* },
|
|
157
|
+
* });
|
|
158
|
+
*
|
|
159
|
+
* console.log(transaction);
|
|
160
|
+
* }
|
|
161
|
+
* runExample().catch(console.error);
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
async scriptComposer(args: {
|
|
165
|
+
sender: AccountAddressInput;
|
|
166
|
+
builder: (builder: AptosScriptComposer) => Promise<AptosScriptComposer>;
|
|
167
|
+
options?: InputGenerateTransactionOptions;
|
|
168
|
+
withFeePayer?: boolean;
|
|
169
|
+
}): Promise<SimpleTransaction> {
|
|
170
|
+
const composer = new AptosScriptComposer(this.config);
|
|
171
|
+
await composer.init();
|
|
172
|
+
const builder = await args.builder(composer);
|
|
173
|
+
const bytes = builder.build();
|
|
174
|
+
const rawTxn = await generateRawTransaction({
|
|
175
|
+
aptosConfig: this.config,
|
|
176
|
+
payload: TransactionPayloadScript.load(new Deserializer(bytes)),
|
|
177
|
+
...args,
|
|
178
|
+
});
|
|
179
|
+
return new SimpleTransaction(rawTxn, args.withFeePayer === true ? AccountAddress.ZERO : undefined);
|
|
180
|
+
}
|
|
181
|
+
|
|
99
182
|
/**
|
|
100
183
|
* Build a multi-agent transaction that allows multiple signers to authorize a transaction.
|
|
101
184
|
*
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Deserializer, Serializer } from "../../bcs";
|
|
2
|
+
import { HexInput } from "../../types";
|
|
3
|
+
import { AccountAddress } from "../accountAddress";
|
|
4
|
+
import { AuthenticationKey } from "../authenticationKey";
|
|
5
|
+
import { Hex } from "../hex";
|
|
6
|
+
import { AccountPublicKey, VerifySignatureArgs } from "./publicKey";
|
|
7
|
+
import { Signature } from "./signature";
|
|
8
|
+
|
|
9
|
+
export class AbstractSignature extends Signature {
|
|
10
|
+
readonly value: Hex;
|
|
11
|
+
|
|
12
|
+
constructor(value: HexInput) {
|
|
13
|
+
super();
|
|
14
|
+
this.value = Hex.fromHexInput(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
serialize(serializer: Serializer): void {
|
|
18
|
+
serializer.serializeBytes(this.value.toUint8Array());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static deserialize(deserializer: Deserializer): AbstractSignature {
|
|
22
|
+
return new AbstractSignature(deserializer.deserializeBytes());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class AbstractPublicKey extends AccountPublicKey {
|
|
27
|
+
readonly accountAddress: AccountAddress;
|
|
28
|
+
|
|
29
|
+
constructor(accountAddress: AccountAddress) {
|
|
30
|
+
super();
|
|
31
|
+
this.accountAddress = accountAddress;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
authKey(): AuthenticationKey {
|
|
35
|
+
return new AuthenticationKey({ data: this.accountAddress.toUint8Array() });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
39
|
+
verifySignature(args: VerifySignatureArgs): boolean {
|
|
40
|
+
throw new Error("This function is not implemented for AbstractPublicKey.");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line class-methods-use-this, @typescript-eslint/no-unused-vars
|
|
44
|
+
serialize(serializer: Serializer): void {
|
|
45
|
+
throw new Error("This function is not implemented for AbstractPublicKey.");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleTransaction,
|
|
3
|
+
InputGenerateTransactionOptions,
|
|
4
|
+
TypeTagAddress,
|
|
5
|
+
TypeTagStruct,
|
|
6
|
+
stringStructTag,
|
|
7
|
+
} from "../transactions";
|
|
8
|
+
import { AccountAddressInput } from "../core";
|
|
9
|
+
import { generateTransaction } from "./transactionSubmission";
|
|
10
|
+
import { MoveFunctionId } from "../types";
|
|
11
|
+
import { AptosConfig } from "../api/aptosConfig";
|
|
12
|
+
import { getFunctionParts } from "../utils/helpers";
|
|
13
|
+
|
|
14
|
+
export async function addAuthenticationFunctionTransaction(args: {
|
|
15
|
+
aptosConfig: AptosConfig;
|
|
16
|
+
sender: AccountAddressInput;
|
|
17
|
+
authenticationFunction: string;
|
|
18
|
+
options?: InputGenerateTransactionOptions;
|
|
19
|
+
}): Promise<SimpleTransaction> {
|
|
20
|
+
const { aptosConfig, sender, authenticationFunction, options } = args;
|
|
21
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction as MoveFunctionId);
|
|
22
|
+
return generateTransaction({
|
|
23
|
+
aptosConfig,
|
|
24
|
+
sender,
|
|
25
|
+
data: {
|
|
26
|
+
function: "0x1::account_abstraction::add_authentication_function",
|
|
27
|
+
typeArguments: [],
|
|
28
|
+
functionArguments: [moduleAddress, moduleName, functionName],
|
|
29
|
+
abi: {
|
|
30
|
+
typeParameters: [],
|
|
31
|
+
parameters: [new TypeTagAddress(), new TypeTagStruct(stringStructTag()), new TypeTagStruct(stringStructTag())],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
options,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function removeAuthenticationFunctionTransaction(args: {
|
|
39
|
+
aptosConfig: AptosConfig;
|
|
40
|
+
sender: AccountAddressInput;
|
|
41
|
+
authenticationFunction: string;
|
|
42
|
+
options?: InputGenerateTransactionOptions;
|
|
43
|
+
}) {
|
|
44
|
+
const { aptosConfig, sender, authenticationFunction, options } = args;
|
|
45
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(authenticationFunction as MoveFunctionId);
|
|
46
|
+
return generateTransaction({
|
|
47
|
+
aptosConfig,
|
|
48
|
+
sender,
|
|
49
|
+
data: {
|
|
50
|
+
function: "0x1::account_abstraction::remove_authentication_function",
|
|
51
|
+
typeArguments: [],
|
|
52
|
+
functionArguments: [moduleAddress, moduleName, functionName],
|
|
53
|
+
abi: {
|
|
54
|
+
typeParameters: [],
|
|
55
|
+
parameters: [new TypeTagAddress(), new TypeTagStruct(stringStructTag()), new TypeTagStruct(stringStructTag())],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
options,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export async function removeDispatchableAuthenticatorTransaction(args: {
|
|
63
|
+
aptosConfig: AptosConfig;
|
|
64
|
+
sender: AccountAddressInput;
|
|
65
|
+
options?: InputGenerateTransactionOptions;
|
|
66
|
+
}) {
|
|
67
|
+
const { aptosConfig, sender, options } = args;
|
|
68
|
+
return generateTransaction({
|
|
69
|
+
aptosConfig,
|
|
70
|
+
sender,
|
|
71
|
+
data: {
|
|
72
|
+
function: "0x1::account_abstraction::remove_authenticator",
|
|
73
|
+
typeArguments: [],
|
|
74
|
+
functionArguments: [],
|
|
75
|
+
abi: { typeParameters: [], parameters: [] },
|
|
76
|
+
},
|
|
77
|
+
options,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -8,7 +8,10 @@ import { AnyPublicKey, AnySignature } from "../../core/crypto";
|
|
|
8
8
|
import { Ed25519PublicKey, Ed25519Signature } from "../../core/crypto/ed25519";
|
|
9
9
|
import { MultiEd25519PublicKey, MultiEd25519Signature } from "../../core/crypto/multiEd25519";
|
|
10
10
|
import { MultiKey, MultiKeySignature } from "../../core/crypto/multiKey";
|
|
11
|
-
import { AccountAuthenticatorVariant } from "../../types";
|
|
11
|
+
import { AccountAuthenticatorVariant, HexInput, MoveFunctionId } from "../../types";
|
|
12
|
+
import { AbstractionAuthDataVariant } from "../../types/abstraction";
|
|
13
|
+
import { AccountAddress, Hex } from "../../core";
|
|
14
|
+
import { getFunctionParts, isValidFunctionInfo } from "../../utils/helpers";
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Represents an account authenticator that can handle multiple authentication variants.
|
|
@@ -43,6 +46,8 @@ export abstract class AccountAuthenticator extends Serializable {
|
|
|
43
46
|
return AccountAuthenticatorMultiKey.load(deserializer);
|
|
44
47
|
case AccountAuthenticatorVariant.NoAccountAuthenticator:
|
|
45
48
|
return AccountAuthenticatorNoAccountAuthenticator.load(deserializer);
|
|
49
|
+
case AccountAuthenticatorVariant.Abstraction:
|
|
50
|
+
return AccountAuthenticatorAbstraction.load(deserializer);
|
|
46
51
|
default:
|
|
47
52
|
throw new Error(`Unknown variant index for AccountAuthenticator: ${index}`);
|
|
48
53
|
}
|
|
@@ -263,3 +268,49 @@ export class AccountAuthenticatorNoAccountAuthenticator extends AccountAuthentic
|
|
|
263
268
|
return new AccountAuthenticatorNoAccountAuthenticator();
|
|
264
269
|
}
|
|
265
270
|
}
|
|
271
|
+
|
|
272
|
+
export class AccountAuthenticatorAbstraction extends AccountAuthenticator {
|
|
273
|
+
public readonly functionInfo: string;
|
|
274
|
+
|
|
275
|
+
public readonly signingMessageDigest: Hex;
|
|
276
|
+
|
|
277
|
+
public readonly authenticator: Hex;
|
|
278
|
+
|
|
279
|
+
constructor(functionInfo: string, signingMessageDigest: HexInput, authenticator: HexInput) {
|
|
280
|
+
super();
|
|
281
|
+
if (!isValidFunctionInfo(functionInfo)) {
|
|
282
|
+
throw new Error(`Invalid function info ${functionInfo} passed into AccountAuthenticatorAbstraction`);
|
|
283
|
+
}
|
|
284
|
+
this.functionInfo = functionInfo;
|
|
285
|
+
this.authenticator = Hex.fromHexInput(authenticator);
|
|
286
|
+
this.signingMessageDigest = Hex.fromHexInput(Hex.fromHexInput(signingMessageDigest).toUint8Array());
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
serialize(serializer: Serializer): void {
|
|
290
|
+
serializer.serializeU32AsUleb128(AccountAuthenticatorVariant.Abstraction);
|
|
291
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(this.functionInfo as MoveFunctionId);
|
|
292
|
+
AccountAddress.fromString(moduleAddress).serialize(serializer);
|
|
293
|
+
serializer.serializeStr(moduleName);
|
|
294
|
+
serializer.serializeStr(functionName);
|
|
295
|
+
serializer.serializeU32AsUleb128(AbstractionAuthDataVariant.V1);
|
|
296
|
+
serializer.serializeBytes(this.signingMessageDigest.toUint8Array());
|
|
297
|
+
serializer.serializeFixedBytes(this.authenticator.toUint8Array());
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
static load(deserializer: Deserializer): AccountAuthenticatorAbstraction {
|
|
301
|
+
const moduleAddress = AccountAddress.deserialize(deserializer);
|
|
302
|
+
const moduleName = deserializer.deserializeStr();
|
|
303
|
+
const functionName = deserializer.deserializeStr();
|
|
304
|
+
const variant = deserializer.deserializeUleb128AsU32();
|
|
305
|
+
if (variant === AbstractionAuthDataVariant.V1) {
|
|
306
|
+
const signingMessageDigest = deserializer.deserializeBytes();
|
|
307
|
+
const authenticator = deserializer.deserializeFixedBytes(deserializer.remaining());
|
|
308
|
+
return new AccountAuthenticatorAbstraction(
|
|
309
|
+
`${moduleAddress}::${moduleName}::${functionName}`,
|
|
310
|
+
signingMessageDigest,
|
|
311
|
+
authenticator,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${variant}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ScriptComposerWasm } from "@aptos-labs/script-composer-pack";
|
|
5
|
+
import { AptosApiType, getFunctionParts } from "../../utils";
|
|
6
|
+
import { AptosConfig } from "../../api/aptosConfig";
|
|
7
|
+
import { InputBatchedFunctionData } from "../types";
|
|
8
|
+
import { fetchMoveFunctionAbi, standardizeTypeTags } from "../transactionBuilder";
|
|
9
|
+
import { CallArgument } from "../../types";
|
|
10
|
+
import { convertCallArgument } from "../transactionBuilder/remoteAbi";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A wrapper class around TransactionComposer, which is a WASM library compiled
|
|
14
|
+
* from aptos-core/aptos-move/script-composer.
|
|
15
|
+
* This class allows the SDK caller to build a transaction that invokes multiple Move functions
|
|
16
|
+
* and allow for arguments to be passed around.
|
|
17
|
+
* */
|
|
18
|
+
export class AptosScriptComposer {
|
|
19
|
+
private config: AptosConfig;
|
|
20
|
+
|
|
21
|
+
private builder?: any;
|
|
22
|
+
|
|
23
|
+
private static transactionComposer?: any;
|
|
24
|
+
|
|
25
|
+
constructor(aptosConfig: AptosConfig) {
|
|
26
|
+
this.config = aptosConfig;
|
|
27
|
+
this.builder = undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Initializing the wasm needed for the script composer, must be called
|
|
31
|
+
// before using the composer.
|
|
32
|
+
async init() {
|
|
33
|
+
if (!AptosScriptComposer.transactionComposer) {
|
|
34
|
+
const module = await import("@aptos-labs/script-composer-pack");
|
|
35
|
+
const { TransactionComposer, initSync } = module;
|
|
36
|
+
if (!ScriptComposerWasm.isInitialized) {
|
|
37
|
+
ScriptComposerWasm.init();
|
|
38
|
+
}
|
|
39
|
+
initSync({ module: ScriptComposerWasm.wasm });
|
|
40
|
+
AptosScriptComposer.transactionComposer = TransactionComposer;
|
|
41
|
+
}
|
|
42
|
+
this.builder = AptosScriptComposer.transactionComposer.single_signer();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Add a move function invocation to the TransactionComposer.
|
|
46
|
+
//
|
|
47
|
+
// Similar to how to create an entry function, the difference is that input arguments could
|
|
48
|
+
// either be a `CallArgument` which represents an abstract value returned from a previous Move call
|
|
49
|
+
// or the regular entry function arguments.
|
|
50
|
+
//
|
|
51
|
+
// The function would also return a list of `CallArgument` that can be passed on to future calls.
|
|
52
|
+
async addBatchedCalls(input: InputBatchedFunctionData): Promise<CallArgument[]> {
|
|
53
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(input.function);
|
|
54
|
+
const nodeUrl = this.config.getRequestUrl(AptosApiType.FULLNODE);
|
|
55
|
+
|
|
56
|
+
// Load the calling module into the builder.
|
|
57
|
+
await this.builder.load_module(nodeUrl, `${moduleAddress}::${moduleName}`);
|
|
58
|
+
|
|
59
|
+
// Load the calling type arguments into the loader.
|
|
60
|
+
if (input.typeArguments !== undefined) {
|
|
61
|
+
await Promise.all(input.typeArguments.map((typeTag) => this.builder.load_type_tag(nodeUrl, typeTag.toString())));
|
|
62
|
+
}
|
|
63
|
+
const typeArguments = standardizeTypeTags(input.typeArguments);
|
|
64
|
+
const functionAbi = await fetchMoveFunctionAbi(moduleAddress, moduleName, functionName, this.config);
|
|
65
|
+
// Check the type argument count against the ABI
|
|
66
|
+
if (typeArguments.length !== functionAbi.typeParameters.length) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const functionArguments: CallArgument[] = input.functionArguments.map((arg, i) =>
|
|
73
|
+
convertCallArgument(arg, functionName, functionAbi, i, typeArguments),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return this.builder.add_batched_call(
|
|
77
|
+
`${moduleAddress}::${moduleName}`,
|
|
78
|
+
functionName,
|
|
79
|
+
typeArguments.map((arg) => arg.toString()),
|
|
80
|
+
functionArguments,
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
build(): Uint8Array {
|
|
85
|
+
return this.builder.generate_batched_calls(true);
|
|
86
|
+
}
|
|
87
|
+
}
|