@aptos-labs/ts-sdk 1.33.2 → 1.35.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 +15 -9
- package/dist/common/{accountAddress-Cf1amU98.d.ts → accountAddress-CuHovHdK.d.ts} +22 -2
- package/dist/common/chunk-RX5UBAME.js +4 -0
- package/dist/common/chunk-RX5UBAME.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 +3139 -2533
- package/dist/common/index.js +33 -35
- 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 +2 -1
- 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 +3 -2
- 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/MultiEd25519Account.d.mts +108 -0
- package/dist/esm/account/MultiEd25519Account.mjs +2 -0
- package/dist/esm/account/MultiKeyAccount.d.mts +2 -2
- 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 +4 -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 +4 -1
- 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 +6 -1
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -0
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +3 -2
- 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/experimental.d.mts +83 -0
- package/dist/esm/api/experimental.mjs +2 -0
- package/dist/esm/api/experimental.mjs.map +1 -0
- 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 +4 -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/deserializer.mjs +1 -1
- 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/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -0
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- 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/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-7IY3DTEF.mjs → chunk-27ESCVVC.mjs} +2 -2
- package/dist/esm/chunk-2SAYQUUX.mjs +2 -0
- package/dist/esm/chunk-2SAYQUUX.mjs.map +1 -0
- package/dist/esm/{chunk-VUIHJIMX.mjs → chunk-2TRQERBL.mjs} +2 -2
- package/dist/esm/chunk-2V636AYW.mjs +2 -0
- package/dist/esm/{chunk-XTJOA5QN.mjs → chunk-2YKERRHD.mjs} +2 -2
- package/dist/esm/chunk-2ZLFQBT2.mjs +2 -0
- package/dist/esm/chunk-2ZLFQBT2.mjs.map +1 -0
- package/dist/esm/{chunk-5YWH3XPN.mjs → chunk-3LDVJ2YK.mjs} +2 -2
- package/dist/esm/chunk-3OLFJ65O.mjs +2 -0
- package/dist/esm/chunk-3OLFJ65O.mjs.map +1 -0
- package/dist/esm/{chunk-ONTWK5FU.mjs → chunk-44EHAKKW.mjs} +2 -2
- package/dist/esm/{chunk-OEQ2U7GK.mjs → chunk-53IBOHXB.mjs} +2 -2
- package/dist/esm/{chunk-YCQUYDZI.mjs → chunk-5H5D6QVX.mjs} +2 -2
- package/dist/esm/{chunk-G4O6FXCF.mjs → chunk-5W2ERBGY.mjs} +2 -2
- package/dist/esm/{chunk-NYETBDSR.mjs → chunk-67A5U2X6.mjs} +2 -2
- package/dist/esm/{chunk-AXYARCYT.mjs → chunk-6IJZRG3U.mjs} +2 -2
- package/dist/esm/{chunk-N4DM5FYH.mjs → chunk-6KZT3KFZ.mjs} +2 -2
- package/dist/esm/chunk-752TOOCA.mjs +2 -0
- package/dist/esm/chunk-752TOOCA.mjs.map +1 -0
- package/dist/esm/{chunk-2WCATZVL.mjs → chunk-7A2KHJ3D.mjs} +2 -2
- package/dist/esm/{chunk-ROT6S6BM.mjs → chunk-7CRQNXR5.mjs} +2 -2
- package/dist/esm/{chunk-FZD5RWSZ.mjs → chunk-7OUPEQRN.mjs} +2 -2
- package/dist/esm/chunk-A3VO773Q.mjs +2 -0
- package/dist/esm/{chunk-OHZURQPY.mjs → chunk-AEGA5N2W.mjs} +2 -2
- package/dist/esm/{chunk-BI3BTSUB.mjs → chunk-AIPHJFJL.mjs} +2 -2
- package/dist/esm/chunk-AQWKKSRN.mjs +2 -0
- package/dist/esm/chunk-AQWKKSRN.mjs.map +1 -0
- package/dist/esm/{chunk-4EUS4E6S.mjs → chunk-B23VO5TB.mjs} +2 -2
- package/dist/esm/chunk-BHVSIRNF.mjs +2 -0
- package/dist/esm/chunk-BHVSIRNF.mjs.map +1 -0
- package/dist/esm/chunk-BMPHQ3E7.mjs +2 -0
- package/dist/esm/chunk-BPHCRTHD.mjs +2 -0
- package/dist/esm/chunk-BPHCRTHD.mjs.map +1 -0
- package/dist/esm/{chunk-DYATTONT.mjs → chunk-BQYKFATL.mjs} +2 -2
- package/dist/esm/chunk-BY3XFRUM.mjs +2 -0
- package/dist/esm/{chunk-77AEKF7K.mjs.map → chunk-BY3XFRUM.mjs.map} +1 -1
- package/dist/esm/chunk-CGTMSLVZ.mjs +2 -0
- package/dist/esm/chunk-CGTMSLVZ.mjs.map +1 -0
- package/dist/esm/{chunk-QQEK7WVP.mjs → chunk-CPAAEEF4.mjs} +2 -2
- package/dist/esm/{chunk-ZAIVZDOL.mjs → chunk-CPFQUFVD.mjs} +2 -2
- package/dist/esm/chunk-CXLNTATW.mjs +2 -0
- package/dist/esm/chunk-CXLNTATW.mjs.map +1 -0
- package/dist/esm/{chunk-ZPV7HPA4.mjs → chunk-DAJFOJ3L.mjs} +2 -2
- package/dist/esm/chunk-DOVH6HPL.mjs +2 -0
- package/dist/esm/{chunk-KOORZTHC.mjs → chunk-E5PAUR4N.mjs} +2 -2
- package/dist/esm/{chunk-E7JDVKFY.mjs → chunk-EGCL6KA6.mjs} +2 -2
- package/dist/esm/{chunk-TOBQ5UE6.mjs → chunk-ERLDXTIY.mjs} +2 -2
- package/dist/esm/chunk-FJ5J7CVW.mjs +2 -0
- package/dist/esm/chunk-FJ5J7CVW.mjs.map +1 -0
- package/dist/esm/{chunk-X6UNY6YM.mjs → chunk-FOEPRHAC.mjs} +2 -2
- package/dist/esm/{chunk-XYB6KYKW.mjs → chunk-G5F5ZOH5.mjs} +2 -2
- package/dist/esm/chunk-GFPEB22G.mjs +1 -0
- package/dist/esm/chunk-GFPEB22G.mjs.map +1 -0
- package/dist/esm/{chunk-AZWVCBK2.mjs → chunk-GI4AR6DQ.mjs} +2 -2
- package/dist/esm/{chunk-3RCAJICY.mjs → chunk-GRRBXHVG.mjs} +2 -2
- package/dist/esm/{chunk-5EYTHMRZ.mjs → chunk-GTVMJJQQ.mjs} +2 -2
- package/dist/esm/{chunk-2TJ6OTVD.mjs → chunk-GU4MD5ST.mjs} +2 -2
- package/dist/esm/chunk-H4YAL2IL.mjs +2 -0
- package/dist/esm/{chunk-ZGVNZE7J.mjs → chunk-HBTJN4RJ.mjs} +2 -2
- package/dist/esm/{chunk-IDTLNF4M.mjs → chunk-HHWJHOFZ.mjs} +2 -2
- package/dist/esm/{chunk-XZ4JRYCE.mjs → chunk-HKL4MFNL.mjs} +2 -2
- package/dist/esm/{chunk-IEUEMBFD.mjs → chunk-HVIF6DW6.mjs} +2 -2
- package/dist/esm/{chunk-MWBRD43V.mjs → chunk-HYJQHVDZ.mjs} +2 -2
- package/dist/esm/chunk-HYJQHVDZ.mjs.map +1 -0
- package/dist/esm/{chunk-JJM6ELMS.mjs → chunk-ILUFGYLO.mjs} +2 -2
- package/dist/esm/chunk-IMTC3J2M.mjs +2 -0
- package/dist/esm/chunk-IMTC3J2M.mjs.map +1 -0
- package/dist/esm/chunk-IMYNN4TW.mjs +2 -0
- package/dist/esm/chunk-IMYNN4TW.mjs.map +1 -0
- package/dist/esm/{chunk-DOQV5BSA.mjs → chunk-IOHESHLR.mjs} +2 -2
- package/dist/esm/{chunk-NBNZ53ZV.mjs → chunk-JNNFNYDO.mjs} +2 -2
- package/dist/esm/{chunk-2UXW3EB7.mjs → chunk-K233I26C.mjs} +2 -2
- package/dist/esm/{chunk-VV4HCOJQ.mjs → chunk-KK5HUWF6.mjs} +2 -2
- package/dist/esm/chunk-KSLLV3ZC.mjs +2 -0
- package/dist/esm/chunk-KSLLV3ZC.mjs.map +1 -0
- package/dist/esm/{chunk-67ZVDKJF.mjs → chunk-L6KVC7CJ.mjs} +2 -2
- package/dist/esm/{chunk-Q4C4U6I4.mjs → chunk-LQOSHBB7.mjs} +2 -2
- package/dist/esm/{chunk-XKUIMGKU.mjs → chunk-LS3IDL2N.mjs} +2 -2
- package/dist/esm/{chunk-2N5KYALM.mjs → chunk-MAWGZICD.mjs} +2 -2
- package/dist/esm/{chunk-S7RZGC56.mjs → chunk-MFLHAVIW.mjs} +2 -2
- package/dist/esm/chunk-OLGEN23M.mjs +2 -0
- package/dist/esm/chunk-OLGEN23M.mjs.map +1 -0
- package/dist/esm/{chunk-MCLYDS3O.mjs → chunk-ONGH5DXZ.mjs} +2 -2
- package/dist/esm/chunk-OPD5EKOA.mjs +2 -0
- package/dist/esm/chunk-OPD5EKOA.mjs.map +1 -0
- package/dist/esm/{chunk-4ZYPDCSP.mjs → chunk-P5CM4C2G.mjs} +2 -2
- package/dist/esm/chunk-PC25RPDV.mjs +2 -0
- package/dist/esm/chunk-PC25RPDV.mjs.map +1 -0
- package/dist/esm/{chunk-N6YTF76Q.mjs → chunk-PDAWVDI7.mjs} +2 -2
- package/dist/esm/chunk-PIPDQFL2.mjs +2 -0
- package/dist/esm/chunk-PIPDQFL2.mjs.map +1 -0
- package/dist/esm/{chunk-43GCGE6C.mjs → chunk-PWGTRRSJ.mjs} +2 -2
- package/dist/esm/{chunk-P7A5RILV.mjs → chunk-PYY2RXFP.mjs} +2 -2
- package/dist/esm/chunk-PYY2RXFP.mjs.map +1 -0
- package/dist/esm/chunk-QUJM5W4L.mjs +2 -0
- package/dist/esm/chunk-QUJM5W4L.mjs.map +1 -0
- package/dist/esm/{chunk-2FBJWTJD.mjs → chunk-QYJKCRVA.mjs} +2 -2
- package/dist/esm/chunk-R6QCPXQG.mjs +2 -0
- package/dist/esm/chunk-R6QCPXQG.mjs.map +1 -0
- package/dist/esm/{chunk-6YHDZLRN.mjs → chunk-RDPWCN4B.mjs} +2 -2
- package/dist/esm/{chunk-MT2RJ7H3.mjs → chunk-RIINVEZA.mjs} +2 -2
- package/dist/esm/{chunk-EBMEXURY.mjs → chunk-RXHER6EA.mjs} +2 -2
- package/dist/esm/chunk-SJDHW55X.mjs +2 -0
- package/dist/esm/chunk-SJDHW55X.mjs.map +1 -0
- package/dist/esm/{chunk-UC23V7PU.mjs → chunk-T7X4GZDU.mjs} +2 -2
- package/dist/esm/{chunk-QHEKBHNU.mjs → chunk-TH5JCPN2.mjs} +2 -2
- package/dist/esm/{chunk-ORMOQWWH.mjs → chunk-TKXEVD7A.mjs} +2 -2
- package/dist/esm/{chunk-FN4C3CKC.mjs → chunk-TTY5GFMN.mjs} +2 -2
- package/dist/esm/chunk-TWETGZ3W.mjs +2 -0
- package/dist/esm/chunk-TWETGZ3W.mjs.map +1 -0
- package/dist/esm/{chunk-E5HGSOG2.mjs → chunk-U4DEYWFT.mjs} +2 -2
- package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
- package/dist/esm/chunk-UIRAXHDH.mjs.map +1 -0
- package/dist/esm/{chunk-OROPNHRY.mjs → chunk-UJJGIPOA.mjs} +2 -2
- package/dist/esm/{chunk-CWKNJZB6.mjs → chunk-US2HZFOM.mjs} +2 -2
- package/dist/esm/{chunk-XY43TPRH.mjs → chunk-VDYUMBOT.mjs} +2 -2
- package/dist/esm/chunk-VHY6ZATX.mjs +2 -0
- package/dist/esm/chunk-VHY6ZATX.mjs.map +1 -0
- package/dist/esm/chunk-VWZEJTGP.mjs +4 -0
- package/dist/esm/chunk-VWZEJTGP.mjs.map +1 -0
- package/dist/esm/{chunk-WUWPN7XV.mjs → chunk-W2C5KRUQ.mjs} +2 -2
- package/dist/esm/{chunk-OR6GFWLG.mjs → chunk-W4SMZ6IW.mjs} +2 -2
- package/dist/esm/chunk-WFKPVKU3.mjs +2 -0
- package/dist/esm/chunk-WFKPVKU3.mjs.map +1 -0
- package/dist/esm/{chunk-5VMAJTTV.mjs → chunk-WHVCUVZP.mjs} +2 -2
- package/dist/esm/{chunk-WQRGDSPD.mjs → chunk-WLDYBSOG.mjs} +2 -2
- package/dist/esm/chunk-XRVZAEQO.mjs +2 -0
- package/dist/esm/chunk-XRVZAEQO.mjs.map +1 -0
- package/dist/esm/chunk-XSBUL2WP.mjs +2 -0
- package/dist/esm/chunk-XSBUL2WP.mjs.map +1 -0
- package/dist/esm/{chunk-BGSEBFFC.mjs → chunk-XW3BXTCZ.mjs} +2 -2
- package/dist/esm/{chunk-6CXMDJQR.mjs → chunk-Y65PKZLK.mjs} +2 -2
- package/dist/esm/{chunk-NWLJ6RW7.mjs → chunk-YAGIE4GN.mjs} +2 -2
- package/dist/esm/{chunk-M77M6NSB.mjs → chunk-YLUULY6G.mjs} +2 -2
- package/dist/esm/{chunk-5EBUWO2M.mjs → chunk-YWSDONJJ.mjs} +2 -2
- package/dist/esm/{chunk-V6VPMNWJ.mjs → chunk-YXYYII5S.mjs} +2 -2
- package/dist/esm/{chunk-XTOIL6MB.mjs → chunk-ZD2TY5N3.mjs} +2 -2
- package/dist/esm/{chunk-FIEMUPXF.mjs → chunk-ZS2IVRHT.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 +37 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +36 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +4 -3
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +35 -1
- 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 +2 -1
- 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 +18 -2
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +34 -15
- 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/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +1 -0
- package/dist/esm/core/hex.mjs +1 -1
- package/dist/esm/core/index.d.mts +2 -1
- 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 +16 -9
- 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/experimental.d.mts +52 -0
- package/dist/esm/internal/experimental.mjs +2 -0
- package/dist/esm/internal/experimental.mjs.map +1 -0
- 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/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +1 -0
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- 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 +1 -0
- 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 +22 -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 +21 -19
- package/src/account/AbstractedAccount.ts +111 -0
- package/src/account/MultiEd25519Account.ts +154 -0
- package/src/account/MultiKeyAccount.ts +1 -2
- package/src/account/index.ts +2 -0
- package/src/api/account/abstraction.ts +239 -0
- package/src/api/account.ts +7 -2
- package/src/api/aptos.ts +9 -0
- package/src/api/aptosConfig.ts +2 -2
- package/src/api/experimental.ts +64 -0
- package/src/api/transactionSubmission/build.ts +85 -2
- package/src/client/core.ts +120 -0
- package/src/client/get.ts +73 -1
- package/src/client/post.ts +70 -1
- package/src/core/crypto/abstraction.ts +47 -0
- package/src/core/crypto/multiEd25519.ts +19 -3
- package/src/core/crypto/multiKey.ts +76 -52
- package/src/core/hex.ts +3 -1
- package/src/internal/abstraction.ts +79 -0
- package/src/internal/experimental.ts +55 -0
- package/src/internal/view.ts +4 -4
- 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 +9 -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 +21 -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-4YLUM62M.mjs +0 -2
- package/dist/esm/chunk-5PXDPMF2.mjs +0 -4
- package/dist/esm/chunk-5PXDPMF2.mjs.map +0 -1
- package/dist/esm/chunk-6IEZPA4H.mjs +0 -2
- package/dist/esm/chunk-6IEZPA4H.mjs.map +0 -1
- package/dist/esm/chunk-6YWYAVFS.mjs +0 -2
- package/dist/esm/chunk-6YWYAVFS.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-DPW6ELCQ.mjs +0 -2
- package/dist/esm/chunk-EMURYYVO.mjs +0 -2
- package/dist/esm/chunk-F2ZTBAJJ.mjs +0 -2
- package/dist/esm/chunk-F2ZTBAJJ.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-MWBRD43V.mjs.map +0 -1
- package/dist/esm/chunk-OSBRPVVI.mjs +0 -2
- package/dist/esm/chunk-OSBRPVVI.mjs.map +0 -1
- package/dist/esm/chunk-P7A5RILV.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-S4LZMY2L.mjs +0 -2
- package/dist/esm/chunk-S4LZMY2L.mjs.map +0 -1
- package/dist/esm/chunk-STY74NUA.mjs +0 -2
- package/dist/esm/chunk-STY74NUA.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-VVXBVJXD.mjs +0 -2
- package/dist/esm/chunk-VVXBVJXD.mjs.map +0 -1
- package/dist/esm/chunk-WCMW2L3P.mjs +0 -2
- package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
- /package/dist/esm/{chunk-FD6FGKYY.mjs.map → account/AbstractedAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-GP4TLDVZ.mjs.map → account/MultiEd25519Account.mjs.map} +0 -0
- /package/dist/esm/{chunk-I5OYNCZS.mjs.map → api/account/abstraction.mjs.map} +0 -0
- /package/dist/esm/{chunk-7IY3DTEF.mjs.map → chunk-27ESCVVC.mjs.map} +0 -0
- /package/dist/esm/{chunk-VUIHJIMX.mjs.map → chunk-2TRQERBL.mjs.map} +0 -0
- /package/dist/esm/{chunk-XJJVJOX5.mjs.map → chunk-2V636AYW.mjs.map} +0 -0
- /package/dist/esm/{chunk-XTJOA5QN.mjs.map → chunk-2YKERRHD.mjs.map} +0 -0
- /package/dist/esm/{chunk-5YWH3XPN.mjs.map → chunk-3LDVJ2YK.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONTWK5FU.mjs.map → chunk-44EHAKKW.mjs.map} +0 -0
- /package/dist/esm/{chunk-OEQ2U7GK.mjs.map → chunk-53IBOHXB.mjs.map} +0 -0
- /package/dist/esm/{chunk-YCQUYDZI.mjs.map → chunk-5H5D6QVX.mjs.map} +0 -0
- /package/dist/esm/{chunk-G4O6FXCF.mjs.map → chunk-5W2ERBGY.mjs.map} +0 -0
- /package/dist/esm/{chunk-NYETBDSR.mjs.map → chunk-67A5U2X6.mjs.map} +0 -0
- /package/dist/esm/{chunk-AXYARCYT.mjs.map → chunk-6IJZRG3U.mjs.map} +0 -0
- /package/dist/esm/{chunk-N4DM5FYH.mjs.map → chunk-6KZT3KFZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2WCATZVL.mjs.map → chunk-7A2KHJ3D.mjs.map} +0 -0
- /package/dist/esm/{chunk-ROT6S6BM.mjs.map → chunk-7CRQNXR5.mjs.map} +0 -0
- /package/dist/esm/{chunk-FZD5RWSZ.mjs.map → chunk-7OUPEQRN.mjs.map} +0 -0
- /package/dist/esm/{chunk-WCMW2L3P.mjs.map → chunk-A3VO773Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-OHZURQPY.mjs.map → chunk-AEGA5N2W.mjs.map} +0 -0
- /package/dist/esm/{chunk-BI3BTSUB.mjs.map → chunk-AIPHJFJL.mjs.map} +0 -0
- /package/dist/esm/{chunk-4EUS4E6S.mjs.map → chunk-B23VO5TB.mjs.map} +0 -0
- /package/dist/esm/{chunk-4YLUM62M.mjs.map → chunk-BMPHQ3E7.mjs.map} +0 -0
- /package/dist/esm/{chunk-DYATTONT.mjs.map → chunk-BQYKFATL.mjs.map} +0 -0
- /package/dist/esm/{chunk-QQEK7WVP.mjs.map → chunk-CPAAEEF4.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZAIVZDOL.mjs.map → chunk-CPFQUFVD.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPV7HPA4.mjs.map → chunk-DAJFOJ3L.mjs.map} +0 -0
- /package/dist/esm/{chunk-DPW6ELCQ.mjs.map → chunk-DOVH6HPL.mjs.map} +0 -0
- /package/dist/esm/{chunk-KOORZTHC.mjs.map → chunk-E5PAUR4N.mjs.map} +0 -0
- /package/dist/esm/{chunk-E7JDVKFY.mjs.map → chunk-EGCL6KA6.mjs.map} +0 -0
- /package/dist/esm/{chunk-TOBQ5UE6.mjs.map → chunk-ERLDXTIY.mjs.map} +0 -0
- /package/dist/esm/{chunk-X6UNY6YM.mjs.map → chunk-FOEPRHAC.mjs.map} +0 -0
- /package/dist/esm/{chunk-XYB6KYKW.mjs.map → chunk-G5F5ZOH5.mjs.map} +0 -0
- /package/dist/esm/{chunk-AZWVCBK2.mjs.map → chunk-GI4AR6DQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-3RCAJICY.mjs.map → chunk-GRRBXHVG.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EYTHMRZ.mjs.map → chunk-GTVMJJQQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2TJ6OTVD.mjs.map → chunk-GU4MD5ST.mjs.map} +0 -0
- /package/dist/esm/{chunk-EMURYYVO.mjs.map → chunk-H4YAL2IL.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZGVNZE7J.mjs.map → chunk-HBTJN4RJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-IDTLNF4M.mjs.map → chunk-HHWJHOFZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-XZ4JRYCE.mjs.map → chunk-HKL4MFNL.mjs.map} +0 -0
- /package/dist/esm/{chunk-IEUEMBFD.mjs.map → chunk-HVIF6DW6.mjs.map} +0 -0
- /package/dist/esm/{chunk-JJM6ELMS.mjs.map → chunk-ILUFGYLO.mjs.map} +0 -0
- /package/dist/esm/{chunk-DOQV5BSA.mjs.map → chunk-IOHESHLR.mjs.map} +0 -0
- /package/dist/esm/{chunk-NBNZ53ZV.mjs.map → chunk-JNNFNYDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-2UXW3EB7.mjs.map → chunk-K233I26C.mjs.map} +0 -0
- /package/dist/esm/{chunk-VV4HCOJQ.mjs.map → chunk-KK5HUWF6.mjs.map} +0 -0
- /package/dist/esm/{chunk-67ZVDKJF.mjs.map → chunk-L6KVC7CJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q4C4U6I4.mjs.map → chunk-LQOSHBB7.mjs.map} +0 -0
- /package/dist/esm/{chunk-XKUIMGKU.mjs.map → chunk-LS3IDL2N.mjs.map} +0 -0
- /package/dist/esm/{chunk-2N5KYALM.mjs.map → chunk-MAWGZICD.mjs.map} +0 -0
- /package/dist/esm/{chunk-S7RZGC56.mjs.map → chunk-MFLHAVIW.mjs.map} +0 -0
- /package/dist/esm/{chunk-MCLYDS3O.mjs.map → chunk-ONGH5DXZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ZYPDCSP.mjs.map → chunk-P5CM4C2G.mjs.map} +0 -0
- /package/dist/esm/{chunk-N6YTF76Q.mjs.map → chunk-PDAWVDI7.mjs.map} +0 -0
- /package/dist/esm/{chunk-43GCGE6C.mjs.map → chunk-PWGTRRSJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2FBJWTJD.mjs.map → chunk-QYJKCRVA.mjs.map} +0 -0
- /package/dist/esm/{chunk-6YHDZLRN.mjs.map → chunk-RDPWCN4B.mjs.map} +0 -0
- /package/dist/esm/{chunk-MT2RJ7H3.mjs.map → chunk-RIINVEZA.mjs.map} +0 -0
- /package/dist/esm/{chunk-EBMEXURY.mjs.map → chunk-RXHER6EA.mjs.map} +0 -0
- /package/dist/esm/{chunk-UC23V7PU.mjs.map → chunk-T7X4GZDU.mjs.map} +0 -0
- /package/dist/esm/{chunk-QHEKBHNU.mjs.map → chunk-TH5JCPN2.mjs.map} +0 -0
- /package/dist/esm/{chunk-ORMOQWWH.mjs.map → chunk-TKXEVD7A.mjs.map} +0 -0
- /package/dist/esm/{chunk-FN4C3CKC.mjs.map → chunk-TTY5GFMN.mjs.map} +0 -0
- /package/dist/esm/{chunk-E5HGSOG2.mjs.map → chunk-U4DEYWFT.mjs.map} +0 -0
- /package/dist/esm/{chunk-OROPNHRY.mjs.map → chunk-UJJGIPOA.mjs.map} +0 -0
- /package/dist/esm/{chunk-CWKNJZB6.mjs.map → chunk-US2HZFOM.mjs.map} +0 -0
- /package/dist/esm/{chunk-XY43TPRH.mjs.map → chunk-VDYUMBOT.mjs.map} +0 -0
- /package/dist/esm/{chunk-WUWPN7XV.mjs.map → chunk-W2C5KRUQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-OR6GFWLG.mjs.map → chunk-W4SMZ6IW.mjs.map} +0 -0
- /package/dist/esm/{chunk-5VMAJTTV.mjs.map → chunk-WHVCUVZP.mjs.map} +0 -0
- /package/dist/esm/{chunk-WQRGDSPD.mjs.map → chunk-WLDYBSOG.mjs.map} +0 -0
- /package/dist/esm/{chunk-BGSEBFFC.mjs.map → chunk-XW3BXTCZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-6CXMDJQR.mjs.map → chunk-Y65PKZLK.mjs.map} +0 -0
- /package/dist/esm/{chunk-NWLJ6RW7.mjs.map → chunk-YAGIE4GN.mjs.map} +0 -0
- /package/dist/esm/{chunk-M77M6NSB.mjs.map → chunk-YLUULY6G.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EBUWO2M.mjs.map → chunk-YWSDONJJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-V6VPMNWJ.mjs.map → chunk-YXYYII5S.mjs.map} +0 -0
- /package/dist/esm/{chunk-XTOIL6MB.mjs.map → chunk-ZD2TY5N3.mjs.map} +0 -0
- /package/dist/esm/{chunk-FIEMUPXF.mjs.map → chunk-ZS2IVRHT.mjs.map} +0 -0
package/dist/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/philip/Documents/General/aptos-ts-sdk/dist/common/index.js","../../src/bcs/consts.ts","../../src/core/hex.ts","../../src/core/common.ts","../../src/core/accountAddress.ts","../../src/core/authenticationKey.ts","../../src/errors/index.ts","../../src/types/generated/queries.ts","../../src/internal/general.ts","../../src/api/account.ts"],"names":["MAX_U8_NUMBER","MAX_U16_NUMBER","MAX_U32_NUMBER","MAX_U64_BIG_INT","MAX_U128_BIG_INT","MAX_U256_BIG_INT","ParsingError","message","invalidReason","HexInvalidReason","Hex","_Hex","data","bytesToHex","_AuthenticationKey"],"mappings":"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","file":"/Users/philip/Documents/General/aptos-ts-sdk/dist/common/index.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256 } from \"../types\";\n\n// Upper bound values for uint8, uint16, uint64 etc. These are all derived as\n// 2^N - 1, where N is the number of bits in the type.\nexport const MAX_U8_NUMBER: Uint8 = 255;\nexport const MAX_U16_NUMBER: Uint16 = 65535;\nexport const MAX_U32_NUMBER: Uint32 = 4294967295;\nexport const MAX_U64_BIG_INT: Uint64 = 18446744073709551615n;\nexport const MAX_U128_BIG_INT: Uint128 = 340282366920938463463374607431768211455n;\nexport const MAX_U256_BIG_INT: Uint256 =\n 115792089237316195423570985008687907853269984665640564039457584007913129639935n;\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { HexInput } from \"../types\";\n\n/**\n * Provides reasons for parsing failures related to hexadecimal values.\n * @group Implementation\n * @category Serialization\n */\nexport enum HexInvalidReason {\n TOO_SHORT = \"too_short\",\n INVALID_LENGTH = \"invalid_length\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n}\n\n/**\n * NOTE: Do not use this class when working with account addresses; use AccountAddress instead.\n * When accepting hex data as input to a function, prefer to accept HexInput and\n *\n * A helper class for working with hex data. Hex data, when represented as a string,\n * generally looks like this, for example: 0xaabbcc, 45cd32, etc.\n *\n * then use the static helper methods of this class to convert it into the desired\n * format. This enables the greatest flexibility for the developer.\n *\n * Example usage:\n * ```typescript\n * getTransactionByHash(txnHash: HexInput): Promise<Transaction> {\n * const txnHashString = Hex.fromHexInput(txnHash).toString();\n * return await getTransactionByHashInner(txnHashString);\n * }\n * ```\n * This call to `Hex.fromHexInput().toString()` converts the HexInput to a hex string\n * with a leading 0x prefix, regardless of what the input format was.\n *\n * Other ways to chain the functions together:\n * - `Hex.fromHexString({ hexInput: \"0x1f\" }).toUint8Array()`\n * - `new Hex([1, 3]).toStringWithoutPrefix()`\n * @group Implementation\n * @category Serialization\n */\nexport class Hex {\n private readonly data: Uint8Array;\n\n /**\n * Create a new Hex instance from a Uint8Array.\n *\n * @param data - The Uint8Array containing the data to initialize the Hex instance.\n * @group Implementation\n * @category Serialization\n */\n constructor(data: Uint8Array) {\n this.data = data;\n }\n\n // ===\n // Methods for representing an instance of Hex as other types.\n // ===\n\n /**\n * Get the inner hex data as a Uint8Array. The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Get the hex data as a string without the 0x prefix.\n *\n * @returns Hex string without 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the hex data as a string with the 0x prefix.\n *\n * @returns Hex string with 0x prefix\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n // ===\n // Methods for creating an instance of Hex from other types.\n // ===\n\n /**\n * Converts a hex string into a Hex instance, allowing for both prefixed and non-prefixed formats.\n *\n * @param str - A hex string, with or without the 0x prefix.\n *\n * @throws ParsingError - If the hex string is too short, has an odd number of characters, or contains invalid hex characters.\n *\n * @returns Hex - The resulting Hex instance created from the provided string.\n * @group Implementation\n * @category Serialization\n */\n static fromHexString(str: string): Hex {\n let input = str;\n\n if (input.startsWith(\"0x\")) {\n input = input.slice(2);\n }\n\n if (input.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.\",\n HexInvalidReason.TOO_SHORT,\n );\n }\n\n if (input.length % 2 !== 0) {\n throw new ParsingError(\"Hex string must be an even number of hex characters.\", HexInvalidReason.INVALID_LENGTH);\n }\n\n try {\n return new Hex(hexToBytes(input));\n } catch (error: any) {\n throw new ParsingError(\n `Hex string contains invalid hex characters: ${error?.message}`,\n HexInvalidReason.INVALID_HEX_CHARS,\n );\n }\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance.\n * This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Hex instance created from the provided hexInput.\n * @group Implementation\n * @category Serialization\n */\n static fromHexInput(hexInput: HexInput): Hex {\n if (hexInput instanceof Uint8Array) return new Hex(hexInput);\n return Hex.fromHexString(hexInput);\n }\n\n /**\n * Converts an instance of HexInput, which can be a string or a Uint8Array, into a Uint8Array.\n *\n * @param hexInput - A HexInput which can be a string or Uint8Array.\n * @returns A Uint8Array created from the provided hexInput.\n */\n static hexInputToUint8Array(hexInput: HexInput): Uint8Array {\n if (hexInput instanceof Uint8Array) return hexInput;\n return Hex.fromHexString(hexInput).toUint8Array();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string with '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string with '0x' prefix (e.g., \"0x1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToString(\"1234\") // returns \"0x1234\"\n * Hex.hexInputToString(\"0x1234\") // returns \"0x1234\"\n * Hex.hexInputToString(new Uint8Array([0x12, 0x34])) // returns \"0x1234\"\n * ```\n */\n static hexInputToString(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toString();\n }\n\n /**\n * Converts a HexInput (string or Uint8Array) to a hex string without '0x' prefix.\n *\n * @param hexInput - The input to convert, either a hex string (with/without '0x' prefix) or Uint8Array\n * @returns A hex string without '0x' prefix (e.g., \"1234\")\n *\n * @example\n * ```typescript\n * Hex.hexInputToStringWithoutPrefix(\"1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(\"0x1234\") // returns \"1234\"\n * Hex.hexInputToStringWithoutPrefix(new Uint8Array([0x12, 0x34])) // returns \"1234\"\n * ```\n */\n static hexInputToStringWithoutPrefix(hexInput: HexInput): string {\n return Hex.fromHexInput(hexInput).toStringWithoutPrefix();\n }\n\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided string is a valid hexadecimal representation.\n *\n * @param str - A hex string representing byte data.\n *\n * @returns An object containing:\n * - valid: A boolean indicating whether the string is valid.\n * - invalidReason: The reason for invalidity if the string is not valid.\n * - invalidReasonMessage: A message explaining why the string is invalid.\n * @group Implementation\n * @category Serialization\n */\n static isValid(str: string): ParsingResult<HexInvalidReason> {\n try {\n Hex.fromHexString(str);\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two Hex instances are equal by comparing their underlying byte data.\n *\n * @param other The Hex instance to compare to.\n * @returns true if the Hex instances are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: Hex): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n\nexport const hexToAsciiString = (hex: string) => new TextDecoder().decode(Hex.fromHexInput(hex).toUint8Array());\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This error is used to explain why parsing failed.\n * @group Implementation\n * @category Serialization\n */\nexport class ParsingError<T> extends Error {\n /**\n * This provides a programmatic way to access why parsing failed. Downstream devs\n * might want to use this to build their own error messages if the default error\n * messages are not suitable for their use case. This should be an enum.\n * @group Implementation\n * @category Serialization\n */\n public invalidReason: T;\n\n /**\n * Creates an instance of the error with a specified message and invalid reason.\n *\n * @param message The error message that describes the issue.\n * @param invalidReason The reason why the input is considered invalid.\n * @group Implementation\n * @category Serialization\n */\n constructor(message: string, invalidReason: T) {\n super(message);\n this.invalidReason = invalidReason;\n }\n}\n\n/**\n * Whereas ParsingError is thrown when parsing fails, e.g. in a fromString function,\n * this type is returned from \"defensive\" functions like isValid.\n * @group Implementation\n * @category Serialization\n */\nexport type ParsingResult<T> = {\n /**\n * True if valid, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n valid: boolean;\n\n /**\n * If valid is false, this will be a code explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReason?: T;\n\n /**\n * If valid is false, this will be a string explaining why parsing failed.\n * @group Implementation\n * @category Serialization\n */\n invalidReasonMessage?: string;\n};\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\nimport { ParsingError, ParsingResult } from \"./common\";\nimport { TransactionArgument } from \"../transactions/instances/transactionArgument\";\nimport { HexInput, ScriptTransactionArgumentVariants } from \"../types\";\n\n/**\n * Provides reasons for an address was invalid.\n * @group Implementation\n * @category Serialization\n */\nexport enum AddressInvalidReason {\n INCORRECT_NUMBER_OF_BYTES = \"incorrect_number_of_bytes\",\n INVALID_HEX_CHARS = \"invalid_hex_chars\",\n TOO_SHORT = \"too_short\",\n TOO_LONG = \"too_long\",\n LEADING_ZERO_X_REQUIRED = \"leading_zero_x_required\",\n LONG_FORM_REQUIRED_UNLESS_SPECIAL = \"long_form_required_unless_special\",\n INVALID_PADDING_ZEROES = \"INVALID_PADDING_ZEROES\",\n INVALID_PADDING_STRICTNESS = \"INVALID_PADDING_STRICTNESS\",\n}\n\n/**\n * The input for an account address, which can be either a hexadecimal string or a standard account address.\n * @group Implementation\n * @category Serialization\n */\nexport type AccountAddressInput = HexInput | AccountAddress;\n\n/**\n * NOTE: Only use this class for account addresses. For other hex data, e.g. transaction\n * hashes, use the Hex class.\n *\n * AccountAddress is used for working with account addresses. Account addresses, when\n * represented as a string, generally look like these examples:\n * - 0x1\n * - 0xaa86fe99004361f747f91342ca13c426ca0cccb0c1217677180c9493bad6ef0c\n *\n * Proper formatting and parsing of account addresses is defined by AIP-40.\n * To learn more about the standard, read the AIP here:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * The comments in this class make frequent reference to the LONG and SHORT formats,\n * as well as \"special\" addresses. To learn what these refer to see AIP-40.\n * @group Implementation\n * @category Serialization\n */\nexport class AccountAddress extends Serializable implements TransactionArgument {\n /**\n * This is the internal representation of an account address.\n * @group Implementation\n * @category Serialization\n */\n readonly data: Uint8Array;\n\n /**\n * The number of bytes that make up an account address.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The length of an address string in LONG form without a leading 0x.\n * @group Implementation\n * @category Serialization\n */\n static readonly LONG_STRING_LENGTH: number = 64;\n\n static ZERO: AccountAddress = AccountAddress.from(\"0x0\");\n\n static ONE: AccountAddress = AccountAddress.from(\"0x1\");\n\n static TWO: AccountAddress = AccountAddress.from(\"0x2\");\n\n static THREE: AccountAddress = AccountAddress.from(\"0x3\");\n\n static FOUR: AccountAddress = AccountAddress.from(\"0x4\");\n\n static A: AccountAddress = AccountAddress.from(\"0xA\");\n\n /**\n * Creates an instance of AccountAddress from a Uint8Array.\n *\n * This function ensures that the input data is exactly 32 bytes long, which is required for a valid account address.\n *\n * @param input A Uint8Array representing an account address.\n * @throws ParsingError if the input length is not equal to 32 bytes.\n * @group Implementation\n * @category Serialization\n */\n constructor(input: Uint8Array) {\n super();\n if (input.length !== AccountAddress.LENGTH) {\n throw new ParsingError(\n \"AccountAddress data should be exactly 32 bytes long\",\n AddressInvalidReason.INCORRECT_NUMBER_OF_BYTES,\n );\n }\n this.data = input;\n }\n\n /**\n * Determines if the address is classified as special, which is defined as 0x0 to 0xf inclusive.\n * In other words, the last byte of the address must be < 0b10000 (16)\n * and every other byte must be zero.\n *\n * For more information on how special addresses are defined, see AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns true if the address is special, false otherwise.\n * @group Implementation\n * @category Serialization\n */\n isSpecial(): boolean {\n return (\n this.data.slice(0, this.data.length - 1).every((byte) => byte === 0) && this.data[this.data.length - 1] < 0b10000\n );\n }\n // ===\n // Methods for representing an instance of AccountAddress as other types.\n // ===\n\n /**\n * Return the AccountAddress as a string as per AIP-40.\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n * This representation returns special addresses in SHORT form (0xf)\n * and other addresses in LONG form (0x + 64 characters).\n *\n * @returns AccountAddress as a string conforming to AIP-40.\n * @group Implementation\n * @category Serialization\n */\n toString(): `0x${string}` {\n return `0x${this.toStringWithoutPrefix()}`;\n }\n\n /**\n * Return the AccountAddress as a string conforming to AIP-40 but without the leading 0x.\n *\n * NOTE: Prefer to use `toString` where possible.\n *\n * @returns AccountAddress as a string without the leading 0x.\n * @group Implementation\n * @category Serialization\n */\n toStringWithoutPrefix(): string {\n let hex = bytesToHex(this.data);\n if (this.isSpecial()) {\n hex = hex[hex.length - 1];\n }\n return hex;\n }\n\n /**\n * Convert the account address to a string in LONG format, which is always 0x followed by 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns AccountAddress as a string in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLong(): `0x${string}` {\n return `0x${this.toStringLongWithoutPrefix()}`;\n }\n\n /**\n * Returns the account address as a string in LONG form without a leading 0x.\n * This function will include leading zeroes and will produce a string of 64 hex characters.\n *\n * NOTE: Prefer to use `toString` where possible, as it formats special addresses using the SHORT form (no leading 0s).\n *\n * @returns {string} The account address in LONG form.\n * @group Implementation\n * @category Serialization\n */\n toStringLongWithoutPrefix(): string {\n return bytesToHex(this.data);\n }\n\n /**\n * Get the inner data as a Uint8Array.\n * The inner data is already a Uint8Array, so no conversion takes place.\n *\n * @returns Hex data as Uint8Array\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data;\n }\n\n /**\n * Serialize the AccountAddress to a Serializer instance's data buffer.\n * @param serializer The serializer to serialize the AccountAddress to.\n * @returns void\n * @example\n * const serializer = new Serializer();\n * const address = AccountAddress.fromString(\"0x1\");\n * address.serialize(serializer);\n * const bytes = serializer.toUint8Array();\n * // `bytes` is now the BCS-serialized address.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows for the proper encoding of data when interacting with entry functions in the blockchain.\n *\n * @param serializer - The serializer instance used to convert the data into bytes.\n * @group Implementation\n * @category Serialization\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function by encoding it into a byte sequence.\n * This process involves serializing the variant index and the instance data, making it suitable for transmission.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Address);\n serializer.serialize(this);\n }\n\n /**\n * Deserialize an AccountAddress from the byte buffer in a Deserializer instance.\n * This function allows you to convert a byte representation of an AccountAddress into an instance of AccountAddress.\n * @param deserializer The deserializer to deserialize the AccountAddress from.\n * @returns An instance of AccountAddress.\n * @example\n * const bytes = hexToBytes(\"0x0102030405060708091011121314151617181920212223242526272829303132\");\n * const deserializer = new Deserializer(bytes);\n * const address = AccountAddress.deserialize(deserializer);\n * // `address` is now an instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AccountAddress {\n const bytes = deserializer.deserializeFixedBytes(AccountAddress.LENGTH);\n return new AccountAddress(bytes);\n }\n\n // ===\n // Methods for creating an instance of AccountAddress from other types.\n // ===\n\n /**\n * NOTE: This function has strict parsing behavior. For relaxed behavior, please use\n * the `fromString` function.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows only the strictest formats defined by AIP-40. In short this\n * means only the following formats are accepted:\n *\n * - LONG\n * - SHORT for special addresses\n *\n * Where:\n * - LONG is defined as 0x + 64 hex characters.\n * - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.\n *\n * This means the following are not accepted:\n * - SHORT for non-special addresses.\n * - Any address without a leading 0x.\n *\n * @param input - A hex string representing an account address.\n *\n * @throws {ParsingError} If the hex string does not start with 0x or is not in a valid format.\n *\n * @remarks\n *\n * This function has strict parsing behavior. For relaxed behavior, please use the `fromString` function.\n *\n * @see AIP-40 documentation for more details on address formats:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @returns An instance of AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStringStrict(input: string): AccountAddress {\n // Assert the string starts with 0x.\n if (!input.startsWith(\"0x\")) {\n throw new ParsingError(\"Hex string must start with a leading 0x.\", AddressInvalidReason.LEADING_ZERO_X_REQUIRED);\n }\n\n const address = AccountAddress.fromString(input);\n\n // Check if the address is in LONG form. If it is not, this is only allowed for\n // special addresses, in which case we check it is in proper SHORT form.\n if (input.length !== AccountAddress.LONG_STRING_LENGTH + 2) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `The given hex string ${input} is not a special address, it must be represented as 0x + 64 chars.`,\n AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL,\n );\n } else if (input.length !== 3) {\n // 0x + one hex char is the only valid SHORT form for special addresses.\n throw new ParsingError(\n // eslint-disable-next-line max-len\n `The given hex string ${input} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,\n AddressInvalidReason.INVALID_PADDING_ZEROES,\n );\n }\n }\n\n return address;\n }\n\n /**\n * NOTE: This function has relaxed parsing behavior. For strict behavior, please use\n * the `fromStringStrict` function. Where possible use `fromStringStrict` rather than this\n * function, `fromString`.\n *\n * Creates an instance of AccountAddress from a hex string.\n *\n * This function allows all formats defined by AIP-40. In short this means the\n * following formats are accepted:\n *\n * - LONG, with or without leading 0x\n * - SHORT*, with or without leading 0x\n *\n * Where:\n * - LONG is 64 hex characters.\n * - SHORT* is 1 to 63 hex characters inclusive. The address can have missing values up to `maxMissingChars` before it is padded.\n * - Padding zeroes are allowed, e.g. 0x0123 is valid.\n *\n * Learn more about the different address formats by reading AIP-40:\n * https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.\n *\n * @param input A hex string representing an account address.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n *\n * @returns An instance of AccountAddress.\n *\n * @throws ParsingError if the hex string is too short, too long, or contains invalid characters.\n * @group Implementation\n * @category Serialization\n */\n static fromString(input: string, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n let parsedInput = input;\n // Remove leading 0x for parsing.\n if (input.startsWith(\"0x\")) {\n parsedInput = input.slice(2);\n }\n\n // Ensure the address string is at least 1 character long.\n if (parsedInput.length === 0) {\n throw new ParsingError(\n \"Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_SHORT,\n );\n }\n\n // Ensure the address string is not longer than 64 characters.\n if (parsedInput.length > 64) {\n throw new ParsingError(\n \"Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.\",\n AddressInvalidReason.TOO_LONG,\n );\n }\n\n // Ensure that the maxMissingChars is between or equal to 0 and 63.\n if (maxMissingChars > 63 || maxMissingChars < 0) {\n throw new ParsingError(\n `maxMissingChars must be between or equal to 0 and 63. Received ${maxMissingChars}`,\n AddressInvalidReason.INVALID_PADDING_STRICTNESS,\n );\n }\n\n let addressBytes: Uint8Array;\n try {\n // Pad the address with leading zeroes, so it is 64 chars long and then convert\n // the hex string to bytes. Every two characters in a hex string constitutes a\n // single byte. So a 64 length hex string becomes a 32 byte array.\n addressBytes = hexToBytes(parsedInput.padStart(64, \"0\"));\n } catch (error: any) {\n // At this point the only way this can fail is if the hex string contains\n // invalid characters.\n throw new ParsingError(`Hex characters are invalid: ${error?.message}`, AddressInvalidReason.INVALID_HEX_CHARS);\n }\n\n const address = new AccountAddress(addressBytes);\n\n // Cannot pad the address if it has more than maxMissingChars missing.\n if (parsedInput.length < 64 - maxMissingChars) {\n if (!address.isSpecial()) {\n throw new ParsingError(\n `Hex string is too short, must be ${64 - maxMissingChars} to 64 chars long, excluding the leading 0x. You may need to fix \nthe addresss by padding it with 0s before passing it to \\`fromString\\` (e.g. <addressString>.padStart(64, '0')). \nReceived ${input}`,\n AddressInvalidReason.TOO_SHORT,\n );\n }\n }\n\n return address;\n }\n\n /**\n * Convenience method for creating an AccountAddress from various input types.\n * This function accepts a string, Uint8Array, or an existing AccountAddress instance and returns the corresponding\n * AccountAddress.\n *\n * @param input - The input to convert into an AccountAddress. This can be a string representation of an address, a Uint8Array,\n * or an existing AccountAddress.\n * @param args.maxMissingChars The number of characters that can be missing in a padded address before it is invalid.\n * @group Implementation\n * @category Serialization\n */\n static from(input: AccountAddressInput, { maxMissingChars = 4 }: { maxMissingChars?: number } = {}): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromString(input, { maxMissingChars });\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n\n /**\n * Create an AccountAddress from various input types, including strings, Uint8Array, and AccountAddress instances.\n *\n * @param input - The input to convert into an AccountAddress, which can be a string, a Uint8Array, or an AccountAddress.\n * @group Implementation\n * @category Serialization\n */\n static fromStrict(input: AccountAddressInput): AccountAddress {\n if (typeof input === \"string\") {\n return AccountAddress.fromStringStrict(input);\n }\n if (input instanceof Uint8Array) {\n return new AccountAddress(input);\n }\n return input;\n }\n // ===\n // Methods for checking validity.\n // ===\n\n /**\n * Check if the provided input is a valid AccountAddress.\n *\n * @param args - The arguments for validation.\n * @param args.input - A hex string representing an account address.\n * @param args.strict - If true, use strict parsing behavior; if false, use relaxed parsing behavior.\n *\n * @returns An object indicating whether the address is valid. If valid, valid = true; if not, valid = false with additional details.\n * If the address is invalid, invalidReason will explain why it is invalid, and invalidReasonMessage will provide the error message.\n * @group Implementation\n * @category Serialization\n */\n static isValid(args: { input: AccountAddressInput; strict?: boolean }): ParsingResult<AddressInvalidReason> {\n try {\n if (args.strict) {\n AccountAddress.fromStrict(args.input);\n } else {\n AccountAddress.from(args.input);\n }\n return { valid: true };\n } catch (error: any) {\n return {\n valid: false,\n invalidReason: error?.invalidReason,\n invalidReasonMessage: error?.message,\n };\n }\n }\n\n /**\n * Determine if two AccountAddresses are equal based on their underlying byte data.\n *\n * @param other - The AccountAddress to compare to.\n * @returns true if the AccountAddresses are equal, false if not.\n * @group Implementation\n * @category Serialization\n */\n equals(other: AccountAddress): boolean {\n if (this.data.length !== other.data.length) return false;\n return this.data.every((value, index) => value === other.data[index]);\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"./accountAddress\";\nimport type { AccountPublicKey } from \"./crypto\";\nimport { Hex } from \"./hex\";\nimport { AuthenticationKeyScheme, HexInput } from \"../types\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\n\n/**\n * Represents an authentication key used for account management. Each account stores an authentication key that enables account\n * owners to rotate their private key(s) without changing the address that hosts their account. The authentication key is a\n * SHA3-256 hash of data and is always 32 bytes in length.\n *\n * @see {@link https://aptos.dev/concepts/accounts | Account Basics}\n *\n * Account addresses can be derived from the AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\nexport class AuthenticationKey extends Serializable {\n /**\n * An authentication key is always a SHA3-256 hash of data, and is always 32 bytes.\n *\n * The data to hash depends on the underlying public key type and the derivation scheme.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The raw bytes of the authentication key.\n * @group Implementation\n * @category Serialization\n */\n public readonly data: Hex;\n\n /**\n * Creates an instance of the AuthenticationKey using the provided hex input.\n * This ensures that the hex input is valid and conforms to the required length for an Authentication Key.\n *\n * @param args - The arguments for constructing the AuthenticationKey.\n * @param args.data - The hex input data to be used for the Authentication Key.\n * @throws {Error} Throws an error if the length of the provided hex input is not equal to the required Authentication Key\n * length.\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { data: HexInput }) {\n super();\n const { data } = args;\n const hex = Hex.fromHexInput(data);\n if (hex.toUint8Array().length !== AuthenticationKey.LENGTH) {\n throw new Error(`Authentication Key length should be ${AuthenticationKey.LENGTH}`);\n }\n this.data = hex;\n }\n\n /**\n * Serializes the fixed bytes data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data.toUint8Array());\n }\n\n /**\n * Deserialize an AuthenticationKey from the byte buffer in a Deserializer instance.\n * @param deserializer - The deserializer to deserialize the AuthenticationKey from.\n * @returns An instance of AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AuthenticationKey {\n const bytes = deserializer.deserializeFixedBytes(AuthenticationKey.LENGTH);\n return new AuthenticationKey({ data: bytes });\n }\n\n /**\n * Convert the internal data representation to a Uint8Array.\n *\n * This function is useful for obtaining a byte representation of the data, which can be utilized for serialization or transmission.\n *\n * @returns Uint8Array representation of the internal data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n /**\n * Generates an AuthenticationKey from the specified scheme and input bytes.\n * This function is essential for creating a valid authentication key based on a given scheme.\n *\n * @param args - The arguments for generating the AuthenticationKey.\n * @param args.scheme - The authentication key scheme to use.\n * @param args.input - The input data in hexadecimal format to derive the key.\n * @returns An instance of AuthenticationKey containing the generated key data.\n * @group Implementation\n * @category Serialization\n */\n static fromSchemeAndBytes(args: { scheme: AuthenticationKeyScheme; input: HexInput }): AuthenticationKey {\n const { scheme, input } = args;\n const inputBytes = Hex.fromHexInput(input).toUint8Array();\n const hashInput = new Uint8Array([...inputBytes, scheme]);\n const hash = sha3Hash.create();\n hash.update(hashInput);\n const hashDigest = hash.digest();\n return new AuthenticationKey({ data: hashDigest });\n }\n\n /**\n * Derives an AuthenticationKey from the provided public key using a specified derivation scheme.\n *\n * @deprecated Use `fromPublicKey` instead.\n * @param args - The arguments for deriving the authentication key.\n * @param args.publicKey - The public key used for the derivation.\n * @param args.scheme - The scheme to use for deriving the authentication key.\n * @group Implementation\n * @category Serialization\n */\n public static fromPublicKeyAndScheme(args: { publicKey: AccountPublicKey; scheme: AuthenticationKeyScheme }) {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Converts a PublicKey to an AuthenticationKey using the derivation scheme inferred from the provided PublicKey instance.\n *\n * @param args - The arguments for the function.\n * @param args.publicKey - The PublicKey to be converted.\n * @returns AuthenticationKey - The derived AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\n static fromPublicKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Derives an account address from an AuthenticationKey by translating the AuthenticationKey bytes directly to an AccountAddress.\n *\n * @returns AccountAddress - The derived account address.\n * @group Implementation\n * @category Serialization\n */\n derivedAddress(): AccountAddress {\n return new AccountAddress(this.data.toUint8Array());\n }\n}\n","import { AptosApiType } from \"../utils/const\";\nimport { getErrorMessage } from \"../utils/helpers\";\nimport { AptosRequest, AptosResponse } from \"../types\";\n\nexport enum KeylessErrorCategory {\n API_ERROR,\n EXTERNAL_API_ERROR,\n SESSION_EXPIRED,\n INVALID_STATE,\n UNKNOWN,\n}\n\nexport enum KeylessErrorResolutionTip {\n REAUTHENTICATE = \"Re-authentiate to continue using your keyless account\",\n // eslint-disable-next-line max-len\n REAUTHENTICATE_UNSURE = \"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support\",\n UPDATE_REQUEST_PARAMS = \"Update the invalid request parameters and reauthenticate.\",\n // eslint-disable-next-line max-len\n RATE_LIMIT_EXCEEDED = \"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.\",\n // eslint-disable-next-line max-len\n SERVER_ERROR = \"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n // eslint-disable-next-line max-len\n CALL_PRECHECK = \"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.\",\n REINSTANTIATE = \"Try instantiating the account again. Avoid manipulating the account object directly\",\n JOIN_SUPPORT_GROUP = \"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n UNKNOWN = \"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n}\n\nexport enum KeylessErrorType {\n EPHEMERAL_KEY_PAIR_EXPIRED,\n\n PROOF_NOT_FOUND,\n\n ASYNC_PROOF_FETCH_FAILED,\n\n INVALID_PROOF_VERIFICATION_FAILED,\n\n INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND,\n\n INVALID_JWT_SIG,\n\n INVALID_JWT_JWK_NOT_FOUND,\n\n INVALID_JWT_ISS_NOT_RECOGNIZED,\n\n INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED,\n\n INVALID_TW_SIG_VERIFICATION_FAILED,\n\n INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND,\n\n INVALID_EXPIRY_HORIZON,\n\n JWT_PARSING_ERROR,\n\n JWK_FETCH_FAILED,\n\n JWK_FETCH_FAILED_FEDERATED,\n\n RATE_LIMIT_EXCEEDED,\n\n PEPPER_SERVICE_INTERNAL_ERROR,\n\n PEPPER_SERVICE_BAD_REQUEST,\n\n PEPPER_SERVICE_OTHER,\n\n PROVER_SERVICE_INTERNAL_ERROR,\n\n PROVER_SERVICE_BAD_REQUEST,\n\n PROVER_SERVICE_OTHER,\n\n FULL_NODE_CONFIG_LOOKUP_ERROR,\n\n FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR,\n\n FULL_NODE_JWKS_LOOKUP_ERROR,\n\n FULL_NODE_OTHER,\n\n UNKNOWN,\n}\n\nconst KeylessErrors: { [key in KeylessErrorType]: [string, KeylessErrorCategory, KeylessErrorResolutionTip] } = {\n [KeylessErrorType.EPHEMERAL_KEY_PAIR_EXPIRED]: [\n \"The ephemeral keypair has expired.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.PROOF_NOT_FOUND]: [\n \"The required proof could not be found.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.CALL_PRECHECK,\n ],\n [KeylessErrorType.ASYNC_PROOF_FETCH_FAILED]: [\n \"The required proof failed to fetch.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_PROOF_VERIFICATION_FAILED]: [\n \"The provided proof is invalid.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND]: [\n \"The verification key used to authenticate was updated.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_JWT_SIG]: [\n \"The JWK was found, but JWT failed verification\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_JWT_JWK_NOT_FOUND]: [\n \"The JWK required to verify the JWT could not be found. The JWK may have been rotated out.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_JWT_ISS_NOT_RECOGNIZED]: [\n \"The JWT issuer is not recognized.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED]: [\n \"The JWT issuer is not supported by the Federated Keyless \",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_TW_SIG_VERIFICATION_FAILED]: [\n \"The training wheels signature is invalid.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND]: [\n \"The public key used to verify the training wheels signature was not found.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_EXPIRY_HORIZON]: [\n \"The expiry horizon is invalid.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.JWK_FETCH_FAILED]: [\n \"Failed to fetch JWKS.\",\n KeylessErrorCategory.EXTERNAL_API_ERROR,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.JWK_FETCH_FAILED_FEDERATED]: [\n \"Failed to fetch JWKS for Federated Keyless provider.\",\n KeylessErrorCategory.EXTERNAL_API_ERROR,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.RATE_LIMIT_EXCEEDED]: [\n \"Rate limit exceeded. Too many requests in a short period.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.RATE_LIMIT_EXCEEDED,\n ],\n [KeylessErrorType.PEPPER_SERVICE_INTERNAL_ERROR]: [\n \"Internal error from Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PEPPER_SERVICE_BAD_REQUEST]: [\n \"Bad request sent to Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.PEPPER_SERVICE_OTHER]: [\n \"Unknown error from Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PROVER_SERVICE_INTERNAL_ERROR]: [\n \"Internal error from Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PROVER_SERVICE_BAD_REQUEST]: [\n \"Bad request sent to Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.PROVER_SERVICE_OTHER]: [\n \"Unknown error from Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.JWT_PARSING_ERROR]: [\n \"Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REINSTANTIATE,\n ],\n [KeylessErrorType.FULL_NODE_CONFIG_LOOKUP_ERROR]: [\n \"Error when looking up on-chain keyless configuration.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR]: [\n \"Error when looking up on-chain verification key.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_JWKS_LOOKUP_ERROR]: [\n \"Error when looking up on-chain JWKS.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_OTHER]: [\n \"Unknown error from full node.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.UNKNOWN]: [\n \"An unknown error has occurred.\",\n KeylessErrorCategory.UNKNOWN,\n KeylessErrorResolutionTip.UNKNOWN,\n ],\n};\n\nexport class KeylessError extends Error {\n readonly innerError?: unknown;\n\n readonly category: KeylessErrorCategory;\n\n readonly resolutionTip: KeylessErrorResolutionTip;\n\n readonly type: KeylessErrorType;\n\n readonly details?: string;\n\n /** @internal this constructor is for sdk internal use - do not instantiate outside of the SDK codebase */\n constructor(args: {\n innerError?: unknown;\n category: KeylessErrorCategory;\n resolutionTip: KeylessErrorResolutionTip;\n type: KeylessErrorType;\n message?: string;\n details?: string;\n }) {\n const { innerError, category, resolutionTip, type, message = KeylessErrors[type][0], details } = args;\n super(message);\n this.name = \"KeylessError\";\n this.innerError = innerError;\n this.category = category;\n this.resolutionTip = resolutionTip;\n this.type = type;\n this.details = details;\n this.message = KeylessError.constructMessage(message, resolutionTip, innerError, details);\n }\n\n static constructMessage(\n message: string,\n tip: KeylessErrorResolutionTip,\n innerError?: unknown,\n details?: string,\n ): string {\n let result = `\\nMessage: ${message}`;\n if (details) {\n result += `\\nDetails: ${details}`;\n }\n if (innerError instanceof AptosApiError) {\n result += `\\nAptosApiError: ${innerError.message}`;\n } else if (innerError !== undefined) {\n result += `\\nError: ${getErrorMessage(innerError)}`;\n }\n result += `\\nKeylessErrorResolutionTip: ${tip}`;\n return result;\n }\n\n /**\n * Static constructor that creates a KeylessError instance using the KeylessErrors constant\n * @param args.type The type of KeylessError\n * @param args.aptosApiError optional AptosApiError supplied for api errors\n * @param args.details optional details to include in the error message\n * @returns A new KeylessError instance\n */\n static fromErrorType(args: { type: KeylessErrorType; error?: unknown; details?: string }): KeylessError {\n const { error, type, details } = args;\n\n const [message, category, resolutionTip] = KeylessErrors[type];\n return new KeylessError({\n message,\n details,\n innerError: error,\n category,\n resolutionTip,\n type,\n });\n }\n}\n\n/**\n * Options for handling errors in the Aptos API.\n */\ntype AptosApiErrorOpts = {\n apiType: AptosApiType;\n aptosRequest: AptosRequest;\n aptosResponse: AptosResponse<any, any>;\n};\n\n/**\n * Represents an error returned from the Aptos API.\n * This class encapsulates the details of the error, including the request URL, response status, and additional data.\n *\n * @param name - The name of the error, which is always \"AptosApiError\".\n * @param url - The URL to which the request was made.\n * @param status - The HTTP response status code (e.g., 400).\n * @param statusText - The message associated with the response status.\n * @param data - The response data returned from the API.\n * @param request - The original AptosRequest that triggered the error.\n */\nexport class AptosApiError extends Error {\n readonly url: string;\n\n readonly status: number;\n\n readonly statusText: string;\n\n readonly data: any;\n\n readonly request: AptosRequest;\n\n /**\n * Constructs an instance of AptosApiError with relevant error details.\n *\n * @param opts - The options for creating the AptosApiError.\n * @param opts.apiType - The type of API that generated the error.\n * @param opts.aptosRequest - The request object that caused the error.\n * @param opts.aptosResponse - The response object containing error details.\n *\n * @internal This constructor is for SDK internal use - do not instantiate outside the SDK codebase.\n */\n constructor({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts) {\n super(deriveErrorMessage({ apiType, aptosRequest, aptosResponse }));\n\n this.name = \"AptosApiError\";\n this.url = aptosResponse.url;\n this.status = aptosResponse.status;\n this.statusText = aptosResponse.statusText;\n this.data = aptosResponse.data;\n this.request = aptosRequest;\n }\n}\n\n/**\n * Derives an error message from the Aptos API response, providing context for debugging.\n * This function helps in understanding the nature of the error encountered during an API request.\n *\n * @param {AptosApiErrorOpts} opts - The options for deriving the error message.\n * @param {AptosApiType} opts.apiType - The type of API being called.\n * @param {AptosRequest} opts.aptosRequest - The original request made to the Aptos API.\n * @param {AptosResponse} opts.aptosResponse - The response received from the Aptos API.\n */\nfunction deriveErrorMessage({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts): string {\n // eslint-disable-next-line max-len\n // extract the W3C trace_id from the response headers if it exists. Some services set this in the response, and it's useful for debugging.\n // See https://www.w3.org/TR/trace-context/#relationship-between-the-headers .\n const traceId = aptosResponse.headers?.traceparent?.split(\"-\")[1];\n const traceIdString = traceId ? `(trace_id:${traceId}) ` : \"\";\n\n const errorPrelude: string = `Request to [${apiType}]: ${aptosRequest.method} ${\n aptosResponse.url ?? aptosRequest.url\n } ${traceIdString}failed with`;\n\n // handle graphql responses from indexer api and extract the error message of the first error\n if (apiType === AptosApiType.INDEXER && aptosResponse.data?.errors?.[0]?.message != null) {\n return `${errorPrelude}: ${aptosResponse.data.errors[0].message}`;\n }\n\n // Received well-known structured error response body - simply serialize and return it.\n // We don't need http status codes etc. in this case.\n if (aptosResponse.data?.message != null && aptosResponse.data?.error_code != null) {\n return `${errorPrelude}: ${JSON.stringify(aptosResponse.data)}`;\n }\n\n // This is the generic/catch-all case. We received some response from the API, but it doesn't appear to be a well-known structure.\n // We print http status codes and the response body (after some trimming),\n // in the hope that this gives enough context what went wrong without printing overly huge messages.\n return `${errorPrelude} status: ${aptosResponse.statusText}(code:${\n aptosResponse.status\n }) and response body: ${serializeAnyPayloadForErrorMessage(aptosResponse.data)}`;\n}\n\nconst SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH = 400;\n\n/**\n * This function accepts a payload of any type (probably an object) and serializes it to a string\n * Since we don't know the type or size of the payload, and we don't want to add a huge object in full to the error message\n * we limit the to the first 200 and last 200 characters of the serialized payload and put a \"...\" in the middle.\n * @param payload - The payload to serialize, which can be of any type.\n *\n * @returns A string representation of the serialized payload, potentially truncated.\n */\nfunction serializeAnyPayloadForErrorMessage(payload: any): string {\n const serializedPayload = JSON.stringify(payload);\n if (serializedPayload.length <= SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH) {\n return serializedPayload;\n }\n return `truncated(original_size:${serializedPayload.length}): ${serializedPayload.slice(\n 0,\n SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2,\n )}...${serializedPayload.slice(-SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2)}`;\n}\n","import * as Types from \"./operations\";\n\nimport { GraphQLClient, RequestOptions } from \"graphql-request\";\ntype GraphQLClientRequestHeaders = RequestOptions[\"requestHeaders\"];\nexport const TokenActivitiesFieldsFragmentDoc = `\n fragment TokenActivitiesFields on token_activities_v2 {\n after_value\n before_value\n entry_function_id_str\n event_account_address\n event_index\n from_address\n is_fungible_v2\n property_version_v1\n to_address\n token_amount\n token_data_id\n token_standard\n transaction_timestamp\n transaction_version\n type\n}\n `;\nexport const AnsTokenFragmentFragmentDoc = `\n fragment AnsTokenFragment on current_aptos_names {\n domain\n expiration_timestamp\n registered_address\n subdomain\n token_standard\n is_primary\n owner_address\n subdomain_expiration_policy\n domain_expiration_timestamp\n}\n `;\nexport const CurrentTokenOwnershipFieldsFragmentDoc = `\n fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {\n token_standard\n token_properties_mutated_v1\n token_data_id\n table_type_v1\n storage_id\n property_version_v1\n owner_address\n last_transaction_version\n last_transaction_timestamp\n is_soulbound_v2\n is_fungible_v2\n amount\n current_token_data {\n collection_id\n description\n is_fungible_v2\n largest_property_version_v1\n last_transaction_timestamp\n last_transaction_version\n maximum\n supply\n token_data_id\n token_name\n token_properties\n token_standard\n token_uri\n decimals\n current_collection {\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n max_supply\n mutable_description\n mutable_uri\n table_handle_v1\n token_standard\n total_minted_v2\n uri\n }\n }\n}\n `;\nexport const GetAccountCoinsCount = `\n query getAccountCoinsCount($address: String) {\n current_fungible_asset_balances_aggregate(\n where: {owner_address: {_eq: $address}}\n ) {\n aggregate {\n count\n }\n }\n}\n `;\nexport const GetAccountCoinsData = `\n query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {\n current_fungible_asset_balances(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n amount\n asset_type\n is_frozen\n is_primary\n last_transaction_timestamp\n last_transaction_version\n owner_address\n storage_id\n token_standard\n metadata {\n token_standard\n symbol\n supply_aggregator_table_key_v1\n supply_aggregator_table_handle_v1\n project_uri\n name\n last_transaction_version\n last_transaction_timestamp\n icon_uri\n decimals\n creator_address\n asset_type\n }\n }\n}\n `;\nexport const GetAccountCollectionsWithOwnedTokens = `\n query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {\n current_collection_ownership_v2_view(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n current_collection {\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n mutable_description\n max_supply\n mutable_uri\n table_handle_v1\n token_standard\n total_minted_v2\n uri\n }\n collection_id\n collection_name\n collection_uri\n creator_address\n distinct_tokens\n last_transaction_version\n owner_address\n single_token_uri\n }\n}\n `;\nexport const GetAccountOwnedTokens = `\n query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetAccountOwnedTokensByTokenData = `\n query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetAccountOwnedTokensFromCollection = `\n query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetAccountTokensCount = `\n query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {\n current_token_ownerships_v2_aggregate(\n where: $where_condition\n offset: $offset\n limit: $limit\n ) {\n aggregate {\n count\n }\n }\n}\n `;\nexport const GetAccountTransactionsCount = `\n query getAccountTransactionsCount($address: String) {\n account_transactions_aggregate(where: {account_address: {_eq: $address}}) {\n aggregate {\n count\n }\n }\n}\n `;\nexport const GetChainTopUserTransactions = `\n query getChainTopUserTransactions($limit: Int) {\n user_transactions(limit: $limit, order_by: {version: desc}) {\n version\n }\n}\n `;\nexport const GetCollectionData = `\n query getCollectionData($where_condition: current_collections_v2_bool_exp!) {\n current_collections_v2(where: $where_condition) {\n uri\n total_minted_v2\n token_standard\n table_handle_v1\n mutable_uri\n mutable_description\n max_supply\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n cdn_asset_uris {\n cdn_image_uri\n asset_uri\n animation_optimizer_retry_count\n cdn_animation_uri\n cdn_json_uri\n image_optimizer_retry_count\n json_parser_retry_count\n raw_animation_uri\n raw_image_uri\n }\n }\n}\n `;\nexport const GetCurrentFungibleAssetBalances = `\n query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {\n current_fungible_asset_balances(\n where: $where_condition\n offset: $offset\n limit: $limit\n ) {\n amount\n asset_type\n is_frozen\n is_primary\n last_transaction_timestamp\n last_transaction_version\n owner_address\n storage_id\n token_standard\n }\n}\n `;\nexport const GetDelegatedStakingActivities = `\n query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {\n delegated_staking_activities(\n where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}\n ) {\n amount\n delegator_address\n event_index\n event_type\n pool_address\n transaction_version\n }\n}\n `;\nexport const GetEvents = `\n query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {\n events(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n account_address\n creation_number\n data\n event_index\n sequence_number\n transaction_block_height\n transaction_version\n type\n indexed_type\n }\n}\n `;\nexport const GetFungibleAssetActivities = `\n query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {\n fungible_asset_activities(\n where: $where_condition\n offset: $offset\n limit: $limit\n ) {\n amount\n asset_type\n block_height\n entry_function_id_str\n event_index\n gas_fee_payer_address\n is_frozen\n is_gas_fee\n is_transaction_success\n owner_address\n storage_id\n storage_refund_amount\n token_standard\n transaction_timestamp\n transaction_version\n type\n }\n}\n `;\nexport const GetFungibleAssetMetadata = `\n query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {\n fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {\n icon_uri\n project_uri\n supply_aggregator_table_handle_v1\n supply_aggregator_table_key_v1\n creator_address\n asset_type\n decimals\n last_transaction_timestamp\n last_transaction_version\n name\n symbol\n token_standard\n supply_v2\n maximum_v2\n }\n}\n `;\nexport const GetNames = `\n query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {\n current_aptos_names(\n limit: $limit\n where: $where_condition\n order_by: $order_by\n offset: $offset\n ) {\n ...AnsTokenFragment\n }\n}\n ${AnsTokenFragmentFragmentDoc}`;\nexport const GetNumberOfDelegators = `\n query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {\n num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {\n num_active_delegator\n pool_address\n }\n}\n `;\nexport const GetObjectData = `\n query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {\n current_objects(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n allow_ungated_transfer\n state_key_hash\n owner_address\n object_address\n last_transaction_version\n last_guid_creation_num\n is_deleted\n }\n}\n `;\nexport const GetProcessorStatus = `\n query getProcessorStatus($where_condition: processor_status_bool_exp) {\n processor_status(where: $where_condition) {\n last_success_version\n processor\n last_updated\n }\n}\n `;\nexport const GetTableItemsData = `\n query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {\n table_items(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n decoded_key\n decoded_value\n key\n table_handle\n transaction_version\n write_set_change_index\n }\n}\n `;\nexport const GetTableItemsMetadata = `\n query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {\n table_metadatas(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n handle\n key_type\n value_type\n }\n}\n `;\nexport const GetTokenActivity = `\n query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {\n token_activities_v2(\n where: $where_condition\n order_by: $order_by\n offset: $offset\n limit: $limit\n ) {\n ...TokenActivitiesFields\n }\n}\n ${TokenActivitiesFieldsFragmentDoc}`;\nexport const GetCurrentTokenOwnership = `\n query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetTokenData = `\n query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {\n current_token_datas_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n collection_id\n description\n is_fungible_v2\n largest_property_version_v1\n last_transaction_timestamp\n last_transaction_version\n maximum\n supply\n token_data_id\n token_name\n token_properties\n token_standard\n token_uri\n decimals\n current_collection {\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n max_supply\n mutable_description\n mutable_uri\n table_handle_v1\n token_standard\n total_minted_v2\n uri\n }\n }\n}\n `;\n\nexport type SdkFunctionWrapper = <T>(\n action: (requestHeaders?: Record<string, string>) => Promise<T>,\n operationName: string,\n operationType?: string,\n variables?: any,\n) => Promise<T>;\n\nconst defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();\n\nexport function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {\n return {\n getAccountCoinsCount(\n variables?: Types.GetAccountCoinsCountQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountCoinsCountQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountCoinsCountQuery>(GetAccountCoinsCount, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountCoinsCount\",\n \"query\",\n variables,\n );\n },\n getAccountCoinsData(\n variables: Types.GetAccountCoinsDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountCoinsDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountCoinsDataQuery>(GetAccountCoinsData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountCoinsData\",\n \"query\",\n variables,\n );\n },\n getAccountCollectionsWithOwnedTokens(\n variables: Types.GetAccountCollectionsWithOwnedTokensQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountCollectionsWithOwnedTokensQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountCollectionsWithOwnedTokensQuery>(\n GetAccountCollectionsWithOwnedTokens,\n variables,\n { ...requestHeaders, ...wrappedRequestHeaders },\n ),\n \"getAccountCollectionsWithOwnedTokens\",\n \"query\",\n variables,\n );\n },\n getAccountOwnedTokens(\n variables: Types.GetAccountOwnedTokensQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountOwnedTokensQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountOwnedTokensQuery>(GetAccountOwnedTokens, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountOwnedTokens\",\n \"query\",\n variables,\n );\n },\n getAccountOwnedTokensByTokenData(\n variables: Types.GetAccountOwnedTokensByTokenDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountOwnedTokensByTokenDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountOwnedTokensByTokenDataQuery>(GetAccountOwnedTokensByTokenData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountOwnedTokensByTokenData\",\n \"query\",\n variables,\n );\n },\n getAccountOwnedTokensFromCollection(\n variables: Types.GetAccountOwnedTokensFromCollectionQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountOwnedTokensFromCollectionQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountOwnedTokensFromCollectionQuery>(\n GetAccountOwnedTokensFromCollection,\n variables,\n { ...requestHeaders, ...wrappedRequestHeaders },\n ),\n \"getAccountOwnedTokensFromCollection\",\n \"query\",\n variables,\n );\n },\n getAccountTokensCount(\n variables?: Types.GetAccountTokensCountQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountTokensCountQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountTokensCountQuery>(GetAccountTokensCount, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountTokensCount\",\n \"query\",\n variables,\n );\n },\n getAccountTransactionsCount(\n variables?: Types.GetAccountTransactionsCountQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountTransactionsCountQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountTransactionsCountQuery>(GetAccountTransactionsCount, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountTransactionsCount\",\n \"query\",\n variables,\n );\n },\n getChainTopUserTransactions(\n variables?: Types.GetChainTopUserTransactionsQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetChainTopUserTransactionsQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetChainTopUserTransactionsQuery>(GetChainTopUserTransactions, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getChainTopUserTransactions\",\n \"query\",\n variables,\n );\n },\n getCollectionData(\n variables: Types.GetCollectionDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetCollectionDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetCollectionDataQuery>(GetCollectionData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getCollectionData\",\n \"query\",\n variables,\n );\n },\n getCurrentFungibleAssetBalances(\n variables?: Types.GetCurrentFungibleAssetBalancesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetCurrentFungibleAssetBalancesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetCurrentFungibleAssetBalancesQuery>(GetCurrentFungibleAssetBalances, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getCurrentFungibleAssetBalances\",\n \"query\",\n variables,\n );\n },\n getDelegatedStakingActivities(\n variables?: Types.GetDelegatedStakingActivitiesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetDelegatedStakingActivitiesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetDelegatedStakingActivitiesQuery>(GetDelegatedStakingActivities, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getDelegatedStakingActivities\",\n \"query\",\n variables,\n );\n },\n getEvents(\n variables?: Types.GetEventsQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetEventsQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetEventsQuery>(GetEvents, variables, { ...requestHeaders, ...wrappedRequestHeaders }),\n \"getEvents\",\n \"query\",\n variables,\n );\n },\n getFungibleAssetActivities(\n variables?: Types.GetFungibleAssetActivitiesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetFungibleAssetActivitiesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetFungibleAssetActivitiesQuery>(GetFungibleAssetActivities, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getFungibleAssetActivities\",\n \"query\",\n variables,\n );\n },\n getFungibleAssetMetadata(\n variables?: Types.GetFungibleAssetMetadataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetFungibleAssetMetadataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetFungibleAssetMetadataQuery>(GetFungibleAssetMetadata, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getFungibleAssetMetadata\",\n \"query\",\n variables,\n );\n },\n getNames(\n variables?: Types.GetNamesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetNamesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetNamesQuery>(GetNames, variables, { ...requestHeaders, ...wrappedRequestHeaders }),\n \"getNames\",\n \"query\",\n variables,\n );\n },\n getNumberOfDelegators(\n variables?: Types.GetNumberOfDelegatorsQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetNumberOfDelegatorsQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetNumberOfDelegatorsQuery>(GetNumberOfDelegators, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getNumberOfDelegators\",\n \"query\",\n variables,\n );\n },\n getObjectData(\n variables?: Types.GetObjectDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetObjectDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetObjectDataQuery>(GetObjectData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getObjectData\",\n \"query\",\n variables,\n );\n },\n getProcessorStatus(\n variables?: Types.GetProcessorStatusQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetProcessorStatusQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetProcessorStatusQuery>(GetProcessorStatus, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getProcessorStatus\",\n \"query\",\n variables,\n );\n },\n getTableItemsData(\n variables: Types.GetTableItemsDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTableItemsDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTableItemsDataQuery>(GetTableItemsData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTableItemsData\",\n \"query\",\n variables,\n );\n },\n getTableItemsMetadata(\n variables: Types.GetTableItemsMetadataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTableItemsMetadataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTableItemsMetadataQuery>(GetTableItemsMetadata, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTableItemsMetadata\",\n \"query\",\n variables,\n );\n },\n getTokenActivity(\n variables: Types.GetTokenActivityQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTokenActivityQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTokenActivityQuery>(GetTokenActivity, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTokenActivity\",\n \"query\",\n variables,\n );\n },\n getCurrentTokenOwnership(\n variables: Types.GetCurrentTokenOwnershipQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetCurrentTokenOwnershipQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetCurrentTokenOwnershipQuery>(GetCurrentTokenOwnership, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getCurrentTokenOwnership\",\n \"query\",\n variables,\n );\n },\n getTokenData(\n variables?: Types.GetTokenDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTokenDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTokenDataQuery>(GetTokenData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTokenData\",\n \"query\",\n variables,\n );\n },\n };\n}\nexport type Sdk = ReturnType<typeof getSdk>;\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/general}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * general namespace and without having a dependency cycle error.\n * @group Implementation\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosFullNode, postAptosIndexer } from \"../client\";\nimport { GetChainTopUserTransactionsResponse, GetProcessorStatusResponse, GraphqlQuery, LedgerInfo } from \"../types\";\nimport { GetChainTopUserTransactionsQuery, GetProcessorStatusQuery } from \"../types/generated/operations\";\nimport { GetChainTopUserTransactions, GetProcessorStatus } from \"../types/generated/queries\";\nimport { ProcessorType } from \"../utils/const\";\n\n/**\n * Retrieves information about the current ledger.\n *\n * @param args - The arguments for retrieving ledger information.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network.\n * @group Implementation\n */\nexport async function getLedgerInfo(args: { aptosConfig: AptosConfig }): Promise<LedgerInfo> {\n const { aptosConfig } = args;\n const { data } = await getAptosFullNode<{}, LedgerInfo>({\n aptosConfig,\n originMethod: \"getLedgerInfo\",\n path: \"\",\n });\n return data;\n}\n\n/**\n * Retrieves the top user transactions for a specific blockchain chain.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.limit - The maximum number of transactions to retrieve.\n * @returns An array of user transactions.\n * @group Implementation\n */\nexport async function getChainTopUserTransactions(args: {\n aptosConfig: AptosConfig;\n limit: number;\n}): Promise<GetChainTopUserTransactionsResponse> {\n const { aptosConfig, limit } = args;\n const graphqlQuery = {\n query: GetChainTopUserTransactions,\n variables: { limit },\n };\n\n const data = await queryIndexer<GetChainTopUserTransactionsQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getChainTopUserTransactions\",\n });\n\n return data.user_transactions;\n}\n\n/**\n * Executes a GraphQL query against the Aptos indexer and retrieves the resulting data.\n *\n * @param args - The arguments for the query.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.query - The GraphQL query to be executed.\n * @param args.originMethod - An optional string to specify the origin method for tracking purposes.\n * @returns The data returned from the query execution.\n * @group Implementation\n */\nexport async function queryIndexer<T extends {}>(args: {\n aptosConfig: AptosConfig;\n query: GraphqlQuery;\n originMethod?: string;\n}): Promise<T> {\n const { aptosConfig, query, originMethod } = args;\n const { data } = await postAptosIndexer<GraphqlQuery, T>({\n aptosConfig,\n originMethod: originMethod ?? \"queryIndexer\",\n path: \"\",\n body: query,\n overrides: { WITH_CREDENTIALS: false },\n });\n return data;\n}\n\n/**\n * Retrieves the current statuses of processors.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @returns The statuses of the processors.\n * @group Implementation\n */\nexport async function getProcessorStatuses(args: { aptosConfig: AptosConfig }): Promise<GetProcessorStatusResponse> {\n const { aptosConfig } = args;\n\n const graphqlQuery = {\n query: GetProcessorStatus,\n };\n\n const data = await queryIndexer<GetProcessorStatusQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getProcessorStatuses\",\n });\n\n return data.processor_status;\n}\n\n/**\n * Retrieves the last success version from the indexer.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @returns The last success version as a BigInt.\n * @group Implementation\n */\nexport async function getIndexerLastSuccessVersion(args: { aptosConfig: AptosConfig }): Promise<bigint> {\n const response = await getProcessorStatuses({ aptosConfig: args.aptosConfig });\n return BigInt(response[0].last_success_version);\n}\n\n/**\n * Retrieves the status of a specified processor in the Aptos network.\n * This function allows you to check the current operational status of a processor, which can be useful for monitoring and troubleshooting.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network.\n * @param args.processorType - The type of processor whose status you want to retrieve.\n * @returns The status of the specified processor.\n * @group Implementation\n */\nexport async function getProcessorStatus(args: {\n aptosConfig: AptosConfig;\n processorType: ProcessorType;\n}): Promise<GetProcessorStatusResponse[0]> {\n const { aptosConfig, processorType } = args;\n\n const whereCondition: { processor: { _eq: string } } = {\n processor: { _eq: processorType },\n };\n\n const graphqlQuery = {\n query: GetProcessorStatus,\n variables: {\n where_condition: whereCondition,\n },\n };\n\n const data = await queryIndexer<GetProcessorStatusQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getProcessorStatus\",\n });\n\n return data.processor_status[0];\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account as AccountModule } from \"../account\";\nimport { AccountAddress, PrivateKey, AccountAddressInput, createObjectAddress } from \"../core\";\nimport {\n AccountData,\n AnyNumber,\n GetAccountCoinsDataResponse,\n GetAccountCollectionsWithOwnedTokenResponse,\n GetAccountOwnedTokensFromCollectionResponse,\n GetAccountOwnedTokensQueryResponse,\n GetObjectDataQueryResponse,\n LedgerVersionArg,\n MoveModuleBytecode,\n MoveResource,\n MoveStructId,\n MoveValue,\n OrderByArg,\n PaginationArgs,\n TokenStandardArg,\n TransactionResponse,\n WhereArg,\n} from \"../types\";\nimport {\n deriveAccountFromPrivateKey,\n getAccountCoinsCount,\n getAccountCoinsData,\n getAccountCollectionsWithOwnedTokens,\n getAccountOwnedObjects,\n getAccountOwnedTokens,\n getAccountOwnedTokensFromCollectionAddress,\n getAccountTokensCount,\n getAccountTransactionsCount,\n getInfo,\n getModule,\n getModules,\n getResource,\n getResources,\n getTransactions,\n lookupOriginalAccountAddress,\n} from \"../internal/account\";\nimport { APTOS_COIN, APTOS_FA, ProcessorType } from \"../utils/const\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { waitForIndexerOnVersion } from \"./utils\";\nimport { CurrentFungibleAssetBalancesBoolExp } from \"../types/generated/types\";\nimport { view } from \"../internal/view\";\nimport { isEncodedStruct, parseEncodedStruct } from \"../utils\";\nimport { memoizeAsync } from \"../utils/memoize\";\n\n/**\n * A class to query all `Account` related queries on Aptos.\n * @group Account\n */\nexport class Account {\n /**\n * Creates an instance of the Aptos client with the provided configuration.\n *\n * @param config - The configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Initialize the Aptos client with testnet configuration\n * const config = new AptosConfig({ network: Network.TESTNET }); // specify your own network if needed\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n constructor(readonly config: AptosConfig) {}\n\n /**\n * Queries the current state for an Aptos account given its account address.\n *\n * @param args - The arguments for retrieving account information.\n * @param args.accountAddress - The Aptos account address to query.\n * @returns The account data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Retrieve account information for a specific address\n * const accountInfo = await aptos.getAccountInfo({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(accountInfo);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountInfo(args: { accountAddress: AccountAddressInput }): Promise<AccountData> {\n return getInfo({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for all modules in an account given an account address.\n * This function may call the API multiple times to auto paginate through results.\n *\n * @param args.accountAddress - The Aptos account address to query modules for.\n * @param args.options.offset - The cursor to start returning results from. Note, this is obfuscated and is not an index.\n * @param args.options.limit - The maximum number of results to return.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it retrieves the latest version.\n *\n * @returns - The account modules associated with the specified address.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching account modules for a specific account\n * const accountModules = await aptos.getAccountModules({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * offset: 0, // starting from the first module\n * limit: 10, // limiting to 10 modules\n * },\n * });\n *\n * console.log(accountModules);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountModules(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs & LedgerVersionArg;\n }): Promise<MoveModuleBytecode[]> {\n return getModules({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for a specific account module given an account address and module name.\n *\n * @param args.accountAddress - The Aptos account address.\n * @param args.moduleName - The name of the module.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n *\n * @returns The account module associated with the specified account address and module name.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the account module for a specific account address and module name\n * const module = await aptos.getAccountModule({\n * accountAddress: \"0x1\", // replace with a real account address\n * moduleName: \"MyModule\" // specify the module name\n * });\n *\n * console.log(module);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountModule(args: {\n accountAddress: AccountAddressInput;\n moduleName: string;\n options?: LedgerVersionArg;\n }): Promise<MoveModuleBytecode> {\n return getModule({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries account transactions given an account address.\n * This function may call the API multiple times to auto paginate and retrieve all account transactions.\n *\n * @param args.accountAddress - The Aptos account address to query transactions for.\n * @param args.options - Optional pagination arguments.\n * @param args.options.offset - The number of transactions to start returning results from.\n * @param args.options.limit - The maximum number of results to return.\n *\n * @returns The account transactions.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetch transactions for a specific account\n * const transactions = await aptos.getAccountTransactions({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * offset: 0, // starting from the first transaction\n * limit: 10, // limiting to 10 transactions\n * },\n * });\n *\n * console.log(transactions);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountTransactions(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs;\n }): Promise<TransactionResponse[]> {\n return getTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries all account resources given an account address.\n * This function may call the API multiple times to auto paginate through results.\n *\n * @param args.accountAddress - The Aptos account address to query resources for.\n * @param args.options.offset - The cursor to start returning results from. Note, this is obfuscated and is not an index.\n * @param args.options.limit - The maximum number of results to return.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns Account resources.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching account resources for a specific account address\n * const resources = await aptos.getAccountResources({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(resources);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountResources(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs & LedgerVersionArg;\n }): Promise<MoveResource[]> {\n return getResources({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries a specific account resource given an account address and resource type.\n *\n * @template T - The typed output of the resource.\n * @param args.accountAddress - The Aptos account address to query.\n * @param args.resourceType - The string representation of an on-chain Move struct type, e.g., \"0x1::aptos_coin::AptosCoin\".\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns The account resource of the specified type.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the account resource for a specific account address and resource type\n * const resource = await aptos.getAccountResource({\n * accountAddress: \"0x1\", // replace with a real account address\n * resourceType: \"0x1::aptos_coin::AptosCoin\"\n * });\n *\n * console.log(resource);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountResource<T extends {} = any>(args: {\n accountAddress: AccountAddressInput;\n resourceType: MoveStructId;\n options?: LedgerVersionArg;\n }): Promise<T> {\n return getResource<T>({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Looks up the account address for a given authentication key, handling both rotated and non-rotated keys.\n *\n * @param args.authenticationKey - The authentication key for which to look up the account address.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns Promise<AccountAddress> - The account address associated with the authentication key.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Look up the original account address for a given authentication key\n * const accountAddress = await aptos.lookupOriginalAccountAddress({\n * authenticationKey: \"0x1\", // replace with a real authentication key\n * });\n *\n * console.log(\"Original Account Address:\", accountAddress);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async lookupOriginalAccountAddress(args: {\n authenticationKey: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: LedgerVersionArg;\n }): Promise<AccountAddress> {\n return lookupOriginalAccountAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries the current count of tokens owned by a specified account.\n *\n * @param args - The parameters for the query.\n * @param args.accountAddress - The account address to query the token count for.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @returns The current count of tokens owned by the account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the count of tokens owned by the account\n * const tokensCount = await aptos.getAccountTokensCount({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(`Tokens Count: ${tokensCount}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountTokensCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.ACCOUNT_TRANSACTION_PROCESSOR,\n });\n return getAccountTokensCount({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the tokens currently owned by a specified account, including NFTs and fungible tokens.\n * If desired, you can filter the results by a specific token standard.\n *\n * @param args.accountAddress The account address for which to retrieve owned tokens.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @param args.options.tokenStandard Optional filter for the NFT standard to query for.\n * @param args.options.offset Optional number to start returning results from.\n * @param args.options.limit Optional number of results to return.\n * @param args.options.orderBy Optional order to sort the tokens by.\n * @returns An array of tokens with their respective data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the tokens owned by a specific account\n * const accountOwnedTokens = await aptos.getAccountOwnedTokens({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify how many tokens to return\n * orderBy: \"created_at\", // specify the order of the results\n * },\n * });\n *\n * console.log(accountOwnedTokens);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountOwnedTokens(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensQueryResponse[0]>;\n }): Promise<GetAccountOwnedTokensQueryResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountOwnedTokens({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries all current tokens of a specific collection that an account owns by the collection address.\n * This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.\n * If you want to get only the token from a specific standard, you can pass an optional tokenStandard parameter.\n *\n * @param args.accountAddress - The account address we want to get the tokens for.\n * @param args.collectionAddress - The address of the collection being queried.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to, before querying.\n * @param args.options.tokenStandard - The NFT standard to query for.\n * @param args.options.offset - The number token to start returning results from.\n * @param args.options.limit - The number of results to return.\n * @param args.options.orderBy - The order to sort the tokens by.\n * @returns Tokens array with the token data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get tokens owned by a specific account in a specific collection\n * const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({\n * accountAddress: \"0x1\", // replace with a real account address\n * collectionAddress: \"0x2\", // replace with a real collection address\n * });\n *\n * console.log(accountOwnedTokens);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountOwnedTokensFromCollectionAddress(args: {\n accountAddress: AccountAddressInput;\n collectionAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensFromCollectionResponse[0]>;\n }): Promise<GetAccountOwnedTokensFromCollectionResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountOwnedTokensFromCollectionAddress({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries for all collections that an account currently has tokens for, including NFTs, fungible tokens, and soulbound tokens.\n * If you want to filter by a specific token standard, you can pass an optional tokenStandard parameter.\n *\n * @param args.accountAddress - The account address we want to get the collections for.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @param args.options.tokenStandard - The NFT standard to query for.\n * @param args.options.offset - The number of the collection to start returning results from.\n * @param args.options.limit - The number of results to return.\n * @param args.options.orderBy - The order to sort the tokens by.\n * @returns Collections array with the collections data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get account collections with owned tokens for a specific account\n * const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * tokenStandard: \"NFT\", // specify the token standard if needed\n * limit: 10, // specify the number of results to return\n * },\n * });\n *\n * console.log(accountCollectionsWithOwnedTokens);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCollectionsWithOwnedTokens(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountCollectionsWithOwnedTokenResponse[0]>;\n }): Promise<GetAccountCollectionsWithOwnedTokenResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountCollectionsWithOwnedTokens({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the current count of transactions submitted by an account.\n *\n * @param args - The parameters for the query.\n * @param args.accountAddress - The account address we want to get the total count for.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @returns Current count of transactions made by an account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the count of transactions for a specific account\n * const accountTransactionsCount = await aptos.getAccountTransactionsCount({\n * accountAddress: \"0x1\", // replace with a real account address\n * minimumLedgerVersion: 1, // specify your own minimum ledger version if needed\n * });\n *\n * console.log(accountTransactionsCount);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountTransactionsCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.ACCOUNT_TRANSACTION_PROCESSOR,\n });\n return getAccountTransactionsCount({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Retrieves the coins data for a specified account.\n *\n * @param args.accountAddress - The account address for which to retrieve the coin's data.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @param args.options.offset - Optional. The number of coins to start returning results from.\n * @param args.options.limit - Optional. The number of results to return.\n * @param args.options.orderBy - Optional. The order to sort the coins by.\n * @param args.options.where - Optional. Filter the results by specific criteria.\n * @returns An array containing the coins data for the specified account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching coins data for a specific account\n * const accountCoinsData = await aptos.getAccountCoinsData({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify the number of results to return\n * orderBy: { asset_type: \"asc\" }, // specify the order of results\n * },\n * });\n *\n * console.log(accountCoinsData);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCoinsData(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs &\n OrderByArg<GetAccountCoinsDataResponse[0]> &\n WhereArg<CurrentFungibleAssetBalancesBoolExp>;\n }): Promise<GetAccountCoinsDataResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getAccountCoinsData({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Retrieves the current count of an account's coins aggregated across all types.\n *\n * @param args The parameters for the account coins count query.\n * @param args.accountAddress The account address we want to get the total count for.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @returns The current count of the aggregated coins for the specified account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Getting the account coins count for a specific account\n * const accountCoinsCount = await aptos.getAccountCoinsCount({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(\"Account Coins Count:\", accountCoinsCount);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCoinsCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getAccountCoinsCount({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieves the current amount of APT for a specified account.\n *\n * @param args The arguments for the account query.\n * @param args.accountAddress The account address for which to retrieve the APT amount.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @returns The current amount of APT for the specified account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the APT amount for a specific account\n * const accountAPTAmount = await aptos.getAccountAPTAmount({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(\"Account APT Amount:\", accountAPTAmount);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountAPTAmount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n return this.getAccountCoinAmount({ coinType: APTOS_COIN, faMetadataAddress: APTOS_FA, ...args });\n }\n\n /**\n * Queries the current amount of a specified coin held by an account.\n *\n * @param args The parameters for querying the account's coin amount.\n * @param args.accountAddress The account address to query for the coin amount.\n * @param args.coinType The coin type to query. Note: If not provided, it may be automatically populated if `faMetadataAddress`\n * is specified.\n * @param args.faMetadataAddress The fungible asset metadata address to query. Note: If not provided, it may be automatically\n * populated if `coinType` is specified.\n * @param args.minimumLedgerVersion Not used anymore, here for backward compatibility\n * see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, will be removed in the near future.\n * Optional ledger version to sync up to before querying.\n * @returns The current amount of the specified coin held by the account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Query the account's coin amount for a specific coin type\n * const accountCoinAmount = await aptos.getAccountCoinAmount({\n * accountAddress: \"0x1\", // replace with a real account address\n * coinType: \"0x1::aptos_coin::AptosCoin\" // specify the coin type\n * });\n *\n * console.log(`Account coin amount: ${accountCoinAmount}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCoinAmount(args: {\n accountAddress: AccountAddressInput;\n coinType?: MoveStructId;\n faMetadataAddress?: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n const { accountAddress, coinType, faMetadataAddress, minimumLedgerVersion } = args;\n\n if (minimumLedgerVersion) {\n // eslint-disable-next-line no-console\n console.warn(\n `minimumLedgerVersion is not used anymore, here for backward \n compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, \n will be removed in the near future`,\n );\n }\n // Attempt to populate the CoinType field if the FA address is provided.\n // We cannot do this internally due to dependency cycles issue.\n let coinAssetType: MoveStructId | undefined = coinType;\n if (coinType === undefined && faMetadataAddress !== undefined) {\n coinAssetType = await memoizeAsync(\n async () => {\n try {\n const pairedCoinTypeStruct = (\n await view({\n aptosConfig: this.config,\n payload: { function: \"0x1::coin::paired_coin\", functionArguments: [faMetadataAddress] },\n })\n ).at(0) as { vec: MoveValue[] };\n\n // Check if the Option has a value, and if so, parse the struct\n if (pairedCoinTypeStruct.vec.length > 0 && isEncodedStruct(pairedCoinTypeStruct.vec[0])) {\n return parseEncodedStruct(pairedCoinTypeStruct.vec[0]) as MoveStructId;\n }\n } catch (error) {\n /* No paired coin type found */\n }\n return undefined;\n },\n `coin-mapping-${faMetadataAddress.toString()}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n }\n\n let faAddress: string;\n\n if (coinType !== undefined && faMetadataAddress !== undefined) {\n faAddress = AccountAddress.from(faMetadataAddress).toStringLong();\n } else if (coinType !== undefined && faMetadataAddress === undefined) {\n // TODO Move to a separate function as defined in the AIP for coin migration\n if (coinType === APTOS_COIN) {\n faAddress = AccountAddress.A.toStringLong();\n } else {\n faAddress = createObjectAddress(AccountAddress.A, coinType).toStringLong();\n }\n } else if (coinType === undefined && faMetadataAddress !== undefined) {\n const addr = AccountAddress.from(faMetadataAddress);\n faAddress = addr.toStringLong();\n if (addr === AccountAddress.A) {\n coinAssetType = APTOS_COIN;\n }\n // The paired CoinType should be populated outside of this function in another\n // async call. We cannot do this internally due to dependency cycles issue.\n } else {\n throw new Error(\"Either coinType, faMetadataAddress, or both must be provided\");\n }\n\n // When there is a coin mapping, use that first, otherwise use the fungible asset address\n // TODO: This function's signature at the top, returns number, but it could be greater than can be represented\n if (coinAssetType !== undefined) {\n const [balanceStr] = await view<[string]>({\n aptosConfig: this.config,\n payload: {\n function: \"0x1::coin::balance\",\n typeArguments: [coinAssetType],\n functionArguments: [accountAddress],\n },\n });\n return parseInt(balanceStr, 10);\n }\n const [balanceStr] = await view<[string]>({\n aptosConfig: this.config,\n payload: {\n function: \"0x1::primary_fungible_store::balance\",\n typeArguments: [\"0x1::object::ObjectCore\"],\n functionArguments: [accountAddress, faAddress],\n },\n });\n return parseInt(balanceStr, 10);\n }\n\n /**\n * Queries an account's owned objects.\n *\n * @param args.accountAddress The account address we want to get the objects for.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @param args.options.offset The starting position to start returning results from.\n * @param args.options.limit The number of results to return.\n * @param args.options.orderBy The order to sort the objects by.\n * @returns Objects array with the object data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the objects owned by the specified account\n * const accountOwnedObjects = await aptos.getAccountOwnedObjects({\n * accountAddress: \"0x1\", // replace with a real account address\n * minimumLedgerVersion: 1, // optional, specify if needed\n * options: {\n * offset: 0, // optional, specify if needed\n * limit: 10, // optional, specify if needed\n * orderBy: \"created_at\", // optional, specify if needed\n * },\n * });\n *\n * console.log(accountOwnedObjects);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountOwnedObjects(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs & OrderByArg<GetObjectDataQueryResponse[0]>;\n }): Promise<GetObjectDataQueryResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.DEFAULT,\n });\n return getAccountOwnedObjects({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Derives an account by providing a private key. This function resolves the provided private key type and derives the public\n * key from it.\n *\n * If the privateKey is a Secp256k1 type, it derives the account using the derived public key and auth key using the SingleKey\n * scheme locally.\n * If the privateKey is an ED25519 type, it looks up the authentication key on chain to determine whether it is a Legacy ED25519\n * key or a Unified ED25519 key, and then derives the account based on that.\n *\n * @param args - The arguments for deriving the account.\n * @param args.privateKey - An account private key.\n * @returns The derived Account type.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Ed25519PrivateKey } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Deriving an account from a private key\n * const account = await aptos.deriveAccountFromPrivateKey({\n * privateKey: new Ed25519PrivateKey(\"0x123\") // replace with a real private key\n * });\n *\n * console.log(account);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async deriveAccountFromPrivateKey(args: { privateKey: PrivateKey }): Promise<AccountModule> {\n return deriveAccountFromPrivateKey({ aptosConfig: this.config, ...args });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/Users/greg/git/aptos-ts-sdk/dist/common/index.js","../../src/bcs/deserializer.ts","../../src/bcs/serializable/fixedBytes.ts","../../src/bcs/serializable/entryFunctionBytes.ts","../../src/bcs/serializable/movePrimitives.ts","../../src/bcs/serializable/moveStructs.ts","../../src/core/crypto/ed25519.ts","../../src/core/authenticationKey.ts","../../src/errors/index.ts","../../src/core/crypto/keyless.ts","../../src/types/generated/queries.ts","../../src/internal/transaction.ts","../../src/api/account.ts","../../src/internal/digitalAsset.ts"],"names":["Deserializer","_Deserializer","data","hex","Hex","length","bytes","value","type","len","bool","low","high","shift","MAX_U32_NUMBER","byte","cls","vector","FixedBytes","_FixedBytes","Serializable","serializer","deserializer","EntryFunctionBytes","_EntryFunctionBytes","fixedBytes","Bool","_Bool","ensureBoolean","bcsBytes","U256","U8","_U8","validateNumberInRange","MAX_U8_NUMBER","U16","_U16","MAX_U16_NUMBER","U32","_U32","U64","_U64","MAX_U64_BIG_INT","U128","_U128","MAX_U128_BIG_INT","_U256","MAX_U256_BIG_INT","MoveVector","_MoveVector","values","Serialized","numbers","v","MoveString","i","_Serialized","vec","_MoveString","fixedStringBytes","MoveOption","_MoveOption","_AuthenticationKey","args","waitForTransaction"],"mappings":"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","file":"/Users/greg/git/aptos-ts-sdk/dist/common/index.js","sourcesContent":[null,"// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport { MAX_U32_NUMBER } from \"./consts\";\nimport { Uint8, Uint16, Uint32, Uint64, Uint128, Uint256, HexInput } from \"../types\";\nimport { Hex } from \"../core/hex\";\n\n/**\n * This interface exists to define Deserializable<T> inputs for functions that\n * deserialize a byte buffer into a type T.\n * It is not intended to be implemented or extended, because Typescript has no support\n * for static methods in interfaces.\n *\n * @template T - The type that this will deserialize into.\n * @group Implementation\n * @category BCS\n */\nexport interface Deserializable<T> {\n /**\n * Deserializes the buffered bytes into an instance of the specified class type.\n * This function provides an alternative syntax for deserialization, allowing users to call\n * `deserializer.deserialize(MyClass)` instead of `MyClass.deserialize(deserializer)`.\n *\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @returns The deserialized value of class type T.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * ```\n * @group Implementation\n * @category BCS\n */\n deserialize(deserializer: Deserializer): T;\n}\n\n/**\n * A class that provides methods for deserializing various data types from a byte buffer.\n * It supports deserialization of primitive types, strings, and complex objects using a BCS (Binary Common Serialization) layout.\n * @group Implementation\n * @category BCS\n */\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n /**\n * Creates a new instance of the class with a copy of the provided data buffer.\n * This prevents outside mutation of the buffer.\n *\n * @param data - The data to be copied into the internal buffer as a Uint8Array.\n * @group Implementation\n * @category BCS\n */\n constructor(data: Uint8Array) {\n // copies data to prevent outside mutation of buffer.\n this.buffer = new ArrayBuffer(data.length);\n new Uint8Array(this.buffer).set(data, 0);\n this.offset = 0;\n }\n\n static fromHex(hex: HexInput): Deserializer {\n const data = Hex.hexInputToUint8Array(hex);\n return new Deserializer(data);\n }\n\n /**\n * Reads a specified number of bytes from the buffer and advances the offset.\n *\n * @param length - The number of bytes to read from the buffer.\n * @throws Throws an error if the read operation exceeds the buffer's length.\n * @group Implementation\n * @category BCS\n */\n private read(length: number): ArrayBuffer {\n if (this.offset + length > this.buffer.byteLength) {\n throw new Error(\"Reached to the end of buffer\");\n }\n\n const bytes = this.buffer.slice(this.offset, this.offset + length);\n this.offset += length;\n return bytes;\n }\n\n /**\n * Returns the number of bytes remaining in the buffer.\n *\n * This information is useful to determine if there's more data to be read.\n *\n * @returns The number of bytes remaining in the buffer.\n * @group Implementation\n * @category BCS\n */\n remaining(): number {\n return this.buffer.byteLength - this.offset;\n }\n\n /**\n * Deserializes a UTF-8 encoded string from a byte array. It first reads the length of the string in bytes,\n * followed by the actual byte content, and decodes it into a string.\n *\n * BCS layout for \"string\": string_length | string_content\n * where string_length is a u32 integer encoded as a uleb128 integer, equal to the number of bytes in string_content.\n *\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeStr() === \"1234abcd\");\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * @deprecated use `deserializeOption(\"string\")` instead.\n *\n * The BCS layout for Optional<String> is 0 if none, else 1 followed by the string length and string content.\n * @returns The deserialized string if it exists, otherwise undefined.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00]));\n * assert(deserializer.deserializeOptionStr() === undefined);\n * const deserializer = new Deserializer(new Uint8Array([1, 8, 49, 50, 51, 52, 97, 98, 99, 100]));\n * assert(deserializer.deserializeOptionStr() === \"1234abcd\");\n * ```\n */\n deserializeOptionStr(): string | undefined {\n return this.deserializeOption(\"string\");\n }\n\n /**\n * Deserializes an optional value from the buffer.\n *\n * The BCS layout for Optional<T> starts with a boolean byte (0 if none, 1 if some),\n * followed by the value if present.\n *\n * @template T - The type of the value to deserialize\n * @param type - Either a Deserializable class or one of the string literals: \"string\", \"bytes\", or \"fixedBytes\"\n * @param len - Required length when type is \"fixedBytes\", ignored otherwise\n * @returns The deserialized value if present, undefined otherwise\n *\n * @throws {Error} When \"fixedBytes\" is specified without a length\n *\n * @example\n * ```typescript\n * // Deserialize an optional string\n * const deserializer = new Deserializer(new Uint8Array([1, 3, 97, 98, 99]));\n * const optStr = deserializer.deserializeOption(\"string\");\n * // optStr === \"abc\"\n *\n * // Deserialize an optional custom type\n * const deserializer = new Deserializer(new Uint8Array([0]));\n * const optValue = deserializer.deserializeOption(MyClass);\n * // optValue === undefined\n *\n * // Deserialize optional bytes\n * const deserializer = new Deserializer(new Uint8Array([1, 3, 1, 2, 3]));\n * const optBytes = deserializer.deserializeOption(\"bytes\");\n * // optBytes === Uint8Array[1, 2, 3]\n *\n * // Deserialize optional fixed bytes\n * const deserializer = new Deserializer(new Uint8Array([1, 1, 2, 3, 4]));\n * const optBytes = deserializer.deserializeOption(\"fixedBytes\", 4);\n * // optBytes === Uint8Array[1, 2, 3, 4]\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeOption(type: \"string\"): string | undefined;\n deserializeOption(type: \"bytes\"): Uint8Array | undefined;\n deserializeOption(type: \"fixedBytes\", len: number): Uint8Array | undefined;\n deserializeOption<T>(type: Deserializable<T>): T | undefined;\n deserializeOption<T>(\n type: Deserializable<T> | \"string\" | \"bytes\" | \"fixedBytes\",\n len?: number,\n ): T | string | Uint8Array | undefined {\n const exists = this.deserializeBool();\n if (!exists) return undefined;\n\n if (type === \"string\") {\n return this.deserializeStr();\n }\n if (type === \"bytes\") {\n return this.deserializeBytes();\n }\n if (type === \"fixedBytes\") {\n if (len === undefined) {\n throw new Error(\"Fixed bytes length not provided\");\n }\n return this.deserializeFixedBytes(len);\n }\n\n return this.deserialize(type);\n }\n\n /**\n * Deserializes an array of bytes.\n *\n * The BCS layout for \"bytes\" consists of a bytes_length followed by the bytes themselves, where bytes_length is a u32 integer\n * encoded as a uleb128 integer, indicating the length of the bytes array.\n *\n * @returns {Uint8Array} The deserialized array of bytes.\n * @group Implementation\n * @category BCS\n */\n deserializeBytes(): Uint8Array {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes of a specified length.\n *\n * @param len - The number of bytes to read from the source.\n * @group Implementation\n * @category BCS\n */\n deserializeFixedBytes(len: number): Uint8Array {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value from a byte stream.\n *\n * The BCS layout for a boolean uses one byte, where \"0x01\" represents true and \"0x00\" represents false.\n * An error is thrown if the byte value is not valid.\n *\n * @returns The deserialized boolean value.\n * @throws Throws an error if the boolean value is invalid.\n * @group Implementation\n * @category BCS\n */\n deserializeBool(): boolean {\n const bool = new Uint8Array(this.read(1))[0];\n if (bool !== 1 && bool !== 0) {\n throw new Error(\"Invalid boolean value\");\n }\n return bool === 1;\n }\n\n /**\n * Deserializes a uint8 number from the binary data.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n *\n * @returns {number} The deserialized uint8 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint16\": Two bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number from a binary format in little-endian representation.\n *\n * BCS layout for \"uint32\": Four bytes.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * This function combines two 32-bit values to return a 64-bit unsigned integer in little-endian representation.\n * @example\n * ```typescript\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\n * @group Implementation\n * @category BCS\n */\n deserializeU64(): Uint64 {\n const low = this.deserializeU32();\n const high = this.deserializeU32();\n\n // combine the two 32-bit values and return (little endian)\n return BigInt((BigInt(high) << BigInt(32)) | BigInt(low));\n }\n\n /**\n * Deserializes a uint128 number from its binary representation.\n * This function combines two 64-bit values to return a single uint128 value in little-endian format.\n *\n * @returns {BigInt} The deserialized uint128 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU128(): Uint128 {\n const low = this.deserializeU64();\n const high = this.deserializeU64();\n\n // combine the two 64-bit values and return (little endian)\n return BigInt((high << BigInt(64)) | low);\n }\n\n /**\n * Deserializes a uint256 number from its binary representation.\n *\n * The BCS layout for \"uint256\" consists of thirty-two bytes in little-endian format.\n *\n * @returns {BigInt} The deserialized uint256 number.\n * @group Implementation\n * @category BCS\n */\n deserializeU256(): Uint256 {\n const low = this.deserializeU128();\n const high = this.deserializeU128();\n\n // combine the two 128-bit values and return (little endian)\n return BigInt((high << BigInt(128)) | low);\n }\n\n /**\n * Deserializes a uleb128 encoded uint32 number.\n *\n * This function is used for interpreting lengths of variable-length sequences and tags of enum values in BCS encoding.\n *\n * @throws {Error} Throws an error if the parsed value exceeds the maximum uint32 number.\n * @returns {number} The deserialized uint32 value.\n * @group Implementation\n * @category BCS\n */\n deserializeUleb128AsU32(): Uint32 {\n let value: bigint = BigInt(0);\n let shift = 0;\n\n while (value < MAX_U32_NUMBER) {\n const byte = this.deserializeU8();\n value |= BigInt(byte & 0x7f) << BigInt(shift);\n\n if ((byte & 0x80) === 0) {\n break;\n }\n shift += 7;\n }\n\n if (value > MAX_U32_NUMBER) {\n throw new Error(\"Overflow while parsing uleb128-encoded uint32 value\");\n }\n\n return Number(value);\n }\n\n /**\n * Helper function that primarily exists to support alternative syntax for deserialization.\n * That is, if we have a `const deserializer: new Deserializer(...)`, instead of having to use\n * `MyClass.deserialize(deserializer)`, we can call `deserializer.deserialize(MyClass)`.\n *\n * @example const deserializer = new Deserializer(new Uint8Array([1, 2, 3]));\n * const value = deserializer.deserialize(MyClass); // where MyClass has a `deserialize` function\n * // value is now an instance of MyClass\n * // equivalent to `const value = MyClass.deserialize(deserializer)`\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n *\n * @returns the deserialized value of class type T\n * @group Implementation\n * @category BCS\n */\n deserialize<T>(cls: Deserializable<T>): T {\n // NOTE: `deserialize` in `cls.deserialize(this)` here is a static method defined in `cls`,\n // It is separate from the `deserialize` instance method defined here in Deserializer.\n return cls.deserialize(this);\n }\n\n /**\n * Deserializes an array of BCS Deserializable values given an existing Deserializer instance with a loaded byte buffer.\n *\n * @param cls The BCS-deserializable class to deserialize the buffered bytes into.\n * @returns An array of deserialized values of type T.\n * @example\n * // serialize a vector of addresses\n * const addresses = new Array<AccountAddress>(\n * AccountAddress.from(\"0x1\"),\n * AccountAddress.from(\"0x2\"),\n * AccountAddress.from(\"0xa\"),\n * AccountAddress.from(\"0xb\"),\n * );\n * const serializer = new Serializer();\n * serializer.serializeVector(addresses);\n * const serializedBytes = serializer.toUint8Array();\n *\n * // deserialize the bytes into an array of addresses\n * const deserializer = new Deserializer(serializedBytes);\n * const deserializedAddresses = deserializer.deserializeVector(AccountAddress);\n * // deserializedAddresses is now an array of AccountAddress instances\n * @group Implementation\n * @category BCS\n */\n deserializeVector<T>(cls: Deserializable<T>): Array<T> {\n const length = this.deserializeUleb128AsU32();\n const vector = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n vector.push(this.deserialize(cls));\n }\n return vector;\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Serializer, Serializable } from \"../serializer\";\nimport { Deserializer } from \"../deserializer\";\nimport { HexInput } from \"../../types\";\nimport { Hex } from \"../../core/hex\";\nimport { TransactionArgument } from \"../../transactions/instances/transactionArgument\";\n\n/**\n * Represents a contiguous sequence of already serialized BCS bytes.\n * \n * This class differs from most other Serializable classes in that its internal byte buffer is serialized to BCS\n * bytes exactly as-is, without prepending the length of the bytes. It is ideal for scenarios where custom serialization\n * is required, such as passing serialized bytes as transaction arguments. Additionally, it serves as a representation \n * of type-agnostic BCS bytes, akin to a vector<u8>.\n * \n * An example use case includes handling bytes resulting from entry function arguments that have been serialized \n * for an entry function.\n * \n * @example\n * const yourCustomSerializedBytes = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);\n * const fixedBytes = new FixedBytes(yourCustomSerializedBytes);\n * const payload = await generateTransactionPayload({\n * function: \"0xbeefcafe::your_module::your_function_that_requires_custom_serialization\",\n * functionArguments: [yourCustomBytes],\n * });\n * \n * This class is particularly useful when you want to handle a fixed-size byte array without the overhead of \n * length prepending, such as when dealing with 32-byte addresses stored as U8 in a MoveVector<U8>.\n\n * For example, if you store each of the 32 bytes for an address as a U8 in a MoveVector<U8>, when you\n * serialize that MoveVector<U8>, it will be serialized to 33 bytes. If you solely want to pass around\n * the 32 bytes as a Serializable class that *does not* prepend the length to the BCS-serialized representation,\n * use this class.* \n * @param value - HexInput representing a sequence of Uint8 bytes.\n * @returns A Serializable FixedBytes instance, which when serialized, does not prepend the length of the bytes.\n * @see EntryFunctionBytes\n * @group Implementation\n * @category BCS\n */\nexport class FixedBytes extends Serializable implements TransactionArgument {\n public value: Uint8Array;\n\n /**\n * Creates an instance of the class with a specified hexadecimal input.\n * The value is converted from hexadecimal format to a Uint8Array.\n *\n * @param value - The hexadecimal input to be converted.\n * @group Implementation\n * @category BCS\n */\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n /**\n * Serializes the fixed bytes value using the provided serializer.\n * This function is essential for converting the fixed bytes into a format suitable for storage or transmission.\n *\n * @param serializer - The serializer instance used for serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.value);\n }\n\n /**\n * Serializes the current instance for an entry function using the provided serializer.\n * This allows the instance to be converted into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serialize(this);\n }\n\n /**\n * Serializes the current instance using the provided serializer.\n * This function is essential for preparing data to be passed as arguments in script functions.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serialize(this);\n }\n\n /**\n * Deserializes a fixed-length byte array from the provided deserializer.\n * This function helps in reconstructing a FixedBytes object from the serialized data.\n *\n * @param deserializer - The deserializer instance used to read the byte data.\n * @param length - The length of the byte array to be deserialized.\n * @group Implementation\n * @category BCS\n */\n static deserialize(deserializer: Deserializer, length: number): FixedBytes {\n const bytes = deserializer.deserializeFixedBytes(length);\n return new FixedBytes(bytes);\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Serializer, Serializable } from \"../serializer\";\nimport { Deserializer } from \"../deserializer\";\nimport { FixedBytes } from \"./fixedBytes\";\nimport { EntryFunctionArgument } from \"../../transactions/instances/transactionArgument\";\nimport { HexInput } from \"../../types\";\n\n/**\n * This class exists solely to represent a sequence of fixed bytes as a serialized entry function, because\n * serializing an entry function appends a prefix that's *only* used for entry function arguments.\n *\n * NOTE: Using this class for serialized script functions will lead to erroneous and unexpected behavior.\n *\n * If you wish to convert this class back to a TransactionArgument, you must know the type\n * of the argument beforehand, and use the appropriate class to deserialize the bytes within\n * an instance of this class.\n * @group Implementation\n * @category BCS\n */\nexport class EntryFunctionBytes extends Serializable implements EntryFunctionArgument {\n public readonly value: FixedBytes;\n\n /**\n * Creates an instance of the class with a specified hexadecimal input value.\n *\n * @param value - The hexadecimal input to be converted into FixedBytes.\n * @group Implementation\n * @category BCS\n */\n private constructor(value: HexInput) {\n super();\n this.value = new FixedBytes(value);\n }\n\n // Note that to see the Move, BCS-serialized representation of the underlying fixed byte vector,\n // we must not serialize the length prefix.\n //\n // In other words, this class is only used to represent a sequence of bytes that are already\n // BCS-serialized as a type. To represent those bytes accurately, the BCS-serialized form is the same exact\n // representation.\n\n /**\n * Serializes the value using the provided serializer.\n * This function is essential for accurately representing a sequence of bytes that are already BCS-serialized as a type.\n *\n * Note that to see the Move, BCS-serialized representation of the underlying fixed byte vector,\n * we must not serialize the length prefix.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void {\n serializer.serialize(this.value);\n }\n\n // When we serialize these bytes as an entry function argument, we need to\n // serialize the length prefix. This essentially converts the underlying fixed byte vector to a type-agnostic\n // byte vector to an `any` type.\n // NOTE: This, and the lack of a `serializeForScriptFunction`, is the only meaningful difference between this\n // class and FixedBytes.\n\n /**\n * Serializes the current instance for use as an entry function argument by converting the underlying fixed byte vector to a\n * type-agnostic byte vector.\n * This process includes serializing the length prefix of the byte vector.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.value.value.length);\n serializer.serialize(this);\n }\n\n /**\n * The only way to create an instance of this class is to use this static method.\n * This function should only be used when deserializing a sequence of EntryFunctionPayload arguments.\n * @param deserializer - The deserializer instance with the buffered bytes.\n * @param length - The length of the bytes to deserialize.\n * @returns An instance of this class, which will now only be usable as an EntryFunctionArgument.\n * @group Implementation\n * @category BCS\n */\n static deserialize(deserializer: Deserializer, length: number): EntryFunctionBytes {\n const fixedBytes = FixedBytes.deserialize(deserializer, length);\n return new EntryFunctionBytes(fixedBytes.value);\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n} from \"../consts\";\nimport { Deserializer } from \"../deserializer\";\nimport { Serializable, Serializer, ensureBoolean, validateNumberInRange } from \"../serializer\";\nimport { TransactionArgument } from \"../../transactions/instances/transactionArgument\";\nimport { AnyNumber, Uint16, Uint32, Uint8, ScriptTransactionArgumentVariants } from \"../../types\";\n\n/**\n * Represents a boolean value that can be serialized and deserialized.\n * This class extends the Serializable class and provides methods to serialize\n * the boolean value for different contexts, such as entry functions and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class Bool extends Serializable implements TransactionArgument {\n public readonly value: boolean;\n\n /**\n * Constructs a new instance with a specified value.\n * This ensures that the value is validated to be within the acceptable range.\n *\n * @param value - The number to be validated and assigned, which must be between 0 and MAX_U256_BIG_INT.\n * @group Implementation\n * @category BCS\n */\n constructor(value: boolean) {\n super();\n\n /**\n * Ensures that the provided value is of type boolean.\n * This function throws an error if the value is not a boolean, helping to enforce type safety in your code.\n *\n * @param value - The value to be checked for boolean type.\n * @throws {Error} Throws an error if the value is not a boolean.\n * @group Implementation\n * @category BCS\n */\n ensureBoolean(value);\n this.value = value;\n }\n\n /**\n * Serializes the value using the provided serializer.\n * This function is essential for converting the value into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBool(this.value);\n }\n\n /**\n * Serializes the current instance for use in an entry function by converting it to a byte sequence.\n * This allows the instance to be properly formatted for serialization in transactions.\n *\n * @param serializer - The serializer instance used to serialize the byte sequence.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Serializes the current instance for use in a script function.\n * This allows for the conversion of the instance into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Bool);\n serializer.serialize(this);\n }\n\n /**\n * Deserializes a U256 value from the provided deserializer.\n *\n * @param deserializer - The deserializer instance used to read the U256 data.\n * @group Implementation\n * @category BCS\n */\n // eslint-disable-next-line class-methods-use-this\n deserialize(deserializer: Deserializer) {\n return new U256(deserializer.deserializeU256());\n }\n\n static deserialize(deserializer: Deserializer): Bool {\n return new Bool(deserializer.deserializeBool());\n }\n}\n\n/**\n * Represents an unsigned 8-bit integer (U8) value.\n * This class extends the Serializable class and provides methods for serialization and deserialization of U8 values.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U8 extends Serializable implements TransactionArgument {\n public readonly value: Uint8;\n\n constructor(value: Uint8) {\n super();\n validateNumberInRange(value, 0, MAX_U8_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU8(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U8 {\n return new U8(deserializer.deserializeU8());\n }\n}\n\n/**\n * Represents a 16-bit unsigned integer (U16) value.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of the U16 value.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U16 extends Serializable implements TransactionArgument {\n public readonly value: Uint16;\n\n constructor(value: Uint16) {\n super();\n validateNumberInRange(value, 0, MAX_U16_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU16(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U16);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U16 {\n return new U16(deserializer.deserializeU16());\n }\n}\n\n/**\n * Represents a 32-bit unsigned integer (U32) that can be serialized and deserialized.\n * This class ensures that the value is within the valid range for a U32.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U32 extends Serializable implements TransactionArgument {\n public readonly value: Uint32;\n\n constructor(value: Uint32) {\n super();\n validateNumberInRange(value, 0, MAX_U32_NUMBER);\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U32);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U32 {\n return new U32(deserializer.deserializeU32());\n }\n}\n\n/**\n * Represents a 64-bit unsigned integer (U64) and provides methods for serialization.\n *\n * This class ensures that the value is within the valid range for a U64 and provides\n * functionality to serialize the value for various use cases, including entry functions\n * and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U64 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U64_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU64(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U64);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U64 {\n return new U64(deserializer.deserializeU64());\n }\n}\n\n/**\n * Represents a 128-bit unsigned integer value.\n * This class provides methods for serialization and deserialization\n * of U128 values, ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U128 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U128_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU128(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U128);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U128 {\n return new U128(deserializer.deserializeU128());\n }\n}\n\n/**\n * Represents a 256-bit unsigned integer (U256) that extends the Serializable class.\n * This class provides methods for serialization and deserialization of U256 values,\n * ensuring that the values are within the valid range.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class U256 extends Serializable implements TransactionArgument {\n public readonly value: bigint;\n\n constructor(value: AnyNumber) {\n super();\n validateNumberInRange(value, BigInt(0), MAX_U256_BIG_INT);\n this.value = BigInt(value);\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU256(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U256);\n serializer.serialize(this);\n }\n\n static deserialize(deserializer: Deserializer): U256 {\n return new U256(deserializer.deserializeU256());\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Bool, U128, U16, U256, U32, U64, U8 } from \"./movePrimitives\";\nimport { Serializable, Serializer } from \"../serializer\";\nimport { Deserializable, Deserializer } from \"../deserializer\";\nimport { AnyNumber, HexInput, ScriptTransactionArgumentVariants } from \"../../types\";\nimport { Hex } from \"../../core/hex\";\nimport { EntryFunctionArgument, TransactionArgument } from \"../../transactions/instances/transactionArgument\";\n\n/**\n * This class is the Aptos Typescript SDK representation of a Move `vector<T>`,\n * where `T` represents either a primitive type (`bool`, `u8`, `u64`, ...)\n * or a BCS-serializable struct itself.\n *\n * It is a BCS-serializable, array-like type that contains an array of values of type `T`,\n * where `T` is a class that implements `Serializable`.\n *\n * The purpose of this class is to facilitate easy construction of BCS-serializable\n * Move `vector<T>` types.\n *\n * @example\n * // in Move: `vector<u8> [1, 2, 3, 4];`\n * const vecOfU8s = new MoveVector<U8>([new U8(1), new U8(2), new U8(3), new U8(4)]);\n * // in Move: `std::bcs::to_bytes(vector<u8> [1, 2, 3, 4]);`\n * const bcsBytes = vecOfU8s.toUint8Array();\n *\n * // vector<vector<u8>> [ vector<u8> [1], vector<u8> [1, 2, 3, 4], vector<u8> [5, 6, 7, 8] ];\n * const vecOfVecs = new MoveVector<MoveVector<U8>>([\n * new MoveVector<U8>([new U8(1)]),\n * MoveVector.U8([1, 2, 3, 4]),\n * MoveVector.U8([5, 6, 7, 8]),\n * ]);\n *\n * // vector<Option<u8>> [ std::option::some<u8>(1), std::option::some<u8>(2) ];\n * const vecOfOptionU8s = new MoveVector<MoveOption<U8>>([\n * MoveOption.U8(1),\n * MoveOption.U8(2),\n * ]);\n *\n * // vector<MoveString> [ std::string::utf8(b\"hello\"), std::string::utf8(b\"world\") ];\n * const vecOfStrings = new MoveVector([new MoveString(\"hello\"), new MoveString(\"world\")]);\n * const vecOfStrings2 = MoveVector.MoveString([\"hello\", \"world\"]);\n *\n * @param values an Array<T> of values where T is a class that implements Serializable\n * @returns a `MoveVector<T>` with the values `values`\n * @group Implementation\n * @category BCS\n */\nexport class MoveVector<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements TransactionArgument\n{\n public values: Array<T>;\n\n /**\n * Initializes a new instance of the class with an optional value.\n * This constructor sets up the internal vector based on the provided value.\n *\n * @param values - The initial value to be stored in the vector, or null to initialize an empty vector.\n * @group Implementation\n * @category BCS\n */\n constructor(values: Array<T>) {\n super();\n this.values = values;\n }\n\n /**\n * Serializes the current instance into a byte sequence suitable for entry functions.\n * This allows the data to be properly formatted for transmission or storage.\n *\n * @param serializer - The serializer instance used to serialize the byte sequence.\n * @group Implementation\n * @category BCS\n */\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * NOTE: This function will only work when the inner values in the `MoveVector` are `U8`s.\n * @param serializer\n * @group Implementation\n * @category BCS\n */\n\n /**\n * Serialize the string as a fixed byte string without the length prefix for use in a script function.\n * @param serializer - The serializer used to convert the byte vector into a format suitable for a script function.\n * @group Implementation\n * @category BCS\n */\n serializeForScriptFunction(serializer: Serializer): void {\n // This checks if the type of a non-empty vector is of type other than U8. If so, we use the Serialized\n // transaction argument type to serialize the argument.\n if (this.values[0] !== undefined && !(this.values[0] instanceof U8)) {\n const serialized = new Serialized(this.bcsToBytes());\n serialized.serializeForScriptFunction(serializer);\n return;\n }\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.U8Vector);\n serializer.serialize(this);\n }\n\n /**\n * Factory method to generate a MoveVector<U8> from a `number` or `undefined`.\n *\n * This method allows you to create a MoveVector that encapsulates a U8 value, enabling you to handle optional U8 values\n * effectively.\n *\n * @param values - The values used to fill the MoveVector. If `values` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U8> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U8([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U8(values: Array<number> | HexInput): MoveVector<U8> {\n let numbers: Array<number>;\n\n if (Array.isArray(values) && values.length === 0) {\n // Handle empty array, since it won't have a \"first value\"\n numbers = [];\n } else if (Array.isArray(values) && typeof values[0] === \"number\") {\n numbers = values;\n } else if (typeof values === \"string\") {\n const hex = Hex.fromHexInput(values);\n numbers = Array.from(hex.toUint8Array());\n } else if (values instanceof Uint8Array) {\n numbers = Array.from(values);\n } else {\n throw new Error(\"Invalid input type, must be an number[], Uint8Array, or hex string\");\n }\n\n return new MoveVector<U8>(numbers.map((v) => new U8(v)));\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `null`.\n *\n * This method allows you to create a MoveVector that can either hold a U16 value or be empty.\n *\n * @param values - The value used to fill the MoveVector. If `value` is null or undefined, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U16> with an inner value `value`.\n * @example\n * ```typescript\n * const v = MoveVector.U16([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n\n */\n static U16(values: Array<number>): MoveVector<U16> {\n return new MoveVector<U16>(values.map((v) => new U16(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U32> from a `number` or `null`.\n *\n * This method allows you to create a MoveVector that can either hold a U32 value or be empty.\n *\n * @param values - The value used to fill the MoveVector. If `value` is null or undefined,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U32> with an inner value `value`.\n *\n * @example\n * ```\n * const v = MoveVector.U32([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n\n */\n static U32(values: Array<number>): MoveVector<U32> {\n return new MoveVector<U32>(values.map((v) => new U32(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U64> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U64 value that can be checked for presence.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null, the resulting MoveVector's\n * `.isSome()` method will return false.\n * @returns A MoveVector<U64> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U64([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U64(values: Array<AnyNumber>): MoveVector<U64> {\n return new MoveVector<U64>(values.map((v) => new U64(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U128> from a number, bigint, or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's `.isSome()`\n * method will return false.\n * @returns A MoveVector<U128> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U128([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U128(values: Array<AnyNumber>): MoveVector<U128> {\n return new MoveVector<U128>(values.map((v) => new U128(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<U256> from a number, bigint, or null/undefined.\n * This allows for the creation of an optional U256 value, enabling checks for presence or absence of a value.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined or null,\n * the resulting MoveVector's .isSome() method will return false.\n * @returns A MoveVector<U256> with an inner value `value`.\n *\n * @example\n * ```typescript\n * const v = MoveVector.U256([1, 2, 3, 4]);\n * ```\n * @group Implementation\n * @category BCS\n */\n static U256(values: Array<AnyNumber>): MoveVector<U256> {\n return new MoveVector<U256>(values.map((v) => new U256(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<Bool> from a `boolean` or `undefined`.\n * This method allows you to create an optional boolean value that can be used in various contexts where a boolean may or may\n * not be present.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<Bool> with an inner value `value`.\n *\n * @example\n * * const v = MoveVector.Bool([true, false, true, false]);\n * @group Implementation\n * @category BCS\n */\n static Bool(values: Array<boolean>): MoveVector<Bool> {\n return new MoveVector<Bool>(values.map((v) => new Bool(v)));\n }\n\n /**\n * Factory method to generate a MoveVector<MoveString> from a `string` or `undefined`.\n * This function creates a MoveVector that encapsulates a MoveString if the provided value is not null or undefined.\n *\n * @param values - The value used to fill the MoveVector. If `value` is undefined, the resulting MoveVector's .isSome() method\n * will return false.\n * @returns A MoveVector<MoveString> with an inner value `value`.\n *\n * @example\n * const v = MoveVector.MoveString([\"hello\", \"world\"]);\n * @group Implementation\n * @category BCS\n */\n static MoveString(values: Array<string>): MoveVector<MoveString> {\n return new MoveVector<MoveString>(values.map((v) => new MoveString(v)));\n }\n\n /**\n * Serializes the current object using the provided serializer.\n * This function will serialize the value if it is present.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category BCS\n */\n serialize(serializer: Serializer): void;\n serialize(serializer: Serializer): void {\n serializer.serializeVector(this.values);\n }\n\n /**\n * Deserialize a MoveVector of type T, specifically where T is a Serializable and Deserializable type.\n *\n * NOTE: This only works with a depth of one. Generics will not work.\n *\n * NOTE: This will not work with types that aren't of the Serializable class.\n *\n * If you're looking for a more flexible deserialization function, you can use the deserializeVector function\n * in the Deserializer class.\n *\n * @example\n * const vec = MoveVector.deserialize(deserializer, U64);\n * @param deserializer the Deserializer instance to use, with bytes loaded into it already.\n * @param cls the class to typecast the input values to, must be a Serializable and Deserializable type.\n * @returns a MoveVector of the corresponding class T\n *\n * @group Implementation\n * @category BCS\n */\n static deserialize<T extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<T>,\n ): MoveVector<T> {\n const length = deserializer.deserializeUleb128AsU32();\n const values = new Array<T>();\n for (let i = 0; i < length; i += 1) {\n values.push(cls.deserialize(deserializer));\n }\n return new MoveVector(values);\n }\n}\n\n/**\n * Represents a serialized data structure that encapsulates a byte array.\n * This class extends the Serializable class and provides methods for serialization\n * and deserialization of byte data, as well as converting to a MoveVector.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class Serialized extends Serializable implements TransactionArgument {\n public readonly value: Uint8Array;\n\n constructor(value: HexInput) {\n super();\n this.value = Hex.fromHexInput(value).toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n this.serialize(serializer);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(ScriptTransactionArgumentVariants.Serialized);\n this.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Serialized {\n return new Serialized(deserializer.deserializeBytes());\n }\n\n /**\n * Deserialize the bytecode into a MoveVector of the specified type.\n * This function allows you to convert serialized data into a usable MoveVector format.\n *\n * @param cls - The class type of the elements in the MoveVector.\n * @group Implementation\n * @category BCS\n */\n toMoveVector<T extends Serializable & EntryFunctionArgument>(cls: Deserializable<T>): MoveVector<T> {\n const deserializer = new Deserializer(this.bcsToBytes());\n deserializer.deserializeUleb128AsU32();\n const vec = deserializer.deserializeVector(cls);\n return new MoveVector(vec);\n }\n}\n\n/**\n * Represents a string value that can be serialized and deserialized.\n * This class extends the Serializable base class and provides methods\n * for serializing the string in different contexts, such as for entry\n * functions and script functions.\n *\n * @extends Serializable\n * @group Implementation\n * @category BCS\n */\nexport class MoveString extends Serializable implements TransactionArgument {\n public value: string;\n\n constructor(value: string) {\n super();\n this.value = value;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.value);\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n serializeForScriptFunction(serializer: Serializer): void {\n // Serialize the string as a fixed byte string, i.e., without the length prefix\n const textEncoder = new TextEncoder();\n const fixedStringBytes = textEncoder.encode(this.value);\n // Put those bytes into a vector<u8> and serialize it as a script function argument\n const vectorU8 = MoveVector.U8(fixedStringBytes);\n vectorU8.serializeForScriptFunction(serializer);\n }\n\n static deserialize(deserializer: Deserializer): MoveString {\n return new MoveString(deserializer.deserializeStr());\n }\n}\n\nexport class MoveOption<T extends Serializable & EntryFunctionArgument>\n extends Serializable\n implements EntryFunctionArgument\n{\n private vec: MoveVector<T>;\n\n public readonly value?: T;\n\n constructor(value?: T | null) {\n super();\n if (typeof value !== \"undefined\" && value !== null) {\n this.vec = new MoveVector([value]);\n } else {\n this.vec = new MoveVector([]);\n }\n\n [this.value] = this.vec.values;\n }\n\n serializeForEntryFunction(serializer: Serializer): void {\n const bcsBytes = this.bcsToBytes();\n serializer.serializeBytes(bcsBytes);\n }\n\n /**\n * Retrieves the inner value of the MoveOption.\n *\n * This method is inspired by Rust's `Option<T>.unwrap()`, where attempting to unwrap a `None` value results in a panic.\n * This method will throw an error if the value is not present.\n *\n * @example\n * const option = new MoveOption<Bool>(new Bool(true));\n * const value = option.unwrap(); // Returns the Bool instance\n *\n * @throws {Error} Throws an error if the MoveOption does not contain a value.\n *\n * @returns {T} The contained value if present.\n * @group Implementation\n * @category BCS\n */\n unwrap(): T {\n if (!this.isSome()) {\n throw new Error(\"Called unwrap on a MoveOption with no value\");\n } else {\n return this.vec.values[0];\n }\n }\n\n /**\n * Check if the MoveOption has a value.\n *\n * @returns {boolean} Returns true if there is exactly one value in the MoveOption.\n * @group Implementation\n * @category BCS\n */\n isSome(): boolean {\n return this.vec.values.length === 1;\n }\n\n serialize(serializer: Serializer): void {\n // serialize 0 or 1\n // if 1, serialize the value\n this.vec.serialize(serializer);\n }\n\n /**\n * Factory method to generate a MoveOption<U8> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U8(1).isSome() === true;\n * MoveOption.U8().isSome() === false;\n * MoveOption.U8(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U8> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U8(value?: number | null): MoveOption<U8> {\n return new MoveOption<U8>(value !== null && value !== undefined ? new U8(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U16> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U16(1).isSome() === true;\n * MoveOption.U16().isSome() === false;\n * MoveOption.U16(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U16> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U16(value?: number | null): MoveOption<U16> {\n return new MoveOption<U16>(value !== null && value !== undefined ? new U16(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U32> from a `number` or `undefined`.\n *\n * @example\n * MoveOption.U32(1).isSome() === true;\n * MoveOption.U32().isSome() === false;\n * MoveOption.U32(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U32> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U32(value?: number | null): MoveOption<U32> {\n return new MoveOption<U32>(value !== null && value !== undefined ? new U32(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U64> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U64(1).isSome() === true;\n * MoveOption.U64().isSome() === false;\n * MoveOption.U64(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U64> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U64(value?: AnyNumber | null): MoveOption<U64> {\n return new MoveOption<U64>(value !== null && value !== undefined ? new U64(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U128> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U128(1).isSome() === true;\n * MoveOption.U128().isSome() === false;\n * MoveOption.U128(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U128> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U128(value?: AnyNumber | null): MoveOption<U128> {\n return new MoveOption<U128>(value !== null && value !== undefined ? new U128(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<U256> from a `number` or a `bigint` or `undefined`.\n *\n * @example\n * MoveOption.U256(1).isSome() === true;\n * MoveOption.U256().isSome() === false;\n * MoveOption.U256(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<U256> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static U256(value?: AnyNumber | null): MoveOption<U256> {\n return new MoveOption<U256>(value !== null && value !== undefined ? new U256(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<Bool> from a `boolean` or `undefined`.\n *\n * @example\n * MoveOption.Bool(true).isSome() === true;\n * MoveOption.Bool().isSome() === false;\n * MoveOption.Bool(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<Bool> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static Bool(value?: boolean | null): MoveOption<Bool> {\n return new MoveOption<Bool>(value !== null && value !== undefined ? new Bool(value) : undefined);\n }\n\n /**\n * Factory method to generate a MoveOption<MoveString> from a `string` or `undefined`.\n *\n * @example\n * MoveOption.MoveString(\"hello\").isSome() === true;\n * MoveOption.MoveString(\"\").isSome() === true;\n * MoveOption.MoveString().isSome() === false;\n * MoveOption.MoveString(undefined).isSome() === false;\n * @param value the value used to fill the MoveOption. If `value` is undefined\n * the resulting MoveOption's .isSome() method will return false.\n * @returns a MoveOption<MoveString> with an inner value `value`\n * @group Implementation\n * @category BCS\n */\n static MoveString(value?: string | null): MoveOption<MoveString> {\n return new MoveOption<MoveString>(value !== null && value !== undefined ? new MoveString(value) : undefined);\n }\n\n static deserialize<U extends Serializable & EntryFunctionArgument>(\n deserializer: Deserializer,\n cls: Deserializable<U>,\n ): MoveOption<U> {\n const vector = MoveVector.deserialize(deserializer, cls);\n return new MoveOption(vector.values[0]);\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { ed25519 } from \"@noble/curves/ed25519\";\nimport { Deserializer } from \"../../bcs/deserializer\";\nimport { Serializable, Serializer } from \"../../bcs/serializer\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Hex } from \"../hex\";\nimport { HexInput, SigningScheme as AuthenticationKeyScheme, PrivateKeyVariants } from \"../../types\";\nimport { CKDPriv, deriveKey, HARDENED_OFFSET, isValidHardenedPath, mnemonicToSeed, splitPath } from \"./hdKey\";\nimport { PrivateKey } from \"./privateKey\";\nimport { AccountPublicKey, PublicKey, VerifySignatureArgs } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { convertSigningMessage } from \"./utils\";\n\n/**\n * L is the value that greater than or equal to will produce a non-canonical signature, and must be rejected\n * @group Implementation\n * @category Serialization\n */\nconst L: number[] = [\n 0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58, 0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14, 0x00, 0x00, 0x00,\n 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\n];\n\n/**\n * Checks if an ED25519 signature is non-canonical.\n * This function helps determine the validity of a signature by verifying its canonical form.\n *\n * @param signature - The signature to be checked for canonicality.\n * @returns A boolean indicating whether the signature is non-canonical.\n *\n * Comes from Aptos Core\n * https://github.com/aptos-labs/aptos-core/blob/main/crates/aptos-crypto/src/ed25519/ed25519_sigs.rs#L47-L85\n * @group Implementation\n * @category Serialization\n */\nexport function isCanonicalEd25519Signature(signature: Signature): boolean {\n const s = signature.toUint8Array().slice(32);\n for (let i = L.length - 1; i >= 0; i -= 1) {\n if (s[i] < L[i]) {\n return true;\n }\n if (s[i] > L[i]) {\n return false;\n }\n }\n // As this stage S == L which implies a non-canonical S.\n return false;\n}\n\n/**\n * Represents the public key of an Ed25519 key pair.\n *\n * Since [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263) Aptos supports\n * `Legacy` and `Unified` authentication keys.\n *\n * Ed25519 scheme is represented in the SDK as `Legacy authentication key` and also\n * as `AnyPublicKey` that represents any `Unified authentication key`.\n * @group Implementation\n * @category Serialization\n */\nexport class Ed25519PublicKey extends AccountPublicKey {\n /**\n * Length of an Ed25519 public key\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * Bytes of the public key\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly key: Hex;\n\n /**\n * Creates an instance of the Ed25519Signature class from a hex input.\n * This constructor validates the length of the signature to ensure it meets the required specifications.\n *\n * @param hexInput - The hex input representing the Ed25519 signature.\n * @throws Error if the signature length is not equal to Ed25519Signature.LENGTH.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput) {\n super();\n\n const hex = Hex.fromHexInput(hexInput);\n if (hex.toUint8Array().length !== Ed25519PublicKey.LENGTH) {\n throw new Error(`PublicKey length should be ${Ed25519PublicKey.LENGTH}`);\n }\n this.key = hex;\n }\n\n // region AccountPublicKey\n\n /**\n * Verifies a signed message using a public key.\n *\n * @param args - The arguments for verification.\n * @param args.message - A signed message as a Hex string or Uint8Array.\n * @param args.signature - The signature of the message.\n * @group Implementation\n * @category Serialization\n */\n verifySignature(args: VerifySignatureArgs): boolean {\n const { message, signature } = args;\n // Verify malleability\n if (!isCanonicalEd25519Signature(signature)) {\n return false;\n }\n\n const messageToVerify = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToVerify).toUint8Array();\n const signatureBytes = signature.toUint8Array();\n const publicKeyBytes = this.key.toUint8Array();\n return ed25519.verify(signatureBytes, messageBytes, publicKeyBytes);\n }\n\n /**\n * Generates an authentication key from the public key using the Ed25519 scheme.\n * This function is essential for creating a secure authentication key that can be used for further cryptographic operations.\n *\n * @returns {AuthenticationKey} The generated authentication key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: AuthenticationKeyScheme.Ed25519,\n input: this.toUint8Array(),\n });\n }\n\n /**\n * Convert the internal data representation to a Uint8Array.\n *\n * @returns Uint8Array representation of the data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.key.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n /**\n * Serializes the data into a byte array using the provided serializer.\n * This allows for the conversion of data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.key.toUint8Array());\n }\n\n /**\n * Deserialize bytes into an Ed25519Signature object.\n * This function is used to convert serialized byte data into a usable Ed25519Signature instance.\n *\n * @param deserializer - The deserializer instance used to read the byte data.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): Ed25519PublicKey {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519PublicKey(bytes);\n }\n\n // endregion\n\n /**\n * Determine if the provided public key is an instance of Ed25519PublicKey.\n *\n * @param publicKey - The public key to check.\n * @returns True if the public key is an instance of Ed25519PublicKey, otherwise false.\n * @deprecated use `instanceof Ed25519PublicKey` instead.\n * @group Implementation\n * @category Serialization\n */\n static isPublicKey(publicKey: AccountPublicKey): publicKey is Ed25519PublicKey {\n return publicKey instanceof Ed25519PublicKey;\n }\n\n /**\n * Determines if the provided public key is a valid Ed25519 public key.\n * This function checks for the presence of the \"key\" property and verifies that its data length matches the expected length\n * for Ed25519 public keys.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid Ed25519 public key.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey): publicKey is Ed25519PublicKey {\n return \"key\" in publicKey && (publicKey.key as any)?.data?.length === Ed25519PublicKey.LENGTH;\n }\n}\n\n/**\n * Represents the private key of an Ed25519 key pair.\n * @group Implementation\n * @category Serialization\n */\nexport class Ed25519PrivateKey extends Serializable implements PrivateKey {\n /**\n * Length of an Ed25519 private key\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The Ed25519 key seed to use for BIP-32 compatibility\n * See more {@link https://github.com/satoshilabs/slips/blob/master/slip-0010.md}\n * @group Implementation\n * @category Serialization\n */\n static readonly SLIP_0010_SEED = \"ed25519 seed\";\n\n /**\n * The Ed25519 signing key\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly signingKey: Hex;\n\n // region Constructors\n\n /**\n * Create a new PrivateKey instance from a Uint8Array or String.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @param hexInput HexInput (string or Uint8Array)\n * @param strict If true, private key must AIP-80 compliant.\n * @group Implementation\n * @category Serialization\n */\n constructor(hexInput: HexInput, strict?: boolean) {\n super();\n\n const privateKeyHex = PrivateKey.parseHexInput(hexInput, PrivateKeyVariants.Ed25519, strict);\n if (privateKeyHex.toUint8Array().length !== Ed25519PrivateKey.LENGTH) {\n throw new Error(`PrivateKey length should be ${Ed25519PrivateKey.LENGTH}`);\n }\n\n // Create keyPair from Private key in Uint8Array format\n this.signingKey = privateKeyHex;\n }\n\n /**\n * Generate a new random private key.\n *\n * @returns Ed25519PrivateKey A newly generated Ed25519 private key.\n * @group Implementation\n * @category Serialization\n */\n static generate(): Ed25519PrivateKey {\n const keyPair = ed25519.utils.randomPrivateKey();\n return new Ed25519PrivateKey(keyPair, false);\n }\n\n /**\n * Derives a private key from a mnemonic seed phrase using a specified BIP44 path.\n * To derive multiple keys from the same phrase, change the path\n *\n * IMPORTANT: Ed25519 supports hardened derivation only, as it lacks a key homomorphism, making non-hardened derivation impossible.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param mnemonics - The mnemonic seed phrase from which the key will be derived.\n * @throws Error if the provided path is not a valid hardened path.\n * @group Implementation\n * @category Serialization\n */\n static fromDerivationPath(path: string, mnemonics: string): Ed25519PrivateKey {\n if (!isValidHardenedPath(path)) {\n throw new Error(`Invalid derivation path ${path}`);\n }\n return Ed25519PrivateKey.fromDerivationPathInner(path, mnemonicToSeed(mnemonics));\n }\n\n /**\n * Derives a child private key from a given BIP44 path and seed.\n * A private inner function so we can separate from the main fromDerivationPath() method\n * to add tests to verify we create the keys correctly.\n *\n * @param path - The BIP44 path used for key derivation.\n * @param seed - The seed phrase created by the mnemonics, represented as a Uint8Array.\n * @param offset - The offset used for key derivation, defaults to HARDENED_OFFSET.\n * @returns An instance of Ed25519PrivateKey derived from the specified path and seed.\n * @group Implementation\n * @category Serialization\n */\n private static fromDerivationPathInner(path: string, seed: Uint8Array, offset = HARDENED_OFFSET): Ed25519PrivateKey {\n const { key, chainCode } = deriveKey(Ed25519PrivateKey.SLIP_0010_SEED, seed);\n\n const segments = splitPath(path).map((el) => parseInt(el, 10));\n\n // Derive the child key based on the path\n const { key: privateKey } = segments.reduce((parentKeys, segment) => CKDPriv(parentKeys, segment + offset), {\n key,\n chainCode,\n });\n return new Ed25519PrivateKey(privateKey, false);\n }\n\n // endregion\n\n // region PrivateKey\n\n /**\n * Derive the Ed25519PublicKey for this private key.\n *\n * @returns Ed25519PublicKey - The derived public key corresponding to the private key.\n * @group Implementation\n * @category Serialization\n */\n publicKey(): Ed25519PublicKey {\n const bytes = ed25519.getPublicKey(this.signingKey.toUint8Array());\n return new Ed25519PublicKey(bytes);\n }\n\n /**\n * Sign the given message with the private key.\n * This function generates a digital signature for the specified message, ensuring its authenticity and integrity.\n *\n * @param message - A message as a string or Uint8Array in HexInput format.\n * @returns A digital signature for the provided message.\n * @group Implementation\n * @category Serialization\n */\n sign(message: HexInput): Ed25519Signature {\n const messageToSign = convertSigningMessage(message);\n const messageBytes = Hex.fromHexInput(messageToSign).toUint8Array();\n const signatureBytes = ed25519.sign(messageBytes, this.signingKey.toUint8Array());\n return new Ed25519Signature(signatureBytes);\n }\n\n /**\n * Get the private key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the private key\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.signingKey.toUint8Array();\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n * @group Implementation\n * @category Serialization\n */\n toString(): string {\n return this.toHexString();\n }\n\n /**\n * Get the private key as a hex string with the 0x prefix.\n *\n * @returns string representation of the private key.\n */\n toHexString(): string {\n return this.signingKey.toString();\n }\n\n /**\n * Get the private key as a AIP-80 compliant hex string.\n *\n * [Read about AIP-80](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md)\n *\n * @returns AIP-80 compliant string representation of the private key.\n */\n toAIP80String(): string {\n return PrivateKey.formatPrivateKey(this.signingKey.toString(), PrivateKeyVariants.Ed25519);\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Ed25519PrivateKey {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519PrivateKey(bytes, false);\n }\n\n // endregion\n\n /**\n * Determines if the provided private key is an instance of Ed25519PrivateKey.\n *\n * @param privateKey - The private key to check.\n * @returns A boolean indicating whether the private key is an Ed25519PrivateKey.\n *\n * @deprecated Use `instanceof Ed25519PrivateKey` instead.\n * @group Implementation\n * @category Serialization\n */\n static isPrivateKey(privateKey: PrivateKey): privateKey is Ed25519PrivateKey {\n return privateKey instanceof Ed25519PrivateKey;\n }\n}\n\n/**\n * Represents a signature of a message signed using an Ed25519 private key.\n * @group Implementation\n * @category Serialization\n */\nexport class Ed25519Signature extends Signature {\n /**\n * Length of an Ed25519 signature, which is 64 bytes.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH = 64;\n\n /**\n * The signature bytes\n * @private\n * @group Implementation\n * @category Serialization\n */\n private readonly data: Hex;\n\n // region Constructors\n\n constructor(hexInput: HexInput) {\n super();\n const data = Hex.fromHexInput(hexInput);\n if (data.toUint8Array().length !== Ed25519Signature.LENGTH) {\n throw new Error(`Signature length should be ${Ed25519Signature.LENGTH}`);\n }\n this.data = data;\n }\n\n // endregion\n\n // region Signature\n\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n // endregion\n\n // region Serializable\n\n serialize(serializer: Serializer): void {\n serializer.serializeBytes(this.data.toUint8Array());\n }\n\n static deserialize(deserializer: Deserializer): Ed25519Signature {\n const bytes = deserializer.deserializeBytes();\n return new Ed25519Signature(bytes);\n }\n\n // endregion\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { AccountAddress } from \"./accountAddress\";\nimport type { AccountPublicKey } from \"./crypto\";\nimport { Hex } from \"./hex\";\nimport { AuthenticationKeyScheme, HexInput } from \"../types\";\nimport { Serializable, Serializer } from \"../bcs/serializer\";\nimport { Deserializer } from \"../bcs/deserializer\";\n\n/**\n * Represents an authentication key used for account management. Each account stores an authentication key that enables account\n * owners to rotate their private key(s) without changing the address that hosts their account. The authentication key is a\n * SHA3-256 hash of data and is always 32 bytes in length.\n *\n * @see {@link https://aptos.dev/concepts/accounts | Account Basics}\n *\n * Account addresses can be derived from the AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\nexport class AuthenticationKey extends Serializable {\n /**\n * An authentication key is always a SHA3-256 hash of data, and is always 32 bytes.\n *\n * The data to hash depends on the underlying public key type and the derivation scheme.\n * @group Implementation\n * @category Serialization\n */\n static readonly LENGTH: number = 32;\n\n /**\n * The raw bytes of the authentication key.\n * @group Implementation\n * @category Serialization\n */\n public readonly data: Hex;\n\n /**\n * Creates an instance of the AuthenticationKey using the provided hex input.\n * This ensures that the hex input is valid and conforms to the required length for an Authentication Key.\n *\n * @param args - The arguments for constructing the AuthenticationKey.\n * @param args.data - The hex input data to be used for the Authentication Key.\n * @throws {Error} Throws an error if the length of the provided hex input is not equal to the required Authentication Key\n * length.\n * @group Implementation\n * @category Serialization\n */\n constructor(args: { data: HexInput }) {\n super();\n const { data } = args;\n const hex = Hex.fromHexInput(data);\n if (hex.toUint8Array().length !== AuthenticationKey.LENGTH) {\n throw new Error(`Authentication Key length should be ${AuthenticationKey.LENGTH}`);\n }\n this.data = hex;\n }\n\n /**\n * Serializes the fixed bytes data into a format suitable for transmission or storage.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data.toUint8Array());\n }\n\n /**\n * Deserialize an AuthenticationKey from the byte buffer in a Deserializer instance.\n * @param deserializer - The deserializer to deserialize the AuthenticationKey from.\n * @returns An instance of AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): AuthenticationKey {\n const bytes = deserializer.deserializeFixedBytes(AuthenticationKey.LENGTH);\n return new AuthenticationKey({ data: bytes });\n }\n\n /**\n * Convert the internal data representation to a Uint8Array.\n *\n * This function is useful for obtaining a byte representation of the data, which can be utilized for serialization or transmission.\n *\n * @returns Uint8Array representation of the internal data.\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.data.toUint8Array();\n }\n\n /**\n * Generates an AuthenticationKey from the specified scheme and input bytes.\n * This function is essential for creating a valid authentication key based on a given scheme.\n *\n * @param args - The arguments for generating the AuthenticationKey.\n * @param args.scheme - The authentication key scheme to use.\n * @param args.input - The input data in hexadecimal format to derive the key.\n * @returns An instance of AuthenticationKey containing the generated key data.\n * @group Implementation\n * @category Serialization\n */\n static fromSchemeAndBytes(args: { scheme: AuthenticationKeyScheme; input: HexInput }): AuthenticationKey {\n const { scheme, input } = args;\n const inputBytes = Hex.fromHexInput(input).toUint8Array();\n const hashInput = new Uint8Array([...inputBytes, scheme]);\n const hash = sha3Hash.create();\n hash.update(hashInput);\n const hashDigest = hash.digest();\n return new AuthenticationKey({ data: hashDigest });\n }\n\n /**\n * Derives an AuthenticationKey from the provided public key using a specified derivation scheme.\n *\n * @deprecated Use `fromPublicKey` instead.\n * @param args - The arguments for deriving the authentication key.\n * @param args.publicKey - The public key used for the derivation.\n * @param args.scheme - The scheme to use for deriving the authentication key.\n * @group Implementation\n * @category Serialization\n */\n public static fromPublicKeyAndScheme(args: { publicKey: AccountPublicKey; scheme: AuthenticationKeyScheme }) {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Converts a PublicKey to an AuthenticationKey using the derivation scheme inferred from the provided PublicKey instance.\n *\n * @param args - The arguments for the function.\n * @param args.publicKey - The PublicKey to be converted.\n * @returns AuthenticationKey - The derived AuthenticationKey.\n * @group Implementation\n * @category Serialization\n */\n static fromPublicKey(args: { publicKey: AccountPublicKey }): AuthenticationKey {\n const { publicKey } = args;\n return publicKey.authKey();\n }\n\n /**\n * Derives an account address from an AuthenticationKey by translating the AuthenticationKey bytes directly to an AccountAddress.\n *\n * @returns AccountAddress - The derived account address.\n * @group Implementation\n * @category Serialization\n */\n derivedAddress(): AccountAddress {\n return new AccountAddress(this.data.toUint8Array());\n }\n}\n","import { AptosApiType } from \"../utils/const\";\nimport { getErrorMessage } from \"../utils/helpers\";\nimport { AptosRequest, AptosResponse } from \"../types\";\n\nexport enum KeylessErrorCategory {\n API_ERROR,\n EXTERNAL_API_ERROR,\n SESSION_EXPIRED,\n INVALID_STATE,\n UNKNOWN,\n}\n\nexport enum KeylessErrorResolutionTip {\n REAUTHENTICATE = \"Re-authentiate to continue using your keyless account\",\n // eslint-disable-next-line max-len\n REAUTHENTICATE_UNSURE = \"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support\",\n UPDATE_REQUEST_PARAMS = \"Update the invalid request parameters and reauthenticate.\",\n // eslint-disable-next-line max-len\n RATE_LIMIT_EXCEEDED = \"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.\",\n // eslint-disable-next-line max-len\n SERVER_ERROR = \"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n // eslint-disable-next-line max-len\n CALL_PRECHECK = \"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.\",\n REINSTANTIATE = \"Try instantiating the account again. Avoid manipulating the account object directly\",\n JOIN_SUPPORT_GROUP = \"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n UNKNOWN = \"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx\",\n}\n\nexport enum KeylessErrorType {\n EPHEMERAL_KEY_PAIR_EXPIRED,\n\n PROOF_NOT_FOUND,\n\n ASYNC_PROOF_FETCH_FAILED,\n\n INVALID_PROOF_VERIFICATION_FAILED,\n\n INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND,\n\n INVALID_JWT_SIG,\n\n INVALID_JWT_JWK_NOT_FOUND,\n\n INVALID_JWT_ISS_NOT_RECOGNIZED,\n\n INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED,\n\n INVALID_TW_SIG_VERIFICATION_FAILED,\n\n INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND,\n\n INVALID_EXPIRY_HORIZON,\n\n JWT_PARSING_ERROR,\n\n JWK_FETCH_FAILED,\n\n JWK_FETCH_FAILED_FEDERATED,\n\n RATE_LIMIT_EXCEEDED,\n\n PEPPER_SERVICE_INTERNAL_ERROR,\n\n PEPPER_SERVICE_BAD_REQUEST,\n\n PEPPER_SERVICE_OTHER,\n\n PROVER_SERVICE_INTERNAL_ERROR,\n\n PROVER_SERVICE_BAD_REQUEST,\n\n PROVER_SERVICE_OTHER,\n\n FULL_NODE_CONFIG_LOOKUP_ERROR,\n\n FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR,\n\n FULL_NODE_JWKS_LOOKUP_ERROR,\n\n FULL_NODE_OTHER,\n\n UNKNOWN,\n}\n\nconst KeylessErrors: { [key in KeylessErrorType]: [string, KeylessErrorCategory, KeylessErrorResolutionTip] } = {\n [KeylessErrorType.EPHEMERAL_KEY_PAIR_EXPIRED]: [\n \"The ephemeral keypair has expired.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.PROOF_NOT_FOUND]: [\n \"The required proof could not be found.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.CALL_PRECHECK,\n ],\n [KeylessErrorType.ASYNC_PROOF_FETCH_FAILED]: [\n \"The required proof failed to fetch.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_PROOF_VERIFICATION_FAILED]: [\n \"The provided proof is invalid.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND]: [\n \"The verification key used to authenticate was updated.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_JWT_SIG]: [\n \"The JWK was found, but JWT failed verification\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_JWT_JWK_NOT_FOUND]: [\n \"The JWK required to verify the JWT could not be found. The JWK may have been rotated out.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_JWT_ISS_NOT_RECOGNIZED]: [\n \"The JWT issuer is not recognized.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED]: [\n \"The JWT issuer is not supported by the Federated Keyless \",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_TW_SIG_VERIFICATION_FAILED]: [\n \"The training wheels signature is invalid.\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REAUTHENTICATE_UNSURE,\n ],\n [KeylessErrorType.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND]: [\n \"The public key used to verify the training wheels signature was not found.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.INVALID_EXPIRY_HORIZON]: [\n \"The expiry horizon is invalid.\",\n KeylessErrorCategory.SESSION_EXPIRED,\n KeylessErrorResolutionTip.REAUTHENTICATE,\n ],\n [KeylessErrorType.JWK_FETCH_FAILED]: [\n \"Failed to fetch JWKS.\",\n KeylessErrorCategory.EXTERNAL_API_ERROR,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.JWK_FETCH_FAILED_FEDERATED]: [\n \"Failed to fetch JWKS for Federated Keyless provider.\",\n KeylessErrorCategory.EXTERNAL_API_ERROR,\n KeylessErrorResolutionTip.JOIN_SUPPORT_GROUP,\n ],\n [KeylessErrorType.RATE_LIMIT_EXCEEDED]: [\n \"Rate limit exceeded. Too many requests in a short period.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.RATE_LIMIT_EXCEEDED,\n ],\n [KeylessErrorType.PEPPER_SERVICE_INTERNAL_ERROR]: [\n \"Internal error from Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PEPPER_SERVICE_BAD_REQUEST]: [\n \"Bad request sent to Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.PEPPER_SERVICE_OTHER]: [\n \"Unknown error from Pepper service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PROVER_SERVICE_INTERNAL_ERROR]: [\n \"Internal error from Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.PROVER_SERVICE_BAD_REQUEST]: [\n \"Bad request sent to Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.UPDATE_REQUEST_PARAMS,\n ],\n [KeylessErrorType.PROVER_SERVICE_OTHER]: [\n \"Unknown error from Prover service.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.JWT_PARSING_ERROR]: [\n \"Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support\",\n KeylessErrorCategory.INVALID_STATE,\n KeylessErrorResolutionTip.REINSTANTIATE,\n ],\n [KeylessErrorType.FULL_NODE_CONFIG_LOOKUP_ERROR]: [\n \"Error when looking up on-chain keyless configuration.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR]: [\n \"Error when looking up on-chain verification key.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_JWKS_LOOKUP_ERROR]: [\n \"Error when looking up on-chain JWKS.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.FULL_NODE_OTHER]: [\n \"Unknown error from full node.\",\n KeylessErrorCategory.API_ERROR,\n KeylessErrorResolutionTip.SERVER_ERROR,\n ],\n [KeylessErrorType.UNKNOWN]: [\n \"An unknown error has occurred.\",\n KeylessErrorCategory.UNKNOWN,\n KeylessErrorResolutionTip.UNKNOWN,\n ],\n};\n\nexport class KeylessError extends Error {\n readonly innerError?: unknown;\n\n readonly category: KeylessErrorCategory;\n\n readonly resolutionTip: KeylessErrorResolutionTip;\n\n readonly type: KeylessErrorType;\n\n readonly details?: string;\n\n /** @internal this constructor is for sdk internal use - do not instantiate outside of the SDK codebase */\n constructor(args: {\n innerError?: unknown;\n category: KeylessErrorCategory;\n resolutionTip: KeylessErrorResolutionTip;\n type: KeylessErrorType;\n message?: string;\n details?: string;\n }) {\n const { innerError, category, resolutionTip, type, message = KeylessErrors[type][0], details } = args;\n super(message);\n this.name = \"KeylessError\";\n this.innerError = innerError;\n this.category = category;\n this.resolutionTip = resolutionTip;\n this.type = type;\n this.details = details;\n this.message = KeylessError.constructMessage(message, resolutionTip, innerError, details);\n }\n\n static constructMessage(\n message: string,\n tip: KeylessErrorResolutionTip,\n innerError?: unknown,\n details?: string,\n ): string {\n let result = `\\nMessage: ${message}`;\n if (details) {\n result += `\\nDetails: ${details}`;\n }\n if (innerError instanceof AptosApiError) {\n result += `\\nAptosApiError: ${innerError.message}`;\n } else if (innerError !== undefined) {\n result += `\\nError: ${getErrorMessage(innerError)}`;\n }\n result += `\\nKeylessErrorResolutionTip: ${tip}`;\n return result;\n }\n\n /**\n * Static constructor that creates a KeylessError instance using the KeylessErrors constant\n * @param args.type The type of KeylessError\n * @param args.aptosApiError optional AptosApiError supplied for api errors\n * @param args.details optional details to include in the error message\n * @returns A new KeylessError instance\n */\n static fromErrorType(args: { type: KeylessErrorType; error?: unknown; details?: string }): KeylessError {\n const { error, type, details } = args;\n\n const [message, category, resolutionTip] = KeylessErrors[type];\n return new KeylessError({\n message,\n details,\n innerError: error,\n category,\n resolutionTip,\n type,\n });\n }\n}\n\n/**\n * Options for handling errors in the Aptos API.\n */\ntype AptosApiErrorOpts = {\n apiType: AptosApiType;\n aptosRequest: AptosRequest;\n aptosResponse: AptosResponse<any, any>;\n};\n\n/**\n * Represents an error returned from the Aptos API.\n * This class encapsulates the details of the error, including the request URL, response status, and additional data.\n *\n * @param name - The name of the error, which is always \"AptosApiError\".\n * @param url - The URL to which the request was made.\n * @param status - The HTTP response status code (e.g., 400).\n * @param statusText - The message associated with the response status.\n * @param data - The response data returned from the API.\n * @param request - The original AptosRequest that triggered the error.\n */\nexport class AptosApiError extends Error {\n readonly url: string;\n\n readonly status: number;\n\n readonly statusText: string;\n\n readonly data: any;\n\n readonly request: AptosRequest;\n\n /**\n * Constructs an instance of AptosApiError with relevant error details.\n *\n * @param opts - The options for creating the AptosApiError.\n * @param opts.apiType - The type of API that generated the error.\n * @param opts.aptosRequest - The request object that caused the error.\n * @param opts.aptosResponse - The response object containing error details.\n *\n * @internal This constructor is for SDK internal use - do not instantiate outside the SDK codebase.\n */\n constructor({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts) {\n super(deriveErrorMessage({ apiType, aptosRequest, aptosResponse }));\n\n this.name = \"AptosApiError\";\n this.url = aptosResponse.url;\n this.status = aptosResponse.status;\n this.statusText = aptosResponse.statusText;\n this.data = aptosResponse.data;\n this.request = aptosRequest;\n }\n}\n\n/**\n * Derives an error message from the Aptos API response, providing context for debugging.\n * This function helps in understanding the nature of the error encountered during an API request.\n *\n * @param {AptosApiErrorOpts} opts - The options for deriving the error message.\n * @param {AptosApiType} opts.apiType - The type of API being called.\n * @param {AptosRequest} opts.aptosRequest - The original request made to the Aptos API.\n * @param {AptosResponse} opts.aptosResponse - The response received from the Aptos API.\n */\nfunction deriveErrorMessage({ apiType, aptosRequest, aptosResponse }: AptosApiErrorOpts): string {\n // eslint-disable-next-line max-len\n // extract the W3C trace_id from the response headers if it exists. Some services set this in the response, and it's useful for debugging.\n // See https://www.w3.org/TR/trace-context/#relationship-between-the-headers .\n const traceId = aptosResponse.headers?.traceparent?.split(\"-\")[1];\n const traceIdString = traceId ? `(trace_id:${traceId}) ` : \"\";\n\n const errorPrelude: string = `Request to [${apiType}]: ${aptosRequest.method} ${\n aptosResponse.url ?? aptosRequest.url\n } ${traceIdString}failed with`;\n\n // handle graphql responses from indexer api and extract the error message of the first error\n if (apiType === AptosApiType.INDEXER && aptosResponse.data?.errors?.[0]?.message != null) {\n return `${errorPrelude}: ${aptosResponse.data.errors[0].message}`;\n }\n\n // Received well-known structured error response body - simply serialize and return it.\n // We don't need http status codes etc. in this case.\n if (aptosResponse.data?.message != null && aptosResponse.data?.error_code != null) {\n return `${errorPrelude}: ${JSON.stringify(aptosResponse.data)}`;\n }\n\n // This is the generic/catch-all case. We received some response from the API, but it doesn't appear to be a well-known structure.\n // We print http status codes and the response body (after some trimming),\n // in the hope that this gives enough context what went wrong without printing overly huge messages.\n return `${errorPrelude} status: ${aptosResponse.statusText}(code:${\n aptosResponse.status\n }) and response body: ${serializeAnyPayloadForErrorMessage(aptosResponse.data)}`;\n}\n\nconst SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH = 400;\n\n/**\n * This function accepts a payload of any type (probably an object) and serializes it to a string\n * Since we don't know the type or size of the payload, and we don't want to add a huge object in full to the error message\n * we limit the to the first 200 and last 200 characters of the serialized payload and put a \"...\" in the middle.\n * @param payload - The payload to serialize, which can be of any type.\n *\n * @returns A string representation of the serialized payload, potentially truncated.\n */\nfunction serializeAnyPayloadForErrorMessage(payload: any): string {\n const serializedPayload = JSON.stringify(payload);\n if (serializedPayload.length <= SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH) {\n return serializedPayload;\n }\n return `truncated(original_size:${serializedPayload.length}): ${serializedPayload.slice(\n 0,\n SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2,\n )}...${serializedPayload.slice(-SERIALIZED_PAYLOAD_TRIM_TO_MAX_LENGTH / 2)}`;\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n// eslint-disable-next-line max-classes-per-file\nimport { JwtPayload, jwtDecode } from \"jwt-decode\";\nimport { sha3_256 } from \"@noble/hashes/sha3\";\nimport { AccountPublicKey, PublicKey } from \"./publicKey\";\nimport { Signature } from \"./signature\";\nimport { Deserializer, Serializable, Serializer } from \"../../bcs\";\nimport { Hex, hexToAsciiString } from \"../hex\";\nimport {\n HexInput,\n EphemeralCertificateVariant,\n AnyPublicKeyVariant,\n SigningScheme,\n ZkpVariant,\n LedgerVersionArg,\n MoveResource,\n} from \"../../types\";\nimport { EphemeralPublicKey, EphemeralSignature } from \"./ephemeral\";\nimport { bigIntToBytesLE, bytesToBigIntLE, hashStrToField, poseidonHash } from \"./poseidon\";\nimport { AuthenticationKey } from \"../authenticationKey\";\nimport { Proof } from \"./proof\";\nimport { Ed25519PublicKey, Ed25519Signature } from \"./ed25519\";\nimport {\n Groth16VerificationKeyResponse,\n KeylessConfigurationResponse,\n MoveAnyStruct,\n PatchedJWKsResponse,\n} from \"../../types/keyless\";\nimport { AptosConfig } from \"../../api/aptosConfig\";\nimport { getAptosFullNode } from \"../../client\";\nimport { memoizeAsync } from \"../../utils/memoize\";\nimport { AccountAddress, AccountAddressInput } from \"../accountAddress\";\nimport { getErrorMessage } from \"../../utils\";\nimport { KeylessError, KeylessErrorType } from \"../../errors\";\n\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const EPK_HORIZON_SECS = 10000000;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_AUD_VAL_BYTES = 120;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_UID_KEY_BYTES = 30;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_UID_VAL_BYTES = 330;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_ISS_VAL_BYTES = 120;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_EXTRA_FIELD_BYTES = 350;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_JWT_HEADER_B64_BYTES = 300;\n/**\n * @group Implementation\n * @category Serialization\n */\nexport const MAX_COMMITED_EPK_BYTES = 93;\n\n/**\n * Represents a Keyless Public Key used for authentication.\n *\n * This class encapsulates the public key functionality for keyless authentication,\n * including methods for generating and verifying signatures, as well as serialization\n * and deserialization of the key. The KeylessPublicKey is represented in the SDK\n * as `AnyPublicKey`.\n * @group Implementation\n * @category Serialization\n */\nexport class KeylessPublicKey extends AccountPublicKey {\n /**\n * The number of bytes that `idCommitment` should be\n * @group Implementation\n * @category Serialization\n */\n static readonly ID_COMMITMENT_LENGTH: number = 32;\n\n /**\n * The value of the 'iss' claim on the JWT which identifies the OIDC provider.\n * @group Implementation\n * @category Serialization\n */\n readonly iss: string;\n\n /**\n * A value representing a cryptographic commitment to a user identity.\n *\n * It is calculated from the aud, uidKey, uidVal, pepper.\n * @group Implementation\n * @category Serialization\n */\n readonly idCommitment: Uint8Array;\n\n /**\n * Constructs an instance with the specified parameters for cryptographic operations.\n *\n * @param args - The parameters required to initialize the instance.\n * @param args.alphaG1 - The hex representation of the alpha G1 value.\n * @param args.betaG2 - The hex representation of the beta G2 value.\n * @param args.deltaG2 - The hex representation of the delta G2 value.\n * @param args.gammaAbcG1 - An array containing two hex representations for gamma ABC G1 values.\n * @param args.gammaG2 - The hex representation of the gamma G2 value.\n * @group Implementation\n * @category Serialization\n */\n // TODO: Fix the JSDoc for the below values\n constructor(iss: string, idCommitment: HexInput) {\n super();\n const idcBytes = Hex.fromHexInput(idCommitment).toUint8Array();\n if (idcBytes.length !== KeylessPublicKey.ID_COMMITMENT_LENGTH) {\n throw new Error(`Id Commitment length in bytes should be ${KeylessPublicKey.ID_COMMITMENT_LENGTH}`);\n }\n this.iss = iss;\n this.idCommitment = idcBytes;\n }\n\n /**\n * Get the authentication key for the keyless public key.\n *\n * @returns AuthenticationKey - The authentication key derived from the keyless public key.\n * @group Implementation\n * @category Serialization\n */\n authKey(): AuthenticationKey {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(AnyPublicKeyVariant.Keyless);\n serializer.serializeFixedBytes(this.bcsToBytes());\n return AuthenticationKey.fromSchemeAndBytes({\n scheme: SigningScheme.SingleKey,\n input: serializer.toUint8Array(),\n });\n }\n\n /**\n * Verifies the validity of a signature for a given message.\n *\n * @param args - The arguments for signature verification.\n * @param args.message - The message that was signed.\n * @param args.signature - The signature to verify against the message.\n * @returns true if the signature is valid; otherwise, false.\n * @group Implementation\n * @category Serialization\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, class-methods-use-this\n verifySignature(args: { message: HexInput; signature: KeylessSignature }): boolean {\n throw new Error(\"Not yet implemented\");\n }\n\n /**\n * Serializes the current instance into a format suitable for transmission or storage.\n * This function ensures that all relevant fields are properly serialized, including the proof and optional fields.\n *\n * @param serializer - The serializer instance used to perform the serialization.\n * @param serializer.proof - The proof to be serialized.\n * @param serializer.expHorizonSecs - The expiration horizon in seconds.\n * @param serializer.extraField - An optional additional field for serialization.\n * @param serializer.overrideAudVal - An optional override value for auditing.\n * @param serializer.trainingWheelsSignature - An optional signature for training wheels.\n * @group Implementation\n * @category Serialization\n */\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.iss);\n serializer.serializeBytes(this.idCommitment);\n }\n\n /**\n * Deserializes a ZeroKnowledgeSig object from the provided deserializer.\n * This function allows you to reconstruct a ZeroKnowledgeSig instance from its serialized form.\n *\n * @param deserializer - The deserializer instance used to read the serialized data.\n * @returns A new instance of ZeroKnowledgeSig.\n * @group Implementation\n * @category Serialization\n */\n static deserialize(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n /**\n * Loads a KeylessPublicKey instance from the provided deserializer.\n * This function is used to deserialize the necessary components to create a KeylessPublicKey.\n *\n * @param deserializer - The deserializer used to extract the string and byte data.\n * @param deserializer.deserializeStr - A method to deserialize a string value.\n * @param deserializer.deserializeBytes - A method to deserialize byte data.\n * @returns A new instance of KeylessPublicKey.\n * @group Implementation\n * @category Serialization\n */\n static load(deserializer: Deserializer): KeylessPublicKey {\n const iss = deserializer.deserializeStr();\n const addressSeed = deserializer.deserializeBytes();\n return new KeylessPublicKey(iss, addressSeed);\n }\n\n /**\n * Determines if the provided public key is an instance of KeylessPublicKey.\n *\n * @param publicKey - The public key to check.\n * @returns A boolean indicating whether the public key is a KeylessPublicKey instance.\n * @group Implementation\n * @category Serialization\n */\n static isPublicKey(publicKey: PublicKey): publicKey is KeylessPublicKey {\n return publicKey instanceof KeylessPublicKey;\n }\n\n /**\n * Creates a KeylessPublicKey from the JWT components plus pepper\n *\n * @param args.iss the iss of the identity\n * @param args.uidKey the key to use to get the uidVal in the JWT token\n * @param args.uidVal the value of the uidKey in the JWT token\n * @param args.aud the client ID of the application\n * @param args.pepper The pepper used to maintain privacy of the account\n * @returns KeylessPublicKey\n * @group Implementation\n * @category Serialization\n */\n static create(args: {\n iss: string;\n uidKey: string;\n uidVal: string;\n aud: string;\n pepper: HexInput;\n }): KeylessPublicKey {\n computeIdCommitment(args);\n return new KeylessPublicKey(args.iss, computeIdCommitment(args));\n }\n\n /**\n * Creates a KeylessPublicKey instance from a JWT and a pepper value.\n * This function is useful for generating a public key that can be used for authentication based on the provided JWT claims and pepper.\n *\n * @param args - The arguments for creating the KeylessPublicKey.\n * @param args.jwt - The JSON Web Token to decode.\n * @param args.pepper - The pepper value used in the key creation process.\n * @param args.uidKey - An optional key to retrieve the unique identifier from the JWT payload, defaults to \"sub\".\n * @returns A KeylessPublicKey instance created from the provided JWT and pepper.\n * @group Implementation\n * @category Serialization\n */\n static fromJwtAndPepper(args: { jwt: string; pepper: HexInput; uidKey?: string }): KeylessPublicKey {\n const { jwt, pepper, uidKey = \"sub\" } = args;\n const jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n if (typeof jwtPayload.iss !== \"string\") {\n throw new Error(\"iss was not found\");\n }\n if (typeof jwtPayload.aud !== \"string\") {\n throw new Error(\"aud was not found or an array of values\");\n }\n const uidVal = jwtPayload[uidKey];\n return KeylessPublicKey.create({ iss: jwtPayload.iss, uidKey, uidVal, aud: jwtPayload.aud, pepper });\n }\n\n /**\n * Checks if the provided public key is a valid instance by verifying its structure and types.\n *\n * @param publicKey - The public key to validate.\n * @returns A boolean indicating whether the public key is a valid instance.\n * @group Implementation\n * @category Serialization\n */\n static isInstance(publicKey: PublicKey) {\n return (\n \"iss\" in publicKey &&\n typeof publicKey.iss === \"string\" &&\n \"idCommitment\" in publicKey &&\n publicKey.idCommitment instanceof Uint8Array\n );\n }\n}\n\nfunction computeIdCommitment(args: { uidKey: string; uidVal: string; aud: string; pepper: HexInput }): Uint8Array {\n const { uidKey, uidVal, aud, pepper } = args;\n\n const fields = [\n bytesToBigIntLE(Hex.fromHexInput(pepper).toUint8Array()),\n hashStrToField(aud, MAX_AUD_VAL_BYTES),\n hashStrToField(uidVal, MAX_UID_VAL_BYTES),\n hashStrToField(uidKey, MAX_UID_KEY_BYTES),\n ];\n\n return bigIntToBytesLE(poseidonHash(fields), KeylessPublicKey.ID_COMMITMENT_LENGTH);\n}\n\n/**\n * Represents a signature of a message signed via a Keyless Account, utilizing proofs or a JWT token for authentication.\n * @group Implementation\n * @category Serialization\n */\nexport class KeylessSignature extends Signature {\n /**\n * The inner signature ZeroKnowledgeSignature or OpenIdSignature\n * @group Implementation\n * @category Serialization\n */\n readonly ephemeralCertificate: EphemeralCertificate;\n\n /**\n * The jwt header in the token used to create the proof/signature. In json string representation.\n * @group Implementation\n * @category Serialization\n */\n readonly jwtHeader: string;\n\n /**\n * The expiry timestamp in seconds of the EphemeralKeyPair used to sign\n * @group Implementation\n * @category Serialization\n */\n readonly expiryDateSecs: number;\n\n /**\n * The ephemeral public key used to verify the signature\n * @group Implementation\n * @category Serialization\n */\n readonly ephemeralPublicKey: EphemeralPublicKey;\n\n /**\n * The signature resulting from signing with the private key of the EphemeralKeyPair\n * @group Implementation\n * @category Serialization\n */\n readonly ephemeralSignature: EphemeralSignature;\n\n constructor(args: {\n jwtHeader: string;\n ephemeralCertificate: EphemeralCertificate;\n expiryDateSecs: number;\n ephemeralPublicKey: EphemeralPublicKey;\n ephemeralSignature: EphemeralSignature;\n }) {\n super();\n const { jwtHeader, ephemeralCertificate, expiryDateSecs, ephemeralPublicKey, ephemeralSignature } = args;\n this.jwtHeader = jwtHeader;\n this.ephemeralCertificate = ephemeralCertificate;\n this.expiryDateSecs = expiryDateSecs;\n this.ephemeralPublicKey = ephemeralPublicKey;\n this.ephemeralSignature = ephemeralSignature;\n }\n\n /**\n * Get the kid of the JWT used to derive the Keyless Account used to sign.\n *\n * @returns the kid as a string\n */\n getJwkKid(): string {\n return parseJwtHeader(this.jwtHeader).kid;\n }\n\n serialize(serializer: Serializer): void {\n this.ephemeralCertificate.serialize(serializer);\n serializer.serializeStr(this.jwtHeader);\n serializer.serializeU64(this.expiryDateSecs);\n this.ephemeralPublicKey.serialize(serializer);\n this.ephemeralSignature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): KeylessSignature {\n const ephemeralCertificate = EphemeralCertificate.deserialize(deserializer);\n const jwtHeader = deserializer.deserializeStr();\n const expiryDateSecs = deserializer.deserializeU64();\n const ephemeralPublicKey = EphemeralPublicKey.deserialize(deserializer);\n const ephemeralSignature = EphemeralSignature.deserialize(deserializer);\n return new KeylessSignature({\n jwtHeader,\n expiryDateSecs: Number(expiryDateSecs),\n ephemeralCertificate,\n ephemeralPublicKey,\n ephemeralSignature,\n });\n }\n\n static getSimulationSignature(): KeylessSignature {\n return new KeylessSignature({\n jwtHeader: \"{}\",\n ephemeralCertificate: new EphemeralCertificate(\n new ZeroKnowledgeSig({\n proof: new ZkProof(\n new Groth16Zkp({ a: new Uint8Array(32), b: new Uint8Array(64), c: new Uint8Array(32) }),\n ZkpVariant.Groth16,\n ),\n expHorizonSecs: 0,\n }),\n EphemeralCertificateVariant.ZkProof,\n ),\n expiryDateSecs: 0,\n ephemeralPublicKey: new EphemeralPublicKey(new Ed25519PublicKey(new Uint8Array(32))),\n ephemeralSignature: new EphemeralSignature(new Ed25519Signature(new Uint8Array(64))),\n });\n }\n\n static isSignature(signature: Signature): signature is KeylessSignature {\n return signature instanceof KeylessSignature;\n }\n}\n\n/**\n * Represents an ephemeral certificate containing a signature, specifically a ZeroKnowledgeSig.\n * This class can be extended to support additional signature types, such as OpenIdSignature.\n *\n * @extends Signature\n * @group Implementation\n * @category Serialization\n */\nexport class EphemeralCertificate extends Signature {\n public readonly signature: Signature;\n\n /**\n * Index of the underlying enum variant\n * @group Implementation\n * @category Serialization\n */\n private readonly variant: EphemeralCertificateVariant;\n\n constructor(signature: Signature, variant: EphemeralCertificateVariant) {\n super();\n this.signature = signature;\n this.variant = variant;\n }\n\n /**\n * Get the public key in bytes (Uint8Array).\n *\n * @returns Uint8Array representation of the public key\n * @group Implementation\n * @category Serialization\n */\n toUint8Array(): Uint8Array {\n return this.signature.toUint8Array();\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.signature.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): EphemeralCertificate {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case EphemeralCertificateVariant.ZkProof:\n return new EphemeralCertificate(ZeroKnowledgeSig.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for EphemeralCertificate: ${variant}`);\n }\n }\n}\n\n/**\n * Represents a fixed-size byte array of 32 bytes, extending the Serializable class.\n * This class is used for handling and serializing G1 bytes in cryptographic operations.\n *\n * @extends Serializable\n * @group Implementation\n * @category Serialization\n */\nclass G1Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 32) {\n throw new Error(\"Input needs to be 32 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G1Bytes {\n const bytes = deserializer.deserializeFixedBytes(32);\n return new G1Bytes(bytes);\n }\n}\n\n/**\n * Represents a 64-byte G2 element in a cryptographic context.\n * This class provides methods for serialization and deserialization of G2 bytes.\n *\n * @extends Serializable\n * @group Implementation\n * @category Serialization\n */\nclass G2Bytes extends Serializable {\n data: Uint8Array;\n\n constructor(data: HexInput) {\n super();\n this.data = Hex.fromHexInput(data).toUint8Array();\n if (this.data.length !== 64) {\n throw new Error(\"Input needs to be 64 bytes\");\n }\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeFixedBytes(this.data);\n }\n\n static deserialize(deserializer: Deserializer): G2Bytes {\n const bytes = deserializer.deserializeFixedBytes(64);\n return new G2Bytes(bytes);\n }\n}\n\n/**\n * Represents a Groth16 zero-knowledge proof, consisting of three proof points in compressed serialization format.\n * The points are the compressed serialization of affine representation of the proof.\n *\n * @extends Proof\n * @group Implementation\n * @category Serialization\n */\nexport class Groth16Zkp extends Proof {\n /**\n * The bytes of G1 proof point a\n * @group Implementation\n * @category Serialization\n */\n a: G1Bytes;\n\n /**\n * The bytes of G2 proof point b\n * @group Implementation\n * @category Serialization\n */\n b: G2Bytes;\n\n /**\n * The bytes of G1 proof point c\n * @group Implementation\n * @category Serialization\n */\n c: G1Bytes;\n\n constructor(args: { a: HexInput; b: HexInput; c: HexInput }) {\n super();\n const { a, b, c } = args;\n this.a = new G1Bytes(a);\n this.b = new G2Bytes(b);\n this.c = new G1Bytes(c);\n }\n\n serialize(serializer: Serializer): void {\n this.a.serialize(serializer);\n this.b.serialize(serializer);\n this.c.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): Groth16Zkp {\n const a = G1Bytes.deserialize(deserializer).bcsToBytes();\n const b = G2Bytes.deserialize(deserializer).bcsToBytes();\n const c = G1Bytes.deserialize(deserializer).bcsToBytes();\n return new Groth16Zkp({ a, b, c });\n }\n}\n\n/**\n * Represents a container for different types of zero-knowledge proofs.\n *\n * @extends Serializable\n * @group Implementation\n * @category Serialization\n */\nexport class ZkProof extends Serializable {\n public readonly proof: Proof;\n\n /**\n * Index of the underlying enum variant\n * @group Implementation\n * @category Serialization\n */\n private readonly variant: ZkpVariant;\n\n constructor(proof: Proof, variant: ZkpVariant) {\n super();\n this.proof = proof;\n this.variant = variant;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeU32AsUleb128(this.variant);\n this.proof.serialize(serializer);\n }\n\n static deserialize(deserializer: Deserializer): ZkProof {\n const variant = deserializer.deserializeUleb128AsU32();\n switch (variant) {\n case ZkpVariant.Groth16:\n return new ZkProof(Groth16Zkp.deserialize(deserializer), variant);\n default:\n throw new Error(`Unknown variant index for ZkProof: ${variant}`);\n }\n }\n}\n\n/**\n * Represents a zero-knowledge signature, encapsulating the proof and its associated metadata.\n *\n * @extends Signature\n * @group Implementation\n * @category Serialization\n */\nexport class ZeroKnowledgeSig extends Signature {\n /**\n * The proof\n * @group Implementation\n * @category Serialization\n */\n readonly proof: ZkProof;\n\n /**\n * The max lifespan of the proof\n * @group Implementation\n * @category Serialization\n */\n readonly expHorizonSecs: number;\n\n /**\n * A key value pair on the JWT token that can be specified on the signature which would reveal the value on chain.\n * Can be used to assert identity or other attributes.\n * @group Implementation\n * @category Serialization\n */\n readonly extraField?: string;\n\n /**\n * The 'aud' value of the recovery service which is set when recovering an account.\n * @group Implementation\n * @category Serialization\n */\n readonly overrideAudVal?: string;\n\n /**\n * The training wheels signature\n * @group Implementation\n * @category Serialization\n */\n readonly trainingWheelsSignature?: EphemeralSignature;\n\n constructor(args: {\n proof: ZkProof;\n expHorizonSecs: number;\n extraField?: string;\n overrideAudVal?: string;\n trainingWheelsSignature?: EphemeralSignature;\n }) {\n super();\n const { proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal } = args;\n this.proof = proof;\n this.expHorizonSecs = expHorizonSecs;\n this.trainingWheelsSignature = trainingWheelsSignature;\n this.extraField = extraField;\n this.overrideAudVal = overrideAudVal;\n }\n\n /**\n * Deserialize a ZeroKnowledgeSig object from its BCS serialization in bytes.\n *\n * @param bytes - The bytes representing the serialized ZeroKnowledgeSig.\n * @returns ZeroKnowledgeSig - The deserialized ZeroKnowledgeSig object.\n * @group Implementation\n * @category Serialization\n */\n static fromBytes(bytes: Uint8Array): ZeroKnowledgeSig {\n return ZeroKnowledgeSig.deserialize(new Deserializer(bytes));\n }\n\n serialize(serializer: Serializer): void {\n this.proof.serialize(serializer);\n serializer.serializeU64(this.expHorizonSecs);\n serializer.serializeOption(this.extraField);\n serializer.serializeOption(this.overrideAudVal);\n serializer.serializeOption(this.trainingWheelsSignature);\n }\n\n static deserialize(deserializer: Deserializer): ZeroKnowledgeSig {\n const proof = ZkProof.deserialize(deserializer);\n const expHorizonSecs = Number(deserializer.deserializeU64());\n const extraField = deserializer.deserializeOption(\"string\");\n const overrideAudVal = deserializer.deserializeOption(\"string\");\n const trainingWheelsSignature = deserializer.deserializeOption(EphemeralSignature);\n return new ZeroKnowledgeSig({ proof, expHorizonSecs, trainingWheelsSignature, extraField, overrideAudVal });\n }\n}\n\n/**\n * Represents the on-chain configuration for how Keyless accounts operate.\n *\n * @remarks\n * This class encapsulates the verification key and the maximum lifespan of ephemeral key pairs,\n * which are essential for the functionality of Keyless accounts.\n * @group Implementation\n * @category Serialization\n */\nexport class KeylessConfiguration {\n /**\n * The verification key used to verify Groth16 proofs on chain\n * @group Implementation\n * @category Serialization\n */\n readonly verificationKey: Groth16VerificationKey;\n\n /**\n * The maximum lifespan of an ephemeral key pair. This is configured on chain.\n * @group Implementation\n * @category Serialization\n */\n readonly maxExpHorizonSecs: number;\n\n constructor(verificationKey: Groth16VerificationKey, maxExpHorizonSecs: number) {\n this.verificationKey = verificationKey;\n this.maxExpHorizonSecs = maxExpHorizonSecs;\n }\n\n static create(res: Groth16VerificationKeyResponse, maxExpHorizonSecs: number): KeylessConfiguration {\n return new KeylessConfiguration(\n new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n }),\n maxExpHorizonSecs,\n );\n }\n}\n\n/**\n * Represents the verification key stored on-chain used to verify Groth16 proofs.\n * @group Implementation\n * @category Serialization\n */\nexport class Groth16VerificationKey {\n // The docstrings below are borrowed from ark-groth16\n\n /**\n * The `alpha * G`, where `G` is the generator of G1\n * @group Implementation\n * @category Serialization\n */\n readonly alphaG1: G1Bytes;\n\n /**\n * The `alpha * H`, where `H` is the generator of G2\n * @group Implementation\n * @category Serialization\n */\n readonly betaG2: G2Bytes;\n\n /**\n * The `delta * H`, where `H` is the generator of G2\n * @group Implementation\n * @category Serialization\n */\n readonly deltaG2: G2Bytes;\n\n /**\n * The `gamma^{-1} * (beta * a_i + alpha * b_i + c_i) * H`, where H is the generator of G1\n * @group Implementation\n * @category Serialization\n */\n readonly gammaAbcG1: [G1Bytes, G1Bytes];\n\n /**\n * The `gamma * H`, where `H` is the generator of G2\n * @group Implementation\n * @category Serialization\n */\n readonly gammaG2: G2Bytes;\n\n constructor(args: {\n alphaG1: HexInput;\n betaG2: HexInput;\n deltaG2: HexInput;\n gammaAbcG1: [HexInput, HexInput];\n gammaG2: HexInput;\n }) {\n const { alphaG1, betaG2, deltaG2, gammaAbcG1, gammaG2 } = args;\n this.alphaG1 = new G1Bytes(alphaG1);\n this.betaG2 = new G2Bytes(betaG2);\n this.deltaG2 = new G2Bytes(deltaG2);\n this.gammaAbcG1 = [new G1Bytes(gammaAbcG1[0]), new G1Bytes(gammaAbcG1[1])];\n this.gammaG2 = new G2Bytes(gammaG2);\n }\n\n /**\n * Calculates the hash of the serialized form of the verification key.\n * This is useful for comparing verification keys or using them as unique identifiers.\n *\n * @returns The SHA3-256 hash of the serialized verification key as a Uint8Array\n */\n public hash(): Uint8Array {\n const serializer = new Serializer();\n this.serialize(serializer);\n return sha3_256.create().update(serializer.toUint8Array()).digest();\n }\n\n serialize(serializer: Serializer): void {\n this.alphaG1.serialize(serializer);\n this.betaG2.serialize(serializer);\n this.deltaG2.serialize(serializer);\n this.gammaAbcG1[0].serialize(serializer);\n this.gammaAbcG1[1].serialize(serializer);\n this.gammaG2.serialize(serializer);\n }\n\n /**\n * Converts a Groth16VerificationKeyResponse object into a Groth16VerificationKey instance.\n *\n * @param res - The Groth16VerificationKeyResponse object containing the verification key data.\n * @param res.alpha_g1 - The alpha G1 value from the response.\n * @param res.beta_g2 - The beta G2 value from the response.\n * @param res.delta_g2 - The delta G2 value from the response.\n * @param res.gamma_abc_g1 - The gamma ABC G1 value from the response.\n * @param res.gamma_g2 - The gamma G2 value from the response.\n * @returns A Groth16VerificationKey instance constructed from the provided response data.\n * @group Implementation\n * @category Serialization\n */\n static fromGroth16VerificationKeyResponse(res: Groth16VerificationKeyResponse): Groth16VerificationKey {\n return new Groth16VerificationKey({\n alphaG1: res.alpha_g1,\n betaG2: res.beta_g2,\n deltaG2: res.delta_g2,\n gammaAbcG1: res.gamma_abc_g1,\n gammaG2: res.gamma_g2,\n });\n }\n}\n\n/**\n * Retrieves the configuration parameters for Keyless Accounts on the blockchain, including the verifying key and the maximum\n * expiry horizon.\n *\n * @param args - The arguments for retrieving the keyless configuration.\n * @param args.aptosConfig - The Aptos configuration object containing network details.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, the latest version will be used.\n * @returns KeylessConfiguration - The configuration object containing the verifying key and maximum expiry horizon.\n * @group Implementation\n * @category Serialization\n */\nexport async function getKeylessConfig(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfiguration> {\n const { aptosConfig } = args;\n try {\n return await memoizeAsync(\n async () => {\n const config = await getKeylessConfigurationResource(args);\n const vk = await getGroth16VerificationKeyResource(args);\n return KeylessConfiguration.create(vk, Number(config.max_exp_horizon_secs));\n },\n `keyless-configuration-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n } catch (error) {\n if (error instanceof KeylessError) {\n throw error;\n }\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.FULL_NODE_OTHER,\n error,\n });\n }\n}\n\n/**\n * Parses a JWT and returns the 'iss', 'aud', and 'uid' values.\n *\n * @param args - The arguments for parsing the JWT.\n * @param args.jwt - The JWT to parse.\n * @param args.uidKey - The key to use for the 'uid' value; defaults to 'sub'.\n * @returns The 'iss', 'aud', and 'uid' values from the JWT.\n */\nexport function getIssAudAndUidVal(args: { jwt: string; uidKey?: string }): {\n iss: string;\n aud: string;\n uidVal: string;\n} {\n const { jwt, uidKey = \"sub\" } = args;\n let jwtPayload: JwtPayload & { [key: string]: string };\n try {\n jwtPayload = jwtDecode<JwtPayload & { [key: string]: string }>(jwt);\n } catch (error) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.JWT_PARSING_ERROR,\n details: `Failed to parse JWT - ${getErrorMessage(error)}`,\n });\n }\n if (typeof jwtPayload.iss !== \"string\") {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.JWT_PARSING_ERROR,\n details: \"JWT is missing 'iss' in the payload. This should never happen.\",\n });\n }\n if (typeof jwtPayload.aud !== \"string\") {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.JWT_PARSING_ERROR,\n details: \"JWT is missing 'aud' in the payload or 'aud' is an array of values.\",\n });\n }\n const uidVal = jwtPayload[uidKey];\n return { iss: jwtPayload.iss, aud: jwtPayload.aud, uidVal };\n}\n\n/**\n * Retrieves the KeylessConfiguration set on chain.\n *\n * @param args - The arguments for retrieving the configuration.\n * @param args.aptosConfig - The configuration for connecting to the Aptos network.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns KeylessConfigurationResponse - The response containing the keyless configuration data.\n * @group Implementation\n * @category Serialization\n */\nasync function getKeylessConfigurationResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<KeylessConfigurationResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Configuration\";\n try {\n const { data } = await getAptosFullNode<{}, MoveResource<KeylessConfigurationResponse>>({\n aptosConfig,\n originMethod: \"getKeylessConfigurationResource\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n return data.data;\n } catch (error) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.FULL_NODE_CONFIG_LOOKUP_ERROR,\n error,\n });\n }\n}\n\n/**\n * Retrieves the Groth16VerificationKey set on the blockchain.\n *\n * @param args - The arguments for retrieving the verification key.\n * @param args.aptosConfig - The Aptos configuration object.\n * @param args.options - Optional parameters for the request.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns Groth16VerificationKeyResponse - The response containing the Groth16 verification key data.\n * @group Implementation\n * @category Serialization\n */\nasync function getGroth16VerificationKeyResource(args: {\n aptosConfig: AptosConfig;\n options?: LedgerVersionArg;\n}): Promise<Groth16VerificationKeyResponse> {\n const { aptosConfig, options } = args;\n const resourceType = \"0x1::keyless_account::Groth16VerificationKey\";\n try {\n const { data } = await getAptosFullNode<{}, MoveResource<Groth16VerificationKeyResponse>>({\n aptosConfig,\n originMethod: \"getGroth16VerificationKeyResource\",\n path: `accounts/${AccountAddress.from(\"0x1\").toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n return data.data;\n } catch (error) {\n throw KeylessError.fromErrorType({\n type: KeylessErrorType.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR,\n error,\n });\n }\n}\n\nexport async function getKeylessJWKs(args: {\n aptosConfig: AptosConfig;\n jwkAddr?: AccountAddressInput;\n options?: LedgerVersionArg;\n}): Promise<Map<string, MoveJWK[]>> {\n const { aptosConfig, jwkAddr, options } = args;\n let resource: MoveResource<PatchedJWKsResponse>;\n if (!jwkAddr) {\n const resourceType = \"0x1::jwks::PatchedJWKs\";\n const { data } = await getAptosFullNode<{}, MoveResource<PatchedJWKsResponse>>({\n aptosConfig,\n originMethod: \"getKeylessJWKs\",\n path: `accounts/0x1/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n resource = data;\n } else {\n const resourceType = \"0x1::jwks::FederatedJWKs\";\n const { data } = await getAptosFullNode<{}, MoveResource<PatchedJWKsResponse>>({\n aptosConfig,\n originMethod: \"getKeylessJWKs\",\n path: `accounts/${AccountAddress.from(jwkAddr).toString()}/resource/${resourceType}`,\n params: { ledger_version: options?.ledgerVersion },\n });\n resource = data;\n }\n\n // Create a map of issuer to JWK arrays\n const jwkMap = new Map<string, MoveJWK[]>();\n for (const entry of resource.data.jwks.entries) {\n const jwks: MoveJWK[] = [];\n for (const jwkStruct of entry.jwks) {\n const { data: jwkData } = jwkStruct.variant;\n const deserializer = new Deserializer(Hex.fromHexInput(jwkData).toUint8Array());\n const jwk = MoveJWK.deserialize(deserializer);\n jwks.push(jwk);\n }\n jwkMap.set(hexToAsciiString(entry.issuer), jwks);\n }\n\n return jwkMap;\n}\n\nexport class MoveJWK extends Serializable {\n public kid: string;\n\n public kty: string;\n\n public alg: string;\n\n public e: string;\n\n public n: string;\n\n constructor(args: { kid: string; kty: string; alg: string; e: string; n: string }) {\n super();\n const { kid, kty, alg, e, n } = args;\n this.kid = kid;\n this.kty = kty;\n this.alg = alg;\n this.e = e;\n this.n = n;\n }\n\n serialize(serializer: Serializer): void {\n serializer.serializeStr(this.kid);\n serializer.serializeStr(this.kty);\n serializer.serializeStr(this.alg);\n serializer.serializeStr(this.e);\n serializer.serializeStr(this.n);\n }\n\n static fromMoveStruct(struct: MoveAnyStruct): MoveJWK {\n const { data } = struct.variant;\n const deserializer = new Deserializer(Hex.fromHexInput(data).toUint8Array());\n return MoveJWK.deserialize(deserializer);\n }\n\n static deserialize(deserializer: Deserializer): MoveJWK {\n const kid = deserializer.deserializeStr();\n const kty = deserializer.deserializeStr();\n const alg = deserializer.deserializeStr();\n const n = deserializer.deserializeStr();\n const e = deserializer.deserializeStr();\n return new MoveJWK({ kid, kty, alg, n, e });\n }\n}\n\ninterface JwtHeader {\n kid: string; // Key ID\n}\n/**\n * Safely parses the JWT header.\n * @param jwtHeader The JWT header string\n * @returns Parsed JWT header as an object.\n */\nexport function parseJwtHeader(jwtHeader: string): JwtHeader {\n try {\n const header = JSON.parse(jwtHeader);\n if (header.kid === undefined) {\n throw new Error(\"JWT header missing kid\");\n }\n return header;\n } catch (error) {\n throw new Error(\"Failed to parse JWT header.\");\n }\n}\n","import * as Types from \"./operations\";\n\nimport { GraphQLClient, RequestOptions } from \"graphql-request\";\ntype GraphQLClientRequestHeaders = RequestOptions[\"requestHeaders\"];\nexport const TokenActivitiesFieldsFragmentDoc = `\n fragment TokenActivitiesFields on token_activities_v2 {\n after_value\n before_value\n entry_function_id_str\n event_account_address\n event_index\n from_address\n is_fungible_v2\n property_version_v1\n to_address\n token_amount\n token_data_id\n token_standard\n transaction_timestamp\n transaction_version\n type\n}\n `;\nexport const AnsTokenFragmentFragmentDoc = `\n fragment AnsTokenFragment on current_aptos_names {\n domain\n expiration_timestamp\n registered_address\n subdomain\n token_standard\n is_primary\n owner_address\n subdomain_expiration_policy\n domain_expiration_timestamp\n}\n `;\nexport const CurrentTokenOwnershipFieldsFragmentDoc = `\n fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {\n token_standard\n token_properties_mutated_v1\n token_data_id\n table_type_v1\n storage_id\n property_version_v1\n owner_address\n last_transaction_version\n last_transaction_timestamp\n is_soulbound_v2\n is_fungible_v2\n amount\n current_token_data {\n collection_id\n description\n is_fungible_v2\n largest_property_version_v1\n last_transaction_timestamp\n last_transaction_version\n maximum\n supply\n token_data_id\n token_name\n token_properties\n token_standard\n token_uri\n decimals\n current_collection {\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n max_supply\n mutable_description\n mutable_uri\n table_handle_v1\n token_standard\n total_minted_v2\n uri\n }\n }\n}\n `;\nexport const GetAccountCoinsCount = `\n query getAccountCoinsCount($address: String) {\n current_fungible_asset_balances_aggregate(\n where: {owner_address: {_eq: $address}}\n ) {\n aggregate {\n count\n }\n }\n}\n `;\nexport const GetAccountCoinsData = `\n query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {\n current_fungible_asset_balances(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n amount\n asset_type\n is_frozen\n is_primary\n last_transaction_timestamp\n last_transaction_version\n owner_address\n storage_id\n token_standard\n metadata {\n token_standard\n symbol\n supply_aggregator_table_key_v1\n supply_aggregator_table_handle_v1\n project_uri\n name\n last_transaction_version\n last_transaction_timestamp\n icon_uri\n decimals\n creator_address\n asset_type\n }\n }\n}\n `;\nexport const GetAccountCollectionsWithOwnedTokens = `\n query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {\n current_collection_ownership_v2_view(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n current_collection {\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n mutable_description\n max_supply\n mutable_uri\n table_handle_v1\n token_standard\n total_minted_v2\n uri\n }\n collection_id\n collection_name\n collection_uri\n creator_address\n distinct_tokens\n last_transaction_version\n owner_address\n single_token_uri\n }\n}\n `;\nexport const GetAccountOwnedTokens = `\n query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetAccountOwnedTokensByTokenData = `\n query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetAccountOwnedTokensFromCollection = `\n query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetAccountTokensCount = `\n query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {\n current_token_ownerships_v2_aggregate(\n where: $where_condition\n offset: $offset\n limit: $limit\n ) {\n aggregate {\n count\n }\n }\n}\n `;\nexport const GetAccountTransactionsCount = `\n query getAccountTransactionsCount($address: String) {\n account_transactions_aggregate(where: {account_address: {_eq: $address}}) {\n aggregate {\n count\n }\n }\n}\n `;\nexport const GetChainTopUserTransactions = `\n query getChainTopUserTransactions($limit: Int) {\n user_transactions(limit: $limit, order_by: {version: desc}) {\n version\n }\n}\n `;\nexport const GetCollectionData = `\n query getCollectionData($where_condition: current_collections_v2_bool_exp!) {\n current_collections_v2(where: $where_condition) {\n uri\n total_minted_v2\n token_standard\n table_handle_v1\n mutable_uri\n mutable_description\n max_supply\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n cdn_asset_uris {\n cdn_image_uri\n asset_uri\n animation_optimizer_retry_count\n cdn_animation_uri\n cdn_json_uri\n image_optimizer_retry_count\n json_parser_retry_count\n raw_animation_uri\n raw_image_uri\n }\n }\n}\n `;\nexport const GetCurrentFungibleAssetBalances = `\n query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {\n current_fungible_asset_balances(\n where: $where_condition\n offset: $offset\n limit: $limit\n ) {\n amount\n asset_type\n is_frozen\n is_primary\n last_transaction_timestamp\n last_transaction_version\n owner_address\n storage_id\n token_standard\n }\n}\n `;\nexport const GetDelegatedStakingActivities = `\n query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {\n delegated_staking_activities(\n where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}\n ) {\n amount\n delegator_address\n event_index\n event_type\n pool_address\n transaction_version\n }\n}\n `;\nexport const GetEvents = `\n query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {\n events(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n account_address\n creation_number\n data\n event_index\n sequence_number\n transaction_block_height\n transaction_version\n type\n indexed_type\n }\n}\n `;\nexport const GetFungibleAssetActivities = `\n query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {\n fungible_asset_activities(\n where: $where_condition\n offset: $offset\n limit: $limit\n ) {\n amount\n asset_type\n block_height\n entry_function_id_str\n event_index\n gas_fee_payer_address\n is_frozen\n is_gas_fee\n is_transaction_success\n owner_address\n storage_id\n storage_refund_amount\n token_standard\n transaction_timestamp\n transaction_version\n type\n }\n}\n `;\nexport const GetFungibleAssetMetadata = `\n query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {\n fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {\n icon_uri\n project_uri\n supply_aggregator_table_handle_v1\n supply_aggregator_table_key_v1\n creator_address\n asset_type\n decimals\n last_transaction_timestamp\n last_transaction_version\n name\n symbol\n token_standard\n supply_v2\n maximum_v2\n }\n}\n `;\nexport const GetNames = `\n query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {\n current_aptos_names(\n limit: $limit\n where: $where_condition\n order_by: $order_by\n offset: $offset\n ) {\n ...AnsTokenFragment\n }\n}\n ${AnsTokenFragmentFragmentDoc}`;\nexport const GetNumberOfDelegators = `\n query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {\n num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {\n num_active_delegator\n pool_address\n }\n}\n `;\nexport const GetObjectData = `\n query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {\n current_objects(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n allow_ungated_transfer\n state_key_hash\n owner_address\n object_address\n last_transaction_version\n last_guid_creation_num\n is_deleted\n }\n}\n `;\nexport const GetProcessorStatus = `\n query getProcessorStatus($where_condition: processor_status_bool_exp) {\n processor_status(where: $where_condition) {\n last_success_version\n processor\n last_updated\n }\n}\n `;\nexport const GetTableItemsData = `\n query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {\n table_items(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n decoded_key\n decoded_value\n key\n table_handle\n transaction_version\n write_set_change_index\n }\n}\n `;\nexport const GetTableItemsMetadata = `\n query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {\n table_metadatas(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n handle\n key_type\n value_type\n }\n}\n `;\nexport const GetTokenActivity = `\n query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {\n token_activities_v2(\n where: $where_condition\n order_by: $order_by\n offset: $offset\n limit: $limit\n ) {\n ...TokenActivitiesFields\n }\n}\n ${TokenActivitiesFieldsFragmentDoc}`;\nexport const GetCurrentTokenOwnership = `\n query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {\n current_token_ownerships_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n ...CurrentTokenOwnershipFields\n }\n}\n ${CurrentTokenOwnershipFieldsFragmentDoc}`;\nexport const GetTokenData = `\n query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {\n current_token_datas_v2(\n where: $where_condition\n offset: $offset\n limit: $limit\n order_by: $order_by\n ) {\n collection_id\n description\n is_fungible_v2\n largest_property_version_v1\n last_transaction_timestamp\n last_transaction_version\n maximum\n supply\n token_data_id\n token_name\n token_properties\n token_standard\n token_uri\n decimals\n current_collection {\n collection_id\n collection_name\n creator_address\n current_supply\n description\n last_transaction_timestamp\n last_transaction_version\n max_supply\n mutable_description\n mutable_uri\n table_handle_v1\n token_standard\n total_minted_v2\n uri\n }\n }\n}\n `;\n\nexport type SdkFunctionWrapper = <T>(\n action: (requestHeaders?: Record<string, string>) => Promise<T>,\n operationName: string,\n operationType?: string,\n variables?: any,\n) => Promise<T>;\n\nconst defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();\n\nexport function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {\n return {\n getAccountCoinsCount(\n variables?: Types.GetAccountCoinsCountQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountCoinsCountQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountCoinsCountQuery>(GetAccountCoinsCount, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountCoinsCount\",\n \"query\",\n variables,\n );\n },\n getAccountCoinsData(\n variables: Types.GetAccountCoinsDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountCoinsDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountCoinsDataQuery>(GetAccountCoinsData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountCoinsData\",\n \"query\",\n variables,\n );\n },\n getAccountCollectionsWithOwnedTokens(\n variables: Types.GetAccountCollectionsWithOwnedTokensQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountCollectionsWithOwnedTokensQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountCollectionsWithOwnedTokensQuery>(\n GetAccountCollectionsWithOwnedTokens,\n variables,\n { ...requestHeaders, ...wrappedRequestHeaders },\n ),\n \"getAccountCollectionsWithOwnedTokens\",\n \"query\",\n variables,\n );\n },\n getAccountOwnedTokens(\n variables: Types.GetAccountOwnedTokensQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountOwnedTokensQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountOwnedTokensQuery>(GetAccountOwnedTokens, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountOwnedTokens\",\n \"query\",\n variables,\n );\n },\n getAccountOwnedTokensByTokenData(\n variables: Types.GetAccountOwnedTokensByTokenDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountOwnedTokensByTokenDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountOwnedTokensByTokenDataQuery>(GetAccountOwnedTokensByTokenData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountOwnedTokensByTokenData\",\n \"query\",\n variables,\n );\n },\n getAccountOwnedTokensFromCollection(\n variables: Types.GetAccountOwnedTokensFromCollectionQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountOwnedTokensFromCollectionQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountOwnedTokensFromCollectionQuery>(\n GetAccountOwnedTokensFromCollection,\n variables,\n { ...requestHeaders, ...wrappedRequestHeaders },\n ),\n \"getAccountOwnedTokensFromCollection\",\n \"query\",\n variables,\n );\n },\n getAccountTokensCount(\n variables?: Types.GetAccountTokensCountQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountTokensCountQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountTokensCountQuery>(GetAccountTokensCount, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountTokensCount\",\n \"query\",\n variables,\n );\n },\n getAccountTransactionsCount(\n variables?: Types.GetAccountTransactionsCountQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetAccountTransactionsCountQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetAccountTransactionsCountQuery>(GetAccountTransactionsCount, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getAccountTransactionsCount\",\n \"query\",\n variables,\n );\n },\n getChainTopUserTransactions(\n variables?: Types.GetChainTopUserTransactionsQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetChainTopUserTransactionsQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetChainTopUserTransactionsQuery>(GetChainTopUserTransactions, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getChainTopUserTransactions\",\n \"query\",\n variables,\n );\n },\n getCollectionData(\n variables: Types.GetCollectionDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetCollectionDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetCollectionDataQuery>(GetCollectionData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getCollectionData\",\n \"query\",\n variables,\n );\n },\n getCurrentFungibleAssetBalances(\n variables?: Types.GetCurrentFungibleAssetBalancesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetCurrentFungibleAssetBalancesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetCurrentFungibleAssetBalancesQuery>(GetCurrentFungibleAssetBalances, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getCurrentFungibleAssetBalances\",\n \"query\",\n variables,\n );\n },\n getDelegatedStakingActivities(\n variables?: Types.GetDelegatedStakingActivitiesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetDelegatedStakingActivitiesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetDelegatedStakingActivitiesQuery>(GetDelegatedStakingActivities, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getDelegatedStakingActivities\",\n \"query\",\n variables,\n );\n },\n getEvents(\n variables?: Types.GetEventsQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetEventsQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetEventsQuery>(GetEvents, variables, { ...requestHeaders, ...wrappedRequestHeaders }),\n \"getEvents\",\n \"query\",\n variables,\n );\n },\n getFungibleAssetActivities(\n variables?: Types.GetFungibleAssetActivitiesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetFungibleAssetActivitiesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetFungibleAssetActivitiesQuery>(GetFungibleAssetActivities, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getFungibleAssetActivities\",\n \"query\",\n variables,\n );\n },\n getFungibleAssetMetadata(\n variables?: Types.GetFungibleAssetMetadataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetFungibleAssetMetadataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetFungibleAssetMetadataQuery>(GetFungibleAssetMetadata, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getFungibleAssetMetadata\",\n \"query\",\n variables,\n );\n },\n getNames(\n variables?: Types.GetNamesQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetNamesQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetNamesQuery>(GetNames, variables, { ...requestHeaders, ...wrappedRequestHeaders }),\n \"getNames\",\n \"query\",\n variables,\n );\n },\n getNumberOfDelegators(\n variables?: Types.GetNumberOfDelegatorsQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetNumberOfDelegatorsQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetNumberOfDelegatorsQuery>(GetNumberOfDelegators, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getNumberOfDelegators\",\n \"query\",\n variables,\n );\n },\n getObjectData(\n variables?: Types.GetObjectDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetObjectDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetObjectDataQuery>(GetObjectData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getObjectData\",\n \"query\",\n variables,\n );\n },\n getProcessorStatus(\n variables?: Types.GetProcessorStatusQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetProcessorStatusQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetProcessorStatusQuery>(GetProcessorStatus, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getProcessorStatus\",\n \"query\",\n variables,\n );\n },\n getTableItemsData(\n variables: Types.GetTableItemsDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTableItemsDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTableItemsDataQuery>(GetTableItemsData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTableItemsData\",\n \"query\",\n variables,\n );\n },\n getTableItemsMetadata(\n variables: Types.GetTableItemsMetadataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTableItemsMetadataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTableItemsMetadataQuery>(GetTableItemsMetadata, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTableItemsMetadata\",\n \"query\",\n variables,\n );\n },\n getTokenActivity(\n variables: Types.GetTokenActivityQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTokenActivityQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTokenActivityQuery>(GetTokenActivity, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTokenActivity\",\n \"query\",\n variables,\n );\n },\n getCurrentTokenOwnership(\n variables: Types.GetCurrentTokenOwnershipQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetCurrentTokenOwnershipQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetCurrentTokenOwnershipQuery>(GetCurrentTokenOwnership, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getCurrentTokenOwnership\",\n \"query\",\n variables,\n );\n },\n getTokenData(\n variables?: Types.GetTokenDataQueryVariables,\n requestHeaders?: GraphQLClientRequestHeaders,\n ): Promise<Types.GetTokenDataQuery> {\n return withWrapper(\n (wrappedRequestHeaders) =>\n client.request<Types.GetTokenDataQuery>(GetTokenData, variables, {\n ...requestHeaders,\n ...wrappedRequestHeaders,\n }),\n \"getTokenData\",\n \"query\",\n variables,\n );\n },\n };\n}\nexport type Sdk = ReturnType<typeof getSdk>;\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/transaction}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * transaction namespace and without having a dependency cycle error.\n * @group Implementation\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { getAptosFullNode, paginateWithCursor } from \"../client\";\nimport { AptosApiError } from \"../errors\";\nimport {\n TransactionResponseType,\n type AnyNumber,\n type GasEstimation,\n type HexInput,\n type PaginationArgs,\n type TransactionResponse,\n WaitForTransactionOptions,\n CommittedTransactionResponse,\n Block,\n} from \"../types\";\nimport { DEFAULT_TXN_TIMEOUT_SEC, ProcessorType } from \"../utils/const\";\nimport { sleep } from \"../utils/helpers\";\nimport { memoizeAsync } from \"../utils/memoize\";\nimport { getIndexerLastSuccessVersion, getProcessorStatus } from \"./general\";\n\n/**\n * Retrieve a list of transactions based on the specified options.\n *\n * @param {Object} args - The parameters for retrieving transactions.\n * @param {Object} args.aptosConfig - The configuration object for Aptos.\n * @param {Object} args.options - The options for pagination.\n * @param {number} args.options.offset - The number of transactions to skip before starting to collect the result set.\n * @param {number} args.options.limit - The maximum number of transactions to return.\n * @group Implementation\n */\nexport async function getTransactions(args: {\n aptosConfig: AptosConfig;\n options?: PaginationArgs;\n}): Promise<TransactionResponse[]> {\n const { aptosConfig, options } = args;\n return paginateWithCursor<{}, TransactionResponse[]>({\n aptosConfig,\n originMethod: \"getTransactions\",\n path: \"transactions\",\n params: { start: options?.offset, limit: options?.limit },\n });\n}\n\n/**\n * Retrieves the estimated gas price for transactions on the Aptos network.\n * This function helps users understand the current gas price, which is essential for transaction planning and cost estimation.\n *\n * @param args - The configuration parameters for the Aptos network.\n * @param args.aptosConfig - The configuration object containing network details.\n * @group Implementation\n */\nexport async function getGasPriceEstimation(args: { aptosConfig: AptosConfig }) {\n const { aptosConfig } = args;\n\n return memoizeAsync(\n async () => {\n const { data } = await getAptosFullNode<{}, GasEstimation>({\n aptosConfig,\n originMethod: \"getGasPriceEstimation\",\n path: \"estimate_gas_price\",\n });\n return data;\n },\n `gas-price-${aptosConfig.network}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n}\n\n/**\n * Retrieves the transaction details associated with a specific ledger version.\n *\n * @param args - The arguments for the transaction retrieval.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.ledgerVersion - The ledger version for which to retrieve the transaction.\n * @returns The transaction details for the specified ledger version.\n * @group Implementation\n */\nexport async function getTransactionByVersion(args: {\n aptosConfig: AptosConfig;\n ledgerVersion: AnyNumber;\n}): Promise<TransactionResponse> {\n const { aptosConfig, ledgerVersion } = args;\n const { data } = await getAptosFullNode<{}, TransactionResponse>({\n aptosConfig,\n originMethod: \"getTransactionByVersion\",\n path: `transactions/by_version/${ledgerVersion}`,\n });\n return data;\n}\n\n/**\n * Retrieves transaction details using the specified transaction hash.\n *\n * @param args - The arguments for retrieving the transaction.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.transactionHash - The hash of the transaction to retrieve.\n * @returns A promise that resolves to the transaction details.\n * @group Implementation\n */\nexport async function getTransactionByHash(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n}): Promise<TransactionResponse> {\n const { aptosConfig, transactionHash } = args;\n const { data } = await getAptosFullNode<{}, TransactionResponse>({\n aptosConfig,\n path: `transactions/by_hash/${transactionHash}`,\n originMethod: \"getTransactionByHash\",\n });\n return data;\n}\n\n/**\n * Checks if a transaction is currently pending based on its hash.\n * This function helps determine the status of a transaction in the Aptos network.\n *\n * @param args - The arguments for checking the transaction status.\n * @param args.aptosConfig - The configuration settings for connecting to the Aptos network.\n * @param args.transactionHash - The hash of the transaction to check.\n * @returns A boolean indicating whether the transaction is pending.\n * @throws An error if the transaction cannot be retrieved due to reasons other than a 404 status.\n * @group Implementation\n */\nexport async function isTransactionPending(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n}): Promise<boolean> {\n const { aptosConfig, transactionHash } = args;\n try {\n const transaction = await getTransactionByHash({ aptosConfig, transactionHash });\n return transaction.type === TransactionResponseType.Pending;\n } catch (e: any) {\n if (e?.status === 404) {\n return true;\n }\n throw e;\n }\n}\n\n/**\n * Waits for a transaction to be confirmed by its hash.\n * This function allows you to monitor the status of a transaction until it is finalized.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.transactionHash - The hash of the transaction to wait for.\n * @group Implementation\n */\nexport async function longWaitForTransaction(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n}): Promise<TransactionResponse> {\n const { aptosConfig, transactionHash } = args;\n const { data } = await getAptosFullNode<{}, TransactionResponse>({\n aptosConfig,\n path: `transactions/wait_by_hash/${transactionHash}`,\n originMethod: \"longWaitForTransaction\",\n });\n return data;\n}\n\n/**\n * Waits for a transaction to be confirmed on the blockchain and handles potential errors during the process.\n * This function allows you to monitor the status of a transaction until it is either confirmed or fails.\n *\n * @param args - The arguments for waiting for a transaction.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.transactionHash - The hash of the transaction to wait for.\n * @param args.options - Optional settings for waiting, including timeout and success check.\n * @param args.options.timeoutSecs - The maximum time to wait for the transaction in seconds. Defaults to a predefined value.\n * @param args.options.checkSuccess - A flag indicating whether to check the success status of the transaction. Defaults to true.\n * @returns A promise that resolves to the transaction response once the transaction is confirmed.\n * @throws WaitForTransactionError if the transaction times out or remains pending.\n * @throws FailedTransactionError if the transaction fails.\n * @group Implementation\n */\nexport async function waitForTransaction(args: {\n aptosConfig: AptosConfig;\n transactionHash: HexInput;\n options?: WaitForTransactionOptions;\n}): Promise<CommittedTransactionResponse> {\n const { aptosConfig, transactionHash, options } = args;\n const timeoutSecs = options?.timeoutSecs ?? DEFAULT_TXN_TIMEOUT_SEC;\n const checkSuccess = options?.checkSuccess ?? true;\n\n let isPending = true;\n let timeElapsed = 0;\n let lastTxn: TransactionResponse | undefined;\n let lastError: AptosApiError | undefined;\n let backoffIntervalMs = 200;\n const backoffMultiplier = 1.5;\n\n /**\n * Handles API errors by throwing the last error or a timeout error for a failed transaction.\n *\n * @param e - The error object that occurred during the API call.\n * @throws {Error} Throws the last error if it exists; otherwise, throws a WaitForTransactionError indicating a timeout.\n * @group Implementation\n */\n function handleAPIError(e: any) {\n // In short, this means we will retry if it was an AptosApiError and the code was 404 or 5xx.\n const isAptosApiError = e instanceof AptosApiError;\n if (!isAptosApiError) {\n throw e; // This would be unexpected\n }\n lastError = e;\n const isRequestError = e.status !== 404 && e.status >= 400 && e.status < 500;\n if (isRequestError) {\n throw e;\n }\n }\n\n // check to see if the txn is already on the blockchain\n try {\n lastTxn = await getTransactionByHash({ aptosConfig, transactionHash });\n isPending = lastTxn.type === TransactionResponseType.Pending;\n } catch (e) {\n handleAPIError(e);\n }\n\n // If the transaction is pending, we do a long wait once to avoid polling\n if (isPending) {\n const startTime = Date.now();\n try {\n lastTxn = await longWaitForTransaction({ aptosConfig, transactionHash });\n isPending = lastTxn.type === TransactionResponseType.Pending;\n } catch (e) {\n handleAPIError(e);\n }\n timeElapsed = (Date.now() - startTime) / 1000;\n }\n\n // Now we do polling to see if the transaction is still pending\n while (isPending) {\n if (timeElapsed >= timeoutSecs) {\n break;\n }\n try {\n // eslint-disable-next-line no-await-in-loop\n lastTxn = await getTransactionByHash({ aptosConfig, transactionHash });\n\n isPending = lastTxn.type === TransactionResponseType.Pending;\n\n if (!isPending) {\n break;\n }\n } catch (e) {\n handleAPIError(e);\n }\n // eslint-disable-next-line no-await-in-loop\n await sleep(backoffIntervalMs);\n timeElapsed += backoffIntervalMs / 1000; // Convert to seconds\n backoffIntervalMs *= backoffMultiplier;\n }\n\n // There is a chance that lastTxn is still undefined. Let's throw the last error otherwise a WaitForTransactionError\n if (lastTxn === undefined) {\n if (lastError) {\n throw lastError;\n } else {\n throw new WaitForTransactionError(\n `Fetching transaction ${transactionHash} failed and timed out after ${timeoutSecs} seconds`,\n lastTxn,\n );\n }\n }\n\n if (lastTxn.type === TransactionResponseType.Pending) {\n throw new WaitForTransactionError(\n `Transaction ${transactionHash} timed out in pending state after ${timeoutSecs} seconds`,\n lastTxn,\n );\n }\n if (!checkSuccess) {\n return lastTxn;\n }\n if (!lastTxn.success) {\n throw new FailedTransactionError(\n `Transaction ${transactionHash} failed with an error: ${lastTxn.vm_status}`,\n lastTxn,\n );\n }\n\n return lastTxn;\n}\n\n/**\n * Waits for the indexer to sync up to the specified ledger version. The timeout is 3 seconds.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.minimumLedgerVersion - The minimum ledger version that the indexer should sync to.\n * @param args.processorType - (Optional) The type of processor to check the last success version from.\n * @group Implementation\n */\nexport async function waitForIndexer(args: {\n aptosConfig: AptosConfig;\n minimumLedgerVersion: AnyNumber;\n processorType?: ProcessorType;\n}): Promise<void> {\n const { aptosConfig, processorType } = args;\n const minimumLedgerVersion = BigInt(args.minimumLedgerVersion);\n const timeoutMilliseconds = 3000; // 3 seconds\n const startTime = new Date().getTime();\n let indexerVersion = BigInt(-1);\n\n while (indexerVersion < minimumLedgerVersion) {\n // check for timeout\n if (new Date().getTime() - startTime > timeoutMilliseconds) {\n throw new Error(\"waitForLastSuccessIndexerVersionSync timeout\");\n }\n\n if (processorType === undefined) {\n // Get the last success version from all processor\n // eslint-disable-next-line no-await-in-loop\n indexerVersion = await getIndexerLastSuccessVersion({ aptosConfig });\n } else {\n // Get the last success version from the specific processor\n // eslint-disable-next-line no-await-in-loop\n const processor = await getProcessorStatus({ aptosConfig, processorType });\n indexerVersion = processor.last_success_version;\n }\n\n if (indexerVersion >= minimumLedgerVersion) {\n // break out immediately if we are synced\n break;\n }\n\n // eslint-disable-next-line no-await-in-loop\n await sleep(200);\n }\n}\n\n/**\n * Represents an error that occurs when waiting for a transaction to complete.\n * This error is thrown by the `waitForTransaction` function when a transaction\n * times out or when the transaction response is undefined.\n *\n * @param message - A descriptive message for the error.\n * @param lastSubmittedTransaction - The last submitted transaction response, if available.\n * @group Implementation\n */\nexport class WaitForTransactionError extends Error {\n public readonly lastSubmittedTransaction: TransactionResponse | undefined;\n\n /**\n * Constructs an instance of the class with a specified message and transaction response.\n *\n * @param message - The message associated with the transaction.\n * @param lastSubmittedTransaction - The transaction response object containing details about the transaction.\n * @group Implementation\n */\n constructor(message: string, lastSubmittedTransaction: TransactionResponse | undefined) {\n super(message);\n this.lastSubmittedTransaction = lastSubmittedTransaction;\n }\n}\n\n/**\n * Represents an error that occurs when a transaction fails.\n * This error is thrown by the `waitForTransaction` function when the `checkSuccess` parameter is set to true.\n *\n * @param message - A description of the error.\n * @param transaction - The transaction response associated with the failure.\n * @group Implementation\n */\nexport class FailedTransactionError extends Error {\n public readonly transaction: TransactionResponse;\n\n constructor(message: string, transaction: TransactionResponse) {\n super(message);\n this.transaction = transaction;\n }\n}\n\n/**\n * Retrieves a block from the Aptos blockchain by its ledger version.\n * This function allows you to obtain detailed information about a specific block, including its transactions if requested.\n *\n * @param args - The arguments for retrieving the block.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos node.\n * @param args.ledgerVersion - The ledger version of the block to retrieve.\n * @param args.options - Optional parameters for the request.\n * @param args.options.withTransactions - Indicates whether to include transactions in the block data.\n * @group Implementation\n */\nexport async function getBlockByVersion(args: {\n aptosConfig: AptosConfig;\n ledgerVersion: AnyNumber;\n options?: { withTransactions?: boolean };\n}): Promise<Block> {\n const { aptosConfig, ledgerVersion, options } = args;\n const { data: block } = await getAptosFullNode<{}, Block>({\n aptosConfig,\n originMethod: \"getBlockByVersion\",\n path: `blocks/by_version/${ledgerVersion}`,\n params: { with_transactions: options?.withTransactions },\n });\n\n return fillBlockTransactions({ block, ...args });\n}\n\n/**\n * Retrieves a block from the Aptos blockchain by its height.\n *\n * @param args - The parameters for retrieving the block.\n * @param args.aptosConfig - The configuration object for connecting to the Aptos network.\n * @param args.blockHeight - The height of the block to retrieve.\n * @param args.options - Optional parameters for the request.\n * @param args.options.withTransactions - Indicates whether to include transactions in the block data.\n * @returns A promise that resolves to the block data, potentially including its transactions.\n * @group Implementation\n */\nexport async function getBlockByHeight(args: {\n aptosConfig: AptosConfig;\n blockHeight: AnyNumber;\n options?: { withTransactions?: boolean };\n}): Promise<Block> {\n const { aptosConfig, blockHeight, options } = args;\n const { data: block } = await getAptosFullNode<{}, Block>({\n aptosConfig,\n originMethod: \"getBlockByHeight\",\n path: `blocks/by_height/${blockHeight}`,\n params: { with_transactions: options?.withTransactions },\n });\n return fillBlockTransactions({ block, ...args });\n}\n\n/**\n * Fills in the block with transactions if not enough were returned. This function ensures that the block contains all relevant\n * transactions by fetching any missing ones based on the specified options.\n * @param args - The arguments for filling the block transactions.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.block - The block object that will be filled with transactions.\n * @param args.options - Optional settings for fetching transactions.\n * @param args.options.withTransactions - Indicates whether to include transactions in the block.\n * @group Implementation\n */\nasync function fillBlockTransactions(args: {\n aptosConfig: AptosConfig;\n block: Block;\n options?: { withTransactions?: boolean };\n}) {\n const { aptosConfig, block, options } = args;\n if (options?.withTransactions) {\n // Transactions should be filled, but this ensures it\n block.transactions = block.transactions ?? [];\n\n const lastTxn = block.transactions[block.transactions.length - 1];\n const firstVersion = BigInt(block.first_version);\n const lastVersion = BigInt(block.last_version);\n\n // Convert the transaction to the type\n const curVersion: string | undefined = (lastTxn as any)?.version;\n let latestVersion;\n\n // This time, if we don't have any transactions, we will try once with the start of the block\n if (curVersion === undefined) {\n latestVersion = firstVersion - 1n;\n } else {\n latestVersion = BigInt(curVersion);\n }\n\n // If we have all the transactions in the block, we can skip out, otherwise we need to fill the transactions\n if (latestVersion === lastVersion) {\n return block;\n }\n\n // For now, we will grab all the transactions in groups of 100, but we can make this more efficient by trying larger\n // amounts\n const fetchFutures = [];\n const pageSize = 100n;\n for (let i = latestVersion + 1n; i < lastVersion; i += BigInt(100)) {\n fetchFutures.push(\n getTransactions({\n aptosConfig,\n options: {\n offset: i,\n limit: Math.min(Number(pageSize), Number(lastVersion - i + 1n)),\n },\n }),\n );\n }\n\n // Combine all the futures\n const responses = await Promise.all(fetchFutures);\n for (const txns of responses) {\n block.transactions.push(...txns);\n }\n }\n\n return block;\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Account as AccountModule } from \"../account\";\nimport { AccountAddress, PrivateKey, AccountAddressInput, createObjectAddress } from \"../core\";\nimport {\n AccountData,\n AnyNumber,\n GetAccountCoinsDataResponse,\n GetAccountCollectionsWithOwnedTokenResponse,\n GetAccountOwnedTokensFromCollectionResponse,\n GetAccountOwnedTokensQueryResponse,\n GetObjectDataQueryResponse,\n LedgerVersionArg,\n MoveModuleBytecode,\n MoveResource,\n MoveStructId,\n MoveValue,\n OrderByArg,\n PaginationArgs,\n TokenStandardArg,\n TransactionResponse,\n WhereArg,\n} from \"../types\";\nimport {\n deriveAccountFromPrivateKey,\n getAccountCoinsCount,\n getAccountCoinsData,\n getAccountCollectionsWithOwnedTokens,\n getAccountOwnedObjects,\n getAccountOwnedTokens,\n getAccountOwnedTokensFromCollectionAddress,\n getAccountTokensCount,\n getAccountTransactionsCount,\n getInfo,\n getModule,\n getModules,\n getResource,\n getResources,\n getTransactions,\n lookupOriginalAccountAddress,\n} from \"../internal/account\";\nimport { APTOS_COIN, APTOS_FA, ProcessorType } from \"../utils/const\";\nimport { AptosConfig } from \"./aptosConfig\";\nimport { waitForIndexerOnVersion } from \"./utils\";\nimport { CurrentFungibleAssetBalancesBoolExp } from \"../types/generated/types\";\nimport { view } from \"../internal/view\";\nimport { isEncodedStruct, parseEncodedStruct } from \"../utils\";\nimport { memoizeAsync } from \"../utils/memoize\";\nimport { AccountAbstraction } from \"./account/abstraction\";\n\n/**\n * A class to query all `Account` related queries on Aptos.\n * @group Account\n */\nexport class Account {\n abstraction: AccountAbstraction;\n\n /**\n * Creates an instance of the Aptos client with the provided configuration.\n *\n * @param config - The configuration settings for the Aptos client.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Initialize the Aptos client with testnet configuration\n * const config = new AptosConfig({ network: Network.TESTNET }); // specify your own network if needed\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n constructor(readonly config: AptosConfig) {\n this.abstraction = new AccountAbstraction(config);\n }\n\n /**\n * Queries the current state for an Aptos account given its account address.\n *\n * @param args - The arguments for retrieving account information.\n * @param args.accountAddress - The Aptos account address to query.\n * @returns The account data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Retrieve account information for a specific address\n * const accountInfo = await aptos.getAccountInfo({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(accountInfo);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountInfo(args: { accountAddress: AccountAddressInput }): Promise<AccountData> {\n return getInfo({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for all modules in an account given an account address.\n * This function may call the API multiple times to auto paginate through results.\n *\n * @param args.accountAddress - The Aptos account address to query modules for.\n * @param args.options.offset - The cursor to start returning results from. Note, this is obfuscated and is not an index.\n * @param args.options.limit - The maximum number of results to return.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it retrieves the latest version.\n *\n * @returns - The account modules associated with the specified address.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching account modules for a specific account\n * const accountModules = await aptos.getAccountModules({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * offset: 0, // starting from the first module\n * limit: 10, // limiting to 10 modules\n * },\n * });\n *\n * console.log(accountModules);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountModules(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs & LedgerVersionArg;\n }): Promise<MoveModuleBytecode[]> {\n return getModules({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries for a specific account module given an account address and module name.\n *\n * @param args.accountAddress - The Aptos account address.\n * @param args.moduleName - The name of the module.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n *\n * @returns The account module associated with the specified account address and module name.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the account module for a specific account address and module name\n * const module = await aptos.getAccountModule({\n * accountAddress: \"0x1\", // replace with a real account address\n * moduleName: \"MyModule\" // specify the module name\n * });\n *\n * console.log(module);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountModule(args: {\n accountAddress: AccountAddressInput;\n moduleName: string;\n options?: LedgerVersionArg;\n }): Promise<MoveModuleBytecode> {\n return getModule({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries account transactions given an account address.\n * This function may call the API multiple times to auto paginate and retrieve all account transactions.\n *\n * @param args.accountAddress - The Aptos account address to query transactions for.\n * @param args.options - Optional pagination arguments.\n * @param args.options.offset - The number of transactions to start returning results from.\n * @param args.options.limit - The maximum number of results to return.\n *\n * @returns The account transactions.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetch transactions for a specific account\n * const transactions = await aptos.getAccountTransactions({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * offset: 0, // starting from the first transaction\n * limit: 10, // limiting to 10 transactions\n * },\n * });\n *\n * console.log(transactions);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountTransactions(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs;\n }): Promise<TransactionResponse[]> {\n return getTransactions({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries all account resources given an account address.\n * This function may call the API multiple times to auto paginate through results.\n *\n * @param args.accountAddress - The Aptos account address to query resources for.\n * @param args.options.offset - The cursor to start returning results from. Note, this is obfuscated and is not an index.\n * @param args.options.limit - The maximum number of results to return.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns Account resources.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching account resources for a specific account address\n * const resources = await aptos.getAccountResources({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(resources);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountResources(args: {\n accountAddress: AccountAddressInput;\n options?: PaginationArgs & LedgerVersionArg;\n }): Promise<MoveResource[]> {\n return getResources({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries a specific account resource given an account address and resource type.\n *\n * @template T - The typed output of the resource.\n * @param args.accountAddress - The Aptos account address to query.\n * @param args.resourceType - The string representation of an on-chain Move struct type, e.g., \"0x1::aptos_coin::AptosCoin\".\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns The account resource of the specified type.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the account resource for a specific account address and resource type\n * const resource = await aptos.getAccountResource({\n * accountAddress: \"0x1\", // replace with a real account address\n * resourceType: \"0x1::aptos_coin::AptosCoin\"\n * });\n *\n * console.log(resource);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountResource<T extends {} = any>(args: {\n accountAddress: AccountAddressInput;\n resourceType: MoveStructId;\n options?: LedgerVersionArg;\n }): Promise<T> {\n return getResource<T>({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Looks up the account address for a given authentication key, handling both rotated and non-rotated keys.\n *\n * @param args.authenticationKey - The authentication key for which to look up the account address.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @param args.options.ledgerVersion - The ledger version to query; if not provided, it will get the latest version.\n * @returns Promise<AccountAddress> - The account address associated with the authentication key.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Look up the original account address for a given authentication key\n * const accountAddress = await aptos.lookupOriginalAccountAddress({\n * authenticationKey: \"0x1\", // replace with a real authentication key\n * });\n *\n * console.log(\"Original Account Address:\", accountAddress);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async lookupOriginalAccountAddress(args: {\n authenticationKey: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: LedgerVersionArg;\n }): Promise<AccountAddress> {\n return lookupOriginalAccountAddress({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Queries the current count of tokens owned by a specified account.\n *\n * @param args - The parameters for the query.\n * @param args.accountAddress - The account address to query the token count for.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @returns The current count of tokens owned by the account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the count of tokens owned by the account\n * const tokensCount = await aptos.getAccountTokensCount({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(`Tokens Count: ${tokensCount}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountTokensCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.ACCOUNT_TRANSACTION_PROCESSOR,\n });\n return getAccountTokensCount({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the tokens currently owned by a specified account, including NFTs and fungible tokens.\n * If desired, you can filter the results by a specific token standard.\n *\n * @param args.accountAddress The account address for which to retrieve owned tokens.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @param args.options.tokenStandard Optional filter for the NFT standard to query for.\n * @param args.options.offset Optional number to start returning results from.\n * @param args.options.limit Optional number of results to return.\n * @param args.options.orderBy Optional order to sort the tokens by.\n * @returns An array of tokens with their respective data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the tokens owned by a specific account\n * const accountOwnedTokens = await aptos.getAccountOwnedTokens({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify how many tokens to return\n * orderBy: \"created_at\", // specify the order of the results\n * },\n * });\n *\n * console.log(accountOwnedTokens);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountOwnedTokens(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensQueryResponse[0]>;\n }): Promise<GetAccountOwnedTokensQueryResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountOwnedTokens({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries all current tokens of a specific collection that an account owns by the collection address.\n * This query returns all tokens (v1 and v2 standards) an account owns, including NFTs, fungible, soulbound, etc.\n * If you want to get only the token from a specific standard, you can pass an optional tokenStandard parameter.\n *\n * @param args.accountAddress - The account address we want to get the tokens for.\n * @param args.collectionAddress - The address of the collection being queried.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to, before querying.\n * @param args.options.tokenStandard - The NFT standard to query for.\n * @param args.options.offset - The number token to start returning results from.\n * @param args.options.limit - The number of results to return.\n * @param args.options.orderBy - The order to sort the tokens by.\n * @returns Tokens array with the token data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get tokens owned by a specific account in a specific collection\n * const accountOwnedTokens = await aptos.getAccountOwnedTokensFromCollectionAddress({\n * accountAddress: \"0x1\", // replace with a real account address\n * collectionAddress: \"0x2\", // replace with a real collection address\n * });\n *\n * console.log(accountOwnedTokens);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountOwnedTokensFromCollectionAddress(args: {\n accountAddress: AccountAddressInput;\n collectionAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountOwnedTokensFromCollectionResponse[0]>;\n }): Promise<GetAccountOwnedTokensFromCollectionResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountOwnedTokensFromCollectionAddress({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries for all collections that an account currently has tokens for, including NFTs, fungible tokens, and soulbound tokens.\n * If you want to filter by a specific token standard, you can pass an optional tokenStandard parameter.\n *\n * @param args.accountAddress - The account address we want to get the collections for.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @param args.options.tokenStandard - The NFT standard to query for.\n * @param args.options.offset - The number of the collection to start returning results from.\n * @param args.options.limit - The number of results to return.\n * @param args.options.orderBy - The order to sort the tokens by.\n * @returns Collections array with the collections data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get account collections with owned tokens for a specific account\n * const accountCollectionsWithOwnedTokens = await aptos.getAccountCollectionsWithOwnedTokens({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * tokenStandard: \"NFT\", // specify the token standard if needed\n * limit: 10, // specify the number of results to return\n * },\n * });\n *\n * console.log(accountCollectionsWithOwnedTokens);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCollectionsWithOwnedTokens(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: TokenStandardArg & PaginationArgs & OrderByArg<GetAccountCollectionsWithOwnedTokenResponse[0]>;\n }): Promise<GetAccountCollectionsWithOwnedTokenResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.TOKEN_V2_PROCESSOR,\n });\n return getAccountCollectionsWithOwnedTokens({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Queries the current count of transactions submitted by an account.\n *\n * @param args - The parameters for the query.\n * @param args.accountAddress - The account address we want to get the total count for.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @returns Current count of transactions made by an account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the count of transactions for a specific account\n * const accountTransactionsCount = await aptos.getAccountTransactionsCount({\n * accountAddress: \"0x1\", // replace with a real account address\n * minimumLedgerVersion: 1, // specify your own minimum ledger version if needed\n * });\n *\n * console.log(accountTransactionsCount);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountTransactionsCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.ACCOUNT_TRANSACTION_PROCESSOR,\n });\n return getAccountTransactionsCount({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Retrieves the coins data for a specified account.\n *\n * @param args.accountAddress - The account address for which to retrieve the coin's data.\n * @param args.minimumLedgerVersion - Optional ledger version to sync up to before querying.\n * @param args.options.offset - Optional. The number of coins to start returning results from.\n * @param args.options.limit - Optional. The number of results to return.\n * @param args.options.orderBy - Optional. The order to sort the coins by.\n * @param args.options.where - Optional. Filter the results by specific criteria.\n * @returns An array containing the coins data for the specified account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Fetching coins data for a specific account\n * const accountCoinsData = await aptos.getAccountCoinsData({\n * accountAddress: \"0x1\", // replace with a real account address\n * options: {\n * limit: 10, // specify the number of results to return\n * orderBy: { asset_type: \"asc\" }, // specify the order of results\n * },\n * });\n *\n * console.log(accountCoinsData);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCoinsData(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs &\n OrderByArg<GetAccountCoinsDataResponse[0]> &\n WhereArg<CurrentFungibleAssetBalancesBoolExp>;\n }): Promise<GetAccountCoinsDataResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getAccountCoinsData({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Retrieves the current count of an account's coins aggregated across all types.\n *\n * @param args The parameters for the account coins count query.\n * @param args.accountAddress The account address we want to get the total count for.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @returns The current count of the aggregated coins for the specified account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Getting the account coins count for a specific account\n * const accountCoinsCount = await aptos.getAccountCoinsCount({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(\"Account Coins Count:\", accountCoinsCount);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCoinsCount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.FUNGIBLE_ASSET_PROCESSOR,\n });\n return getAccountCoinsCount({ aptosConfig: this.config, ...args });\n }\n\n /**\n * Retrieves the current amount of APT for a specified account. If the account does not exist, it will return 0.\n *\n * @param args The arguments for the account query.\n * @param args.accountAddress The account address for which to retrieve the APT amount.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @returns The current amount of APT for the specified account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the APT amount for a specific account\n * const accountAPTAmount = await aptos.getAccountAPTAmount({ accountAddress: \"0x1\" }); // replace with a real account address\n * console.log(\"Account APT Amount:\", accountAPTAmount);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountAPTAmount(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n return this.getAccountCoinAmount({ coinType: APTOS_COIN, faMetadataAddress: APTOS_FA, ...args });\n }\n\n /**\n * Queries the current amount of a specified coin held by an account.\n *\n * @param args The parameters for querying the account's coin amount.\n * @param args.accountAddress The account address to query for the coin amount.\n * @param args.coinType The coin type to query. Note: If not provided, it may be automatically populated if `faMetadataAddress`\n * is specified.\n * @param args.faMetadataAddress The fungible asset metadata address to query. Note: If not provided, it may be automatically\n * populated if `coinType` is specified.\n * @param args.minimumLedgerVersion Not used anymore, here for backward compatibility\n * see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, will be removed in the near future.\n * Optional ledger version to sync up to before querying.\n * @returns The current amount of the specified coin held by the account.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Query the account's coin amount for a specific coin type\n * const accountCoinAmount = await aptos.getAccountCoinAmount({\n * accountAddress: \"0x1\", // replace with a real account address\n * coinType: \"0x1::aptos_coin::AptosCoin\" // specify the coin type\n * });\n *\n * console.log(`Account coin amount: ${accountCoinAmount}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountCoinAmount(args: {\n accountAddress: AccountAddressInput;\n coinType?: MoveStructId;\n faMetadataAddress?: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n }): Promise<number> {\n const { accountAddress, coinType, faMetadataAddress, minimumLedgerVersion } = args;\n\n if (minimumLedgerVersion) {\n // eslint-disable-next-line no-console\n console.warn(\n `minimumLedgerVersion is not used anymore, here for backward \n compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519, \n will be removed in the near future`,\n );\n }\n // Attempt to populate the CoinType field if the FA address is provided.\n // We cannot do this internally due to dependency cycles issue.\n let coinAssetType: MoveStructId | undefined = coinType;\n if (coinType === undefined && faMetadataAddress !== undefined) {\n coinAssetType = await memoizeAsync(\n async () => {\n try {\n const pairedCoinTypeStruct = (\n await view({\n aptosConfig: this.config,\n payload: { function: \"0x1::coin::paired_coin\", functionArguments: [faMetadataAddress] },\n })\n ).at(0) as { vec: MoveValue[] };\n\n // Check if the Option has a value, and if so, parse the struct\n if (pairedCoinTypeStruct.vec.length > 0 && isEncodedStruct(pairedCoinTypeStruct.vec[0])) {\n return parseEncodedStruct(pairedCoinTypeStruct.vec[0]) as MoveStructId;\n }\n } catch (error) {\n /* No paired coin type found */\n }\n return undefined;\n },\n `coin-mapping-${faMetadataAddress.toString()}`,\n 1000 * 60 * 5, // 5 minutes\n )();\n }\n\n let faAddress: string;\n\n if (coinType !== undefined && faMetadataAddress !== undefined) {\n faAddress = AccountAddress.from(faMetadataAddress).toStringLong();\n } else if (coinType !== undefined && faMetadataAddress === undefined) {\n // TODO Move to a separate function as defined in the AIP for coin migration\n if (coinType === APTOS_COIN) {\n faAddress = AccountAddress.A.toStringLong();\n } else {\n faAddress = createObjectAddress(AccountAddress.A, coinType).toStringLong();\n }\n } else if (coinType === undefined && faMetadataAddress !== undefined) {\n const addr = AccountAddress.from(faMetadataAddress);\n faAddress = addr.toStringLong();\n if (addr === AccountAddress.A) {\n coinAssetType = APTOS_COIN;\n }\n // The paired CoinType should be populated outside of this function in another\n // async call. We cannot do this internally due to dependency cycles issue.\n } else {\n throw new Error(\"Either coinType, faMetadataAddress, or both must be provided\");\n }\n\n // When there is a coin mapping, use that first, otherwise use the fungible asset address\n // TODO: This function's signature at the top, returns number, but it could be greater than can be represented\n if (coinAssetType !== undefined) {\n const [balanceStr] = await view<[string]>({\n aptosConfig: this.config,\n payload: {\n function: \"0x1::coin::balance\",\n typeArguments: [coinAssetType],\n functionArguments: [accountAddress],\n },\n });\n return parseInt(balanceStr, 10);\n }\n const [balanceStr] = await view<[string]>({\n aptosConfig: this.config,\n payload: {\n function: \"0x1::primary_fungible_store::balance\",\n typeArguments: [\"0x1::object::ObjectCore\"],\n functionArguments: [accountAddress, faAddress],\n },\n });\n return parseInt(balanceStr, 10);\n }\n\n /**\n * Queries an account's owned objects.\n *\n * @param args.accountAddress The account address we want to get the objects for.\n * @param args.minimumLedgerVersion Optional ledger version to sync up to before querying.\n * @param args.options.offset The starting position to start returning results from.\n * @param args.options.limit The number of results to return.\n * @param args.options.orderBy The order to sort the objects by.\n * @returns Objects array with the object data.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Get the objects owned by the specified account\n * const accountOwnedObjects = await aptos.getAccountOwnedObjects({\n * accountAddress: \"0x1\", // replace with a real account address\n * minimumLedgerVersion: 1, // optional, specify if needed\n * options: {\n * offset: 0, // optional, specify if needed\n * limit: 10, // optional, specify if needed\n * orderBy: \"created_at\", // optional, specify if needed\n * },\n * });\n *\n * console.log(accountOwnedObjects);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async getAccountOwnedObjects(args: {\n accountAddress: AccountAddressInput;\n minimumLedgerVersion?: AnyNumber;\n options?: PaginationArgs & OrderByArg<GetObjectDataQueryResponse[0]>;\n }): Promise<GetObjectDataQueryResponse> {\n await waitForIndexerOnVersion({\n config: this.config,\n minimumLedgerVersion: args.minimumLedgerVersion,\n processorType: ProcessorType.DEFAULT,\n });\n return getAccountOwnedObjects({\n aptosConfig: this.config,\n ...args,\n });\n }\n\n /**\n * Derives an account by providing a private key. This function resolves the provided private key type and derives the public\n * key from it.\n *\n * If the privateKey is a Secp256k1 type, it derives the account using the derived public key and auth key using the SingleKey\n * scheme locally.\n * If the privateKey is an ED25519 type, it looks up the authentication key on chain to determine whether it is a Legacy ED25519\n * key or a Unified ED25519 key, and then derives the account based on that.\n *\n * @param args - The arguments for deriving the account.\n * @param args.privateKey - An account private key.\n * @returns The derived Account type.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, Ed25519PrivateKey } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Deriving an account from a private key\n * const account = await aptos.deriveAccountFromPrivateKey({\n * privateKey: new Ed25519PrivateKey(\"0x123\") // replace with a real private key\n * });\n *\n * console.log(account);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Account\n */\n async deriveAccountFromPrivateKey(args: { privateKey: PrivateKey }): Promise<AccountModule> {\n return deriveAccountFromPrivateKey({ aptosConfig: this.config, ...args });\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This file contains the underlying implementations for exposed API surface in\n * the {@link api/digitalAsset}. By moving the methods out into a separate file,\n * other namespaces and processes can access these methods without depending on the entire\n * digitalAsset namespace and without having a dependency cycle error.\n * @group Implementation\n */\n\nimport { AptosConfig } from \"../api/aptosConfig\";\nimport { Bool, MoveString, MoveVector, U64 } from \"../bcs\";\nimport { AccountAddress, AccountAddressInput } from \"../core\";\nimport { Account } from \"../account\";\nimport { EntryFunctionABI, InputGenerateTransactionOptions } from \"../transactions/types\";\nimport {\n AnyNumber,\n GetCollectionDataResponse,\n GetCurrentTokenOwnershipResponse,\n GetOwnedTokensResponse,\n GetTokenActivityResponse,\n GetTokenDataResponse,\n MoveAbility,\n MoveStructId,\n OrderByArg,\n PaginationArgs,\n TokenStandardArg,\n WhereArg,\n} from \"../types\";\nimport {\n GetCollectionDataQuery,\n GetCurrentTokenOwnershipQuery,\n GetTokenActivityQuery,\n GetTokenDataQuery,\n} from \"../types/generated/operations\";\nimport {\n GetCollectionData,\n GetCurrentTokenOwnership,\n GetTokenActivity,\n GetTokenData,\n} from \"../types/generated/queries\";\nimport { queryIndexer } from \"./general\";\nimport { generateTransaction } from \"./transactionSubmission\";\nimport { MAX_U64_BIG_INT } from \"../bcs/consts\";\nimport {\n CurrentCollectionsV2BoolExp,\n CurrentTokenOwnershipsV2BoolExp,\n TokenActivitiesV2BoolExp,\n} from \"../types/generated/types\";\nimport {\n checkOrConvertArgument,\n objectStructTag,\n parseTypeTag,\n stringStructTag,\n TypeTagAddress,\n TypeTagBool,\n TypeTagGeneric,\n TypeTagStruct,\n TypeTagU64,\n TypeTagVector,\n} from \"../transactions\";\nimport { SimpleTransaction } from \"../transactions/instances/simpleTransaction\";\n\n// A property type map for the user input and what Move expects\nconst PropertyTypeMap = {\n BOOLEAN: \"bool\",\n U8: \"u8\",\n U16: \"u16\",\n U32: \"u32\",\n U64: \"u64\",\n U128: \"u128\",\n U256: \"u256\",\n ADDRESS: \"address\",\n STRING: \"0x1::string::String\",\n ARRAY: \"vector<u8>\",\n};\n\n/**\n * The keys of the PropertyTypeMap, representing different property types.\n * @group Implementation\n */\nexport type PropertyType = keyof typeof PropertyTypeMap;\n\n/**\n * Accepted property value types for user input, including boolean, number, bigint, string, AccountAddress, and Uint8Array.\n * To pass in an Array, use Uint8Array type\n * for example `new MoveVector([new MoveString(\"hello\"), new MoveString(\"world\")]).bcsToBytes()`\n * @group Implementation\n */\nexport type PropertyValue = boolean | number | bigint | string | AccountAddress | Uint8Array;\n\n// The default digital asset type to use if non provided\nconst defaultDigitalAssetType = \"0x4::token::Token\";\n\n// FETCH QUERIES\n\n/**\n * Retrieves data for a specific digital asset using its address.\n *\n * @param args - The arguments for fetching digital asset data.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.digitalAssetAddress - The address of the digital asset to retrieve data for.\n * @returns The data of the specified digital asset.\n * @group Implementation\n */\nexport async function getDigitalAssetData(args: {\n aptosConfig: AptosConfig;\n digitalAssetAddress: AccountAddressInput;\n}): Promise<GetTokenDataResponse> {\n const { aptosConfig, digitalAssetAddress } = args;\n\n const whereCondition: { token_data_id: { _eq: string } } = {\n token_data_id: { _eq: AccountAddress.from(digitalAssetAddress).toStringLong() },\n };\n\n const graphqlQuery = {\n query: GetTokenData,\n variables: {\n where_condition: whereCondition,\n },\n };\n\n const data = await queryIndexer<GetTokenDataQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getDigitalAssetData\",\n });\n\n return data.current_token_datas_v2[0];\n}\n\n/**\n * Retrieves the current ownership details of a specified digital asset.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.digitalAssetAddress - The address of the digital asset to query ownership for.\n * @returns The current ownership details of the specified digital asset.\n * @group Implementation\n */\nexport async function getCurrentDigitalAssetOwnership(args: {\n aptosConfig: AptosConfig;\n digitalAssetAddress: AccountAddressInput;\n}): Promise<GetCurrentTokenOwnershipResponse> {\n const { aptosConfig, digitalAssetAddress } = args;\n\n const whereCondition: CurrentTokenOwnershipsV2BoolExp = {\n token_data_id: { _eq: AccountAddress.from(digitalAssetAddress).toStringLong() },\n amount: { _gt: 0 },\n };\n\n const graphqlQuery = {\n query: GetCurrentTokenOwnership,\n variables: {\n where_condition: whereCondition,\n },\n };\n\n const data = await queryIndexer<GetCurrentTokenOwnershipQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getCurrentDigitalAssetOwnership\",\n });\n\n return data.current_token_ownerships_v2[0];\n}\n\n/**\n * Retrieves the digital assets owned by a specified account address.\n *\n * @param args - The arguments for retrieving owned digital assets.\n * @param args.aptosConfig - The configuration for connecting to the Aptos network.\n * @param args.ownerAddress - The address of the account whose owned digital assets are being queried.\n * @param args.options - Optional pagination and ordering parameters for the query.\n * @param args.options.offset - The number of records to skip for pagination.\n * @param args.options.limit - The maximum number of records to return.\n * @param args.options.orderBy - The criteria for ordering the results.\n *\n * @returns An array of digital assets currently owned by the specified account.\n * @group Implementation\n */\nexport async function getOwnedDigitalAssets(args: {\n aptosConfig: AptosConfig;\n ownerAddress: AccountAddressInput;\n options?: PaginationArgs & OrderByArg<GetTokenActivityResponse[0]>;\n}): Promise<GetOwnedTokensResponse> {\n const { aptosConfig, ownerAddress, options } = args;\n\n const whereCondition: CurrentTokenOwnershipsV2BoolExp = {\n owner_address: { _eq: AccountAddress.from(ownerAddress).toStringLong() },\n amount: { _gt: 0 },\n };\n\n const graphqlQuery = {\n query: GetCurrentTokenOwnership,\n variables: {\n where_condition: whereCondition,\n offset: options?.offset,\n limit: options?.limit,\n order_by: options?.orderBy,\n },\n };\n\n const data = await queryIndexer<GetCurrentTokenOwnershipQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getOwnedDigitalAssets\",\n });\n\n return data.current_token_ownerships_v2;\n}\n\n/**\n * Retrieves the activity associated with a specific digital asset.\n * This function allows you to track the token activities for a given digital asset address.\n *\n * @param args - The arguments for retrieving digital asset activity.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.digitalAssetAddress - The address of the digital asset to query.\n * @param args.options - Optional parameters for pagination and ordering.\n * @param args.options.offset - The number of records to skip before starting to collect the result set.\n * @param args.options.limit - The maximum number of records to return.\n * @param args.options.orderBy - The criteria to order the results by.\n * @returns A promise that resolves to an array of token activities for the specified digital asset.\n * @group Implementation\n */\nexport async function getDigitalAssetActivity(args: {\n aptosConfig: AptosConfig;\n digitalAssetAddress: AccountAddressInput;\n options?: PaginationArgs & OrderByArg<GetTokenActivityResponse[0]>;\n}): Promise<GetTokenActivityResponse> {\n const { aptosConfig, digitalAssetAddress, options } = args;\n\n const whereCondition: TokenActivitiesV2BoolExp = {\n token_data_id: { _eq: AccountAddress.from(digitalAssetAddress).toStringLong() },\n };\n\n const graphqlQuery = {\n query: GetTokenActivity,\n variables: {\n where_condition: whereCondition,\n offset: options?.offset,\n limit: options?.limit,\n order_by: options?.orderBy,\n },\n };\n\n const data = await queryIndexer<GetTokenActivityQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getDigitalAssetActivity\",\n });\n\n return data.token_activities_v2;\n}\n\n/**\n * Options for creating a collection, allowing customization of various attributes such as supply limits, mutability of metadata,\n * and royalty settings.\n *\n * @param maxSupply - Maximum number of tokens that can be minted in the collection.\n * @param mutableDescription - Indicates if the collection description can be changed after creation.\n * @param mutableRoyalty - Indicates if the royalty settings can be modified after creation.\n * @param mutableURI - Indicates if the collection URI can be updated.\n * @param mutableTokenDescription - Indicates if individual token descriptions can be modified.\n * @param mutableTokenName - Indicates if individual token names can be changed.\n * @param mutableTokenProperties - Indicates if individual token properties can be altered.\n * @param mutableTokenURI - Indicates if individual token URIs can be updated.\n * @param tokensBurnableByCreator - Indicates if the creator can burn tokens from the collection.\n * @param tokensFreezableByCreator - Indicates if the creator can freeze tokens in the collection.\n * @param royaltyNumerator - The numerator for calculating royalties.\n * @param royaltyDenominator - The denominator for calculating royalties.\n * @group Implementation\n */\nexport interface CreateCollectionOptions {\n maxSupply?: AnyNumber;\n mutableDescription?: boolean;\n mutableRoyalty?: boolean;\n mutableURI?: boolean;\n mutableTokenDescription?: boolean;\n mutableTokenName?: boolean;\n mutableTokenProperties?: boolean;\n mutableTokenURI?: boolean;\n tokensBurnableByCreator?: boolean;\n tokensFreezableByCreator?: boolean;\n royaltyNumerator?: number;\n royaltyDenominator?: number;\n}\n\nconst createCollectionAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [\n new TypeTagStruct(stringStructTag()),\n new TypeTagU64(),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagBool(),\n new TypeTagU64(),\n new TypeTagU64(),\n ],\n};\n\n/**\n * Creates a new collection transaction on the Aptos blockchain.\n * This function allows you to define the properties of the collection, including its name, description, and URI.\n *\n * @param args - The parameters for creating the collection transaction.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.creator - The account that will create the collection.\n * @param args.description - A description of the collection.\n * @param args.name - The name of the collection.\n * @param args.uri - The URI associated with the collection.\n * @param args.options - Optional parameters for generating the transaction.\n * @param args.maxSupply - The maximum supply of tokens in the collection (optional).\n * @param args.mutableDescription - Indicates if the collection description can be changed (optional, defaults to true).\n * @param args.mutableRoyalty - Indicates if the royalty settings can be changed (optional, defaults to true).\n * @param args.mutableURI - Indicates if the URI can be changed (optional, defaults to true).\n * @param args.mutableTokenDescription - Indicates if the token description can be changed (optional, defaults to true).\n * @param args.mutableTokenName - Indicates if the token name can be changed (optional, defaults to true).\n * @param args.mutableTokenProperties - Indicates if the token properties can be changed (optional, defaults to true).\n * @param args.mutableTokenURI - Indicates if the token URI can be changed (optional, defaults to true).\n * @param args.tokensBurnableByCreator - Indicates if tokens can be burned by the creator (optional, defaults to true).\n * @param args.tokensFreezableByCreator - Indicates if tokens can be frozen by the creator (optional, defaults to true).\n * @param args.royaltyNumerator - The numerator for calculating royalties (optional, defaults to 0).\n * @param args.royaltyDenominator - The denominator for calculating royalties (optional, defaults to 1).\n * @group Implementation\n */\nexport async function createCollectionTransaction(\n args: {\n aptosConfig: AptosConfig;\n creator: Account;\n description: string;\n name: string;\n uri: string;\n options?: InputGenerateTransactionOptions;\n } & CreateCollectionOptions,\n): Promise<SimpleTransaction> {\n const { aptosConfig, options, creator } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::create_collection\",\n functionArguments: [\n // Do not change the order\n new MoveString(args.description),\n new U64(args.maxSupply ?? MAX_U64_BIG_INT),\n new MoveString(args.name),\n new MoveString(args.uri),\n new Bool(args.mutableDescription ?? true),\n new Bool(args.mutableRoyalty ?? true),\n new Bool(args.mutableURI ?? true),\n new Bool(args.mutableTokenDescription ?? true),\n new Bool(args.mutableTokenName ?? true),\n new Bool(args.mutableTokenProperties ?? true),\n new Bool(args.mutableTokenURI ?? true),\n new Bool(args.tokensBurnableByCreator ?? true),\n new Bool(args.tokensFreezableByCreator ?? true),\n new U64(args.royaltyNumerator ?? 0),\n new U64(args.royaltyDenominator ?? 1),\n ],\n abi: createCollectionAbi,\n },\n options,\n });\n}\n\n/**\n * Retrieves data for the current collections based on specified options.\n *\n * @param args - The arguments for the function.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.options - Optional parameters for filtering and pagination.\n * @param args.options.tokenStandard - The token standard to filter the collections (default is \"v2\").\n * @param args.options.offset - The offset for pagination.\n * @param args.options.limit - The limit for pagination.\n * @param args.options.where - The conditions to filter the collections.\n * @returns The data of the current collections.\n * @group Implementation\n */\nexport async function getCollectionData(args: {\n aptosConfig: AptosConfig;\n options?: TokenStandardArg & PaginationArgs & WhereArg<CurrentCollectionsV2BoolExp>;\n}): Promise<GetCollectionDataResponse> {\n const { aptosConfig, options } = args;\n\n const whereCondition: any = options?.where;\n\n if (options?.tokenStandard) {\n whereCondition.token_standard = { _eq: options?.tokenStandard ?? \"v2\" };\n }\n\n const graphqlQuery = {\n query: GetCollectionData,\n variables: {\n where_condition: whereCondition,\n offset: options?.offset,\n limit: options?.limit,\n },\n };\n const data = await queryIndexer<GetCollectionDataQuery>({\n aptosConfig,\n query: graphqlQuery,\n originMethod: \"getCollectionData\",\n });\n\n return data.current_collections_v2[0];\n}\n\n/**\n * Retrieves collection data based on the creator's address and the collection name.\n *\n * @param args - The arguments for retrieving the collection data.\n * @param args.aptosConfig - The Aptos configuration object.\n * @param args.creatorAddress - The address of the creator whose collection data is being retrieved.\n * @param args.collectionName - The name of the collection to fetch data for.\n * @param args.options - Optional parameters for filtering the results, including token standard and pagination options.\n * @param args.options.tokenStandard - The token standard to filter the results by (optional).\n * @param args.options.pagination - Pagination options for the results (optional).\n * @group Implementation\n */\nexport async function getCollectionDataByCreatorAddressAndCollectionName(args: {\n aptosConfig: AptosConfig;\n creatorAddress: AccountAddressInput;\n collectionName: string;\n options?: TokenStandardArg & PaginationArgs;\n}): Promise<GetCollectionDataResponse> {\n const { aptosConfig, creatorAddress, collectionName, options } = args;\n const address = AccountAddress.from(creatorAddress);\n\n const whereCondition: any = {\n collection_name: { _eq: collectionName },\n creator_address: { _eq: address.toStringLong() },\n };\n if (options?.tokenStandard) {\n whereCondition.token_standard = { _eq: options?.tokenStandard ?? \"v2\" };\n }\n\n return getCollectionData({ aptosConfig, options: { ...options, where: whereCondition } });\n}\n\n/**\n * Retrieves collection data associated with a specific creator's address.\n * This function allows you to filter the collections based on the creator's address and optional token standards.\n *\n * @param args - The arguments for retrieving collection data.\n * @param args.aptosConfig - The configuration for the Aptos network.\n * @param args.creatorAddress - The address of the creator whose collection data is being retrieved.\n * @param args.options - Optional parameters for filtering the results.\n * @param args.options.tokenStandard - The token standard to filter the collections by.\n * @param args.options.pagination - Pagination options for the results.\n * @group Implementation\n */\nexport async function getCollectionDataByCreatorAddress(args: {\n aptosConfig: AptosConfig;\n creatorAddress: AccountAddressInput;\n options?: TokenStandardArg & PaginationArgs;\n}): Promise<GetCollectionDataResponse> {\n const { aptosConfig, creatorAddress, options } = args;\n const address = AccountAddress.from(creatorAddress);\n\n const whereCondition: any = {\n creator_address: { _eq: address.toStringLong() },\n };\n if (options?.tokenStandard) {\n whereCondition.token_standard = { _eq: options?.tokenStandard ?? \"v2\" };\n }\n\n return getCollectionData({ aptosConfig, options: { ...options, where: whereCondition } });\n}\n\n/**\n * Retrieves data for a specific collection using its unique identifier.\n * This function allows you to filter the collection data based on the token standard and pagination options.\n *\n * @param args - The arguments for retrieving collection data.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.collectionId - The unique identifier for the collection.\n * @param args.options - Optional parameters for filtering by token standard and pagination.\n * @param args.options.tokenStandard - The standard of the token to filter the collection data.\n * @param args.options.page - The page number for pagination.\n * @param args.options.limit - The number of items per page for pagination.\n * @group Implementation\n */\nexport async function getCollectionDataByCollectionId(args: {\n aptosConfig: AptosConfig;\n collectionId: AccountAddressInput;\n options?: TokenStandardArg & PaginationArgs;\n}): Promise<GetCollectionDataResponse> {\n const { aptosConfig, collectionId, options } = args;\n const address = AccountAddress.from(collectionId);\n\n const whereCondition: any = {\n collection_id: { _eq: address.toStringLong() },\n };\n\n if (options?.tokenStandard) {\n whereCondition.token_standard = { _eq: options?.tokenStandard ?? \"v2\" };\n }\n\n return getCollectionData({ aptosConfig, options: { ...options, where: whereCondition } });\n}\n\n/**\n * Retrieves the collection ID based on the creator's address and the collection name.\n * This function helps in identifying a specific collection within the Aptos ecosystem.\n *\n * @param args - The parameters for retrieving the collection ID.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.creatorAddress - The address of the creator of the collection.\n * @param args.collectionName - The name of the collection to look up.\n * @param args.options - Optional parameters for additional filtering.\n * @param args.options.tokenStandard - The token standard to filter the collection (default is \"v2\").\n * @returns The ID of the specified collection.\n * @group Implementation\n */\nexport async function getCollectionId(args: {\n aptosConfig: AptosConfig;\n creatorAddress: AccountAddressInput;\n collectionName: string;\n options?: TokenStandardArg;\n}): Promise<string> {\n const { creatorAddress, collectionName, options, aptosConfig } = args;\n const address = AccountAddress.from(creatorAddress);\n\n const whereCondition: any = {\n collection_name: { _eq: collectionName },\n creator_address: { _eq: address.toStringLong() },\n };\n if (options?.tokenStandard) {\n whereCondition.token_standard = { _eq: options?.tokenStandard ?? \"v2\" };\n }\n\n return (await getCollectionData({ aptosConfig, options: { where: whereCondition } })).collection_id;\n}\n\n// TRANSACTIONS\n\nconst mintDigitalAssetAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagVector(new TypeTagStruct(stringStructTag())),\n new TypeTagVector(new TypeTagStruct(stringStructTag())),\n new TypeTagVector(TypeTagVector.u8()),\n ],\n};\n\n/**\n * Creates a transaction to mint a digital asset on the Aptos blockchain.\n * This function allows you to specify various attributes of the asset, including its collection, description, name, and URI.\n *\n * @param args - The arguments for minting the digital asset.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.creator - The account that will create the digital asset.\n * @param args.collection - The name of the collection to which the asset belongs.\n * @param args.description - A brief description of the digital asset.\n * @param args.name - The name of the digital asset.\n * @param args.uri - The URI pointing to the asset's metadata.\n * @param [args.propertyKeys] - Optional array of property keys associated with the asset.\n * @param [args.propertyTypes] - Optional array of property types corresponding to the asset's properties.\n * @param [args.propertyValues] - Optional array of property values for the asset's properties.\n * @param [args.options] - Optional transaction generation options.\n * @group Implementation\n */\nexport async function mintDigitalAssetTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n collection: string;\n description: string;\n name: string;\n uri: string;\n propertyKeys?: Array<string>;\n propertyTypes?: Array<PropertyType>;\n propertyValues?: Array<PropertyValue>;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const {\n aptosConfig,\n options,\n creator,\n collection,\n description,\n name,\n uri,\n propertyKeys,\n propertyTypes,\n propertyValues,\n } = args;\n const convertedPropertyType = propertyTypes?.map((type) => PropertyTypeMap[type]);\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::mint\",\n functionArguments: [\n new MoveString(collection),\n new MoveString(description),\n new MoveString(name),\n new MoveString(uri),\n MoveVector.MoveString(propertyKeys ?? []),\n MoveVector.MoveString(convertedPropertyType ?? []),\n\n /**\n * Retrieves the raw values of specified properties from an array of property values based on their types.\n *\n * @param propertyValues - An array of property values from which to extract the raw data.\n * @param propertyTypes - An array of strings representing the types of properties to retrieve.\n * @returns An array of Uint8Array containing the raw values for the specified property types.\n * @group Implementation\n */\n getPropertyValueRaw(propertyValues ?? [], convertedPropertyType ?? []),\n ],\n abi: mintDigitalAssetAbi,\n },\n options,\n });\n}\n\nconst transferDigitalAssetAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagAddress()],\n};\n\n/**\n * Initiates a transaction to transfer a digital asset from one account to another.\n * This function helps in executing the transfer of digital assets securely and efficiently.\n *\n * @param args - The arguments required to perform the transfer.\n * @param args.aptosConfig - Configuration settings for the Aptos client.\n * @param args.sender - The account initiating the transfer.\n * @param args.digitalAssetAddress - The address of the digital asset being transferred.\n * @param args.recipient - The address of the account receiving the digital asset.\n * @param args.digitalAssetType - (Optional) The type of the digital asset being transferred.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function transferDigitalAssetTransaction(args: {\n aptosConfig: AptosConfig;\n sender: Account;\n digitalAssetAddress: AccountAddressInput;\n recipient: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, sender, digitalAssetAddress, recipient, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: sender.accountAddress,\n data: {\n function: \"0x1::object::transfer\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [AccountAddress.from(digitalAssetAddress), AccountAddress.from(recipient)],\n abi: transferDigitalAssetAbi,\n },\n options,\n });\n}\n\nconst mintSoulBoundAbi: EntryFunctionABI = {\n typeParameters: [],\n parameters: [\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n new TypeTagVector(new TypeTagStruct(stringStructTag())),\n new TypeTagVector(new TypeTagStruct(stringStructTag())),\n new TypeTagVector(TypeTagVector.u8()),\n new TypeTagAddress(),\n ],\n};\n\n/**\n * Creates a transaction to mint a soul-bound token.\n * This function allows you to specify the token's attributes and recipient, facilitating the creation of unique digital assets.\n *\n * @param args - The parameters required to mint the soul-bound token.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.account - The account initiating the minting transaction.\n * @param args.collection - The name of the collection to which the token belongs.\n * @param args.description - A description of the token being minted.\n * @param args.name - The name of the token.\n * @param args.uri - The URI pointing to the token's metadata.\n * @param args.recipient - The address of the account that will receive the minted token.\n * @param [args.propertyKeys] - Optional array of property keys associated with the token.\n * @param [args.propertyTypes] - Optional array of property types corresponding to the property keys.\n * @param [args.propertyValues] - Optional array of property values that match the property keys and types.\n * @param [args.options] - Optional transaction generation options.\n * @throws Error if the counts of property keys, property types, and property values do not match.\n * @group Implementation\n */\nexport async function mintSoulBoundTransaction(args: {\n aptosConfig: AptosConfig;\n account: Account;\n collection: string;\n description: string;\n name: string;\n uri: string;\n recipient: AccountAddressInput;\n propertyKeys?: Array<string>;\n propertyTypes?: Array<PropertyType>;\n propertyValues?: Array<PropertyValue>;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const {\n aptosConfig,\n account,\n collection,\n description,\n name,\n uri,\n recipient,\n propertyKeys,\n propertyTypes,\n propertyValues,\n options,\n } = args;\n if (propertyKeys?.length !== propertyValues?.length) {\n throw new Error(\"Property keys and property values counts do not match\");\n }\n if (propertyTypes?.length !== propertyValues?.length) {\n throw new Error(\"Property types and property values counts do not match\");\n }\n const convertedPropertyType = propertyTypes?.map((type) => PropertyTypeMap[type]);\n return generateTransaction({\n aptosConfig,\n sender: account.accountAddress,\n data: {\n function: \"0x4::aptos_token::mint_soul_bound\",\n functionArguments: [\n collection,\n description,\n name,\n uri,\n MoveVector.MoveString(propertyKeys ?? []),\n MoveVector.MoveString(convertedPropertyType ?? []),\n getPropertyValueRaw(propertyValues ?? [], convertedPropertyType ?? []),\n recipient,\n ],\n abi: mintSoulBoundAbi,\n },\n options,\n });\n}\n\nconst burnDigitalAssetAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0)))],\n};\n\n/**\n * Creates a transaction to burn a specified digital asset.\n * This function allows users to permanently remove a digital asset from their account.\n *\n * @param args - The arguments for the transaction.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.creator - The account that is initiating the burn transaction.\n * @param args.digitalAssetAddress - The address of the digital asset to be burned.\n * @param args.digitalAssetType - Optional; the type of the digital asset being burned.\n * @param args.options - Optional; additional options for generating the transaction.\n * @group Implementation\n */\nexport async function burnDigitalAssetTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::burn\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [AccountAddress.from(digitalAssetAddress)],\n abi: burnDigitalAssetAbi,\n },\n options,\n });\n}\n\nconst freezeDigitalAssetAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0)))],\n};\n\n/**\n * Creates a transaction to freeze the transfer of a digital asset.\n * This function helps you prevent the transfer of a specified digital asset by generating the appropriate transaction.\n *\n * @param args - The parameters for the transaction.\n * @param args.aptosConfig - The configuration settings for the Aptos client.\n * @param args.creator - The account that is creating the transaction.\n * @param args.digitalAssetAddress - The address of the digital asset to be frozen.\n * @param args.digitalAssetType - (Optional) The type of the digital asset as a Move struct ID.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function freezeDigitalAssetTransferTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::freeze_transfer\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [digitalAssetAddress],\n abi: freezeDigitalAssetAbi,\n },\n options,\n });\n}\n\nconst unfreezeDigitalAssetAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0)))],\n};\n\n/**\n * Unfreezes a digital asset transfer transaction, allowing the transfer of the specified digital asset.\n *\n * @param args - The arguments for unfreezing the digital asset transfer transaction.\n * @param args.aptosConfig - The Aptos configuration settings.\n * @param args.creator - The account that is initiating the unfreeze transaction.\n * @param args.digitalAssetAddress - The address of the digital asset to be unfrozen.\n * @param args.digitalAssetType - (Optional) The type of the digital asset being unfrozen.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function unfreezeDigitalAssetTransferTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::unfreeze_transfer\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [digitalAssetAddress],\n abi: unfreezeDigitalAssetAbi,\n },\n options,\n });\n}\n\nconst setDigitalAssetDescriptionAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagStruct(stringStructTag())],\n};\n\n/**\n * Sets the description for a digital asset, allowing users to provide additional context or information about the asset.\n *\n * @param args - The arguments for setting the digital asset description.\n * @param args.aptosConfig - The Aptos configuration to use for the transaction.\n * @param args.creator - The account that is creating the transaction.\n * @param args.description - The new description for the digital asset.\n * @param args.digitalAssetAddress - The address of the digital asset whose description is being set.\n * @param args.digitalAssetType - (Optional) The type of the digital asset.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function setDigitalAssetDescriptionTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n description: string;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, description, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::set_description\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [AccountAddress.from(digitalAssetAddress), new MoveString(description)],\n abi: setDigitalAssetDescriptionAbi,\n },\n options,\n });\n}\n\nconst setDigitalAssetNameAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagStruct(stringStructTag())],\n};\n\n/**\n * Sets the name of a digital asset on the Aptos blockchain.\n * This function allows you to update the name of a specified digital asset, enabling better identification and categorization.\n *\n * @param args - The parameters for setting the digital asset name.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.creator - The account that is creating the transaction.\n * @param args.name - The new name to assign to the digital asset.\n * @param args.digitalAssetAddress - The address of the digital asset to update.\n * @param args.digitalAssetType - (Optional) The type of the digital asset, represented as a Move struct ID.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function setDigitalAssetNameTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n name: string;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, name, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::set_name\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [AccountAddress.from(digitalAssetAddress), new MoveString(name)],\n abi: setDigitalAssetNameAbi,\n },\n options,\n });\n}\n\nconst setDigitalAssetURIAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagStruct(stringStructTag())],\n};\n\n/**\n * Sets the URI for a digital asset, allowing you to update the metadata associated with it.\n *\n * @param args - The arguments for setting the digital asset URI.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.creator - The account that is creating the transaction.\n * @param args.uri - The new URI to be set for the digital asset.\n * @param args.digitalAssetAddress - The address of the digital asset whose URI is being set.\n * @param args.digitalAssetType - The optional type of the digital asset; defaults to a predefined type if not provided.\n * @param args.options - Optional settings for generating the transaction.\n * @group Implementation\n */\nexport async function setDigitalAssetURITransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n uri: string;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, uri, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::set_uri\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [AccountAddress.from(digitalAssetAddress), new MoveString(uri)],\n abi: setDigitalAssetURIAbi,\n },\n options,\n });\n}\n\nconst addDigitalAssetPropertyAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [\n new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n TypeTagVector.u8(),\n ],\n};\n\n/**\n * Creates a transaction to add a property to a digital asset.\n * This function helps in enhancing the metadata associated with a digital asset by allowing the addition of custom properties.\n *\n * @param args - The arguments for the transaction.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.creator - The account that is creating the transaction.\n * @param args.propertyKey - The key for the property being added.\n * @param args.propertyType - The type of the property being added.\n * @param args.propertyValue - The value of the property being added.\n * @param args.digitalAssetAddress - The address of the digital asset to which the property is being added.\n * @param args.digitalAssetType - The optional type of the digital asset.\n * @param args.options - Optional transaction generation options.\n * @group Implementation\n */\nexport async function addDigitalAssetPropertyTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n propertyKey: string;\n propertyType: PropertyType;\n propertyValue: PropertyValue;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const {\n aptosConfig,\n creator,\n propertyKey,\n propertyType,\n propertyValue,\n digitalAssetAddress,\n digitalAssetType,\n options,\n } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::add_property\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [\n AccountAddress.from(digitalAssetAddress),\n new MoveString(propertyKey),\n new MoveString(PropertyTypeMap[propertyType]),\n MoveVector.U8(getSinglePropertyValueRaw(propertyValue, PropertyTypeMap[propertyType])),\n ],\n abi: addDigitalAssetPropertyAbi,\n },\n options,\n });\n}\n\nconst removeDigitalAssetPropertyAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))), new TypeTagStruct(stringStructTag())],\n};\n\n/**\n * Removes a property from a digital asset on the Aptos blockchain.\n * This function helps in managing the attributes of digital assets by allowing the removal of specific properties.\n *\n * @param args - The arguments for the transaction.\n * @param args.aptosConfig - The configuration object for Aptos.\n * @param args.creator - The account that is creating the transaction.\n * @param args.propertyKey - The key of the property to be removed.\n * @param args.digitalAssetAddress - The address of the digital asset from which the property will be removed.\n * @param args.digitalAssetType - The type of the digital asset (optional).\n * @param args.options - Additional options for generating the transaction (optional).\n * @group Implementation\n */\nexport async function removeDigitalAssetPropertyTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n propertyKey: string;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const { aptosConfig, creator, propertyKey, digitalAssetAddress, digitalAssetType, options } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::remove_property\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [AccountAddress.from(digitalAssetAddress), new MoveString(propertyKey)],\n abi: removeDigitalAssetPropertyAbi,\n },\n options,\n });\n}\n\nconst updateDigitalAssetPropertyAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }],\n parameters: [\n new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))),\n new TypeTagStruct(stringStructTag()),\n new TypeTagStruct(stringStructTag()),\n TypeTagVector.u8(),\n ],\n};\n\n/**\n * Updates a property of a digital asset by generating a transaction for the Aptos blockchain.\n * This function allows you to modify attributes of a digital asset, facilitating dynamic changes to its properties.\n *\n * @param args - The arguments for updating the digital asset property.\n * @param args.aptosConfig - The configuration settings for the Aptos blockchain.\n * @param args.creator - The account that is creating the transaction.\n * @param args.propertyKey - The key of the property to be updated.\n * @param args.propertyType - The type of the property being updated.\n * @param args.propertyValue - The new value for the property.\n * @param args.digitalAssetAddress - The address of the digital asset to update.\n * @param args.digitalAssetType - (Optional) The type of the digital asset.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function updateDigitalAssetPropertyTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n propertyKey: string;\n propertyType: PropertyType;\n propertyValue: PropertyValue;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const {\n aptosConfig,\n creator,\n propertyKey,\n propertyType,\n propertyValue,\n digitalAssetAddress,\n digitalAssetType,\n options,\n } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::update_property\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType],\n functionArguments: [\n AccountAddress.from(digitalAssetAddress),\n new MoveString(propertyKey),\n new MoveString(PropertyTypeMap[propertyType]),\n\n /**\n * Retrieves the raw byte representation of a single property value based on its type.\n *\n * @param propertyValue - The value of the property to convert.\n * @param propertyType - The type of the property, which determines how the value is processed.\n * @returns The raw byte representation of the property value.\n * @group Implementation\n */\n getSinglePropertyValueRaw(propertyValue, PropertyTypeMap[propertyType]),\n ],\n abi: updateDigitalAssetPropertyAbi,\n },\n options,\n });\n}\n\nconst addDigitalAssetTypedPropertyAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }, { constraints: [] }],\n parameters: [\n new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))),\n new TypeTagStruct(stringStructTag()),\n new TypeTagGeneric(1),\n ],\n};\n\n/**\n * Creates a transaction to add a typed property to a digital asset.\n * This function helps in customizing digital assets by associating them with specific properties.\n *\n * @param args - The arguments required to create the transaction.\n * @param args.aptosConfig - The configuration settings for Aptos.\n * @param args.creator - The account that is creating the transaction.\n * @param args.propertyKey - The key for the property being added.\n * @param args.propertyType - The type of the property being added.\n * @param args.propertyValue - The value of the property being added.\n * @param args.digitalAssetAddress - The address of the digital asset to which the property is being added.\n * @param args.digitalAssetType - (Optional) The type of the digital asset.\n * @param args.options - (Optional) Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function addDigitalAssetTypedPropertyTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n propertyKey: string;\n propertyType: PropertyType;\n propertyValue: PropertyValue;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const {\n aptosConfig,\n creator,\n propertyKey,\n propertyType,\n propertyValue,\n digitalAssetAddress,\n digitalAssetType,\n options,\n } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::add_typed_property\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType, PropertyTypeMap[propertyType]],\n functionArguments: [AccountAddress.from(digitalAssetAddress), new MoveString(propertyKey), propertyValue],\n abi: addDigitalAssetTypedPropertyAbi,\n },\n options,\n });\n}\n\nconst updateDigitalAssetTypedPropertyAbi: EntryFunctionABI = {\n typeParameters: [{ constraints: [MoveAbility.KEY] }, { constraints: [] }],\n parameters: [\n new TypeTagStruct(objectStructTag(new TypeTagGeneric(0))),\n new TypeTagStruct(stringStructTag()),\n new TypeTagGeneric(1),\n ],\n};\n\n/**\n * Updates the typed property of a digital asset by generating a transaction for the Aptos blockchain.\n *\n * @param args - The arguments for updating the digital asset typed property.\n * @param args.aptosConfig - The configuration settings for the Aptos network.\n * @param args.creator - The account that is creating the transaction.\n * @param args.propertyKey - The key of the property to be updated.\n * @param args.propertyType - The type of the property being updated.\n * @param args.propertyValue - The new value for the property.\n * @param args.digitalAssetAddress - The address of the digital asset to be updated.\n * @param args.digitalAssetType - Optional. The type of the digital asset, if not provided, defaults to the standard type.\n * @param args.options - Optional. Additional options for generating the transaction.\n * @group Implementation\n */\nexport async function updateDigitalAssetTypedPropertyTransaction(args: {\n aptosConfig: AptosConfig;\n creator: Account;\n propertyKey: string;\n propertyType: PropertyType;\n propertyValue: PropertyValue;\n digitalAssetAddress: AccountAddressInput;\n digitalAssetType?: MoveStructId;\n options?: InputGenerateTransactionOptions;\n}): Promise<SimpleTransaction> {\n const {\n aptosConfig,\n creator,\n propertyKey,\n propertyType,\n propertyValue,\n digitalAssetAddress,\n digitalAssetType,\n options,\n } = args;\n return generateTransaction({\n aptosConfig,\n sender: creator.accountAddress,\n data: {\n function: \"0x4::aptos_token::update_typed_property\",\n typeArguments: [digitalAssetType ?? defaultDigitalAssetType, PropertyTypeMap[propertyType]],\n functionArguments: [AccountAddress.from(digitalAssetAddress), new MoveString(propertyKey), propertyValue],\n abi: updateDigitalAssetTypedPropertyAbi,\n },\n options,\n });\n}\n\nfunction getPropertyValueRaw(propertyValues: Array<PropertyValue>, propertyTypes: Array<string>): Array<Uint8Array> {\n const results = new Array<Uint8Array>();\n propertyTypes.forEach((typ, index) => {\n results.push(getSinglePropertyValueRaw(propertyValues[index], typ));\n });\n\n return results;\n}\n\nfunction getSinglePropertyValueRaw(propertyValue: PropertyValue, propertyType: string): Uint8Array {\n const typeTag = parseTypeTag(propertyType);\n const res = checkOrConvertArgument(propertyValue, typeTag, 0, []);\n return res.bcsToBytes();\n}\n"]}
|