@aptos-labs/ts-sdk 1.33.2-sc.0 → 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/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 +2489 -2235
- package/dist/common/index.js +33 -35
- package/dist/common/index.js.map +1 -1
- 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.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +16 -16
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +2 -0
- package/dist/esm/account/index.mjs +1 -1
- 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/abstraction.mjs.map +1 -0
- package/dist/esm/api/account.d.mts +2 -0
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +1 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +1 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +1 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +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.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/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-CYMVZJHC.mjs → chunk-2FNFUTFJ.mjs} +2 -2
- package/dist/esm/{chunk-4UYVRG5Z.mjs → chunk-2GIPNLDO.mjs} +2 -2
- package/dist/esm/{chunk-UQ7D5CSM.mjs → chunk-33CBJFX2.mjs} +2 -2
- package/dist/esm/{chunk-P54RNN4V.mjs → chunk-3EY7MT2M.mjs} +2 -2
- package/dist/esm/{chunk-KPLWOVKG.mjs → chunk-3HFZN7L5.mjs} +2 -2
- 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-FC2IYWI7.mjs → chunk-4T75XRI2.mjs} +2 -2
- package/dist/esm/{chunk-EBS4BKER.mjs → chunk-4UK4MUSD.mjs} +2 -2
- package/dist/esm/{chunk-GL4OJVYH.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-CDYLZDD2.mjs → chunk-6JTNS5O6.mjs} +2 -2
- package/dist/esm/{chunk-UF6SI2QE.mjs → chunk-6LGXFXXR.mjs} +2 -2
- package/dist/esm/{chunk-T6NQDM7D.mjs → chunk-6PBMD2BQ.mjs} +2 -2
- package/dist/esm/chunk-7C2RDOWS.mjs +1 -0
- package/dist/esm/chunk-7C2RDOWS.mjs.map +1 -0
- package/dist/esm/{chunk-ECZYQTNN.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-A3NEASNH.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-P4VF7BN4.mjs → chunk-BYHCW7MI.mjs} +2 -2
- package/dist/esm/{chunk-AD3A7DTH.mjs → chunk-CRFLR3ZY.mjs} +2 -2
- package/dist/esm/{chunk-CWRANLXZ.mjs → chunk-CSG67JHZ.mjs} +2 -2
- package/dist/esm/chunk-CSG67JHZ.mjs.map +1 -0
- package/dist/esm/{chunk-BFIXIXHO.mjs → chunk-CXNF73OX.mjs} +2 -2
- package/dist/esm/{chunk-32WLD3F3.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-CGTHWGSJ.mjs → chunk-DLLDRANJ.mjs} +2 -2
- package/dist/esm/{chunk-KFGXOZ77.mjs → chunk-DMS7K76O.mjs} +2 -2
- package/dist/esm/{chunk-KNTAED2Z.mjs → chunk-DNJQWGB7.mjs} +2 -2
- package/dist/esm/{chunk-NW2WUKWV.mjs → chunk-DNWFDS7F.mjs} +2 -2
- package/dist/esm/{chunk-XIFIACCB.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-AIABPCUF.mjs.map → chunk-EY2JUXEC.mjs.map} +1 -1
- package/dist/esm/{chunk-KG23XFU2.mjs → chunk-G6RLN6ET.mjs} +2 -2
- package/dist/esm/{chunk-G5ZWH5T3.mjs → chunk-GQX5KMF7.mjs} +2 -2
- package/dist/esm/{chunk-X3SO2LDX.mjs → chunk-H4GZWYIG.mjs} +2 -2
- package/dist/esm/chunk-HEAWDTLG.mjs +2 -0
- package/dist/esm/{chunk-XHPWHA6B.mjs.map → chunk-HEAWDTLG.mjs.map} +1 -1
- package/dist/esm/{chunk-SQR3AIY7.mjs → chunk-HFCWJ6QL.mjs} +2 -2
- package/dist/esm/{chunk-FQECACH3.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-PTS3BTOU.mjs → chunk-HT2WC3QV.mjs} +2 -2
- package/dist/esm/{chunk-ODEDSSQL.mjs → chunk-I7YHK6ZF.mjs} +2 -2
- package/dist/esm/{chunk-N4VVDQA5.mjs → chunk-IDTLNF4M.mjs} +2 -2
- package/dist/esm/chunk-IMTC3J2M.mjs +2 -0
- package/dist/esm/chunk-IMTC3J2M.mjs.map +1 -0
- package/dist/esm/{chunk-67ZANQ3R.mjs → chunk-J7HRQ2IH.mjs} +2 -2
- package/dist/esm/{chunk-H3XZ3FZY.mjs → chunk-JF66JS2R.mjs} +2 -2
- package/dist/esm/{chunk-I7JGKVOC.mjs → chunk-KEJAUCQF.mjs} +2 -2
- package/dist/esm/{chunk-Y6QTKAQO.mjs → chunk-L2AQG3G3.mjs} +2 -2
- package/dist/esm/{chunk-7HLNV3QL.mjs → chunk-L6FONDPA.mjs} +2 -2
- package/dist/esm/{chunk-ZJNPBHEI.mjs → chunk-N7C6LQPZ.mjs} +2 -2
- package/dist/esm/{chunk-VZELORLW.mjs → chunk-O37BZP2G.mjs} +2 -2
- package/dist/esm/{chunk-SOLQ5VON.mjs → chunk-OURSLL3I.mjs} +2 -2
- package/dist/esm/{chunk-PHJRCZQ3.mjs → chunk-P7SE5LQE.mjs} +2 -2
- package/dist/esm/{chunk-3XH3NNSR.mjs → chunk-PNSF3E67.mjs} +2 -2
- package/dist/esm/{chunk-UONSJQUV.mjs → chunk-PR3W2QEH.mjs} +2 -2
- package/dist/esm/{chunk-KFCLSJC3.mjs → chunk-PWYJWTEM.mjs} +2 -2
- package/dist/esm/{chunk-VCIJX6R4.mjs → chunk-Q7RG7KQS.mjs} +2 -2
- package/dist/esm/{chunk-6IIAGMDR.mjs → chunk-QBFGY74I.mjs} +2 -2
- package/dist/esm/{chunk-XLFX2YQA.mjs → chunk-S47HA7O7.mjs} +2 -2
- package/dist/esm/{chunk-6IPM5P4L.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-XGF7UNEW.mjs → chunk-TM6IKHMX.mjs} +2 -2
- package/dist/esm/{chunk-FNXO3URE.mjs → chunk-U2SJIG2T.mjs} +2 -2
- package/dist/esm/{chunk-SZRZ3HIL.mjs → chunk-ULHOJ2BE.mjs} +2 -2
- package/dist/esm/{chunk-4ZJJINCW.mjs → chunk-UTXEW2FT.mjs} +2 -2
- package/dist/esm/{chunk-K2CSACQY.mjs → chunk-V2EXS6TM.mjs} +2 -2
- package/dist/esm/{chunk-FKJ3GCBI.mjs → chunk-V7G2EDNR.mjs} +2 -2
- package/dist/esm/{chunk-R7QOPBWA.mjs → chunk-VKDTI6NX.mjs} +2 -2
- package/dist/esm/{chunk-PNDCGNVH.mjs → chunk-VOCI2675.mjs} +2 -2
- package/dist/esm/{chunk-VVAKGJDN.mjs → chunk-WXDA4CCR.mjs} +2 -2
- package/dist/esm/{chunk-66AQ2MJ6.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-67BUAZ6O.mjs → chunk-X6IHNXWY.mjs} +2 -2
- package/dist/esm/{chunk-JJM6ELMS.mjs → chunk-XAPQNCTN.mjs} +2 -2
- package/dist/esm/{chunk-DW3ETAZB.mjs → chunk-XDIX7NIP.mjs} +2 -2
- package/dist/esm/{chunk-6XHBRRS6.mjs → chunk-XH3BEKII.mjs} +2 -2
- package/dist/esm/{chunk-PUNTBVRJ.mjs → chunk-XXHZQFYW.mjs} +2 -2
- package/dist/esm/{chunk-YPGI5HAA.mjs → chunk-Y3Y4DVCK.mjs} +2 -2
- package/dist/esm/{chunk-CNCRJ56P.mjs → chunk-YIF242TF.mjs} +2 -2
- package/dist/esm/{chunk-CWKNJZB6.mjs → chunk-ZCEBDPBJ.mjs} +2 -2
- package/dist/esm/{chunk-Q3VS6AEN.mjs → chunk-ZP5EBIBE.mjs} +2 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- 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/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.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- 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.mjs +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +6 -3
- 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.mjs +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +11 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +2 -2
- 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/index.mjs +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.d.mts +4 -4
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/scriptComposer/index.d.mts +6 -0
- package/dist/esm/transactions/scriptComposer/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +2 -17
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
- 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/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.mjs +1 -1
- package/dist/esm/types/types.d.mts +2 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +18 -2
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- 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 +1 -1
- 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/core/crypto/abstraction.ts +47 -0
- package/src/internal/abstraction.ts +79 -0
- package/src/transactions/authenticator/account.ts +52 -1
- package/src/transactions/scriptComposer/index.ts +8 -7
- package/src/transactions/transactionBuilder/helpers.ts +1 -22
- package/src/transactions/transactionBuilder/remoteAbi.ts +7 -0
- package/src/transactions/transactionBuilder/transactionBuilder.ts +2 -1
- package/src/types/abstraction.ts +6 -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-AIABPCUF.mjs +0 -2
- package/dist/esm/chunk-CWRANLXZ.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-FQXEX2HN.mjs +0 -2
- package/dist/esm/chunk-FQXEX2HN.mjs.map +0 -1
- package/dist/esm/chunk-GP4TLDVZ.mjs +0 -1
- package/dist/esm/chunk-IJ2QKE4W.mjs +0 -2
- package/dist/esm/chunk-IJ2QKE4W.mjs.map +0 -1
- package/dist/esm/chunk-NDUIXMIA.mjs +0 -2
- package/dist/esm/chunk-NDUIXMIA.mjs.map +0 -1
- package/dist/esm/chunk-Q2C6ZY5N.mjs +0 -4
- package/dist/esm/chunk-Q2C6ZY5N.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-UYONA6PP.mjs +0 -2
- package/dist/esm/chunk-UYONA6PP.mjs.map +0 -1
- package/dist/esm/chunk-XHPWHA6B.mjs +0 -2
- /package/dist/esm/{chunk-GP4TLDVZ.mjs.map → account/AbstractedAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-CYMVZJHC.mjs.map → chunk-2FNFUTFJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-4UYVRG5Z.mjs.map → chunk-2GIPNLDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-UQ7D5CSM.mjs.map → chunk-33CBJFX2.mjs.map} +0 -0
- /package/dist/esm/{chunk-P54RNN4V.mjs.map → chunk-3EY7MT2M.mjs.map} +0 -0
- /package/dist/esm/{chunk-KPLWOVKG.mjs.map → chunk-3HFZN7L5.mjs.map} +0 -0
- /package/dist/esm/{chunk-FC2IYWI7.mjs.map → chunk-4T75XRI2.mjs.map} +0 -0
- /package/dist/esm/{chunk-EBS4BKER.mjs.map → chunk-4UK4MUSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-GL4OJVYH.mjs.map → chunk-5BSMF22B.mjs.map} +0 -0
- /package/dist/esm/{chunk-CDYLZDD2.mjs.map → chunk-6JTNS5O6.mjs.map} +0 -0
- /package/dist/esm/{chunk-UF6SI2QE.mjs.map → chunk-6LGXFXXR.mjs.map} +0 -0
- /package/dist/esm/{chunk-T6NQDM7D.mjs.map → chunk-6PBMD2BQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-ECZYQTNN.mjs.map → chunk-7CYCKCVU.mjs.map} +0 -0
- /package/dist/esm/{chunk-A3NEASNH.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-P4VF7BN4.mjs.map → chunk-BYHCW7MI.mjs.map} +0 -0
- /package/dist/esm/{chunk-AD3A7DTH.mjs.map → chunk-CRFLR3ZY.mjs.map} +0 -0
- /package/dist/esm/{chunk-BFIXIXHO.mjs.map → chunk-CXNF73OX.mjs.map} +0 -0
- /package/dist/esm/{chunk-32WLD3F3.mjs.map → chunk-D6T3NYOA.mjs.map} +0 -0
- /package/dist/esm/{chunk-CGTHWGSJ.mjs.map → chunk-DLLDRANJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-KFGXOZ77.mjs.map → chunk-DMS7K76O.mjs.map} +0 -0
- /package/dist/esm/{chunk-KNTAED2Z.mjs.map → chunk-DNJQWGB7.mjs.map} +0 -0
- /package/dist/esm/{chunk-NW2WUKWV.mjs.map → chunk-DNWFDS7F.mjs.map} +0 -0
- /package/dist/esm/{chunk-XIFIACCB.mjs.map → chunk-DWJ3PGWE.mjs.map} +0 -0
- /package/dist/esm/{chunk-KG23XFU2.mjs.map → chunk-G6RLN6ET.mjs.map} +0 -0
- /package/dist/esm/{chunk-G5ZWH5T3.mjs.map → chunk-GQX5KMF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-X3SO2LDX.mjs.map → chunk-H4GZWYIG.mjs.map} +0 -0
- /package/dist/esm/{chunk-SQR3AIY7.mjs.map → chunk-HFCWJ6QL.mjs.map} +0 -0
- /package/dist/esm/{chunk-FQECACH3.mjs.map → chunk-HL2O3T57.mjs.map} +0 -0
- /package/dist/esm/{chunk-PTS3BTOU.mjs.map → chunk-HT2WC3QV.mjs.map} +0 -0
- /package/dist/esm/{chunk-ODEDSSQL.mjs.map → chunk-I7YHK6ZF.mjs.map} +0 -0
- /package/dist/esm/{chunk-N4VVDQA5.mjs.map → chunk-IDTLNF4M.mjs.map} +0 -0
- /package/dist/esm/{chunk-67ZANQ3R.mjs.map → chunk-J7HRQ2IH.mjs.map} +0 -0
- /package/dist/esm/{chunk-H3XZ3FZY.mjs.map → chunk-JF66JS2R.mjs.map} +0 -0
- /package/dist/esm/{chunk-I7JGKVOC.mjs.map → chunk-KEJAUCQF.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y6QTKAQO.mjs.map → chunk-L2AQG3G3.mjs.map} +0 -0
- /package/dist/esm/{chunk-7HLNV3QL.mjs.map → chunk-L6FONDPA.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZJNPBHEI.mjs.map → chunk-N7C6LQPZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-VZELORLW.mjs.map → chunk-O37BZP2G.mjs.map} +0 -0
- /package/dist/esm/{chunk-SOLQ5VON.mjs.map → chunk-OURSLL3I.mjs.map} +0 -0
- /package/dist/esm/{chunk-PHJRCZQ3.mjs.map → chunk-P7SE5LQE.mjs.map} +0 -0
- /package/dist/esm/{chunk-3XH3NNSR.mjs.map → chunk-PNSF3E67.mjs.map} +0 -0
- /package/dist/esm/{chunk-UONSJQUV.mjs.map → chunk-PR3W2QEH.mjs.map} +0 -0
- /package/dist/esm/{chunk-KFCLSJC3.mjs.map → chunk-PWYJWTEM.mjs.map} +0 -0
- /package/dist/esm/{chunk-VCIJX6R4.mjs.map → chunk-Q7RG7KQS.mjs.map} +0 -0
- /package/dist/esm/{chunk-6IIAGMDR.mjs.map → chunk-QBFGY74I.mjs.map} +0 -0
- /package/dist/esm/{chunk-XLFX2YQA.mjs.map → chunk-S47HA7O7.mjs.map} +0 -0
- /package/dist/esm/{chunk-6IPM5P4L.mjs.map → chunk-SCBYJU6K.mjs.map} +0 -0
- /package/dist/esm/{chunk-XGF7UNEW.mjs.map → chunk-TM6IKHMX.mjs.map} +0 -0
- /package/dist/esm/{chunk-FNXO3URE.mjs.map → chunk-U2SJIG2T.mjs.map} +0 -0
- /package/dist/esm/{chunk-SZRZ3HIL.mjs.map → chunk-ULHOJ2BE.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ZJJINCW.mjs.map → chunk-UTXEW2FT.mjs.map} +0 -0
- /package/dist/esm/{chunk-K2CSACQY.mjs.map → chunk-V2EXS6TM.mjs.map} +0 -0
- /package/dist/esm/{chunk-FKJ3GCBI.mjs.map → chunk-V7G2EDNR.mjs.map} +0 -0
- /package/dist/esm/{chunk-R7QOPBWA.mjs.map → chunk-VKDTI6NX.mjs.map} +0 -0
- /package/dist/esm/{chunk-PNDCGNVH.mjs.map → chunk-VOCI2675.mjs.map} +0 -0
- /package/dist/esm/{chunk-VVAKGJDN.mjs.map → chunk-WXDA4CCR.mjs.map} +0 -0
- /package/dist/esm/{chunk-66AQ2MJ6.mjs.map → chunk-X24PSWCX.mjs.map} +0 -0
- /package/dist/esm/{chunk-67BUAZ6O.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-DW3ETAZB.mjs.map → chunk-XDIX7NIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-6XHBRRS6.mjs.map → chunk-XH3BEKII.mjs.map} +0 -0
- /package/dist/esm/{chunk-PUNTBVRJ.mjs.map → chunk-XXHZQFYW.mjs.map} +0 -0
- /package/dist/esm/{chunk-YPGI5HAA.mjs.map → chunk-Y3Y4DVCK.mjs.map} +0 -0
- /package/dist/esm/{chunk-CNCRJ56P.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-Q3VS6AEN.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");
|
|
@@ -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
|
+
}
|
|
@@ -2,18 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { ScriptComposerWasm } from "@aptos-labs/script-composer-pack";
|
|
5
|
-
import { AptosApiType } from "../../utils";
|
|
5
|
+
import { AptosApiType, getFunctionParts } from "../../utils";
|
|
6
6
|
import { AptosConfig } from "../../api/aptosConfig";
|
|
7
7
|
import { InputBatchedFunctionData } from "../types";
|
|
8
|
-
import { fetchMoveFunctionAbi,
|
|
8
|
+
import { fetchMoveFunctionAbi, standardizeTypeTags } from "../transactionBuilder";
|
|
9
9
|
import { CallArgument } from "../../types";
|
|
10
10
|
import { convertCallArgument } from "../transactionBuilder/remoteAbi";
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
* */
|
|
17
18
|
export class AptosScriptComposer {
|
|
18
19
|
private config: AptosConfig;
|
|
19
20
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "../types";
|
|
11
11
|
import { Bool, FixedBytes, MoveOption, MoveString, MoveVector, U128, U16, U256, U32, U64, U8 } from "../../bcs";
|
|
12
12
|
import { AccountAddress } from "../../core";
|
|
13
|
-
import { MoveFunction
|
|
13
|
+
import { MoveFunction } from "../../types";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Determines if the provided argument is of type boolean.
|
|
@@ -317,24 +317,3 @@ export function findFirstNonSignerArg(functionAbi: MoveFunction): number {
|
|
|
317
317
|
}
|
|
318
318
|
return index;
|
|
319
319
|
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Splits a function identifier into its constituent parts: module address, module name, and function name.
|
|
323
|
-
* This function helps in validating and extracting details from a function identifier string.
|
|
324
|
-
*
|
|
325
|
-
* @param functionArg - The function identifier string in the format "moduleAddress::moduleName::functionName".
|
|
326
|
-
* @returns An object containing the module address, module name, and function name.
|
|
327
|
-
* @throws Error if the function identifier does not contain exactly three parts.
|
|
328
|
-
* @group Implementation
|
|
329
|
-
* @category Transactions
|
|
330
|
-
*/
|
|
331
|
-
export function getFunctionParts(functionArg: MoveFunctionId) {
|
|
332
|
-
const funcNameParts = functionArg.split("::");
|
|
333
|
-
if (funcNameParts.length !== 3) {
|
|
334
|
-
throw new Error(`Invalid function ${functionArg}`);
|
|
335
|
-
}
|
|
336
|
-
const moduleAddress = funcNameParts[0];
|
|
337
|
-
const moduleName = funcNameParts[1];
|
|
338
|
-
const functionName = funcNameParts[2];
|
|
339
|
-
return { moduleAddress, moduleName, functionName };
|
|
340
|
-
}
|
|
@@ -423,6 +423,13 @@ function parseArg(
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
if (isString(arg)) {
|
|
427
|
+
// In a web env, arguments are passing as strings
|
|
428
|
+
if (arg.startsWith("[")) {
|
|
429
|
+
return checkOrConvertArgument(JSON.parse(arg), param, position, genericTypeParams);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
426
433
|
// TODO: Support Uint16Array, Uint32Array, BigUint64Array?
|
|
427
434
|
|
|
428
435
|
if (Array.isArray(arg)) {
|
|
@@ -77,9 +77,10 @@ import {
|
|
|
77
77
|
} from "../types";
|
|
78
78
|
import { convertArgument, fetchEntryFunctionAbi, fetchViewFunctionAbi, standardizeTypeTags } from "./remoteAbi";
|
|
79
79
|
import { memoizeAsync } from "../../utils/memoize";
|
|
80
|
-
import {
|
|
80
|
+
import { isScriptDataInput } from "./helpers";
|
|
81
81
|
import { SimpleTransaction } from "../instances/simpleTransaction";
|
|
82
82
|
import { MultiAgentTransaction } from "../instances/multiAgentTransaction";
|
|
83
|
+
import { getFunctionParts } from "../../utils/helpers";
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
86
|
* Builds a transaction payload based on the provided arguments and returns a transaction payload.
|
package/src/types/types.ts
CHANGED
package/src/utils/helpers.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { decode } from "js-base64";
|
|
5
|
-
import { MoveStructId } from "../types";
|
|
5
|
+
import { MoveFunctionId, MoveStructId } from "../types";
|
|
6
|
+
import { AccountAddress } from "../core/accountAddress";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Sleep for the specified amount of time in milliseconds.
|
|
@@ -175,3 +176,29 @@ export const isEncodedStruct = (
|
|
|
175
176
|
typeof structObj.account_address === "string" &&
|
|
176
177
|
typeof structObj.module_name === "string" &&
|
|
177
178
|
typeof structObj.struct_name === "string";
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Splits a function identifier into its constituent parts: module address, module name, and function name.
|
|
182
|
+
* This function helps in validating and extracting details from a function identifier string.
|
|
183
|
+
*
|
|
184
|
+
* @param functionArg - The function identifier string in the format "moduleAddress::moduleName::functionName".
|
|
185
|
+
* @returns An object containing the module address, module name, and function name.
|
|
186
|
+
* @throws Error if the function identifier does not contain exactly three parts.
|
|
187
|
+
* @group Implementation
|
|
188
|
+
* @category Transactions
|
|
189
|
+
*/
|
|
190
|
+
export function getFunctionParts(functionArg: MoveFunctionId) {
|
|
191
|
+
const funcNameParts = functionArg.split("::");
|
|
192
|
+
if (funcNameParts.length !== 3) {
|
|
193
|
+
throw new Error(`Invalid function ${functionArg}`);
|
|
194
|
+
}
|
|
195
|
+
const moduleAddress = funcNameParts[0];
|
|
196
|
+
const moduleName = funcNameParts[1];
|
|
197
|
+
const functionName = funcNameParts[2];
|
|
198
|
+
return { moduleAddress, moduleName, functionName };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function isValidFunctionInfo(functionInfo: string): boolean {
|
|
202
|
+
const parts = functionInfo.split("::");
|
|
203
|
+
return parts.length === 3 && AccountAddress.isValid({ input: parts[0] }).valid;
|
|
204
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var i=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var m=(e,n,t,r)=>{for(var o=r>1?void 0:r?u(n,t):n,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(r?a(n,t,o):a(o))||o);return r&&o&&i(n,t,o),o};var _jsbase64 = require('js-base64');async function p(e){return new Promise(n=>{setTimeout(n,e)})}function f(e){return e instanceof Error?e.message:String(e)}var _=()=>Math.floor(Date.now()/1e3);function S(e){let n=new Date(e*1e3);return n.setMinutes(0),n.setSeconds(0),n.setMilliseconds(0),Math.floor(n.getTime()/1e3)}function x(e){let n=e.replace(/-/g,"+").replace(/_/g,"/"),t=n+"==".substring(0,(3-n.length%3)%3);return _jsbase64.decode.call(void 0, t)}var h=(e,n)=>e*10**n,y= exports.h =(e,n)=>e/10**n,c=e=>{let n="";for(let t=2;t<e.length;t+=2)n+=String.fromCharCode(parseInt(e.substring(t,t+2),16));return n},b= exports.i =e=>{let{account_address:n,module_name:t,struct_name:r}=e,o=c(t),s=c(r);return`${n}::${o}::${s}`},M= exports.j =e=>typeof e=="object"&&!Array.isArray(e)&&e!==null&&"account_address"in e&&"module_name"in e&&"struct_name"in e&&typeof e.account_address=="string"&&typeof e.module_name=="string"&&typeof e.struct_name=="string";exports.a = m; exports.b = p; exports.c = f; exports.d = _; exports.e = S; exports.f = x; exports.g = h; exports.h = y; exports.i = b; exports.j = M;
|
|
2
|
-
//# sourceMappingURL=chunk-IHUCZKG2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/philip/Documents/General/aptos-ts-sdk/dist/common/chunk-IHUCZKG2.js","../../src/utils/helpers.ts"],"names":["sleep","timeMs","resolve","getErrorMessage","error","nowInSeconds","floorToWholeHour","timestampInSeconds","date","base64UrlDecode","base64Url","base64","paddedBase64","decode","convertAmountFromHumanReadableToOnChain","value","decimal","convertAmountFromOnChainToHumanReadable","hexToAscii","hex","str","n","parseEncodedStruct","structObj","account_address","module_name","struct_name","moduleName","structName"],"mappings":"AAAA,6EAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCGvM,qCAAuB,MAWvB,SAAsBA,CAAAA,CAAMC,CAAAA,CAA+B,CACzD,OAAO,IAAI,OAAA,CAASC,CAAAA,EAAY,CAC9B,UAAA,CAAWA,CAAAA,CAASD,CAAM,CAC5B,CAAC,CACH,CAUO,SAASE,CAAAA,CAAgBC,CAAAA,CAAwB,CACtD,OAAOA,EAAAA,WAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,MAAA,CAAOA,CAAK,CAC9D,CAMO,IAAMC,CAAAA,CAAe,CAAA,CAAA,EAAM,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,GAAA,CAAI,CAAA,CAAI,GAAI,CAAA,CAUvD,SAASC,CAAAA,CAAiBC,CAAAA,CAAoC,CACnE,IAAMC,CAAAA,CAAO,IAAI,IAAA,CAAKD,CAAAA,CAAqB,GAAI,CAAA,CAE/C,OAAAC,CAAAA,CAAK,UAAA,CAAW,CAAC,CAAA,CACjBA,CAAAA,CAAK,UAAA,CAAW,CAAC,CAAA,CACjBA,CAAAA,CAAK,eAAA,CAAgB,CAAC,CAAA,CACf,IAAA,CAAK,KAAA,CAAMA,CAAAA,CAAK,OAAA,CAAQ,CAAA,CAAI,GAAI,CACzC,CAWO,SAASC,CAAAA,CAAgBC,CAAAA,CAA2B,CAEzD,IAAMC,CAAAA,CAASD,CAAAA,CAAU,OAAA,CAAQ,IAAA,CAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,IAAA,CAAM,GAAG,CAAA,CAEvDE,CAAAA,CAAeD,CAAAA,CAAS,IAAA,CAAK,SAAA,CAAU,CAAA,CAAA,CAAI,CAAA,CAAKA,CAAAA,CAAO,MAAA,CAAS,CAAA,CAAA,CAAM,CAAC,CAAA,CAE7E,OADsBE,8BAAAA,CAAmB,CAE3C,CAeO,IAAMC,CAAAA,CAA0C,CAACC,CAAAA,CAAeC,CAAAA,CAAAA,EAAoBD,CAAAA,CAAQ,EAAA,EAAMC,CAAAA,CAe5FC,CAAAA,aAA0C,CAACF,CAAAA,CAAeC,CAAAA,CAAAA,EAAoBD,CAAAA,CAAQ,EAAA,EAAMC,CAAAA,CAYnGE,CAAAA,CAAcC,CAAAA,EAAgB,CAClC,IAAIC,CAAAA,CAAM,EAAA,CACV,GAAA,CAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIF,CAAAA,CAAI,MAAA,CAAQE,CAAAA,EAAK,CAAA,CACnCD,CAAAA,EAAO,MAAA,CAAO,YAAA,CAAa,QAAA,CAASD,CAAAA,CAAI,SAAA,CAAUE,CAAAA,CAAGA,CAAAA,CAAI,CAAC,CAAA,CAAG,EAAE,CAAC,CAAA,CAElE,OAAOD,CACT,CAAA,CAmBaE,CAAAA,aAAsBC,CAAAA,EAIf,CAElB,GAAM,CAAE,eAAA,CAAAC,CAAAA,CAAiB,WAAA,CAAAC,CAAAA,CAAa,WAAA,CAAAC,CAAY,CAAA,CAAIH,CAAAA,CAChDI,CAAAA,CAAaT,CAAAA,CAAWO,CAAW,CAAA,CACnCG,CAAAA,CAAaV,CAAAA,CAAWQ,CAAW,CAAA,CACzC,MAAO,CAAA,EAAA","file":"/Users/philip/Documents/General/aptos-ts-sdk/dist/common/chunk-IHUCZKG2.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { decode } from \"js-base64\";\nimport { MoveStructId } from \"../types\";\n\n/**\n * Sleep for the specified amount of time in milliseconds.\n * This function can be used to introduce delays in asynchronous operations.\n *\n * @param timeMs - The time in milliseconds to sleep.\n * @group Implementation\n * @category Utils\n */\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\n/**\n * Get the error message from an unknown error.\n *\n * @param error The error to get the message from\n * @returns The error message\n * @group Implementation\n * @category Utils\n */\nexport function getErrorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * @group Implementation\n * @category Utils\n */\nexport const nowInSeconds = () => Math.floor(Date.now() / 1000);\n\n/**\n * Floors the given timestamp to the nearest whole hour.\n * This function is useful for normalizing timestamps to hourly intervals.\n *\n * @param timestampInSeconds - The timestamp in seconds to be floored.\n * @group Implementation\n * @category Utils\n */\nexport function floorToWholeHour(timestampInSeconds: number): number {\n const date = new Date(timestampInSeconds * 1000);\n // Reset minutes and seconds to zero\n date.setMinutes(0);\n date.setSeconds(0);\n date.setMilliseconds(0);\n return Math.floor(date.getTime() / 1000);\n}\n\n/**\n * Decodes a base64 URL-encoded string into its original form.\n * This function is useful for converting base64 URL-encoded data back to a readable format.\n *\n * @param base64Url - The base64 URL-encoded string to decode.\n * @returns The decoded string.\n * @group Implementation\n * @category Utils\n */\nexport function base64UrlDecode(base64Url: string): string {\n // Replace base64url-specific characters\n const base64 = base64Url.replace(/-/g, \"+\").replace(/_/g, \"/\");\n // Pad the string with '=' characters if needed\n const paddedBase64 = base64 + \"==\".substring(0, (3 - (base64.length % 3)) % 3);\n const decodedString = decode(paddedBase64);\n return decodedString;\n}\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * a human-readable amount format to the smallest unit format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n * @group Implementation\n * @category Utils\n */\nexport const convertAmountFromHumanReadableToOnChain = (value: number, decimal: number) => value * 10 ** decimal;\n\n/**\n * Amount is represented in the smallest unit format on chain, this function converts\n * the smallest unit format to a human-readable amount format\n * @example\n * human-readable amount format: 500\n * on chain amount format when decimal is 8: 50000000000\n *\n * @param value The value in human-readable format\n * @param decimal The token decimal\n * @returns The value in the smallest units\n * @group Implementation\n * @category Utils\n */\nexport const convertAmountFromOnChainToHumanReadable = (value: number, decimal: number) => value / 10 ** decimal;\n\n/**\n * Convert a hex string to an ascii string with the `0x` prefix.\n *\n * `0x6170746f735f636f696e` --> `aptos_coin`\n *\n * @param hex The hex string to convert (e.g. `0x6170746f735f636f696e`)\n * @returns The ascii string\n * @group Implementation\n * @category Utils\n */\nconst hexToAscii = (hex: string) => {\n let str = \"\";\n for (let n = 2; n < hex.length; n += 2) {\n str += String.fromCharCode(parseInt(hex.substring(n, n + 2), 16));\n }\n return str;\n};\n\n/**\n * Convert an encoded struct to a MoveStructId.\n *\n * @example\n * const structObj = {\n * account_address: \"0x1\",\n * module_name: \"0x6170746f735f636f696e\",\n * struct_name: \"0x4170746f73436f696e\",\n * };\n * // structId is \"0x1::aptos_coin::AptosCoin\"\n * const structId = parseEncodedStruct(structObj);\n *\n * @param structObj The struct with account_address, module_name, and struct_name properties\n * @returns The MoveStructId\n * @group Implementation\n * @category Utils\n */\nexport const parseEncodedStruct = (structObj: {\n account_address: string;\n module_name: string;\n struct_name: string;\n}): MoveStructId => {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n const { account_address, module_name, struct_name } = structObj;\n const moduleName = hexToAscii(module_name);\n const structName = hexToAscii(struct_name);\n return `${account_address}::${moduleName}::${structName}`;\n};\n\n/**\n * Determines whether the given object is an encoded struct type with the following properties:\n * - account_address: string\n * - module_name: string\n * - struct_name: string\n *\n * @param structObj The object to check\n * @returns Whether the object is an encoded struct type\n * @group Implementation\n * @category Utils\n */\nexport const isEncodedStruct = (\n structObj: any,\n): structObj is {\n account_address: string;\n module_name: string;\n struct_name: string;\n} =>\n typeof structObj === \"object\" &&\n !Array.isArray(structObj) &&\n structObj !== null &&\n \"account_address\" in structObj &&\n \"module_name\" in structObj &&\n \"struct_name\" in structObj &&\n typeof structObj.account_address === \"string\" &&\n typeof structObj.module_name === \"string\" &&\n typeof structObj.struct_name === \"string\";\n"]}
|