@aptos-labs/ts-sdk 1.33.2 → 1.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/common/{accountAddress-Cf1amU98.d.ts → accountAddress-CDtCLtJA.d.ts} +3 -2
- package/dist/common/chunk-ZYPBABLQ.js +4 -0
- package/dist/common/chunk-ZYPBABLQ.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +2631 -2273
- package/dist/common/index.js +28 -30
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +1 -0
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +91 -0
- package/dist/esm/account/AbstractedAccount.mjs +2 -0
- package/dist/esm/account/Account.d.mts +1 -0
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +17 -16
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +1 -0
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +1 -0
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +1 -0
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +1 -0
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +1 -0
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +1 -0
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +3 -0
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.d.mts +1 -0
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.d.mts +209 -0
- package/dist/esm/api/account/abstraction.mjs +2 -0
- package/dist/esm/api/account.d.mts +3 -0
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +1 -0
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +3 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -0
- package/dist/esm/api/coin.d.mts +1 -0
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +1 -0
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +1 -0
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +1 -0
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +1 -0
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +1 -0
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +3 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +2 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +1 -0
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +1 -0
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -0
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -0
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +66 -0
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +1 -0
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +1 -0
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs.map +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -0
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +1 -0
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +1 -0
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +1 -0
- package/dist/esm/bcs/deserializer.d.mts +1 -0
- package/dist/esm/bcs/index.d.mts +1 -0
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -0
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -0
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -0
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -0
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +1 -0
- package/dist/esm/{chunk-OEQ2U7GK.mjs → chunk-2FNFUTFJ.mjs} +2 -2
- package/dist/esm/{chunk-DOQV5BSA.mjs → chunk-2GIPNLDO.mjs} +2 -2
- package/dist/esm/{chunk-6YHDZLRN.mjs → chunk-33CBJFX2.mjs} +2 -2
- package/dist/esm/{chunk-WUWPN7XV.mjs → chunk-3EY7MT2M.mjs} +2 -2
- package/dist/esm/{chunk-2UXW3EB7.mjs → chunk-3HFZN7L5.mjs} +2 -2
- package/dist/esm/chunk-3OLFJ65O.mjs +2 -0
- package/dist/esm/chunk-3OLFJ65O.mjs.map +1 -0
- package/dist/esm/chunk-42T3UGSW.mjs +2 -0
- package/dist/esm/chunk-42T3UGSW.mjs.map +1 -0
- package/dist/esm/chunk-4776UXL6.mjs +2 -0
- package/dist/esm/chunk-4776UXL6.mjs.map +1 -0
- package/dist/esm/{chunk-QQEK7WVP.mjs → chunk-4T75XRI2.mjs} +2 -2
- package/dist/esm/{chunk-MCLYDS3O.mjs → chunk-4UK4MUSD.mjs} +2 -2
- package/dist/esm/{chunk-FIEMUPXF.mjs → chunk-5BSMF22B.mjs} +2 -2
- package/dist/esm/chunk-66HHRRIX.mjs +2 -0
- package/dist/esm/chunk-66HHRRIX.mjs.map +1 -0
- package/dist/esm/{chunk-XYB6KYKW.mjs → chunk-6JTNS5O6.mjs} +2 -2
- package/dist/esm/{chunk-E7JDVKFY.mjs → chunk-6LGXFXXR.mjs} +2 -2
- package/dist/esm/{chunk-43GCGE6C.mjs → chunk-6PBMD2BQ.mjs} +2 -2
- package/dist/esm/chunk-7C2RDOWS.mjs +1 -0
- package/dist/esm/{chunk-OROPNHRY.mjs → chunk-7CYCKCVU.mjs} +2 -2
- package/dist/esm/chunk-7DPHPPMG.mjs +2 -0
- package/dist/esm/chunk-7DPHPPMG.mjs.map +1 -0
- package/dist/esm/chunk-ABXES4FS.mjs +2 -0
- package/dist/esm/chunk-ABXES4FS.mjs.map +1 -0
- package/dist/esm/{chunk-VV4HCOJQ.mjs → chunk-AC3BISWL.mjs} +2 -2
- package/dist/esm/chunk-BBUN4IO4.mjs +2 -0
- package/dist/esm/chunk-BBUN4IO4.mjs.map +1 -0
- package/dist/esm/{chunk-QHEKBHNU.mjs → chunk-BUTMGMSD.mjs} +2 -2
- package/dist/esm/{chunk-V6VPMNWJ.mjs → chunk-BYHCW7MI.mjs} +2 -2
- package/dist/esm/{chunk-M77M6NSB.mjs → chunk-CRFLR3ZY.mjs} +2 -2
- package/dist/esm/chunk-CSG67JHZ.mjs +2 -0
- package/dist/esm/chunk-CSG67JHZ.mjs.map +1 -0
- package/dist/esm/{chunk-5VMAJTTV.mjs → chunk-CXNF73OX.mjs} +2 -2
- package/dist/esm/{chunk-4EUS4E6S.mjs → chunk-D6T3NYOA.mjs} +2 -2
- package/dist/esm/chunk-DBIZE7G6.mjs +2 -0
- package/dist/esm/chunk-DBIZE7G6.mjs.map +1 -0
- package/dist/esm/{chunk-X6UNY6YM.mjs → chunk-DLLDRANJ.mjs} +2 -2
- package/dist/esm/{chunk-ZAIVZDOL.mjs → chunk-DMS7K76O.mjs} +2 -2
- package/dist/esm/chunk-DNJQWGB7.mjs +2 -0
- package/dist/esm/chunk-DNJQWGB7.mjs.map +1 -0
- package/dist/esm/{chunk-BGSEBFFC.mjs → chunk-DNWFDS7F.mjs} +2 -2
- package/dist/esm/{chunk-OHZURQPY.mjs → chunk-DWJ3PGWE.mjs} +2 -2
- package/dist/esm/chunk-EGZI6EJ2.mjs +2 -0
- package/dist/esm/chunk-EGZI6EJ2.mjs.map +1 -0
- package/dist/esm/chunk-EY2JUXEC.mjs +2 -0
- package/dist/esm/{chunk-77AEKF7K.mjs.map → chunk-EY2JUXEC.mjs.map} +1 -1
- package/dist/esm/{chunk-IEUEMBFD.mjs → chunk-G6RLN6ET.mjs} +2 -2
- package/dist/esm/{chunk-NBNZ53ZV.mjs → chunk-GQX5KMF7.mjs} +2 -2
- package/dist/esm/{chunk-2FBJWTJD.mjs → chunk-H4GZWYIG.mjs} +2 -2
- package/dist/esm/chunk-HEAWDTLG.mjs +2 -0
- package/dist/esm/chunk-HEAWDTLG.mjs.map +1 -0
- package/dist/esm/{chunk-2N5KYALM.mjs → chunk-HFCWJ6QL.mjs} +2 -2
- package/dist/esm/{chunk-2TJ6OTVD.mjs → chunk-HL2O3T57.mjs} +2 -2
- package/dist/esm/chunk-HLJE5XGE.mjs +2 -0
- package/dist/esm/chunk-HLJE5XGE.mjs.map +1 -0
- package/dist/esm/{chunk-5EYTHMRZ.mjs → chunk-HT2WC3QV.mjs} +2 -2
- package/dist/esm/{chunk-VVXBVJXD.mjs → chunk-I7YHK6ZF.mjs} +2 -2
- package/dist/esm/chunk-IMTC3J2M.mjs +2 -0
- package/dist/esm/chunk-IMTC3J2M.mjs.map +1 -0
- package/dist/esm/{chunk-ONTWK5FU.mjs → chunk-J7HRQ2IH.mjs} +2 -2
- package/dist/esm/{chunk-S7RZGC56.mjs → chunk-JF66JS2R.mjs} +2 -2
- package/dist/esm/{chunk-UC23V7PU.mjs → chunk-KEJAUCQF.mjs} +2 -2
- package/dist/esm/{chunk-6CXMDJQR.mjs → chunk-L2AQG3G3.mjs} +2 -2
- package/dist/esm/{chunk-XTJOA5QN.mjs → chunk-L6FONDPA.mjs} +2 -2
- package/dist/esm/{chunk-67ZVDKJF.mjs → chunk-N7C6LQPZ.mjs} +2 -2
- package/dist/esm/{chunk-OR6GFWLG.mjs → chunk-O37BZP2G.mjs} +2 -2
- package/dist/esm/{chunk-XZ4JRYCE.mjs → chunk-OURSLL3I.mjs} +2 -2
- package/dist/esm/{chunk-7IY3DTEF.mjs → chunk-P7SE5LQE.mjs} +2 -2
- package/dist/esm/{chunk-6YWYAVFS.mjs → chunk-PNSF3E67.mjs} +2 -2
- package/dist/esm/{chunk-E5HGSOG2.mjs → chunk-PR3W2QEH.mjs} +2 -2
- package/dist/esm/{chunk-P7A5RILV.mjs → chunk-PWYJWTEM.mjs} +2 -2
- package/dist/esm/{chunk-ZPV7HPA4.mjs → chunk-Q7RG7KQS.mjs} +2 -2
- package/dist/esm/{chunk-WQRGDSPD.mjs → chunk-QBFGY74I.mjs} +2 -2
- package/dist/esm/{chunk-XY43TPRH.mjs → chunk-S47HA7O7.mjs} +2 -2
- package/dist/esm/{chunk-5EBUWO2M.mjs → chunk-SCBYJU6K.mjs} +2 -2
- package/dist/esm/chunk-TDGUMBON.mjs +4 -0
- package/dist/esm/chunk-TDGUMBON.mjs.map +1 -0
- package/dist/esm/{chunk-FZD5RWSZ.mjs → chunk-TM6IKHMX.mjs} +2 -2
- package/dist/esm/{chunk-KOORZTHC.mjs → chunk-U2SJIG2T.mjs} +2 -2
- package/dist/esm/chunk-UIRAXHDH.mjs +1 -0
- package/dist/esm/chunk-UIRAXHDH.mjs.map +1 -0
- package/dist/esm/{chunk-S4LZMY2L.mjs → chunk-ULHOJ2BE.mjs} +2 -2
- package/dist/esm/{chunk-VUIHJIMX.mjs → chunk-UTXEW2FT.mjs} +2 -2
- package/dist/esm/{chunk-4ZYPDCSP.mjs → chunk-V2EXS6TM.mjs} +2 -2
- package/dist/esm/{chunk-6IEZPA4H.mjs → chunk-V7G2EDNR.mjs} +2 -2
- package/dist/esm/{chunk-MWBRD43V.mjs → chunk-VKDTI6NX.mjs} +2 -2
- package/dist/esm/{chunk-NYETBDSR.mjs → chunk-VOCI2675.mjs} +2 -2
- package/dist/esm/{chunk-NWLJ6RW7.mjs → chunk-WXDA4CCR.mjs} +2 -2
- package/dist/esm/{chunk-ZGVNZE7J.mjs → chunk-X24PSWCX.mjs} +2 -2
- package/dist/esm/chunk-X2CPDUOS.mjs +2 -0
- package/dist/esm/chunk-X2CPDUOS.mjs.map +1 -0
- package/dist/esm/{chunk-YCQUYDZI.mjs → chunk-X6IHNXWY.mjs} +2 -2
- package/dist/esm/{chunk-JJM6ELMS.mjs → chunk-XAPQNCTN.mjs} +2 -2
- package/dist/esm/{chunk-5YWH3XPN.mjs → chunk-XDIX7NIP.mjs} +2 -2
- package/dist/esm/{chunk-DYATTONT.mjs → chunk-XH3BEKII.mjs} +2 -2
- package/dist/esm/{chunk-AXYARCYT.mjs → chunk-XXHZQFYW.mjs} +2 -2
- package/dist/esm/{chunk-3RCAJICY.mjs → chunk-Y3Y4DVCK.mjs} +2 -2
- package/dist/esm/{chunk-OSBRPVVI.mjs → chunk-YIF242TF.mjs} +2 -2
- package/dist/esm/{chunk-CWKNJZB6.mjs → chunk-ZCEBDPBJ.mjs} +2 -2
- package/dist/esm/{chunk-2WCATZVL.mjs → chunk-ZP5EBIBE.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +1 -0
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +1 -0
- package/dist/esm/client/core.d.mts +1 -0
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -0
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +1 -0
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -0
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +1 -0
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +1 -0
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +1 -0
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +1 -0
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +1 -0
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.d.mts +30 -0
- package/dist/esm/core/crypto/abstraction.mjs +2 -0
- package/dist/esm/core/crypto/abstraction.mjs.map +1 -0
- package/dist/esm/core/crypto/ed25519.d.mts +1 -0
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +1 -0
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +1 -0
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +1 -0
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +1 -0
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +1 -0
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +1 -0
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +1 -0
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +1 -0
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +1 -0
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +1 -0
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +1 -0
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +1 -0
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.d.mts +1 -0
- package/dist/esm/core/hex.d.mts +1 -0
- package/dist/esm/core/index.d.mts +1 -0
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +1 -0
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +10 -5
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.d.mts +55 -0
- package/dist/esm/internal/abstraction.mjs +2 -0
- package/dist/esm/internal/abstraction.mjs.map +1 -0
- package/dist/esm/internal/account.d.mts +1 -0
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -0
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +1 -0
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +1 -0
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +1 -0
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -0
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +1 -0
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +1 -0
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +1 -0
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +1 -0
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -0
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +1 -0
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -0
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +1 -0
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +1 -0
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +12 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +2 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +3 -2
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +6 -4
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +1 -0
- package/dist/esm/transactions/instances/identifier.d.mts +1 -0
- package/dist/esm/transactions/instances/index.d.mts +1 -0
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -0
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -0
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +5 -4
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -0
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -0
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -0
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +1 -0
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +1 -0
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +1 -0
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/scriptComposer/index.d.mts +53 -0
- package/dist/esm/transactions/scriptComposer/index.mjs +2 -0
- package/dist/esm/transactions/scriptComposer/index.mjs.map +1 -0
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +3 -17
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +3 -2
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +23 -2
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -0
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +3 -2
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +1 -0
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +1 -0
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +10 -1
- package/dist/esm/types/abstraction.d.mts +8 -0
- package/dist/esm/types/abstraction.mjs +2 -0
- package/dist/esm/types/abstraction.mjs.map +1 -0
- package/dist/esm/types/index.d.mts +1 -0
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +3 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +19 -2
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +2 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +1 -0
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +25 -18
- package/src/account/AbstractedAccount.ts +111 -0
- package/src/account/index.ts +1 -0
- package/src/api/account/abstraction.ts +239 -0
- package/src/api/account.ts +6 -1
- package/src/api/aptos.ts +3 -0
- package/src/api/transactionSubmission/build.ts +85 -2
- package/src/core/crypto/abstraction.ts +47 -0
- package/src/internal/abstraction.ts +79 -0
- package/src/transactions/authenticator/account.ts +52 -1
- package/src/transactions/index.ts +1 -0
- package/src/transactions/scriptComposer/index.ts +87 -0
- package/src/transactions/transactionBuilder/helpers.ts +1 -22
- package/src/transactions/transactionBuilder/remoteAbi.ts +62 -1
- package/src/transactions/transactionBuilder/transactionBuilder.ts +2 -1
- package/src/transactions/types.ts +11 -0
- package/src/types/abstraction.ts +6 -0
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +1 -0
- package/src/utils/helpers.ts +28 -1
- package/src/version.ts +1 -1
- package/dist/common/chunk-IHUCZKG2.js +0 -2
- package/dist/common/chunk-IHUCZKG2.js.map +0 -1
- package/dist/esm/chunk-5PXDPMF2.mjs +0 -4
- package/dist/esm/chunk-5PXDPMF2.mjs.map +0 -1
- package/dist/esm/chunk-77AEKF7K.mjs +0 -2
- package/dist/esm/chunk-AFEHO5PP.mjs +0 -2
- package/dist/esm/chunk-AFEHO5PP.mjs.map +0 -1
- package/dist/esm/chunk-DAFSKSZ5.mjs +0 -2
- package/dist/esm/chunk-DAFSKSZ5.mjs.map +0 -1
- package/dist/esm/chunk-FD6FGKYY.mjs +0 -1
- package/dist/esm/chunk-GP4TLDVZ.mjs +0 -1
- package/dist/esm/chunk-HBH2NQKU.mjs +0 -2
- package/dist/esm/chunk-HBH2NQKU.mjs.map +0 -1
- package/dist/esm/chunk-I5OYNCZS.mjs +0 -1
- package/dist/esm/chunk-JBEUUULP.mjs +0 -2
- package/dist/esm/chunk-JBEUUULP.mjs.map +0 -1
- package/dist/esm/chunk-KVM2SGSF.mjs +0 -2
- package/dist/esm/chunk-KVM2SGSF.mjs.map +0 -1
- package/dist/esm/chunk-MLSAZJZK.mjs +0 -2
- package/dist/esm/chunk-MLSAZJZK.mjs.map +0 -1
- package/dist/esm/chunk-QHC5DKVZ.mjs +0 -2
- package/dist/esm/chunk-QHC5DKVZ.mjs.map +0 -1
- package/dist/esm/chunk-U2PRGW4O.mjs +0 -2
- package/dist/esm/chunk-U2PRGW4O.mjs.map +0 -1
- /package/dist/esm/{chunk-FD6FGKYY.mjs.map → account/AbstractedAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-GP4TLDVZ.mjs.map → api/account/abstraction.mjs.map} +0 -0
- /package/dist/esm/{chunk-OEQ2U7GK.mjs.map → chunk-2FNFUTFJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-DOQV5BSA.mjs.map → chunk-2GIPNLDO.mjs.map} +0 -0
- /package/dist/esm/{chunk-6YHDZLRN.mjs.map → chunk-33CBJFX2.mjs.map} +0 -0
- /package/dist/esm/{chunk-WUWPN7XV.mjs.map → chunk-3EY7MT2M.mjs.map} +0 -0
- /package/dist/esm/{chunk-2UXW3EB7.mjs.map → chunk-3HFZN7L5.mjs.map} +0 -0
- /package/dist/esm/{chunk-QQEK7WVP.mjs.map → chunk-4T75XRI2.mjs.map} +0 -0
- /package/dist/esm/{chunk-MCLYDS3O.mjs.map → chunk-4UK4MUSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-FIEMUPXF.mjs.map → chunk-5BSMF22B.mjs.map} +0 -0
- /package/dist/esm/{chunk-XYB6KYKW.mjs.map → chunk-6JTNS5O6.mjs.map} +0 -0
- /package/dist/esm/{chunk-E7JDVKFY.mjs.map → chunk-6LGXFXXR.mjs.map} +0 -0
- /package/dist/esm/{chunk-43GCGE6C.mjs.map → chunk-6PBMD2BQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-I5OYNCZS.mjs.map → chunk-7C2RDOWS.mjs.map} +0 -0
- /package/dist/esm/{chunk-OROPNHRY.mjs.map → chunk-7CYCKCVU.mjs.map} +0 -0
- /package/dist/esm/{chunk-VV4HCOJQ.mjs.map → chunk-AC3BISWL.mjs.map} +0 -0
- /package/dist/esm/{chunk-QHEKBHNU.mjs.map → chunk-BUTMGMSD.mjs.map} +0 -0
- /package/dist/esm/{chunk-V6VPMNWJ.mjs.map → chunk-BYHCW7MI.mjs.map} +0 -0
- /package/dist/esm/{chunk-M77M6NSB.mjs.map → chunk-CRFLR3ZY.mjs.map} +0 -0
- /package/dist/esm/{chunk-5VMAJTTV.mjs.map → chunk-CXNF73OX.mjs.map} +0 -0
- /package/dist/esm/{chunk-4EUS4E6S.mjs.map → chunk-D6T3NYOA.mjs.map} +0 -0
- /package/dist/esm/{chunk-X6UNY6YM.mjs.map → chunk-DLLDRANJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZAIVZDOL.mjs.map → chunk-DMS7K76O.mjs.map} +0 -0
- /package/dist/esm/{chunk-BGSEBFFC.mjs.map → chunk-DNWFDS7F.mjs.map} +0 -0
- /package/dist/esm/{chunk-OHZURQPY.mjs.map → chunk-DWJ3PGWE.mjs.map} +0 -0
- /package/dist/esm/{chunk-IEUEMBFD.mjs.map → chunk-G6RLN6ET.mjs.map} +0 -0
- /package/dist/esm/{chunk-NBNZ53ZV.mjs.map → chunk-GQX5KMF7.mjs.map} +0 -0
- /package/dist/esm/{chunk-2FBJWTJD.mjs.map → chunk-H4GZWYIG.mjs.map} +0 -0
- /package/dist/esm/{chunk-2N5KYALM.mjs.map → chunk-HFCWJ6QL.mjs.map} +0 -0
- /package/dist/esm/{chunk-2TJ6OTVD.mjs.map → chunk-HL2O3T57.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EYTHMRZ.mjs.map → chunk-HT2WC3QV.mjs.map} +0 -0
- /package/dist/esm/{chunk-VVXBVJXD.mjs.map → chunk-I7YHK6ZF.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONTWK5FU.mjs.map → chunk-J7HRQ2IH.mjs.map} +0 -0
- /package/dist/esm/{chunk-S7RZGC56.mjs.map → chunk-JF66JS2R.mjs.map} +0 -0
- /package/dist/esm/{chunk-UC23V7PU.mjs.map → chunk-KEJAUCQF.mjs.map} +0 -0
- /package/dist/esm/{chunk-6CXMDJQR.mjs.map → chunk-L2AQG3G3.mjs.map} +0 -0
- /package/dist/esm/{chunk-XTJOA5QN.mjs.map → chunk-L6FONDPA.mjs.map} +0 -0
- /package/dist/esm/{chunk-67ZVDKJF.mjs.map → chunk-N7C6LQPZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-OR6GFWLG.mjs.map → chunk-O37BZP2G.mjs.map} +0 -0
- /package/dist/esm/{chunk-XZ4JRYCE.mjs.map → chunk-OURSLL3I.mjs.map} +0 -0
- /package/dist/esm/{chunk-7IY3DTEF.mjs.map → chunk-P7SE5LQE.mjs.map} +0 -0
- /package/dist/esm/{chunk-6YWYAVFS.mjs.map → chunk-PNSF3E67.mjs.map} +0 -0
- /package/dist/esm/{chunk-E5HGSOG2.mjs.map → chunk-PR3W2QEH.mjs.map} +0 -0
- /package/dist/esm/{chunk-P7A5RILV.mjs.map → chunk-PWYJWTEM.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPV7HPA4.mjs.map → chunk-Q7RG7KQS.mjs.map} +0 -0
- /package/dist/esm/{chunk-WQRGDSPD.mjs.map → chunk-QBFGY74I.mjs.map} +0 -0
- /package/dist/esm/{chunk-XY43TPRH.mjs.map → chunk-S47HA7O7.mjs.map} +0 -0
- /package/dist/esm/{chunk-5EBUWO2M.mjs.map → chunk-SCBYJU6K.mjs.map} +0 -0
- /package/dist/esm/{chunk-FZD5RWSZ.mjs.map → chunk-TM6IKHMX.mjs.map} +0 -0
- /package/dist/esm/{chunk-KOORZTHC.mjs.map → chunk-U2SJIG2T.mjs.map} +0 -0
- /package/dist/esm/{chunk-S4LZMY2L.mjs.map → chunk-ULHOJ2BE.mjs.map} +0 -0
- /package/dist/esm/{chunk-VUIHJIMX.mjs.map → chunk-UTXEW2FT.mjs.map} +0 -0
- /package/dist/esm/{chunk-4ZYPDCSP.mjs.map → chunk-V2EXS6TM.mjs.map} +0 -0
- /package/dist/esm/{chunk-6IEZPA4H.mjs.map → chunk-V7G2EDNR.mjs.map} +0 -0
- /package/dist/esm/{chunk-MWBRD43V.mjs.map → chunk-VKDTI6NX.mjs.map} +0 -0
- /package/dist/esm/{chunk-NYETBDSR.mjs.map → chunk-VOCI2675.mjs.map} +0 -0
- /package/dist/esm/{chunk-NWLJ6RW7.mjs.map → chunk-WXDA4CCR.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZGVNZE7J.mjs.map → chunk-X24PSWCX.mjs.map} +0 -0
- /package/dist/esm/{chunk-YCQUYDZI.mjs.map → chunk-X6IHNXWY.mjs.map} +0 -0
- /package/dist/esm/{chunk-JJM6ELMS.mjs.map → chunk-XAPQNCTN.mjs.map} +0 -0
- /package/dist/esm/{chunk-5YWH3XPN.mjs.map → chunk-XDIX7NIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-DYATTONT.mjs.map → chunk-XH3BEKII.mjs.map} +0 -0
- /package/dist/esm/{chunk-AXYARCYT.mjs.map → chunk-XXHZQFYW.mjs.map} +0 -0
- /package/dist/esm/{chunk-3RCAJICY.mjs.map → chunk-Y3Y4DVCK.mjs.map} +0 -0
- /package/dist/esm/{chunk-OSBRPVVI.mjs.map → chunk-YIF242TF.mjs.map} +0 -0
- /package/dist/esm/{chunk-CWKNJZB6.mjs.map → chunk-ZCEBDPBJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-2WCATZVL.mjs.map → chunk-ZP5EBIBE.mjs.map} +0 -0
package/dist/common/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkIHUCZKG2js = require('./chunk-IHUCZKG2.js');var Vr=255,Hr=65535,Ne=4294967295,gt=18446744073709551615n,ir=340282366920938463463374607431768211455n,qr=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var _utils = require('@noble/hashes/utils');var J=class extends Error{constructor(e,t){super(e),this.invalidReason=t}};var Fa=(n=>(n.TOO_SHORT="too_short",n.INVALID_LENGTH="invalid_length",n.INVALID_HEX_CHARS="invalid_hex_chars",n))(Fa||{}),m= exports.Hex =class r{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let t=e;if(t.startsWith("0x")&&(t=t.slice(2)),t.length===0)throw new J("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(t.length%2!==0)throw new J("Hex string must be an even number of hex characters.","invalid_length");try{return new r(_utils.hexToBytes.call(void 0, t))}catch(n){throw new J(`Hex string contains invalid hex characters: ${_optionalChain([n, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new r(e):r.fromHexString(e)}static hexInputToUint8Array(e){return e instanceof Uint8Array?e:r.fromHexString(e).toUint8Array()}static hexInputToString(e){return r.fromHexInput(e).toString()}static hexInputToStringWithoutPrefix(e){return r.fromHexInput(e).toStringWithoutPrefix()}static isValid(e){try{return r.fromHexString(e),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _4 => _4.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}},Fi= exports.hexToAsciiString =r=>new TextDecoder().decode(m.fromHexInput(r).toUint8Array());var D=class r{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=m.hexInputToUint8Array(e);return new r(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<Ne;){let n=this.deserializeU8();if(e|=BigInt(n&127)<<BigInt(t),!(n&128))break;t+=7}if(e>Ne)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),n=new Array;for(let i=0;i<t;i+=1)n.push(this.deserialize(e));return n}};var y=class{bcsToBytes(){let e=new B;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return m.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},B= exports.Serializer =class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let t=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,t,n){this.ensureBufferWillHandleSize(t);let i=new DataView(this.buffer,this.offset);e.apply(i,[0,n,!0]),this.offset+=t}serializeStr(e){let t=new TextEncoder;this.serializeBytes(t.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){Gn(e);let t=e?1:0;this.appendToBuffer(new Uint8Array([t]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let t=BigInt(e)&BigInt(Ne),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(t)),this.serializeU32(Number(n))}serializeU128(e){let t=BigInt(e)>,n=BigInt(e)>>BigInt(64);this.serializeU64(t),this.serializeU64(n)}serializeU256(e){let t=BigInt(e)&ir,n=BigInt(e)>>BigInt(128);this.serializeU128(t),this.serializeU128(n)}serializeU32AsUleb128(e){let t=e,n=[];for(;t>>>7;)n.push(t&127|128),t>>>=7;n.push(t),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(t=>{t.serialize(this)})}serializeOption(e,t){let n=e!==void 0;this.serializeBool(n),n&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?t!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};_chunkIHUCZKG2js.a.call(void 0, [yt(0,Vr)],B.prototype,"serializeU8",1),_chunkIHUCZKG2js.a.call(void 0, [yt(0,Hr)],B.prototype,"serializeU16",1),_chunkIHUCZKG2js.a.call(void 0, [yt(0,Ne)],B.prototype,"serializeU32",1),_chunkIHUCZKG2js.a.call(void 0, [yt(BigInt(0),gt)],B.prototype,"serializeU64",1),_chunkIHUCZKG2js.a.call(void 0, [yt(BigInt(0),ir)],B.prototype,"serializeU128",1),_chunkIHUCZKG2js.a.call(void 0, [yt(BigInt(0),qr)],B.prototype,"serializeU256",1),_chunkIHUCZKG2js.a.call(void 0, [yt(0,Ne)],B.prototype,"serializeU32AsUleb128",1);function Gn(r){if(typeof r!="boolean")throw new Error(`${r} is not a boolean value`)}var Ga=(r,e,t)=>`${r} is out of range: [${e}, ${t}]`;function tt(r,e,t){let n=BigInt(r);if(n>BigInt(t)||n<BigInt(e))throw new Error(Ga(r,e,t))}function yt(r,e){return(t,n,i)=>{let o=i.value;return i.value=function(a){return tt(a,r,e),o.apply(this,[a])},i}}var mt=class r extends y{constructor(e){super(),this.value=m.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let n=e.deserializeFixedBytes(t);return new r(n)}};var $r=class r extends y{constructor(e){super(),this.value=new mt(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let n=mt.deserialize(e,t);return new r(n.value)}};var Wr=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(Wr||{}),Gi= exports.TypeTagVariants =(d=>(d[d.Bool=0]="Bool",d[d.U8=1]="U8",d[d.U64=2]="U64",d[d.U128=3]="U128",d[d.Address=4]="Address",d[d.Signer=5]="Signer",d[d.Vector=6]="Vector",d[d.Struct=7]="Struct",d[d.U16=8]="U16",d[d.U32=9]="U32",d[d.U256=10]="U256",d[d.Reference=254]="Reference",d[d.Generic=255]="Generic",d))(Gi||{}),or= exports.ScriptTransactionArgumentVariants =(l=>(l[l.U8=0]="U8",l[l.U64=1]="U64",l[l.U128=2]="U128",l[l.Address=3]="Address",l[l.U8Vector=4]="U8Vector",l[l.Bool=5]="Bool",l[l.U16=6]="U16",l[l.U32=7]="U32",l[l.U256=8]="U256",l[l.Serialized=9]="Serialized",l))(or||{}),Bi= exports.TransactionPayloadVariants =(n=>(n[n.Script=0]="Script",n[n.EntryFunction=2]="EntryFunction",n[n.Multisig=3]="Multisig",n))(Bi||{}),Mi= exports.TransactionVariants =(t=>(t[t.MultiAgentTransaction=0]="MultiAgentTransaction",t[t.FeePayerTransaction=1]="FeePayerTransaction",t))(Mi||{}),Li= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(Li||{}),Vi= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o[o.NoAccountAuthenticator=4]="NoAccountAuthenticator",o))(Vi||{}),Qr= exports.PrivateKeyVariants =(t=>(t.Ed25519="ed25519",t.Secp256k1="secp256k1",t))(Qr||{}),sr= exports.AnyPublicKeyVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.Secp256k1=1]="Secp256k1",i[i.Keyless=3]="Keyless",i[i.FederatedKeyless=4]="FederatedKeyless",i))(sr||{}),Hi= exports.AnySignatureVariant =(n=>(n[n.Ed25519=0]="Ed25519",n[n.Secp256k1=1]="Secp256k1",n[n.Keyless=3]="Keyless",n))(Hi||{}),Bn= exports.EphemeralPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(Bn||{}),qi= exports.EphemeralSignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e))(qi||{}),Mn= exports.EphemeralCertificateVariant =(e=>(e[e.ZkProof=0]="ZkProof",e))(Mn||{}),Ln= exports.ZkpVariant =(e=>(e[e.Groth16=0]="Groth16",e))(Ln||{}),Vn= exports.TransactionResponseType =(a=>(a.Pending="pending_transaction",a.User="user_transaction",a.Genesis="genesis_transaction",a.BlockMetadata="block_metadata_transaction",a.StateCheckpoint="state_checkpoint_transaction",a.Validator="validator_transaction",a.BlockEpilogue="block_epilogue_transaction",a))(Vn||{});function sp(r){return r.type==="pending_transaction"}function ap(r){return r.type==="user_transaction"}function cp(r){return r.type==="genesis_transaction"}function up(r){return r.type==="block_metadata_transaction"}function pp(r){return r.type==="state_checkpoint_transaction"}function dp(r){return r.type==="validator_transaction"}function lp(r){return r.type==="block_epilogue_transaction"}function gp(r){return"signature"in r&&r.signature==="ed25519_signature"}function yp(r){return"signature"in r&&r.signature==="secp256k1_ecdsa_signature"}function mp(r){return r.type==="multi_agent_signature"}function fp(r){return r.type==="fee_payer_signature"}function Ap(r){return r.type==="multi_ed25519_signature"}var Ba=(n=>(n.PRIVATE="private",n.PUBLIC="public",n.FRIEND="friend",n))(Ba||{}),$i= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))($i||{}),Ma= exports.RoleType =(t=>(t.VALIDATOR="validator",t.FULL_NODE="full_node",t))(Ma||{}),oe= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(oe||{}),Hn= exports.SigningSchemeInput =(t=>(t[t.Ed25519=0]="Ed25519",t[t.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",t))(Hn||{}),Wi= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(Wi||{});var U=class r extends y{constructor(e){super(),Gn(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new ye(e.deserializeU256())}static deserialize(e){return new r(e.deserializeBool())}},X= exports.U8 =class r extends y{constructor(e){super(),tt(e,0,Vr),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new r(e.deserializeU8())}},_e= exports.U16 =class r extends y{constructor(e){super(),tt(e,0,Hr),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new r(e.deserializeU16())}},xe= exports.U32 =class r extends y{constructor(e){super(),tt(e,0,Ne),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new r(e.deserializeU32())}},Q= exports.U64 =class r extends y{constructor(e){super(),tt(e,BigInt(0),gt),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new r(e.deserializeU64())}},Ee= exports.U128 =class r extends y{constructor(e){super(),tt(e,BigInt(0),ir),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new r(e.deserializeU128())}},ye= exports.U256 =class r extends y{constructor(e){super(),tt(e,BigInt(0),qr),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new r(e.deserializeU256())}};var S=class r extends y{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof X)){new ar(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let n=m.fromHexInput(e);t=Array.from(n.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new r(t.map(n=>new X(n)))}static U16(e){return new r(e.map(t=>new _e(t)))}static U32(e){return new r(e.map(t=>new xe(t)))}static U64(e){return new r(e.map(t=>new Q(t)))}static U128(e){return new r(e.map(t=>new Ee(t)))}static U256(e){return new r(e.map(t=>new ye(t)))}static Bool(e){return new r(e.map(t=>new U(t)))}static MoveString(e){return new r(e.map(t=>new x(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let n=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<n;o+=1)i.push(t.deserialize(e));return new r(i)}},ar= exports.Serialized =class r extends y{constructor(e){super(),this.value=m.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new r(e.deserializeBytes())}toMoveVector(e){let t=new D(this.bcsToBytes());t.deserializeUleb128AsU32();let n=t.deserializeVector(e);return new S(n)}},x= exports.MoveString =class r extends y{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let n=new TextEncoder().encode(this.value);S.U8(n).serializeForScriptFunction(e)}static deserialize(e){return new r(e.deserializeStr())}},Y= exports.MoveOption =class r extends y{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new r(e!=null?new X(e):void 0)}static U16(e){return new r(e!=null?new _e(e):void 0)}static U32(e){return new r(e!=null?new xe(e):void 0)}static U64(e){return new r(e!=null?new Q(e):void 0)}static U128(e){return new r(e!=null?new Ee(e):void 0)}static U256(e){return new r(e!=null?new ye(e):void 0)}static Bool(e){return new r(e!=null?new U(e):void 0)}static MoveString(e){return new r(e!=null?new x(e):void 0)}static deserialize(e,t){let n=S.deserialize(e,t);return new r(n.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Va=(c=>(c.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",c.INVALID_HEX_CHARS="invalid_hex_chars",c.TOO_SHORT="too_short",c.TOO_LONG="too_long",c.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",c.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",c.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",c.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",c))(Va||{}),E=class E extends y{constructor(e){if(super(),e.length!==E.LENGTH)throw new J("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let t=e.deserializeFixedBytes(E.LENGTH);return new E(t)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new J("Hex string must start with a leading 0x.","leading_zero_x_required");let t=E.fromString(e);if(e.length!==E.LONG_STRING_LENGTH+2)if(t.isSpecial()){if(e.length!==3)throw new J(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new J(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return t}static fromString(e,{maxMissingChars:t=4}={}){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new J("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new J("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(t>63||t<0)throw new J(`maxMissingChars must be between or equal to 0 and 63. Received ${t}`,"INVALID_PADDING_STRICTNESS");let i;try{i=_utils.hexToBytes.call(void 0, n.padStart(64,"0"))}catch(s){throw new J(`Hex characters are invalid: ${_optionalChain([s, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}let o=new E(i);if(n.length<64-t&&!o.isSpecial())throw new J(`Hex string is too short, must be ${64-t} to 64 chars long, excluding the leading 0x. You may need to fix
|
|
2
|
-
the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
|
|
3
|
-
Received ${e}`,"too_short");return o}static from(e,{maxMissingChars:t=4}={}){return typeof e=="string"?E.fromString(e,{maxMissingChars:t}):e instanceof Uint8Array?new E(e):e}static fromStrict(e){return typeof e=="string"?E.fromStringStrict(e):e instanceof Uint8Array?new E(e):e}static isValid(e){try{return e.strict?E.fromStrict(e.input):E.from(e.input),{valid:!0}}catch(t){return{valid:!1,invalidReason:_optionalChain([t, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([t, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((t,n)=>t===e.data[n])}};E.LENGTH=32,E.LONG_STRING_LENGTH=64,E.ZERO=E.from("0x0"),E.ONE=E.from("0x1"),E.TWO=E.from("0x2"),E.THREE=E.from("0x3"),E.FOUR=E.from("0x4"),E.A=E.from("0xA");var u=E;var rt=class rt extends y{constructor(e){super();let{data:t}=e,n=m.fromHexInput(t);if(n.toUint8Array().length!==rt.LENGTH)throw new Error(`Authentication Key length should be ${rt.LENGTH}`);this.data=n}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(rt.LENGTH);return new rt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:n}=e,i=m.fromHexInput(n).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new rt({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};rt.LENGTH=32;var L=rt;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var ji = _interopRequireWildcard(_bip39);var Wa=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Qa= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,ja= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(ja||{}),Ji= exports.HARDENED_OFFSET =2147483648;function Xi(r){return Qa.test(r)}function Yi(r){return Wa.test(r)}var qn=(r,e)=>{let t=_hmac.hmac.create(_sha512.sha512,r).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Zi= exports.CKDPriv =({key:r,chainCode:e},t)=>{let n=new ArrayBuffer(4);new DataView(n).setUint32(0,t);let i=new Uint8Array(n),o=new Uint8Array([0]),s=new Uint8Array([...o,...r,...i]);return qn(e,s)},Ja=r=>r.replace(/'/g,""),eo= exports.splitPath =r=>r.split("/").slice(1).map(Ja),jr= exports.mnemonicToSeed =r=>{let e=r.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return ji.mnemonicToSeedSync(e)};var cr=class cr{static formatPrivateKey(e,t){let n=cr.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(n)&&(i=i.split("-")[2]),`${n}${m.fromHexInput(i).toString()}`}static parseHexInput(e,t,n){let i,o=cr.AIP80_PREFIXES[t];if(typeof e=="string")if(!n&&!e.startsWith(o))i=m.fromHexInput(e),n!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=m.fromHexString(e.split("-")[2]);else throw n?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=m.fromHexInput(e);return i}};cr.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var nt=cr;var ft=class extends y{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return m.fromHexInput(e).toString()}},se= exports.AccountPublicKey =class extends ft{};var V=class extends y{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return m.fromHexInput(e).toString()}};var zt=r=>typeof r=="string"?m.isValid(r).valid?r:new TextEncoder().encode(r):r;var $n=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Xa(r){let e=r.toUint8Array().slice(32);for(let t=$n.length-1;t>=0;t-=1){if(e[t]<$n[t])return!0;if(e[t]>$n[t])return!1}return!1}var it=class it extends se{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==it.LENGTH)throw new Error(`PublicKey length should be ${it.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:n}=e;if(!Xa(n))return!1;let i=zt(t),o=m.fromHexInput(i).toUint8Array(),s=n.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}authKey(){return L.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new it(t)}static isPublicKey(e){return e instanceof it}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _8 => _8.key, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.length])===it.LENGTH}};it.LENGTH=32;var P=it,me=class me extends y{constructor(e,t){super();let n=nt.parseHexInput(e,"ed25519",t);if(n.toUint8Array().length!==me.LENGTH)throw new Error(`PrivateKey length should be ${me.LENGTH}`);this.signingKey=n}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new me(e,!1)}static fromDerivationPath(e,t){if(!Yi(e))throw new Error(`Invalid derivation path ${e}`);return me.fromDerivationPathInner(e,jr(t))}static fromDerivationPathInner(e,t,n=Ji){let{key:i,chainCode:o}=qn(me.SLIP_0010_SEED,t),s=eo(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Zi(c,p+n),{key:i,chainCode:o});return new me(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let t=zt(e),n=m.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(n,this.signingKey.toUint8Array());return new I(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return nt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new me(t,!1)}static isPrivateKey(e){return e instanceof me}};me.LENGTH=32,me.SLIP_0010_SEED="ed25519 seed";var H=me,Dt=class Dt extends V{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Dt.LENGTH)throw new Error(`Signature length should be ${Dt.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Dt(t)}};Dt.LENGTH=64;var I=Dt;var fe=class fe extends se{constructor(e){super();let{publicKeys:t,threshold:n}=e;if(t.length>fe.MAX_KEYS||t.length<fe.MIN_KEYS)throw new Error(`Must have between ${fe.MIN_KEYS} and ${fe.MAX_KEYS} public keys, inclusive`);if(n<fe.MIN_THRESHOLD||n>t.length)throw new Error(`Threshold must be between ${fe.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=n}verifySignature(e){let{message:t,signature:n}=e;if(!(n instanceof At))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((n.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==n.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:n.signatures[o]}))return!1;return!0}authKey(){return L.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((t,n)=>{e.set(t.toUint8Array(),n*P.LENGTH)}),e[this.publicKeys.length*P.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),n=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=P.LENGTH){let s=o;i.push(new P(t.subarray(s,s+P.LENGTH)))}return new fe({publicKeys:i,threshold:n})}};fe.MAX_KEYS=32,fe.MIN_KEYS=2,fe.MIN_THRESHOLD=1;var Ot=fe,ce=class ce extends V{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ce.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(n instanceof Uint8Array))this.bitmap=ce.createBitmap({bits:n});else{if(n.length!==ce.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ce.BITMAP_LEN}`);this.bitmap=n}}toUint8Array(){let e=new Uint8Array(this.signatures.length*I.LENGTH+ce.BITMAP_LEN);return this.signatures.forEach((t,n)=>{e.set(t.toUint8Array(),n*I.LENGTH)}),e.set(this.bitmap,this.signatures.length*I.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),n=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-n.length;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new ce({signatures:i,bitmap:n})}static createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ce.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),p=i[c];p|=n>>s%8,i[c]=p}),i}};ce.MAX_SIGNATURES_SUPPORTED=32,ce.BITMAP_LEN=4;var At=ce;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Pe=class Pe extends ft{constructor(e){super();let t=m.fromHexInput(e),{length:n}=t.toUint8Array();if(n===Pe.LENGTH)this.key=t;else if(n===Pe.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=m.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Pe.LENGTH} or ${Pe.COMPRESSED_LENGTH}, received ${n}`)}verifySignature(e){let{message:t,signature:n}=e,i=zt(t),o=m.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=n.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new ht(t)}static deserialize(e){let t=e.deserializeBytes();return new Pe(t)}static isPublicKey(e){return e instanceof Pe}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _11 => _11.key, 'optionalAccess', _12 => _12.data, 'optionalAccess', _13 => _13.length])===Pe.LENGTH}};Pe.LENGTH=65,Pe.COMPRESSED_LENGTH=33;var Fe=Pe,Ce=class Ce extends y{constructor(e,t){super();let n=nt.parseHexInput(e,"secp256k1",t);if(n.toUint8Array().length!==Ce.LENGTH)throw new Error(`PrivateKey length should be ${Ce.LENGTH}`);this.key=n}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ce(e,!1)}static fromDerivationPath(e,t){if(!Xi(e))throw new Error(`Invalid derivation path ${e}`);return Ce.fromDerivationPathInner(e,jr(t))}static fromDerivationPathInner(e,t){let{privateKey:n}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(n===null)throw new Error("Invalid key");return new Ce(n,!1)}sign(e){let t=zt(e),n=m.fromHexInput(t),i=_sha3.sha3_256.call(void 0, n.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new ht(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Fe(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return nt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ce(t,!1)}static isPrivateKey(e){return e instanceof Ce}};Ce.LENGTH=32;var Ge=Ce,Nt=class Nt extends V{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Nt.LENGTH)throw new Error(`Signature length should be ${Nt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Nt(t)}};Nt.LENGTH=64;var ht=Nt;var _jwtdecode = require('jwt-decode');var Tt=class r extends ft{constructor(e){super();let t=e.constructor.name;switch(t){case P.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:n}=e;return this.publicKey.verifySignature({message:t,signature:n.signature})}serialize(e){if(this.publicKey instanceof P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof r}},Re= exports.EphemeralSignature =class r extends V{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=m.fromHexInput(e),n=new D(t.toUint8Array());return r.deserialize(n)}serialize(e){if(this.signature instanceof I)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var Wn=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],no=31,mc=16,ro=(mc-1)*no;function Xr(r,e){let n=new TextEncoder().encode(r);return fc(n,e)}function fc(r,e){if(r.length>e)throw new Error(`Inputted bytes of length ${r} is longer than ${e}`);let t=Qn(r,e);return dr(t)}function Ac(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);let t=bc(r,e);return hc(t)}function Qn(r,e){if(r.length>e)throw new Error(`Input bytes of length ${r} is longer than ${e}`);return Ac(r,e).concat([BigInt(r.length)])}function hc(r){if(r.length>ro)throw new Error(`Can't pack more than ${ro}. Was given ${r.length} bytes`);return Tc(r,no).map(e=>pr(e))}function Tc(r,e){let t=[];for(let n=0;n<r.length;n+=e)t.push(r.subarray(n,n+e));return t}function pr(r){let e=BigInt(0);for(let t=r.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(r[t]);return e}function io(r,e){let t=BigInt(r),n=new Uint8Array(e);for(let i=0;i<e;i+=1)n[i]=Number(t&BigInt(255)),t>>=BigInt(8);return n}function bc(r,e){if(e<r.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(r);for(let n=r.length;n<e;n+=1)t[n]=0;return t}function dr(r){if(r.length>Wn.length)throw new Error(`Unable to hash input of length ${r.length}. Max input length is ${Wn.length}`);return Wn[r.length-1](r)}var Yr=class extends y{};var oo="1.33.2";var so={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},ao= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},co= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},jn= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Jn= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Xn= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(Xn||{}),Yn= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},wl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var Ft=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(Ft||{}),uo= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,po= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Zr= exports.DEFAULT_TXN_TIMEOUT_SEC =20,bt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",lo= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",go= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Zn= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Be= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(Be||{}),yo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function mo(r,e){let t=e.bcsToBytes(),n=new D(t);return r.deserialize(n)}var wc=(o=>(o[o.API_ERROR=0]="API_ERROR",o[o.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",o[o.SESSION_EXPIRED=2]="SESSION_EXPIRED",o[o.INVALID_STATE=3]="INVALID_STATE",o[o.UNKNOWN=4]="UNKNOWN",o))(wc||{}),Sc= exports.KeylessErrorResolutionTip =(p=>(p.REAUTHENTICATE="Re-authentiate to continue using your keyless account",p.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",p.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",p.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.",p.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",p.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",p.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p))(Sc||{}),en= exports.KeylessErrorType =(f=>(f[f.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",f[f.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",f[f.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",f[f.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",f[f.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",f[f.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",f[f.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",f[f.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",f[f.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",f[f.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",f[f.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",f[f.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",f[f.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",f[f.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",f[f.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",f[f.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",f[f.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",f[f.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",f[f.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",f[f.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",f[f.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",f[f.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",f[f.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",f[f.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",f[f.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",f[f.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",f[f.UNKNOWN=26]="UNKNOWN",f))(en||{}),fo={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"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."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["An unknown error has occurred.",4,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},k= exports.KeylessError =class r extends Error{constructor(e){let{innerError:t,category:n,resolutionTip:i,type:o,message:s=fo[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=n,this.resolutionTip=i,this.type=o,this.details=a,this.message=r.constructMessage(s,i,t,a)}static constructMessage(e,t,n,i){let o=`
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkZYPBABLQjs = require('./chunk-ZYPBABLQ.js');var C=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunkZYPBABLQjs.j.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunkZYPBABLQjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>_chunkZYPBABLQjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var pt=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=_chunkZYPBABLQjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var Hn=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=new pt(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=pt.deserialize(e,t);return new n(r.value)}};var U=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.n.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new le(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},J= exports.U8 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,0,_chunkZYPBABLQjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},we= exports.U16 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,0,_chunkZYPBABLQjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},Se= exports.U32 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,0,_chunkZYPBABLQjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},W= exports.U64 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,BigInt(0),_chunkZYPBABLQjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},_e= exports.U128 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,BigInt(0),_chunkZYPBABLQjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},le= exports.U256 =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),_chunkZYPBABLQjs.p.call(void 0, e,BigInt(0),_chunkZYPBABLQjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var _=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof J)){new sn(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunkZYPBABLQjs.j.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new J(r)))}static U16(e){return new n(e.map(t=>new we(t)))}static U32(e){return new n(e.map(t=>new Se(t)))}static U64(e){return new n(e.map(t=>new W(t)))}static U128(e){return new n(e.map(t=>new _e(t)))}static U256(e){return new n(e.map(t=>new le(t)))}static Bool(e){return new n(e.map(t=>new U(t)))}static MoveString(e){return new n(e.map(t=>new E(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},sn= exports.Serialized =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=_chunkZYPBABLQjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new C(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new _(r)}},E= exports.MoveString =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);_.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},X= exports.MoveOption =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new _([e]):this.vec=new _([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new J(e):void 0)}static U16(e){return new n(e!=null?new we(e):void 0)}static U32(e){return new n(e!=null?new Se(e):void 0)}static U64(e){return new n(e!=null?new W(e):void 0)}static U128(e){return new n(e!=null?new _e(e):void 0)}static U256(e){return new n(e!=null?new le(e):void 0)}static Bool(e){return new n(e!=null?new U(e):void 0)}static MoveString(e){return new n(e!=null?new E(e):void 0)}static deserialize(e,t){let r=_.deserialize(e,t);return new n(r.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var tt=class tt extends _chunkZYPBABLQjs.l{constructor(e){super();let{data:t}=e,r=_chunkZYPBABLQjs.j.fromHexInput(t);if(r.toUint8Array().length!==tt.LENGTH)throw new Error(`Authentication Key length should be ${tt.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(tt.LENGTH);return new tt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunkZYPBABLQjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new tt({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunkZYPBABLQjs.Z)(this.data.toUint8Array())}};tt.LENGTH=32;var B=tt;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var $i = _interopRequireWildcard(_bip39);var Xa=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ya= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Za= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Za||{}),Wi= exports.HARDENED_OFFSET =2147483648;function Qi(n){return Ya.test(n)}function ji(n){return Xa.test(n)}var Br=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Ji= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return Br(e,s)},ec=n=>n.replace(/'/g,""),Xi= exports.splitPath =n=>n.split("/").slice(1).map(ec),$n= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return $i.mnemonicToSeedSync(e)};var an=class an{static formatPrivateKey(e,t){let r=an.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunkZYPBABLQjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=an.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunkZYPBABLQjs.j.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunkZYPBABLQjs.j.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunkZYPBABLQjs.j.fromHexInput(e);return i}};an.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var nt=an;var lt=class extends _chunkZYPBABLQjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkZYPBABLQjs.j.fromHexInput(e).toString()}},Y= exports.AccountPublicKey =class extends lt{};var M=class extends _chunkZYPBABLQjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkZYPBABLQjs.j.fromHexInput(e).toString()}};var kt=n=>typeof n=="string"?_chunkZYPBABLQjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var Mr=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function tc(n){let e=n.toUint8Array().slice(32);for(let t=Mr.length-1;t>=0;t-=1){if(e[t]<Mr[t])return!0;if(e[t]>Mr[t])return!1}return!1}var rt=class rt extends Y{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e);if(t.toUint8Array().length!==rt.LENGTH)throw new Error(`PublicKey length should be ${rt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!tc(r))return!1;let i=kt(t),o=_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}authKey(){return B.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new rt(t)}static isPublicKey(e){return e instanceof rt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _2 => _2.key, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.length])===rt.LENGTH}};rt.LENGTH=32;var x=rt,ge=class ge extends _chunkZYPBABLQjs.l{constructor(e,t){super();let r=nt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==ge.LENGTH)throw new Error(`PrivateKey length should be ${ge.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new ge(e,!1)}static fromDerivationPath(e,t){if(!ji(e))throw new Error(`Invalid derivation path ${e}`);return ge.fromDerivationPathInner(e,$n(t))}static fromDerivationPathInner(e,t,r=Wi){let{key:i,chainCode:o}=Br(ge.SLIP_0010_SEED,t),s=Xi(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>Ji(c,d+r),{key:i,chainCode:o});return new ge(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new x(e)}sign(e){let t=kt(e),r=_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new I(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return nt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new ge(t,!1)}static isPrivateKey(e){return e instanceof ge}};ge.LENGTH=32,ge.SLIP_0010_SEED="ed25519 seed";var q=ge,Ot=class Ot extends M{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e);if(t.toUint8Array().length!==Ot.LENGTH)throw new Error(`Signature length should be ${Ot.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ot(t)}};Ot.LENGTH=64;var I=Ot;var me=class me extends Y{constructor(e){super();let{publicKeys:t,threshold:r}=e;if(t.length>me.MAX_KEYS||t.length<me.MIN_KEYS)throw new Error(`Must have between ${me.MIN_KEYS} and ${me.MAX_KEYS} public keys, inclusive`);if(r<me.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${me.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof gt))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*x.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*x.LENGTH)}),e[this.publicKeys.length*x.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=x.LENGTH){let s=o;i.push(new x(t.subarray(s,s+x.LENGTH)))}return new me({publicKeys:i,threshold:r})}};me.MAX_KEYS=32,me.MIN_KEYS=2,me.MIN_THRESHOLD=1;var Ft=me,ae=class ae extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ae.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=ae.createBitmap({bits:r});else{if(r.length!==ae.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ae.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*I.LENGTH+ae.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*I.LENGTH)}),e.set(this.bitmap,this.signatures.length*I.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new ae({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ae.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};ae.MAX_SIGNATURES_SUPPORTED=32,ae.BITMAP_LEN=4;var gt=ae;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Pe=class Pe extends lt{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Pe.LENGTH)this.key=t;else if(r===Pe.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunkZYPBABLQjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Pe.LENGTH} or ${Pe.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=kt(t),o=_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new mt(t)}static deserialize(e){let t=e.deserializeBytes();return new Pe(t)}static isPublicKey(e){return e instanceof Pe}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _5 => _5.key, 'optionalAccess', _6 => _6.data, 'optionalAccess', _7 => _7.length])===Pe.LENGTH}};Pe.LENGTH=65,Pe.COMPRESSED_LENGTH=33;var Fe=Pe,Ie=class Ie extends _chunkZYPBABLQjs.l{constructor(e,t){super();let r=nt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Ie.LENGTH)throw new Error(`PrivateKey length should be ${Ie.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ie(e,!1)}static fromDerivationPath(e,t){if(!Qi(e))throw new Error(`Invalid derivation path ${e}`);return Ie.fromDerivationPathInner(e,$n(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Ie(r,!1)}sign(e){let t=kt(e),r=_chunkZYPBABLQjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new mt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Fe(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return nt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ie(t,!1)}static isPrivateKey(e){return e instanceof Ie}};Ie.LENGTH=32;var Ne=Ie,Nt=class Nt extends M{constructor(e){super();let t=_chunkZYPBABLQjs.j.fromHexInput(e);if(t.toUint8Array().length!==Nt.LENGTH)throw new Error(`Signature length should be ${Nt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Nt(t)}};Nt.LENGTH=64;var mt=Nt;var _jwtdecode = require('jwt-decode');var yt=class n extends lt{constructor(e){super();let t=e.constructor.name;switch(t){case x.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}serialize(e){if(this.publicKey instanceof x)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(x.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},ve= exports.EphemeralSignature =class n extends M{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunkZYPBABLQjs.j.fromHexInput(e),r=new C(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof I)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var Vr=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],eo=31,Tc=16,Zi=(Tc-1)*eo;function Qn(n,e){let r=new TextEncoder().encode(n);return bc(r,e)}function bc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=qr(n,e);return dn(t)}function wc(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Pc(n,e);return Sc(t)}function qr(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return wc(n,e).concat([BigInt(n.length)])}function Sc(n){if(n.length>Zi)throw new Error(`Can't pack more than ${Zi}. Was given ${n.length} bytes`);return _c(n,eo).map(e=>un(e))}function _c(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function un(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function to(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Pc(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function dn(n){if(n.length>Vr.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${Vr.length}`);return Vr[n.length-1](n)}var jn=class extends _chunkZYPBABLQjs.l{};var no="1.34.0";var ro={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},io= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},oo= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Lr= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Hr= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},$r= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))($r||{}),Wr= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},cl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var ft=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(ft||{}),so= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,ao= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Jn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,At= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",co= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",uo= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Qr= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Ge= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(Ge||{}),po= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function lo(n,e){let t=e.bcsToBytes(),r=new C(t);return n.deserialize(r)}var Ec=(o=>(o[o.API_ERROR=0]="API_ERROR",o[o.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",o[o.SESSION_EXPIRED=2]="SESSION_EXPIRED",o[o.INVALID_STATE=3]="INVALID_STATE",o[o.UNKNOWN=4]="UNKNOWN",o))(Ec||{}),xc= exports.KeylessErrorResolutionTip =(d=>(d.REAUTHENTICATE="Re-authentiate to continue using your keyless account",d.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",d.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",d.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.",d.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",d.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",d.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d))(xc||{}),Xn= exports.KeylessErrorType =(f=>(f[f.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",f[f.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",f[f.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",f[f.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",f[f.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",f[f.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",f[f.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",f[f.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",f[f.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",f[f.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",f[f.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",f[f.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",f[f.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",f[f.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",f[f.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",f[f.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",f[f.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",f[f.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",f[f.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",f[f.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",f[f.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",f[f.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",f[f.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",f[f.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",f[f.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",f[f.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",f[f.UNKNOWN=26]="UNKNOWN",f))(Xn||{}),go={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"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."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["An unknown error has occurred.",4,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},z= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=go[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
|
|
4
2
|
Message: ${e}`;return i&&(o+=`
|
|
5
|
-
Details: ${i}`),
|
|
6
|
-
AptosApiError: ${
|
|
7
|
-
Error: ${
|
|
8
|
-
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,details:i}=e,[o,s,a]=fo[n];return new r({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:n})}},Ae= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:n}){super(_c({apiType:e,aptosRequest:t,aptosResponse:n})),this.name="AptosApiError",this.url=n.url,this.status=n.status,this.statusText=n.statusText,this.data=n.data,this.request=t}};function _c({apiType:r,aptosRequest:e,aptosResponse:t}){let n=_optionalChain([t, 'access', _14 => _14.headers, 'optionalAccess', _15 => _15.traceparent, 'optionalAccess', _16 => _16.split, 'call', _17 => _17("-"), 'access', _18 => _18[1]]),i=n?`(trace_id:${n}) `:"",o=`Request to [${r}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return r==="Indexer"&&_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.errors, 'optionalAccess', _21 => _21[0], 'optionalAccess', _22 => _22.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _23 => _23.data, 'optionalAccess', _24 => _24.message])!=null&&_optionalChain([t, 'access', _25 => _25.data, 'optionalAccess', _26 => _26.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${xc(t.data)}`}var ei=400;function xc(r){let e=JSON.stringify(r);return e.length<=ei?e:`truncated(original_size:${e.length}): ${e.slice(0,ei/2)}...${e.slice(-ei/2)}`}async function Ec(r,e){let{url:t,method:n,body:i,contentType:o,params:s,overrides:a,originMethod:c}=r,p={..._optionalChain([a, 'optionalAccess', _27 => _27.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${oo}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _28 => _28.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _29 => _29.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _30 => _30.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _31 => _31.API_KEY])}`),e.provider({url:t,method:n,body:i,params:s,headers:p,overrides:a})}async function tn(r,e,t){let{url:n,path:i}=r,o=i?`${n}/${i}`:n,s=await Ec({...r,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Ae({apiType:t,aptosRequest:r,aptosResponse:a})}async function rn(r){let{aptosConfig:e,overrides:t,params:n,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=r,p=e.getRequestUrl(c);return tn({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:n,overrides:{...e.clientConfig,...t}},e,r.type)}async function q(r){let{aptosConfig:e}=r;return rn({...r,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function Ql(r){return rn({...r,type:"Pepper"})}async function nn(r){let e=[],t,n=r.params;do{let i=await rn({type:"Fullnode",aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),n.start=t}while(t!=null);return e}async function ti(r){let e=[],t,n=r.params,i=n.limit;do{let o=await rn({type:"Fullnode",aptosConfig:r.aptosConfig,originMethod:r.originMethod,path:r.path,params:n,overrides:r.overrides});if(t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),n.offset=t,i!==void 0){let s=i-e.length;if(s<=0)break;n.limit=s}}while(t!=null);return e}async function lr(r){let{type:e,originMethod:t,path:n,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=r,l=c.getRequestUrl(e);return tn({url:l,method:"POST",originMethod:t,path:n,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,r.type)}async function ot(r){let{aptosConfig:e}=r;return lr({...r,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.fullnodeConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function Ao(r){let{aptosConfig:e}=r;return lr({...r,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...r.overrides,HEADERS:{..._optionalChain([e, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([e, 'access', _42 => _42.indexerConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function ho(r){let{aptosConfig:e}=r,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _44 => _44.clientConfig, 'optionalAccess', _45 => delete _45.API_KEY]),lr({...r,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...r.overrides,HEADERS:{..._optionalChain([t, 'access', _46 => _46.clientConfig, 'optionalAccess', _47 => _47.HEADERS]),..._optionalChain([t, 'access', _48 => _48.faucetConfig, 'optionalAccess', _49 => _49.HEADERS])}}})}async function To(r){return lr({...r,type:"Pepper"})}async function bo(r){return lr({...r,type:"Prover"})}var ri=new Map;function Ke(r,e,t){return async(...n)=>{if(ri.has(e)){let{value:o,timestamp:s}=ri.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await r(...n);return ri.set(e,{value:i,timestamp:Date.now()}),i}}var vg=1e7,vc= exports.MAX_AUD_VAL_BYTES =120,Ic= exports.MAX_UID_KEY_BYTES =30,Cc= exports.MAX_UID_VAL_BYTES =330,Ig= exports.MAX_ISS_VAL_BYTES =120,Cg= exports.MAX_EXTRA_FIELD_BYTES =350,Rg= exports.MAX_JWT_HEADER_B64_BYTES =300,Kg= exports.MAX_COMMITED_EPK_BYTES =93,Ue=class Ue extends se{constructor(e,t){super();let n=m.fromHexInput(t).toUint8Array();if(n.length!==Ue.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ue.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=n}authKey(){let e=new B;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),L.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Ue(t,n)}static load(e){let t=e.deserializeStr(),n=e.deserializeBytes();return new Ue(t,n)}static isPublicKey(e){return e instanceof Ue}static create(e){return wo(e),new Ue(e.iss,wo(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:n,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Ue.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:n})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ue.ID_COMMITMENT_LENGTH=32;var O=Ue;function wo(r){let{uidKey:e,uidVal:t,aud:n,pepper:i}=r,o=[pr(m.fromHexInput(i).toUint8Array()),Xr(n,vc),Xr(t,Cc),Xr(e,Ic)];return io(dr(o),O.ID_COMMITMENT_LENGTH)}var Le=class r extends V{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:n,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=n,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Uc(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Gt.deserialize(e),n=e.deserializeStr(),i=e.deserializeU64(),o=Tt.deserialize(e),s=Re.deserialize(e);return new r({jwtHeader:n,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new r({jwtHeader:"{}",ephemeralCertificate:new Gt(new ve({proof:new Mt(new Bt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new Tt(new P(new Uint8Array(32))),ephemeralSignature:new Re(new I(new Uint8Array(64)))})}static isSignature(e){return e instanceof r}},Gt= exports.EphemeralCertificate =class r extends V{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(ve.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Me=class r extends y{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new r(t)}},wt=class r extends y{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new r(t)}},Bt= exports.Groth16Zkp =class r extends Yr{constructor(e){super();let{a:t,b:n,c:i}=e;this.a=new Me(t),this.b=new wt(n),this.c=new Me(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Me.deserialize(e).bcsToBytes(),n=wt.deserialize(e).bcsToBytes(),i=Me.deserialize(e).bcsToBytes();return new r({a:t,b:n,c:i})}},Mt= exports.ZkProof =class r extends y{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new r(Bt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ve= exports.ZeroKnowledgeSig =class r extends V{constructor(e){super();let{proof:t,expHorizonSecs:n,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=n,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return r.deserialize(new D(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Mt.deserialize(e),n=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Re);return new r({proof:t,expHorizonSecs:n,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},ni= exports.KeylessConfiguration =class r{constructor(e,t){this.verificationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new r(new ii({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},ii= exports.Groth16VerificationKey =class r{constructor(e){let{alphaG1:t,betaG2:n,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Me(t),this.betaG2=new wt(n),this.deltaG2=new wt(i),this.gammaAbcG1=[new Me(o[0]),new Me(o[1])],this.gammaG2=new wt(s)}hash(){let e=new B;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new r({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function gr(r){let{aptosConfig:e}=r;try{return await Ke(async()=>{let t=await Rc(r),n=await Kc(r);return ni.create(n,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof k?t:k.fromErrorType({type:25,error:t})}}function Ve(r){let{jwt:e,uidKey:t="sub"}=r,n;try{n=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw k.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkIHUCZKG2js.c.call(void 0, o)}`})}if(typeof n.iss!="string")throw k.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof n.aud!="string")throw k.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=n[t];return{iss:n.iss,aud:n.aud,uidVal:i}}async function Rc(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Configuration";try{let{data:i}=await q({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${n}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _50 => _50.ledgerVersion])}});return i.data}catch(i){throw k.fromErrorType({type:22,error:i})}}async function Kc(r){let{aptosConfig:e,options:t}=r,n="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await q({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${n}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _51 => _51.ledgerVersion])}});return i.data}catch(i){throw k.fromErrorType({type:23,error:i})}}async function _o(r){let{aptosConfig:e,jwkAddr:t,options:n}=r,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await q({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _52 => _52.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await q({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _53 => _53.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:p}=c.variant,l=new D(m.fromHexInput(p).toUint8Array()),h=oi.deserialize(l);a.push(h)}o.set(Fi(s.issuer),a)}return o}var oi=class r extends y{constructor(e){super();let{kid:t,kty:n,alg:i,e:o,n:s}=e;this.kid=t,this.kty=n,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,n=new D(m.fromHexInput(t).toUint8Array());return r.deserialize(n)}static deserialize(e){let t=e.deserializeStr(),n=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new r({kid:t,kty:n,alg:i,n:o,e:s})}};function Uc(r){try{let e=JSON.parse(r);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var re=class r extends se{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new B;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),L.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=O.deserialize(e);return new r(t,n)}static isPublicKey(e){return e instanceof r}static create(e){return new r(e.jwkAddress,O.create(e))}static fromJwtAndPepper(e){return new r(e.jwkAddress,O.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof O}};var N=class r extends se{constructor(e){if(super(),this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof Fe)this.variant=1;else if(e instanceof O)this.variant=3;else if(e instanceof re)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:n}=e;return $.isInstance(n)?this.publicKey.verifySignature({message:t,signature:n.signature}):!1}authKey(){return L.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=P.deserialize(e);break;case 1:n=Fe.deserialize(e);break;case 3:n=O.deserialize(e);break;case 4:n=re.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new r(n)}static isPublicKey(e){return e instanceof r}isEd25519(){return this.publicKey instanceof P}isSecp256k1PublicKey(){return this.publicKey instanceof Fe}static isInstance(e){return"publicKey"in e&&"variant"in e}},$= exports.AnySignature =class r extends V{constructor(e){if(super(),this.signature=e,e instanceof I)this.variant=0;else if(e instanceof ht)this.variant=1;else if(e instanceof Le)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=I.deserialize(e);break;case 1:n=ht.deserialize(e);break;case 3:n=Le.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new r(n)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function kc(r){let e=r;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var ke=class r extends se{constructor(e){super();let{publicKeys:t,signaturesRequired:n}=e;if(n<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<n)throw new Error(`Provided ${t.length} public keys is smaller than the ${n} required signatures`);this.publicKeys=t.map(i=>i instanceof N?i:new N(i)),this.signaturesRequired=n}verifySignature(e){throw new Error("not implemented")}authKey(){return L.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(N),n=e.deserializeU8();return new r({publicKeys:t,signaturesRequired:n})}createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),p=i[c];p|=n>>s%8,i[c]=p}),i}getIndex(e){let t=e instanceof N?e:new N(e),n=this.publicKeys.findIndex(i=>i.toString()===t.toString());if(n!==-1)return n;throw new Error(`Public key ${e} not found in MultiKey ${this.publicKeys}`)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},ue=class ue extends V{constructor(e){super();let{signatures:t,bitmap:n}=e;if(t.length>ue.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ue.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof $?o:new $(o)),!(n instanceof Uint8Array))this.bitmap=ue.createBitmap({bits:n});else{if(n.length!==ue.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ue.BITMAP_LEN}`);this.bitmap=n}let i=this.bitmap.reduce((o,s)=>o+kc(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,n=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=ue.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ue.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=n>>s%8,i[a]=c}),i}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector($),n=e.deserializeBytes();return new ue({signatures:t,bitmap:n})}};ue.BITMAP_LEN=4,ue.MAX_SIGNATURES_SUPPORTED=ue.BITMAP_LEN*8;var He=ue;var Z=class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ie.load(e);case 1:return on.load(e);case 2:return ae.load(e);case 3:return ze.load(e);case 4:return Lt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ie}isMultiEd25519(){return this instanceof on}isSingleKey(){return this instanceof ae}isMultiKey(){return this instanceof ze}},Ie= exports.AccountAuthenticatorEd25519 =class r extends Z{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),n=I.deserialize(e);return new r(t,n)}},on= exports.AccountAuthenticatorMultiEd25519 =class r extends Z{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Ot.deserialize(e),n=At.deserialize(e);return new r(t,n)}},ae= exports.AccountAuthenticatorSingleKey =class r extends Z{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=N.deserialize(e),n=$.deserialize(e);return new r(t,n)}},ze= exports.AccountAuthenticatorMultiKey =class r extends Z{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=ke.deserialize(e),n=He.deserialize(e);return new r(t,n)}},Lt= exports.AccountAuthenticatorNoAccountAuthenticator =class r extends Z{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}};var Vt=class r extends y{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new r(t)}};var R=class r extends y{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new r(t)}};var sn=(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...n,254]);return new u(_sha3.sha3_256.call(void 0, i))},Hy= exports.createResourceAddress =(r,e)=>{let t=r.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...n,255]);return new u(_sha3.sha3_256.call(void 0, i))},qy= exports.createTokenAddress =(r,e,t)=>{let n=`${e}::${t}`;return sn(r,n)};var yr=class r extends y{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new r(u.fromString(t[0]),new R(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=R.deserialize(e);return new r(t,n)}};var F=class r extends y{deserialize(e){let t=u.deserialize(e),n=R.deserialize(e),i=R.deserialize(e),o=e.deserializeVector(r);return new De(t,n,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return M.load(e);case 1:return pe.load(e);case 2:return j.load(e);case 3:return We.load(e);case 4:return ee.load(e);case 5:return St.load(e);case 6:return C.load(e);case 7:return A.load(e);case 8:return qe.load(e);case 9:return $e.load(e);case 10:return Qe.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof M}isAddress(){return this instanceof ee}isGeneric(){return this instanceof G}isSigner(){return this instanceof St}isVector(){return this instanceof C}isStruct(){return this instanceof A}isU8(){return this instanceof pe}isU16(){return this instanceof qe}isU32(){return this instanceof $e}isU64(){return this instanceof j}isU128(){return this instanceof We}isU256(){return this instanceof Qe}isPrimitive(){return this instanceof St||this instanceof ee||this instanceof M||this instanceof pe||this instanceof qe||this instanceof $e||this instanceof j||this instanceof We||this instanceof Qe}},M= exports.TypeTagBool =class r extends F{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new r}},pe= exports.TypeTagU8 =class r extends F{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new r}},qe= exports.TypeTagU16 =class r extends F{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new r}},$e= exports.TypeTagU32 =class r extends F{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new r}},j= exports.TypeTagU64 =class r extends F{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new r}},We= exports.TypeTagU128 =class r extends F{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new r}},Qe= exports.TypeTagU256 =class r extends F{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new r}},ee= exports.TypeTagAddress =class r extends F{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new r}},St= exports.TypeTagSigner =class r extends F{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new r}},an= exports.TypeTagReference =class r extends F{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let n=F.deserialize(t);return new r(n)}},G= exports.TypeTagGeneric =class r extends F{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let n=t.deserializeU32();return new r(n)}},C= exports.TypeTagVector =class r extends F{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new r(new pe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let n=F.deserialize(t);return new r(n)}},A= exports.TypeTagStruct =class r extends F{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(n=>n.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let n=De.deserialize(t);return new r(n)}isTypeTag(t,n,i){return this.value.moduleName.identifier===n&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},De= exports.StructTag =class r extends y{constructor(e,t,n,i){super(),this.address=e,this.moduleName=t,this.name=n,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=u.deserialize(e),n=R.deserialize(e),i=R.deserialize(e),o=e.deserializeVector(F);return new r(t,n,i,o)}};function ym(){return new De(u.ONE,new R("aptos_coin"),new R("AptosCoin"),[])}function v(){return new De(u.ONE,new R("string"),new R("String"),[])}function mm(r){return new De(u.ONE,new R("option"),new R("Option"),[r])}function de(r){return new De(u.ONE,new R("object"),new R("Object"),[r])}function zc(r){let e=r.deserializeUleb128AsU32();switch(e){case 0:return X.deserialize(r);case 1:return Q.deserialize(r);case 2:return Ee.deserialize(r);case 3:return u.deserialize(r);case 4:return S.deserialize(r,X);case 5:return U.deserialize(r);case 6:return _e.deserialize(r);case 7:return xe.deserialize(r);case 8:return ye.deserialize(r);case 9:return ar.deserialize(r);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var _t=class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return mr.load(e);case 2:return fr.load(e);case 3:return Ar.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},mr= exports.TransactionPayloadScript =class r extends _t{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=hr.deserialize(e);return new r(t)}},fr= exports.TransactionPayloadEntryFunction =class r extends _t{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=xt.deserialize(e);return new r(t)}},Ar= exports.TransactionPayloadMultiSig =class r extends _t{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Tr.deserialize(e);return new r(t)}},xt= exports.EntryFunction =class r{constructor(e,t,n,i){this.module_name=e,this.function_name=t,this.type_args=n,this.args=i}static build(e,t,n,i){return new r(yr.fromStr(e),new R(t),n,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=yr.deserialize(e),n=R.deserialize(e),i=e.deserializeVector(F),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=$r.deserialize(e,c);s.push(p)}return new r(t,n,i,s)}},hr= exports.Script =class r{constructor(e,t,n){this.bytecode=e,this.type_args=t,this.args=n}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),n=e.deserializeVector(F),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=zc(e);o.push(a)}return new r(t,n,o)}},Tr= exports.MultiSig =class r{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=u.deserialize(e),n=e.deserializeBool(),i;return n&&(i=br.deserialize(e)),new r(t,i)}},br= exports.MultiSigTransactionPayload =class r extends y{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new r(xt.deserialize(e))}};var he=class r extends y{constructor(e,t,n,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=n,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=u.deserialize(e),n=e.deserializeU64(),i=_t.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Vt.deserialize(e);return new r(t,n,i,o,s,a,c)}},cn= exports.RawTransactionWithData =class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Et.load(e);case 1:return Pt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Et= exports.MultiAgentRawTransaction =class r extends cn{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=he.deserialize(e),n=e.deserializeVector(u);return new r(t,n)}},Pt= exports.FeePayerRawTransaction =class r extends cn{constructor(e,t,n){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=n}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=he.deserialize(e),n=e.deserializeVector(u),i=u.deserialize(e);return new r(t,n,i)}};var un=class extends y{constructor(t){super();this.accountAddress=u.ONE;this.moduleName=new x("account");this.structName=new x("RotationProofChallenge");this.sequenceNumber=new Q(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var je=class extends y{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return vt.load(e);case 1:return pn.load(e);case 2:return It.load(e);case 3:return Ct.load(e);case 4:return st.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof vt}isMultiEd25519(){return this instanceof pn}isMultiAgent(){return this instanceof It}isFeePayer(){return this instanceof Ct}isSingleSender(){return this instanceof st}},vt= exports.TransactionAuthenticatorEd25519 =class r extends je{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=P.deserialize(e),n=I.deserialize(e);return new r(t,n)}},pn= exports.TransactionAuthenticatorMultiEd25519 =class r extends je{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Ot.deserialize(e),n=At.deserialize(e);return new r(t,n)}},It= exports.TransactionAuthenticatorMultiAgent =class r extends je{constructor(e,t,n){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=n}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=Z.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(Z);return new r(t,n,i)}},Ct= exports.TransactionAuthenticatorFeePayer =class r extends je{constructor(e,t,n,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=n,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=Z.deserialize(e),n=e.deserializeVector(u),i=e.deserializeVector(Z),o=u.deserialize(e),s=Z.deserialize(e),a={address:o,authenticator:s};return new r(t,n,i,a)}},st= exports.TransactionAuthenticatorSingleSender =class r extends je{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=Z.deserialize(e);return new r(t)}};var Je=class r extends y{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=he.deserialize(e),n=je.deserialize(e);return new r(t,n)}};var dn=class r extends y{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=he.deserialize(e),n=e.deserializeBool(),i;return n&&(i=u.deserialize(e)),new r(t,i)}};var ln=class r extends y{constructor(e,t,n){super(),this.rawTransaction=e,this.feePayerAddress=n,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=he.deserialize(e),n=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new r(t,n,o)}};function si(r){return r.feePayerAddress?new Pt(r.rawTransaction,_nullishCoalesce(r.secondarySignerAddresses, () => ([])),r.feePayerAddress):r.secondarySignerAddresses?new Et(r.rawTransaction,r.secondarySignerAddresses):r.rawTransaction}function Ht(r,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let n=t.digest(),i=r,o=new Uint8Array(n.length+i.length);return o.set(n),o.set(i,n.length),o}function vf(r){return Ht(r.bcsToBytes(),`APTOS::${r.constructor.name}`)}function qt(r){let e=si(r);return r.feePayerAddress?Ht(e.bcsToBytes(),Zn):r.secondarySignerAddresses?Ht(e.bcsToBytes(),Zn):Ht(e.bcsToBytes(),go)}var Te=class r{constructor(e){this.signingScheme=0;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}static generate(){let e=H.generate();return new r({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:n}=e,i=H.fromDerivationPath(t,n);return new r({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new Ie(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ie(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(qt(e))}};function ai(r){return typeof r=="object"&&r!==null&&"getAnyPublicKey"in r&&typeof r.getAnyPublicKey=="function"}var be=class r{constructor(e){this.signingScheme=2;let{privateKey:t,address:n}=e;this.privateKey=t,this.publicKey=new N(t.publicKey()),this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,n;switch(t){case 0:n=H.generate();break;case 2:n=Ge.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new r({privateKey:n})}static fromDerivationPath(e){let{scheme:t=0,path:n,mnemonic:i}=e,o;switch(t){case 0:o=H.fromDerivationPath(n,i);break;case 2:o=Ge.fromDerivationPath(n,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new r({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new ae(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ae(this.publicKey,this.signTransaction(e))}sign(e){return new $(this.privateKey.sign(e))}signTransaction(e){return this.sign(qt(e))}static fromEd25519Account(e){return new r({privateKey:e.privateKey,address:e.accountAddress})}};var at=class{static generate(e={}){let{scheme:t=0,legacy:n=!0}=e;return t===0&&n?Te.generate():be.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:n,legacy:i=!0}=e;return t instanceof H&&i?new Te({privateKey:t,address:n}):new be({privateKey:t,address:n})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:n,path:i,legacy:o=!0}=e;return t===0&&o?Te.fromDerivationPath({mnemonic:n,path:i}):be.fromDerivationPath({scheme:t,mnemonic:n,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var Nc=1209600,$t=class $t extends y{constructor(e){super();let{privateKey:t,expiryDateSecs:n,blinder:i}=e;this.privateKey=t,this.publicKey=new Tt(t.publicKey()),this.expiryDateSecs=n||_chunkIHUCZKG2js.e.call(void 0, _chunkIHUCZKG2js.d.call(void 0, )+Nc),this.blinder=i!==void 0?m.fromHexInput(i).toUint8Array():Fc();let o=Qn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(pr(this.blinder));let s=dr(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),n;switch(t){case 0:n=H.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new $t({privateKey:n,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return $t.deserialize(new D(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _54 => _54.scheme])){case 0:default:t=H.generate()}return new $t({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _55 => _55.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Re(this.privateKey.sign(e))}};$t.BLINDER_LENGTH=31;var Rt=$t;function Fc(){return _utils.randomBytes.call(void 0, Rt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function gn(r){return r!=null&&typeof r.checkKeylessAccountValidity=="function"}var Wt=class Wt extends y{constructor(t){super();this.signingScheme=2;let{address:n,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:p,proof:l,proofFetchCallback:h,jwt:g,verificationKeyHash:d}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=g,this.emitter=new _eventemitter32.default,this.proofOrPromise=l,l instanceof ve)this.proof=l;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async K=>{await h(K),this.emitter.removeAllListeners()}),this.init(l)}let b=m.fromHexInput(p).toUint8Array();if(b.length!==Wt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Wt.PEPPER_LENGTH}`);if(this.pepper=b,d!==void 0){if(m.hexInputToUint8Array(d).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=m.hexInputToUint8Array(d)}}getAnyPublicKey(){return new N(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(n){n instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:n.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let n=u.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Rt.deserialize(t),c=ve.deserialize(t),p=t.deserializeOption("fixedBytes",32);return{address:n,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:p}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let n=new $(this.sign(t)),i=new N(this.publicKey);return new ae(i,n)}signTransactionWithAuthenticator(t){let n=new $(this.signTransaction(t)),i=new N(this.publicKey);return new ae(i,n)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw k.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw k.fromErrorType({type:2});let n=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(n.kid===void 0)throw k.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await gr({aptosConfig:t});if(m.hexInputToString(i.hash())!==m.hexInputToString(this.verificationKeyHash))throw k.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await Wt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:n.kid})}sign(t){let{expiryDateSecs:n}=this.ephemeralKeyPair;if(this.isExpired())throw k.fromErrorType({type:0});if(this.proof===void 0)throw k.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new Le({jwtHeader:_chunkIHUCZKG2js.f.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Gt(this.proof,0),expiryDateSecs:n,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw k.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let n=si(t),o=new ci(n,this.proof.proof).hash();return this.sign(o)}verifySignature(t){let{message:n,signature:i}=t;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:n,signature:i.ephemeralSignature}))}static async fetchJWK(t){let{aptosConfig:n,publicKey:i,kid:o}=t,s=i instanceof O?i:i.keylessPublicKey,{iss:a}=s,c,p=i instanceof re?i.jwkAddress:void 0;try{c=await _o({aptosConfig:n,jwkAddr:p})}catch(g){throw k.fromErrorType({type:24,error:g,details:`Failed to fetch ${p?"Federated":"Patched"}JWKs ${p?`for address ${p}`:"0x1"}`})}let l=c.get(a);if(l===void 0)throw k.fromErrorType({type:7,details:`JWKs for issuer ${a} not found.`});let h=l.find(g=>g.kid===o);if(h===void 0)throw k.fromErrorType({type:6,details:`JWK with kid '${o}' for issuer '${a}' not found.`});return h}};Wt.PEPPER_LENGTH=31;var le=Wt,ci= exports.TransactionAndProof =class extends y{constructor(t,n){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=n}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Ht(this.bcsToBytes(),this.domainSeparator)}};var Xe=class r extends le{constructor(e){let t=O.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:n,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=le.partialDeserialize(e),{iss:p,aud:l,uidVal:h}=Ve({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:h,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return r.deserialize(new D(m.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:p}=e,{iss:l,aud:h,uidVal:g}=Ve({jwt:i,uidKey:a});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:g,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var Kt=class r extends le{constructor(e){let t=re.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:n,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=le.partialDeserialize(e),p=u.deserialize(e),{iss:l,aud:h,uidVal:g}=Ve({jwt:o,uidKey:s});return new r({address:t,proof:n,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:g,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return r.deserialize(D.fromHex(e))}static create(e){let{address:t,proof:n,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:l}=e,{iss:h,aud:g,uidVal:d}=Ve({jwt:i,uidKey:c});return new r({address:t,proof:n,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:d,aud:g,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var wr=class r{constructor(e){this.signingScheme=3;let{multiKey:t,address:n}=e,i=e.signers.map(a=>a instanceof Te?be.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=n?u.from(n):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{publicKeys:t,signaturesRequired:n,signers:i}=e,o=new ke({publicKeys:t,signaturesRequired:n});return new r({multiKey:o,signers:i})}static isMultiKeySigner(e){return e instanceof r}signWithAuthenticator(e){return new ze(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ze(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(n=>n instanceof le).map(async n=>n.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let n=this.signers.filter(i=>i instanceof le).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(n)}sign(e){let t=[];for(let n of this.signers)t.push(n.sign(e));return new He({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let n of this.signers)t.push(n.signTransaction(e));return new He({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:n}=e;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<n.signatures.length;o+=1){let s=n.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:t,signature:s}))return!1}return!0}};function Eo(r){let e=r.deserializeUleb128AsU32();if(!Object.values(oe).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:u.deserialize(r),signingScheme:e}}function Po(r,e){if(e.serializeStr(r.jwt),e.serializeStr(r.uidKey),e.serializeFixedBytes(r.pepper),r.ephemeralKeyPair.serialize(e),r.proof===void 0)throw new Error("Cannot serialize - proof undefined");r.proof.serialize(e),e.serializeOption(r.verificationKeyHash,32)}function vo(r){let e=r.deserializeStr(),t=r.deserializeStr(),n=r.deserializeFixedBytes(31),i=Rt.deserialize(r),o=ve.deserialize(r),s=r.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:n,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Io;(h=>{function r(g){let d=new B;switch(d.serializeU32AsUleb128(g.signingScheme),g.accountAddress.serialize(d),g.signingScheme){case 0:return g.privateKey.serialize(d),d.toUint8Array();case 2:{if(!ai(g))throw new Error("Account is not a SingleKeySigner");let b=g.getAnyPublicKey();switch(d.serializeU32AsUleb128(b.variant),b.variant){case 3:return Po(g,d),d.toUint8Array();case 4:{let K=g;return Po(K,d),K.publicKey.jwkAddress.serialize(d),d.serializeBool(K.audless),d.toUint8Array()}case 1:case 0:return g.privateKey.serialize(d),d.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=g;return b.publicKey.serialize(d),d.serializeU32AsUleb128(b.signers.length),b.signers.forEach(K=>{d.serializeFixedBytes(r(K))}),d.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${g.signingScheme}`)}}h.toBytes=r;function e(g){return m.hexInputToStringWithoutPrefix(r(g))}h.toHexStringWithoutPrefix=e;function t(g){return m.hexInputToString(r(g))}h.toHexString=t;function n(g){let{address:d,signingScheme:b}=Eo(g);switch(b){case 0:{let K=H.deserialize(g);return new Te({privateKey:K,address:d})}case 2:{let K=g.deserializeUleb128AsU32();switch(K){case 0:{let te=H.deserialize(g);return new be({privateKey:te,address:d})}case 1:{let te=Ge.deserialize(g);return new be({privateKey:te,address:d})}case 3:{let te=vo(g),dt=Ve(te);return new Xe({...te,...dt})}case 4:{let te=vo(g),dt=u.deserialize(g),Ut=g.deserializeBool(),kt=Ve(te);return new Kt({...te,...kt,jwkAddress:dt,audless:Ut})}default:throw new Error(`Unsupported public key variant ${K}`)}}case 3:{let K=ke.deserialize(g),te=g.deserializeUleb128AsU32(),dt=new Array;for(let Ut=0;Ut<te;Ut+=1){let kt=n(g);if(!ai(kt)&&!(kt instanceof Te))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");dt.push(kt)}return new wr({multiKey:K,signers:dt,address:d})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=n;function i(g){let d=p(g);if(!(d instanceof Xe))throw new Error("Deserialization of KeylessAccount failed");return d}h.keylessAccountFromHex=i;function o(g){let d=p(g);if(!(d instanceof Kt))throw new Error("Deserialization of FederatedKeylessAccount failed");return d}h.federatedKeylessAccountFromHex=o;function s(g){let d=p(g);if(!(d instanceof wr))throw new Error("Deserialization of MultiKeyAccount failed");return d}h.multiKeyAccountFromHex=s;function a(g){let d=p(g);if(!(d instanceof be))throw new Error("Deserialization of SingleKeyAccount failed");return d}h.singleKeyAccountFromHex=a;function c(g){let d=p(g);if(!(d instanceof Te))throw new Error("Deserialization of Ed25519Account failed");return d}h.ed25519AccountFromHex=c;function p(g){return n(D.fromHex(g))}h.fromHex=p;function l(g){return p(g)}h.fromBytes=l})(Io||(Io= exports.AccountUtils ={}));var Mc=`
|
|
3
|
+
Details: ${i}`),r instanceof ye?o+=`
|
|
4
|
+
AptosApiError: ${r.message}`:r!==void 0&&(o+=`
|
|
5
|
+
Error: ${_chunkZYPBABLQjs.$.call(void 0, r)}`),o+=`
|
|
6
|
+
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=go[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},ye= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(Ic({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function Ic({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _8 => _8.headers, 'optionalAccess', _9 => _9.traceparent, 'optionalAccess', _10 => _10.split, 'call', _11 => _11("-"), 'access', _12 => _12[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.errors, 'optionalAccess', _15 => _15[0], 'optionalAccess', _16 => _16.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _17 => _17.data, 'optionalAccess', _18 => _18.message])!=null&&_optionalChain([t, 'access', _19 => _19.data, 'optionalAccess', _20 => _20.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${vc(t.data)}`}var jr=400;function vc(n){let e=JSON.stringify(n);return e.length<=jr?e:`truncated(original_size:${e.length}): ${e.slice(0,jr/2)}...${e.slice(-jr/2)}`}async function Cc(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _21 => _21.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${no}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _22 => _22.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _23 => _23.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _24 => _24.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _25 => _25.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a})}async function Yn(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Cc({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new ye({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ye({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ye({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ye({apiType:t,aptosRequest:n,aptosResponse:a})}async function Zn(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return Yn({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function L(n){let{aptosConfig:e}=n;return Zn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _26 => _26.clientConfig, 'optionalAccess', _27 => _27.HEADERS]),..._optionalChain([e, 'access', _28 => _28.fullnodeConfig, 'optionalAccess', _29 => _29.HEADERS])}}})}async function kl(n){return Zn({...n,type:"Pepper"})}async function er(n){let e=[],t,r=n.params;do{let i=await Zn({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function Jr(n){let e=[],t,r=n.params,i=r.limit;do{let o=await Zn({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});if(t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),r.offset=t,i!==void 0){let s=i-e.length;if(s<=0)break;r.limit=s}}while(t!=null);return e}async function pn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:d}=n,y=c.getRequestUrl(e);return Yn({url:y,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function it(n){let{aptosConfig:e}=n;return pn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _30 => _30.clientConfig, 'optionalAccess', _31 => _31.HEADERS]),..._optionalChain([e, 'access', _32 => _32.fullnodeConfig, 'optionalAccess', _33 => _33.HEADERS])}}})}async function mo(n){let{aptosConfig:e}=n;return pn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _34 => _34.clientConfig, 'optionalAccess', _35 => _35.HEADERS]),..._optionalChain([e, 'access', _36 => _36.indexerConfig, 'optionalAccess', _37 => _37.HEADERS])}}})}async function yo(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _38 => _38.clientConfig, 'optionalAccess', _39 => delete _39.API_KEY]),pn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([t, 'access', _42 => _42.faucetConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function fo(n){return pn({...n,type:"Pepper"})}async function Ao(n){return pn({...n,type:"Prover"})}var Xr=new Map;function Ce(n,e,t){return async(...r)=>{if(Xr.has(e)){let{value:o,timestamp:s}=Xr.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return Xr.set(e,{value:i,timestamp:Date.now()}),i}}var mg=1e7,Rc= exports.MAX_AUD_VAL_BYTES =120,Uc= exports.MAX_UID_KEY_BYTES =30,zc= exports.MAX_UID_VAL_BYTES =330,yg= exports.MAX_ISS_VAL_BYTES =120,fg= exports.MAX_EXTRA_FIELD_BYTES =350,Ag= exports.MAX_JWT_HEADER_B64_BYTES =300,hg= exports.MAX_COMMITED_EPK_BYTES =93,Ke=class Ke extends Y{constructor(e,t){super();let r=_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array();if(r.length!==Ke.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ke.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunkZYPBABLQjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ke(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ke(t,r)}static isPublicKey(e){return e instanceof Ke}static create(e){return ho(e),new Ke(e.iss,ho(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return Ke.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};Ke.ID_COMMITMENT_LENGTH=32;var k=Ke;function ho(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[un(_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array()),Qn(r,Rc),Qn(t,zc),Qn(e,Uc)];return to(dn(o),k.ID_COMMITMENT_LENGTH)}var Me=class n extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return Oc(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=Gt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=yt.deserialize(e),s=ve.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Gt(new Ee({proof:new Mt(new Bt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new yt(new x(new Uint8Array(32))),ephemeralSignature:new ve(new I(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Gt= exports.EphemeralCertificate =class n extends M{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(Ee.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Be=class n extends _chunkZYPBABLQjs.l{constructor(e){if(super(),this.data=_chunkZYPBABLQjs.j.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new n(t)}},ht=class n extends _chunkZYPBABLQjs.l{constructor(e){if(super(),this.data=_chunkZYPBABLQjs.j.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new n(t)}},Bt= exports.Groth16Zkp =class n extends jn{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new Be(t),this.b=new ht(r),this.c=new Be(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Be.deserialize(e).bcsToBytes(),r=ht.deserialize(e).bcsToBytes(),i=Be.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}},Mt= exports.ZkProof =class n extends _chunkZYPBABLQjs.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(Bt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},Ee= exports.ZeroKnowledgeSig =class n extends M{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new C(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Mt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(ve);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},Yr= exports.KeylessConfiguration =class n{constructor(e,t){this.verificationKey=e,this.maxExpHorizonSecs=t}static create(e,t){return new n(new Zr({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),t)}},Zr= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Be(t),this.betaG2=new ht(r),this.deltaG2=new ht(i),this.gammaAbcG1=[new Be(o[0]),new Be(o[1])],this.gammaG2=new ht(s)}hash(){let e=new _chunkZYPBABLQjs.m;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}};async function ln(n){let{aptosConfig:e}=n;try{return await Ce(async()=>{let t=await Dc(n),r=await kc(n);return Yr.create(r,Number(t.max_exp_horizon_secs))},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof z?t:z.fromErrorType({type:25,error:t})}}function Ve(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw z.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkZYPBABLQjs.$.call(void 0, o)}`})}if(typeof r.iss!="string")throw z.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw z.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function Dc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await L({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunkZYPBABLQjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _44 => _44.ledgerVersion])}});return i.data}catch(i){throw z.fromErrorType({type:22,error:i})}}async function kc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await L({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunkZYPBABLQjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}catch(i){throw z.fromErrorType({type:23,error:i})}}async function bo(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await L({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _46 => _46.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await L({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _47 => _47.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,y=new C(_chunkZYPBABLQjs.j.fromHexInput(d).toUint8Array()),h=ei.deserialize(y);a.push(h)}o.set(_chunkZYPBABLQjs.k.call(void 0, s.issuer),a)}return o}var ei=class n extends _chunkZYPBABLQjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new C(_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:o,e:s})}};function Oc(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var te=class n extends Y{constructor(e,t){super(),this.jwkAddress=_chunkZYPBABLQjs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunkZYPBABLQjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=k.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}static create(e){return new n(e.jwkAddress,k.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,k.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunkZYPBABLQjs.Z&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof k}};var O=class n extends Y{constructor(e){if(super(),this.publicKey=e,e instanceof x)this.variant=0;else if(e instanceof Fe)this.variant=1;else if(e instanceof k)this.variant=3;else if(e instanceof te)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return H.isInstance(r)?this.publicKey.verifySignature({message:t,signature:r.signature}):!1}authKey(){return B.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=x.deserialize(e);break;case 1:r=Fe.deserialize(e);break;case 3:r=k.deserialize(e);break;case 4:r=te.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof x}isSecp256k1PublicKey(){return this.publicKey instanceof Fe}static isInstance(e){return"publicKey"in e&&"variant"in e}},H= exports.AnySignature =class n extends M{constructor(e){if(super(),this.signature=e,e instanceof I)this.variant=0;else if(e instanceof mt)this.variant=1;else if(e instanceof Me)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=I.deserialize(e);break;case 1:r=mt.deserialize(e);break;case 3:r=Me.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function Fc(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Re=class n extends Y{constructor(e){super();let{publicKeys:t,signaturesRequired:r}=e;if(r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof O?i:new O(i)),this.signaturesRequired=r}verifySignature(e){throw new Error("not implemented")}authKey(){return B.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(O),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}getIndex(e){let t=e instanceof O?e:new O(e),r=this.publicKeys.findIndex(i=>i.toString()===t.toString());if(r!==-1)return r;throw new Error(`Public key ${e} not found in MultiKey ${this.publicKeys}`)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},ce=class ce extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ce.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof H?o:new H(o)),!(r instanceof Uint8Array))this.bitmap=ce.createBitmap({bits:r});else{if(r.length!==ce.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ce.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Fc(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=ce.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ce.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(H),r=e.deserializeBytes();return new ce({signatures:t,bitmap:r})}};ce.BITMAP_LEN=4,ce.MAX_SIGNATURES_SUPPORTED=ce.BITMAP_LEN*8;var qe=ce;var tr=(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...r,254]);return new (0, _chunkZYPBABLQjs.Z)(_sha3.sha3_256.call(void 0, i))},Am= exports.createResourceAddress =(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...r,255]);return new (0, _chunkZYPBABLQjs.Z)(_sha3.sha3_256.call(void 0, i))},hm= exports.createTokenAddress =(n,e,t)=>{let r=`${e}::${t}`;return tr(n,r)};var Q=class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return xe.load(e);case 1:return nr.load(e);case 2:return ie.load(e);case 3:return Ue.load(e);case 4:return Vt.load(e);case 5:return gn.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof xe}isMultiEd25519(){return this instanceof nr}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof Ue}},xe= exports.AccountAuthenticatorEd25519 =class n extends Q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=x.deserialize(e),r=I.deserialize(e);return new n(t,r)}},nr= exports.AccountAuthenticatorMultiEd25519 =class n extends Q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Ft.deserialize(e),r=gt.deserialize(e);return new n(t,r)}},ie= exports.AccountAuthenticatorSingleKey =class n extends Q{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=O.deserialize(e),r=H.deserialize(e);return new n(t,r)}},Ue= exports.AccountAuthenticatorMultiKey =class n extends Q{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Re.deserialize(e),r=qe.deserialize(e);return new n(t,r)}},Vt= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends Q{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},gn= exports.AccountAuthenticatorAbstraction =class n extends Q{constructor(e,t,r){if(super(),!_chunkZYPBABLQjs.ia.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=_chunkZYPBABLQjs.j.fromHexInput(r),this.signingMessageDigest=_chunkZYPBABLQjs.j.fromHexInput(_chunkZYPBABLQjs.j.fromHexInput(t).toUint8Array())}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, this.functionInfo);_chunkZYPBABLQjs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),e.serializeFixedBytes(this.authenticator.toUint8Array())}static load(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var qt=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var K=class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var mn=class n extends _chunkZYPBABLQjs.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(_chunkZYPBABLQjs.Z.fromString(t[0]),new K(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=K.deserialize(e);return new n(t,r)}};var N=class n extends _chunkZYPBABLQjs.l{deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=K.deserialize(e),i=K.deserialize(e),o=e.deserializeVector(n);return new ze(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return V.load(e);case 1:return ue.load(e);case 2:return j.load(e);case 3:return $e.load(e);case 4:return F.load(e);case 5:return Tt.load(e);case 6:return v.load(e);case 7:return A.load(e);case 8:return Le.load(e);case 9:return He.load(e);case 10:return We.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof V}isAddress(){return this instanceof F}isGeneric(){return this instanceof G}isSigner(){return this instanceof Tt}isVector(){return this instanceof v}isStruct(){return this instanceof A}isU8(){return this instanceof ue}isU16(){return this instanceof Le}isU32(){return this instanceof He}isU64(){return this instanceof j}isU128(){return this instanceof $e}isU256(){return this instanceof We}isPrimitive(){return this instanceof Tt||this instanceof F||this instanceof V||this instanceof ue||this instanceof Le||this instanceof He||this instanceof j||this instanceof $e||this instanceof We}},V= exports.TypeTagBool =class n extends N{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},ue= exports.TypeTagU8 =class n extends N{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Le= exports.TypeTagU16 =class n extends N{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},He= exports.TypeTagU32 =class n extends N{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},j= exports.TypeTagU64 =class n extends N{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},$e= exports.TypeTagU128 =class n extends N{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},We= exports.TypeTagU256 =class n extends N{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},F= exports.TypeTagAddress =class n extends N{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Tt= exports.TypeTagSigner =class n extends N{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},rr= exports.TypeTagReference =class n extends N{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=N.deserialize(t);return new n(r)}},G= exports.TypeTagGeneric =class n extends N{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},v= exports.TypeTagVector =class n extends N{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ue)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=N.deserialize(t);return new n(r)}},A= exports.TypeTagStruct =class n extends N{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=ze.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(_chunkZYPBABLQjs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunkZYPBABLQjs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunkZYPBABLQjs.Z.ONE,"object","Object")}},ze= exports.StructTag =class n extends _chunkZYPBABLQjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=K.deserialize(e),i=K.deserialize(e),o=e.deserializeVector(N);return new n(t,r,i,o)}};function cy(){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("aptos_coin"),new K("AptosCoin"),[])}function P(){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("string"),new K("String"),[])}function uy(n){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("option"),new K("Option"),[n])}function de(n){return new ze(_chunkZYPBABLQjs.Z.ONE,new K("object"),new K("Object"),[n])}function Nc(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return J.deserialize(n);case 1:return W.deserialize(n);case 2:return _e.deserialize(n);case 3:return _chunkZYPBABLQjs.Z.deserialize(n);case 4:return _.deserialize(n,J);case 5:return U.deserialize(n);case 6:return we.deserialize(n);case 7:return Se.deserialize(n);case 8:return le.deserialize(n);case 9:return sn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var bt=class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return wt.load(e);case 2:return yn.load(e);case 3:return fn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},wt= exports.TransactionPayloadScript =class n extends bt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=An.deserialize(e);return new n(t)}},yn= exports.TransactionPayloadEntryFunction =class n extends bt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=St.deserialize(e);return new n(t)}},fn= exports.TransactionPayloadMultiSig =class n extends bt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=hn.deserialize(e);return new n(t)}},St= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(mn.fromStr(e),new K(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=mn.deserialize(e),r=K.deserialize(e),i=e.deserializeVector(N),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=Hn.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},An= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(N),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Nc(e);o.push(a)}return new n(t,r,o)}},hn= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Tn.deserialize(e)),new n(t,i)}},Tn= exports.MultiSigTransactionPayload =class n extends _chunkZYPBABLQjs.l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(St.deserialize(e))}};var fe=class n extends _chunkZYPBABLQjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=_chunkZYPBABLQjs.Z.deserialize(e),r=e.deserializeU64(),i=bt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=qt.deserialize(e);return new n(t,r,i,o,s,a,c)}},ir= exports.RawTransactionWithData =class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return _t.load(e);case 1:return Pt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},_t= exports.MultiAgentRawTransaction =class n extends ir{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=fe.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z);return new n(t,r)}},Pt= exports.FeePayerRawTransaction =class n extends ir{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=fe.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=_chunkZYPBABLQjs.Z.deserialize(e);return new n(t,r,i)}};var or=class extends _chunkZYPBABLQjs.l{constructor(t){super();this.accountAddress=_chunkZYPBABLQjs.Z.ONE;this.moduleName=new E("account");this.structName=new E("RotationProofChallenge");this.sequenceNumber=new W(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=_.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var Qe=class extends _chunkZYPBABLQjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Et.load(e);case 1:return sr.load(e);case 2:return xt.load(e);case 3:return It.load(e);case 4:return ot.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Et}isMultiEd25519(){return this instanceof sr}isMultiAgent(){return this instanceof xt}isFeePayer(){return this instanceof It}isSingleSender(){return this instanceof ot}},Et= exports.TransactionAuthenticatorEd25519 =class n extends Qe{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=x.deserialize(e),r=I.deserialize(e);return new n(t,r)}},sr= exports.TransactionAuthenticatorMultiEd25519 =class n extends Qe{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Ft.deserialize(e),r=gt.deserialize(e);return new n(t,r)}},xt= exports.TransactionAuthenticatorMultiAgent =class n extends Qe{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=Q.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=e.deserializeVector(Q);return new n(t,r,i)}},It= exports.TransactionAuthenticatorFeePayer =class n extends Qe{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=Q.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=e.deserializeVector(Q),o=_chunkZYPBABLQjs.Z.deserialize(e),s=Q.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ot= exports.TransactionAuthenticatorSingleSender =class n extends Qe{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=Q.deserialize(e);return new n(t)}};var je=class n extends _chunkZYPBABLQjs.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=fe.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}};var Lt=class n extends _chunkZYPBABLQjs.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=fe.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunkZYPBABLQjs.Z.deserialize(e)),new n(t,i)}};var ar=class n extends _chunkZYPBABLQjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=fe.deserialize(e),r=e.deserializeVector(_chunkZYPBABLQjs.Z),i=e.deserializeBool(),o;return i&&(o=_chunkZYPBABLQjs.Z.deserialize(e)),new n(t,r,o)}};function ti(n){return n.feePayerAddress?new Pt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new _t(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Ht(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function wf(n){return Ht(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Je(n){let e=ti(n);return n.feePayerAddress?Ht(e.bcsToBytes(),Qr):n.secondarySignerAddresses?Ht(e.bcsToBytes(),Qr):Ht(e.bcsToBytes(),uo)}var Ae=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=q.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=q.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new xe(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new xe(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Je(e))}};function ni(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var he=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new O(t.publicKey()),this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=q.generate();break;case 2:r=Ne.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=Ne.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new ie(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ie(this.publicKey,this.signTransaction(e))}sign(e){return new H(this.privateKey.sign(e))}signTransaction(e){return this.sign(Je(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var De=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Ae.generate():he.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new Ae({privateKey:t,address:r}):new he({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?Ae.fromDerivationPath({mnemonic:r,path:i}):he.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var _utils = require('@noble/hashes/utils');var Mc=1209600,$t=class $t extends _chunkZYPBABLQjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new yt(t.publicKey()),this.expiryDateSecs=r||_chunkZYPBABLQjs.ba.call(void 0, _chunkZYPBABLQjs.aa.call(void 0, )+Mc),this.blinder=i!==void 0?_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array():Vc();let o=qr(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(un(this.blinder));let s=dn(o);this.nonce=s.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new $t({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return $t.deserialize(new C(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _48 => _48.scheme])){case 0:default:t=q.generate()}return new $t({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _49 => _49.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new ve(this.privateKey.sign(e))}};$t.BLINDER_LENGTH=31;var vt=$t;function Vc(){return _utils.randomBytes.call(void 0, vt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function cr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var Wt=class Wt extends _chunkZYPBABLQjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:y,proofFetchCallback:h,jwt:p,verificationKeyHash:l}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new _eventemitter32.default,this.proofOrPromise=y,y instanceof Ee)this.proof=y;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async R=>{await h(R),this.emitter.removeAllListeners()}),this.init(y)}let b=_chunkZYPBABLQjs.j.fromHexInput(d).toUint8Array();if(b.length!==Wt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Wt.PEPPER_LENGTH}`);if(this.pepper=b,l!==void 0){if(_chunkZYPBABLQjs.j.hexInputToUint8Array(l).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunkZYPBABLQjs.j.hexInputToUint8Array(l)}}getAnyPublicKey(){return new O(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=_chunkZYPBABLQjs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=vt.deserialize(t),c=Ee.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new H(this.sign(t)),i=new O(this.publicKey);return new ie(i,r)}signTransactionWithAuthenticator(t){let r=new H(this.signTransaction(t)),i=new O(this.publicKey);return new ie(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw z.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw z.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw z.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await ln({aptosConfig:t});if(_chunkZYPBABLQjs.j.hexInputToString(i.hash())!==_chunkZYPBABLQjs.j.hexInputToString(this.verificationKeyHash))throw z.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await Wt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw z.fromErrorType({type:0});if(this.proof===void 0)throw z.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new Me({jwtHeader:_chunkZYPBABLQjs.ca.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Gt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw z.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=ti(t),o=new ri(r,this.proof.proof).hash();return this.sign(o)}verifySignature(t){let{message:r,signature:i}=t;return!(this.isExpired()||!this.ephemeralKeyPair.getPublicKey().verifySignature({message:r,signature:i.ephemeralSignature}))}static async fetchJWK(t){let{aptosConfig:r,publicKey:i,kid:o}=t,s=i instanceof k?i:i.keylessPublicKey,{iss:a}=s,c,d=i instanceof te?i.jwkAddress:void 0;try{c=await bo({aptosConfig:r,jwkAddr:d})}catch(p){throw z.fromErrorType({type:24,error:p,details:`Failed to fetch ${d?"Federated":"Patched"}JWKs ${d?`for address ${d}`:"0x1"}`})}let y=c.get(a);if(y===void 0)throw z.fromErrorType({type:7,details:`JWKs for issuer ${a} not found.`});let h=y.find(p=>p.kid===o);if(h===void 0)throw z.fromErrorType({type:6,details:`JWK with kid '${o}' for issuer '${a}' not found.`});return h}};Wt.PEPPER_LENGTH=31;var pe=Wt,ri= exports.TransactionAndProof =class extends _chunkZYPBABLQjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return Ht(this.bcsToBytes(),this.domainSeparator)}};var Xe=class n extends pe{constructor(e){let t=k.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=pe.partialDeserialize(e),{iss:d,aud:y,uidVal:h}=Ve({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:h,aud:y,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new C(_chunkZYPBABLQjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d}=e,{iss:y,aud:h,uidVal:p}=Ve({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:y,uidKey:a,uidVal:p,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:d?d.hash():void 0})}};var Ct=class n extends pe{constructor(e){let t=te.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=pe.partialDeserialize(e),d=_chunkZYPBABLQjs.Z.deserialize(e),{iss:y,aud:h,uidVal:p}=Ve({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:y,uidKey:s,uidVal:p,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(C.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:y}=e,{iss:h,aud:p,uidVal:l}=Ve({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:l,aud:p,pepper:s,jwkAddress:_chunkZYPBABLQjs.Z.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:y?y.hash():void 0})}};var bn=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof Ae?he.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?_chunkZYPBABLQjs.Z.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{publicKeys:t,signaturesRequired:r,signers:i}=e,o=new Re({publicKeys:t,signaturesRequired:r});return new n({multiKey:o,signers:i})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Ue(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ue(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof pe).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof pe).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new qe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new qe({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){let{message:t,signature:r}=e;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:t,signature:s}))return!1}return!0}};function So(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunkZYPBABLQjs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunkZYPBABLQjs.Z.deserialize(n),signingScheme:e}}function _o(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Po(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=vt.deserialize(n),o=Ee.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Eo;(h=>{function n(p){let l=new _chunkZYPBABLQjs.m;switch(l.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(l),p.signingScheme){case 0:return p.privateKey.serialize(l),l.toUint8Array();case 2:{if(!ni(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(l.serializeU32AsUleb128(b.variant),b.variant){case 3:return _o(p,l),l.toUint8Array();case 4:{let R=p;return _o(R,l),R.publicKey.jwkAddress.serialize(l),l.serializeBool(R.audless),l.toUint8Array()}case 1:case 0:return p.privateKey.serialize(l),l.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(l),l.serializeU32AsUleb128(b.signers.length),b.signers.forEach(R=>{l.serializeFixedBytes(n(R))}),l.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}h.toBytes=n;function e(p){return _chunkZYPBABLQjs.j.hexInputToStringWithoutPrefix(n(p))}h.toHexStringWithoutPrefix=e;function t(p){return _chunkZYPBABLQjs.j.hexInputToString(n(p))}h.toHexString=t;function r(p){let{address:l,signingScheme:b}=So(p);switch(b){case 0:{let R=q.deserialize(p);return new Ae({privateKey:R,address:l})}case 2:{let R=p.deserializeUleb128AsU32();switch(R){case 0:{let ee=q.deserialize(p);return new he({privateKey:ee,address:l})}case 1:{let ee=Ne.deserialize(p);return new he({privateKey:ee,address:l})}case 3:{let ee=Po(p),ct=Ve(ee);return new Xe({...ee,...ct})}case 4:{let ee=Po(p),ct=_chunkZYPBABLQjs.Z.deserialize(p),Ut=p.deserializeBool(),zt=Ve(ee);return new Ct({...ee,...zt,jwkAddress:ct,audless:Ut})}default:throw new Error(`Unsupported public key variant ${R}`)}}case 3:{let R=Re.deserialize(p),ee=p.deserializeUleb128AsU32(),ct=new Array;for(let Ut=0;Ut<ee;Ut+=1){let zt=r(p);if(!ni(zt)&&!(zt instanceof Ae))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");ct.push(zt)}return new bn({multiKey:R,signers:ct,address:l})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=r;function i(p){let l=d(p);if(!(l instanceof Xe))throw new Error("Deserialization of KeylessAccount failed");return l}h.keylessAccountFromHex=i;function o(p){let l=d(p);if(!(l instanceof Ct))throw new Error("Deserialization of FederatedKeylessAccount failed");return l}h.federatedKeylessAccountFromHex=o;function s(p){let l=d(p);if(!(l instanceof bn))throw new Error("Deserialization of MultiKeyAccount failed");return l}h.multiKeyAccountFromHex=s;function a(p){let l=d(p);if(!(l instanceof he))throw new Error("Deserialization of SingleKeyAccount failed");return l}h.singleKeyAccountFromHex=a;function c(p){let l=d(p);if(!(l instanceof Ae))throw new Error("Deserialization of Ed25519Account failed");return l}h.ed25519AccountFromHex=c;function d(p){return r(C.fromHex(p))}h.fromHex=d;function y(p){return d(p)}h.fromBytes=y})(Eo||(Eo= exports.AccountUtils ={}));var wn=class n extends M{constructor(e){super(),this.value=_chunkZYPBABLQjs.j.fromHexInput(e)}serialize(e){e.serializeBytes(this.value.toUint8Array())}static deserialize(e){return new n(e.deserializeBytes())}},ur=class extends Y{constructor(e){super(),this.accountAddress=e}authKey(){return new B({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var Io=class n extends De{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunkZYPBABLQjs.ia.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new ur(this.accountAddress),this.sign=o=>new wn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunkZYPBABLQjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new gn(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(Je(t))}signTransaction(t){return this.sign(Je(t))}setSigner(t){this.sign=r=>new wn(t(r))}};var Hc=`
|
|
9
7
|
fragment TokenActivitiesFields on token_activities_v2 {
|
|
10
8
|
after_value
|
|
11
9
|
before_value
|
|
@@ -23,7 +21,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
23
21
|
transaction_version
|
|
24
22
|
type
|
|
25
23
|
}
|
|
26
|
-
|
|
24
|
+
`,$c=`
|
|
27
25
|
fragment AnsTokenFragment on current_aptos_names {
|
|
28
26
|
domain
|
|
29
27
|
expiration_timestamp
|
|
@@ -35,7 +33,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
35
33
|
subdomain_expiration_policy
|
|
36
34
|
domain_expiration_timestamp
|
|
37
35
|
}
|
|
38
|
-
`,
|
|
36
|
+
`,dr=`
|
|
39
37
|
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
|
|
40
38
|
token_standard
|
|
41
39
|
token_properties_mutated_v1
|
|
@@ -82,7 +80,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
|
-
`,
|
|
83
|
+
`,vo=`
|
|
86
84
|
query getAccountCoinsCount($address: String) {
|
|
87
85
|
current_fungible_asset_balances_aggregate(
|
|
88
86
|
where: {owner_address: {_eq: $address}}
|
|
@@ -92,7 +90,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
|
-
`,
|
|
93
|
+
`,Co=`
|
|
96
94
|
query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
|
|
97
95
|
current_fungible_asset_balances(
|
|
98
96
|
where: $where_condition
|
|
@@ -159,7 +157,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
159
157
|
single_token_uri
|
|
160
158
|
}
|
|
161
159
|
}
|
|
162
|
-
`,
|
|
160
|
+
`,Ro=`
|
|
163
161
|
query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
164
162
|
current_token_ownerships_v2(
|
|
165
163
|
where: $where_condition
|
|
@@ -170,7 +168,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
170
168
|
...CurrentTokenOwnershipFields
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
|
-
${
|
|
171
|
+
${dr}`,Jh=`
|
|
174
172
|
query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
175
173
|
current_token_ownerships_v2(
|
|
176
174
|
where: $where_condition
|
|
@@ -181,7 +179,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
181
179
|
...CurrentTokenOwnershipFields
|
|
182
180
|
}
|
|
183
181
|
}
|
|
184
|
-
${
|
|
182
|
+
${dr}`,Uo=`
|
|
185
183
|
query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
186
184
|
current_token_ownerships_v2(
|
|
187
185
|
where: $where_condition
|
|
@@ -192,7 +190,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
192
190
|
...CurrentTokenOwnershipFields
|
|
193
191
|
}
|
|
194
192
|
}
|
|
195
|
-
${
|
|
193
|
+
${dr}`,zo=`
|
|
196
194
|
query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
|
|
197
195
|
current_token_ownerships_v2_aggregate(
|
|
198
196
|
where: $where_condition
|
|
@@ -212,13 +210,13 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
212
210
|
}
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
|
-
`,
|
|
213
|
+
`,ko=`
|
|
216
214
|
query getChainTopUserTransactions($limit: Int) {
|
|
217
215
|
user_transactions(limit: $limit, order_by: {version: desc}) {
|
|
218
216
|
version
|
|
219
217
|
}
|
|
220
218
|
}
|
|
221
|
-
`,
|
|
219
|
+
`,Oo=`
|
|
222
220
|
query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
|
|
223
221
|
current_collections_v2(where: $where_condition) {
|
|
224
222
|
uri
|
|
@@ -266,7 +264,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
266
264
|
token_standard
|
|
267
265
|
}
|
|
268
266
|
}
|
|
269
|
-
`,
|
|
267
|
+
`,No=`
|
|
270
268
|
query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
|
|
271
269
|
delegated_staking_activities(
|
|
272
270
|
where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
|
|
@@ -279,7 +277,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
279
277
|
transaction_version
|
|
280
278
|
}
|
|
281
279
|
}
|
|
282
|
-
`,
|
|
280
|
+
`,Go=`
|
|
283
281
|
query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
|
|
284
282
|
events(
|
|
285
283
|
where: $where_condition
|
|
@@ -298,7 +296,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
298
296
|
indexed_type
|
|
299
297
|
}
|
|
300
298
|
}
|
|
301
|
-
`,
|
|
299
|
+
`,Bo=`
|
|
302
300
|
query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
|
|
303
301
|
fungible_asset_activities(
|
|
304
302
|
where: $where_condition
|
|
@@ -323,7 +321,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
323
321
|
type
|
|
324
322
|
}
|
|
325
323
|
}
|
|
326
|
-
`,
|
|
324
|
+
`,Mo=`
|
|
327
325
|
query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
|
|
328
326
|
fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
|
|
329
327
|
icon_uri
|
|
@@ -353,14 +351,14 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
353
351
|
...AnsTokenFragment
|
|
354
352
|
}
|
|
355
353
|
}
|
|
356
|
-
${
|
|
354
|
+
${$c}`,ii=`
|
|
357
355
|
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
358
356
|
num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
|
|
359
357
|
num_active_delegator
|
|
360
358
|
pool_address
|
|
361
359
|
}
|
|
362
360
|
}
|
|
363
|
-
`,
|
|
361
|
+
`,pr=`
|
|
364
362
|
query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
|
|
365
363
|
current_objects(
|
|
366
364
|
where: $where_condition
|
|
@@ -377,7 +375,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
377
375
|
is_deleted
|
|
378
376
|
}
|
|
379
377
|
}
|
|
380
|
-
`,
|
|
378
|
+
`,oi=`
|
|
381
379
|
query getProcessorStatus($where_condition: processor_status_bool_exp) {
|
|
382
380
|
processor_status(where: $where_condition) {
|
|
383
381
|
last_success_version
|
|
@@ -401,7 +399,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
401
399
|
write_set_change_index
|
|
402
400
|
}
|
|
403
401
|
}
|
|
404
|
-
`,
|
|
402
|
+
`,qo=`
|
|
405
403
|
query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
|
|
406
404
|
table_metadatas(
|
|
407
405
|
where: $where_condition
|
|
@@ -414,7 +412,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
414
412
|
value_type
|
|
415
413
|
}
|
|
416
414
|
}
|
|
417
|
-
`,
|
|
415
|
+
`,Lo=`
|
|
418
416
|
query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
|
|
419
417
|
token_activities_v2(
|
|
420
418
|
where: $where_condition
|
|
@@ -425,7 +423,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
425
423
|
...TokenActivitiesFields
|
|
426
424
|
}
|
|
427
425
|
}
|
|
428
|
-
${
|
|
426
|
+
${Hc}`,si=`
|
|
429
427
|
query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
430
428
|
current_token_ownerships_v2(
|
|
431
429
|
where: $where_condition
|
|
@@ -436,7 +434,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
436
434
|
...CurrentTokenOwnershipFields
|
|
437
435
|
}
|
|
438
436
|
}
|
|
439
|
-
${
|
|
437
|
+
${dr}`,Ho=`
|
|
440
438
|
query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
|
|
441
439
|
current_token_datas_v2(
|
|
442
440
|
where: $where_condition
|
|
@@ -476,7 +474,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:n,de
|
|
|
476
474
|
}
|
|
477
475
|
}
|
|
478
476
|
}
|
|
479
|
-
`;async function fn(r){let{aptosConfig:e}=r,{data:t}=await q({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function Wo(r){let{aptosConfig:e,limit:t}=r;return(await T({aptosConfig:e,query:{query:Oo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function T(r){let{aptosConfig:e,query:t,originMethod:n}=r,{data:i}=await Ao({aptosConfig:e,originMethod:_nullishCoalesce(n, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Vc(r){let{aptosConfig:e}=r;return(await T({aptosConfig:e,query:{query:pi},originMethod:"getProcessorStatuses"})).processor_status}async function An(r){let e=await Vc({aptosConfig:r.aptosConfig});return BigInt(e[0].last_success_version)}async function hn(r){let{aptosConfig:e,processorType:t}=r;return(await T({aptosConfig:e,query:{query:pi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Tn(r){let{aptosConfig:e,handle:t,data:n,options:i}=r;return(await ot({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _56 => _56.ledgerVersion])},body:n})).data}async function Qo(r){let{aptosConfig:e,options:t}=r,n={query:Vo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _57 => _57.where]),offset:_optionalChain([t, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([t, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([t, 'optionalAccess', _60 => _60.orderBy])}};return(await T({aptosConfig:e,query:n,originMethod:"getTableItemsData"})).table_items}async function jo(r){let{aptosConfig:e,options:t}=r,n={query:Ho,variables:{where_condition:_optionalChain([t, 'optionalAccess', _61 => _61.where]),offset:_optionalChain([t, 'optionalAccess', _62 => _62.offset]),limit:_optionalChain([t, 'optionalAccess', _63 => _63.limit]),order_by:_optionalChain([t, 'optionalAccess', _64 => _64.orderBy])}};return(await T({aptosConfig:e,query:n,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Oe(r){let{aptosConfig:e,accountAddress:t}=r,{data:n}=await q({aptosConfig:e,originMethod:"getInfo",path:`accounts/${u.from(t).toString()}`});return n}async function Yo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return ti({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _65 => _65.ledgerVersion]),offset:_optionalChain([n, 'optionalAccess', _66 => _66.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _67 => _67.limit]), () => (1e3))}})}async function bn(r){return _optionalChain([r, 'access', _68 => _68.options, 'optionalAccess', _69 => _69.ledgerVersion])!==void 0?Jo(r):Ke(async()=>Jo(r),`module-${r.accountAddress}-${r.moduleName}`,1e3*60*5)()}async function Jo(r){let{aptosConfig:e,accountAddress:t,moduleName:n,options:i}=r,{data:o}=await q({aptosConfig:e,originMethod:"getModule",path:`accounts/${u.from(t).toString()}/module/${n}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _70 => _70.ledgerVersion])}});return o}async function Zo(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return nn({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:_optionalChain([n, 'optionalAccess', _71 => _71.offset]),limit:_optionalChain([n, 'optionalAccess', _72 => _72.limit])}})}async function es(r){let{aptosConfig:e,accountAddress:t,options:n}=r;return ti({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([n, 'optionalAccess', _73 => _73.ledgerVersion]),offset:_optionalChain([n, 'optionalAccess', _74 => _74.offset]),limit:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _75 => _75.limit]), () => (999))}})}async function li(r){let{aptosConfig:e,accountAddress:t,resourceType:n,options:i}=r,{data:o}=await q({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${n}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _76 => _76.ledgerVersion])}});return o.data}async function jt(r){let{aptosConfig:e,authenticationKey:t,options:n}=r,i=await li({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:n}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await Tn({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:n});return u.from(a)}catch(a){if(a instanceof Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function ts(r){let{aptosConfig:e,accountAddress:t}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await T({aptosConfig:e,query:{query:zo,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function rs(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([n, 'optionalAccess', _77 => _77.tokenStandard])&&(o.token_standard={_eq:_optionalChain([n, 'optionalAccess', _78 => _78.tokenStandard])});let s={query:Uo,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _79 => _79.offset]),limit:_optionalChain([n, 'optionalAccess', _80 => _80.limit]),order_by:_optionalChain([n, 'optionalAccess', _81 => _81.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ns(r){let{aptosConfig:e,accountAddress:t,collectionAddress:n,options:i}=r,o=u.from(t).toStringLong(),s=u.from(n).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _82 => _82.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _83 => _83.tokenStandard])});let c={query:ko,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _84 => _84.offset]),limit:_optionalChain([i, 'optionalAccess', _85 => _85.limit]),order_by:_optionalChain([i, 'optionalAccess', _86 => _86.orderBy])}};return(await T({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function is(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}};_optionalChain([n, 'optionalAccess', _87 => _87.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([n, 'optionalAccess', _88 => _88.tokenStandard])}});let s={query:Ko,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _89 => _89.offset]),limit:_optionalChain([n, 'optionalAccess', _90 => _90.limit]),order_by:_optionalChain([n, 'optionalAccess', _91 => _91.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function os(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:Do,variables:{address:n}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function ss(r){let{aptosConfig:e,accountAddress:t,options:n}=r,i=u.from(t).toStringLong(),o={..._optionalChain([n, 'optionalAccess', _92 => _92.where]),owner_address:{_eq:i}},s={query:Ro,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _93 => _93.offset]),limit:_optionalChain([n, 'optionalAccess', _94 => _94.limit]),order_by:_optionalChain([n, 'optionalAccess', _95 => _95.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function as(r){let{aptosConfig:e,accountAddress:t}=r,n=u.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:Co,variables:{address:n}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function cs(r){let{aptosConfig:e,accountAddress:t,options:n}=r,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:mn,variables:{where_condition:o,offset:_optionalChain([n, 'optionalAccess', _96 => _96.offset]),limit:_optionalChain([n, 'optionalAccess', _97 => _97.limit]),order_by:_optionalChain([n, 'optionalAccess', _98 => _98.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function us(r){let{aptosConfig:e,privateKey:t}=r,n=new N(t.publicKey());if(t instanceof Ge){let o=L.fromPublicKey({publicKey:n}).derivedAddress();return at.fromPrivateKey({privateKey:t,address:o})}if(t instanceof H){let i=L.fromPublicKey({publicKey:n});if(await Xo({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return at.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=L.fromPublicKey({publicKey:n.publicKey});if(await Xo({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return at.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function Xo(r){let{aptosConfig:e,authKey:t}=r,n=await jt({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Oe({aptosConfig:e,accountAddress:n}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${n.toString()}`)}}async function yi(r){let{aptosConfig:e,options:t}=r;return nn({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _99 => _99.offset]),limit:_optionalChain([t, 'optionalAccess', _100 => _100.limit])}})}async function Sn(r){let{aptosConfig:e}=r;return Ke(async()=>{let{data:t}=await q({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function ps(r){let{aptosConfig:e,ledgerVersion:t}=r,{data:n}=await q({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return n}async function Sr(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await q({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return n}async function ds(r){let{aptosConfig:e,transactionHash:t}=r;try{return(await Sr({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(n){if(_optionalChain([n, 'optionalAccess', _101 => _101.status])===404)return!0;throw n}}async function Hc(r){let{aptosConfig:e,transactionHash:t}=r,{data:n}=await q({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return n}async function Jt(r){let{aptosConfig:e,transactionHash:t,options:n}=r,i=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _102 => _102.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _103 => _103.checkSuccess]), () => (!0)),s=!0,a=0,c,p,l=200,h=1.5;function g(d){if(!(d instanceof Ae)||(p=d,d.status!==404&&d.status>=400&&d.status<500))throw d}try{c=await Sr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(d){g(d)}if(s){let d=Date.now();try{c=await Hc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){g(b)}a=(Date.now()-d)/1e3}for(;s&&!(a>=i);){try{if(c=await Sr({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(d){g(d)}await _chunkIHUCZKG2js.b.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new wn(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new wn(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new gi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function _n(r){let{aptosConfig:e,processorType:t}=r,n=BigInt(r.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<n;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await An({aptosConfig:e}):s=(await hn({aptosConfig:e,processorType:t})).last_success_version,s>=n)break;await _chunkIHUCZKG2js.b.call(void 0, 200)}}var wn=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},gi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function ls(r){let{aptosConfig:e,ledgerVersion:t,options:n}=r,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _104 => _104.withTransactions])}});return ys({block:i,...r})}async function gs(r){let{aptosConfig:e,blockHeight:t,options:n}=r,{data:i}=await q({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([n, 'optionalAccess', _105 => _105.withTransactions])}});return ys({block:i,...r})}async function ys(r){let{aptosConfig:e,block:t,options:n}=r;if(_optionalChain([n, 'optionalAccess', _106 => _106.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _107 => _107.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let p=[],l=100n;for(let g=c+1n;g<s;g+=BigInt(100))p.push(yi({aptosConfig:e,options:{offset:g,limit:Math.min(Number(l),Number(s-g+1n))}}));let h=await Promise.all(p);for(let g of h)t.transactions.push(...g)}return t}async function w(r){r.minimumLedgerVersion!==void 0&&await _n({aptosConfig:r.config,minimumLedgerVersion:r.minimumLedgerVersion,processorType:r.processorType})}function ms(r){return typeof r=="boolean"}function ct(r){return typeof r=="string"}function qc(r){return typeof r=="number"}function xn(r){if(qc(r))return r;if(ct(r)&&r!=="")return Number.parseInt(r,10)}function En(r){return typeof r=="number"||typeof r=="bigint"||typeof r=="string"}function fs(r){return r==null}function As(r){return mi(r)||Ai(r)||hi(r)||Ti(r)||bi(r)||wi(r)||Si(r)||Pn(r)||fi(r)||$c(r)||r instanceof S||r instanceof Y}function mi(r){return r instanceof U}function Pn(r){return r instanceof u}function fi(r){return r instanceof x}function $c(r){return r instanceof mt}function Ai(r){return r instanceof X}function hi(r){return r instanceof _e}function Ti(r){return r instanceof xe}function bi(r){return r instanceof Q}function wi(r){return r instanceof Ee}function Si(r){return r instanceof ye}function hs(r){return"bytecode"in r}function z(r,e){throw new Error(`Type mismatch for argument ${e}, expected '${r}'`)}function Ts(r){let e=r.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?r.params.length:e}function _r(r){let e=r.split("::");if(e.length!==3)throw new Error(`Invalid function ${r}`);let t=e[0],n=e[1],i=e[2];return{moduleAddress:t,moduleName:n,functionName:i}}function bs(r){return!!r.match(/^[_a-zA-Z0-9]+$/)}function ws(r){return!!r.match(/\s/)}function Wc(r){return!!r.match(/^T[0-9]+$/)}function Qc(r){return!!r.match(/^&.+$/)}function jc(r){switch(r){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function Jc(r,e){let t=e;for(;t<r.length;t+=1){let n=r[t];if(!ws(n))break}return t}var Xc=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(Xc||{}),W= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Ye(r,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _108 => _108.allowGenerics]), () => (!1)),n=[],i=[],o=[],s=0,a="",c=1;for(;s<r.length;){let p=r[s];if(p==="<")n.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let b=xr(a,i,t);o.push(b)}let l=n.pop();if(l===void 0)throw new W(r,"unexpected '>'");if(c!==o.length)throw new W(r,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:g,savedExpectedTypes:d}=l;i=o,o=g,a=h,c=d}else if(p===","){if(n.length===0)throw new W(r,"unexpected ','");if(a.length===0)throw new W(r,"no type argument before ','");let l=xr(a,i,t);i=[],o.push(l),a="",c+=1}else if(ws(p)){let l=!1;if(a.length!==0){let g=xr(a,i,t);i=[],o.push(g),a="",l=!0}s=Jc(r,s);let h=r[s];if(s<r.length&&l&&h!==","&&h!==">")throw new W(r,"unexpected whitespace character");continue}else a+=p;s+=1}if(n.length>0)throw new W(r,"no matching '>' for '<'");switch(o.length){case 0:return xr(a,i,t);case 1:if(a==="")return o[0];throw new W(r,"unexpected ','");default:throw new W(r,"unexpected whitespace character")}}function xr(r,e,t){let n=r.trim(),i=n.toLowerCase();if(jc(i)&&e.length>0)throw new W(r,"primitive types not expected to have type arguments");switch(n.toLowerCase()){case"signer":return new St;case"bool":return new M;case"address":return new ee;case"u8":return new pe;case"u16":return new qe;case"u32":return new $e;case"u64":return new j;case"u128":return new We;case"u256":return new Qe;case"vector":if(e.length!==1)throw new W(r,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(Qc(n)){let a=n.substring(1);return new an(xr(a,e,t))}if(Wc(n)){if(t)return new G(Number(n.split("T")[1]));throw new W(r,"unexpected generic type")}if(!n.match(/:/))throw new W(r,"unknown type");let o=n.split("::");if(o.length!==3)throw new W(r,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch (e3){throw new W(r,"struct address must be valid")}if(!bs(o[1]))throw new W(r,"module name must only contain alphanumeric or '_' characters");if(!bs(o[2]))throw new W(r,"struct name must only contain alphanumeric or '_' characters");return new A(new De(s,new R(o[1]),new R(o[2]),e))}}var Yc=new TextEncoder;function vn(r){return _nullishCoalesce(_optionalChain([r, 'optionalAccess', _109 => _109.map, 'call', _110 => _110(e=>ct(e)?Ye(e):e)]), () => ([]))}async function Ss(r,e,t,n){let i=await bn({aptosConfig:n,accountAddress:r,moduleName:e});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===t)}async function _s(r,e,t,n){let i=await Ss(r,e,t,n);if(!i)throw new Error(`Could not find entry function ABI for '${r}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${r}::${e}::${t}' is not an entry function`);let o=Ts(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ye(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function xs(r,e,t,n){let i=await Ss(r,e,t,n);if(!i)throw new Error(`Could not find view function ABI for '${r}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${r}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Ye(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ye(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function xi(r,e,t,n,i){if(n>=e.parameters.length)throw new Error(`Too many arguments for '${r}', expected ${e.parameters.length}`);let o=e.parameters[n];return Xt(t,o,n,i)}function Xt(r,e,t,n){return As(r)?(_i(e,r,t),r):Zc(r,e,t,n)}function Zc(r,e,t,n){if(e.isBool()){if(ms(r))return new U(r);if(ct(r)){if(r==="true")return new U(!0);if(r==="false")return new U(!1)}z("boolean",t)}if(e.isAddress()){if(ct(r))return u.fromString(r);z("string | AccountAddress",t)}if(e.isU8()){let i=xn(r);if(i!==void 0)return new X(i);z("number | string",t)}if(e.isU16()){let i=xn(r);if(i!==void 0)return new _e(i);z("number | string",t)}if(e.isU32()){let i=xn(r);if(i!==void 0)return new xe(i);z("number | string",t)}if(e.isU64()){if(En(r))return new Q(BigInt(r));z("bigint | number | string",t)}if(e.isU128()){if(En(r))return new Ee(BigInt(r));z("bigint | number | string",t)}if(e.isU256()){if(En(r))return new ye(BigInt(r));z("bigint | number | string",t)}if(e.isGeneric()){let i=e.value;if(i<0||i>=n.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Xt(r,n[i],t,n)}if(e.isVector()){if(e.value.isU8()){if(ct(r))return S.U8(Yc.encode(r));if(r instanceof Uint8Array)return S.U8(r);if(r instanceof ArrayBuffer)return S.U8(new Uint8Array(r))}if(Array.isArray(r))return new S(r.map(i=>Xt(i,e.value,t,n)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(ct(r))return new x(r);z("string",t)}if(e.isObject()){if(ct(r))return u.fromString(r);z("string | AccountAddress",t)}if(e.isOption()){if(fs(r)){let i=e.value.typeArgs[0];return i instanceof M?new Y(null):i instanceof ee?new Y(null):i instanceof pe?new Y(null):i instanceof qe?new Y(null):i instanceof $e?new Y(null):i instanceof j?new Y(null):i instanceof We?new Y(null):i instanceof Qe?new Y(null):new Y(null)}return new Y(Xt(r,e.value.typeArgs[0],t,n))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function _i(r,e,t){if(r.isBool()){if(mi(e))return;z("Bool",t)}if(r.isAddress()){if(Pn(e))return;z("AccountAddress",t)}if(r.isU8()){if(Ai(e))return;z("U8",t)}if(r.isU16()){if(hi(e))return;z("U16",t)}if(r.isU32()){if(Ti(e))return;z("U32",t)}if(r.isU64()){if(bi(e))return;z("U64",t)}if(r.isU128()){if(wi(e))return;z("U128",t)}if(r.isU256()){if(Si(e))return;z("U256",t)}if(r.isVector()){if(e instanceof S){e.values.length>0&&_i(r.value,e.values[0],t);return}z("MoveVector",t)}if(r instanceof A){if(r.isString()){if(fi(e))return;z("MoveString",t)}if(r.isObject()){if(Pn(e))return;z("AccountAddress",t)}if(r.isOption()){if(e instanceof Y){e.value!==void 0&&_i(r.value.typeArgs[0],e.value,t);return}z("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${r.toString()}'`)}async function In(r){if(hs(r))return nu(r);let{moduleAddress:e,moduleName:t,functionName:n}=_r(r.function),i=await Is({key:"entry-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:_s});return tu({...r,abi:i})}function tu(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=_r(r.function),o=vn(r.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=r.functionArguments.map((c,p)=>xi(r.function,e,c,p,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${n}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=xt.build(`${t}::${n}`,i,o,s);if("multisigAddress"in r){let c=u.from(r.multisigAddress);return new Ar(new Tr(c,new br(a)))}return new fr(a)}async function Es(r){let{moduleAddress:e,moduleName:t,functionName:n}=_r(r.function),i=await Is({key:"view-function",moduleAddress:e,moduleName:t,functionName:n,aptosConfig:r.aptosConfig,abi:r.abi,fetch:xs});return ru({abi:i,...r})}function ru(r){let e=r.abi,{moduleAddress:t,moduleName:n,functionName:i}=_r(r.function),o=vn(r.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _111 => _111.functionArguments, 'optionalAccess', _112 => _112.map, 'call', _113 => _113((a,c)=>xi(r.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${n}::${i}', expected ${e.parameters.length} but got ${s.length}`);return xt.build(`${t}::${n}`,i,o,s)}function nu(r){return new mr(new hr(m.fromHexInput(r.bytecode).toUint8Array(),vn(r.typeArguments),r.functionArguments))}async function iu(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=async()=>Yn[e.network]?{chainId:Yn[e.network]}:{chainId:(await fn({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _114 => _114.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Sn({aptosConfig:e})).gas_estimate},c=async()=>{let K=async()=>_optionalChain([i, 'optionalAccess', _115 => _115.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Oe({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await K()}catch (e4){return 0}else return K()},[{chainId:p},{gasEstimate:l},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:g,gasUnitPrice:d,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _116 => _116.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _117 => _117.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _118 => _118.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new he(u.from(t),BigInt(h),n,BigInt(g),BigInt(d),BigInt(b),new Vt(p))}async function Ei(r){let{aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o}=r,s=await iu({aptosConfig:e,sender:t,payload:n,options:i,feePayerAddress:o});if("secondarySignerAddresses"in r){let a=_nullishCoalesce(_optionalChain([r, 'access', _119 => _119.secondarySignerAddresses, 'optionalAccess', _120 => _120.map, 'call', _121 => _121(c=>u.from(c))]), () => ([]));return new ln(s,a,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}return new dn(s,r.feePayerAddress?u.from(r.feePayerAddress):void 0)}function Ps(r){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:n,feePayerPublicKey:i}=r,o=Yt(e);if(t.feePayerAddress){let a=new Pt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(n?c=n.map(h=>Yt(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Yt(void 0)));let p=Yt(i),l=new Ct(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new Je(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Et(t.rawTransaction,t.secondarySignerAddresses),c=[];n?c=n.map(l=>Yt(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Yt(void 0));let p=new It(o,t.secondarySignerAddresses,c);return new Je(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof Ie)s=new vt(o.public_key,o.signature);else if(o instanceof ae||o instanceof ze)s=new st(o);else if(o instanceof Lt)s=new st(o);else throw new Error("Invalid public key");return new Je(t.rawTransaction,s).bcsToBytes()}function Yt(r){if(!r)return new Lt;let t=O.isInstance(r)||re.isInstance(r)||Fe.isInstance(r)?new N(r):r,n=new I(new Uint8Array(64));if(P.isInstance(t))return new Ie(t,n);if(N.isInstance(t))return O.isInstance(t.publicKey)?new ae(t,new $(Le.getSimulationSignature())):new ae(t,new $(n));if(ke.isInstance(t))return new ze(t,new He({signatures:t.publicKeys.map(()=>new $(n)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Pi(r){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:n}=r,i=mo(Z,r.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Ct(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(n, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!n)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new It(i,e.secondarySignerAddresses,n)}else i instanceof Ie?o=new vt(i.public_key,i.signature):o=new st(i);return new Je(e.rawTransaction,o).bcsToBytes()}function vs(r){let e=_sha3.sha3_256.create();for(let t of r)e.update(t);return e.digest()}var ou=vs(["APTOS::Transaction"]);function pb(r){let e=Pi(r);return new m(vs([ou,new Uint8Array([0]),e])).toString()}async function Is({key:r,moduleAddress:e,moduleName:t,functionName:n,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ke(async()=>s(e,t,n,i),`${r}-${i.network}-${e}-${t}-${n}`,1e3*60*5)()}async function we(r){let{aptosConfig:e,payload:t,options:n}=r,i=await Es({...t,aptosConfig:e}),o=new B;i.serialize(o);let s=o.toUint8Array(),{data:a}=await ot({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([n, 'optionalAccess', _122 => _122.ledgerVersion])},body:s});return a}async function Cs(r){let{aptosConfig:e,payload:t,options:n}=r,{data:i}=await ot({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([n, 'optionalAccess', _123 => _123.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}var Er=class{constructor(e){this.config=e}async getAccountInfo(e){return Oe({aptosConfig:this.config,...e})}async getAccountModules(e){return Yo({aptosConfig:this.config,...e})}async getAccountModule(e){return bn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Zo({aptosConfig:this.config,...e})}async getAccountResources(e){return es({aptosConfig:this.config,...e})}async getAccountResource(e){return li({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return jt({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),ts({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),rs({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ns({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),is({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),os({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ss({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),as({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:bt,faMetadataAddress:lo,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:n,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
|
|
477
|
+
`;async function lr(n){let{aptosConfig:e}=n,{data:t}=await L({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function $o(n){let{aptosConfig:e,limit:t}=n;return(await T({aptosConfig:e,query:{query:ko,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function T(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await mo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Wc(n){let{aptosConfig:e}=n;return(await T({aptosConfig:e,query:{query:oi},originMethod:"getProcessorStatuses"})).processor_status}async function gr(n){let e=await Wc({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function mr(n){let{aptosConfig:e,processorType:t}=n;return(await T({aptosConfig:e,query:{query:oi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function yr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await it({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _50 => _50.ledgerVersion])},body:r})).data}async function Wo(n){let{aptosConfig:e,options:t}=n,r={query:Vo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _51 => _51.where]),offset:_optionalChain([t, 'optionalAccess', _52 => _52.offset]),limit:_optionalChain([t, 'optionalAccess', _53 => _53.limit]),order_by:_optionalChain([t, 'optionalAccess', _54 => _54.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function Qo(n){let{aptosConfig:e,options:t}=n,r={query:qo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _55 => _55.where]),offset:_optionalChain([t, 'optionalAccess', _56 => _56.offset]),limit:_optionalChain([t, 'optionalAccess', _57 => _57.limit]),order_by:_optionalChain([t, 'optionalAccess', _58 => _58.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function ke(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await L({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}`});return r}async function Xo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Jr({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _59 => _59.ledgerVersion]),offset:_optionalChain([r, 'optionalAccess', _60 => _60.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _61 => _61.limit]), () => (1e3))}})}async function fr(n){return _optionalChain([n, 'access', _62 => _62.options, 'optionalAccess', _63 => _63.ledgerVersion])!==void 0?jo(n):Ce(async()=>jo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function jo(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await L({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _64 => _64.ledgerVersion])}});return o}async function Yo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return er({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([r, 'optionalAccess', _66 => _66.limit])}})}async function Zo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Jr({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _67 => _67.ledgerVersion]),offset:_optionalChain([r, 'optionalAccess', _68 => _68.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _69 => _69.limit]), () => (999))}})}async function ai(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await L({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunkZYPBABLQjs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _70 => _70.ledgerVersion])}});return o.data}async function jt(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await ai({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunkZYPBABLQjs.Z.from(t);try{let a=await yr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunkZYPBABLQjs.Z.from(a)}catch(a){if(a instanceof ye&&a.data.error_code==="table_item_not_found")return s;throw a}}async function es(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await T({aptosConfig:e,query:{query:zo,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function ts(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _71 => _71.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _72 => _72.tokenStandard])});let s={query:Ro,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _73 => _73.offset]),limit:_optionalChain([r, 'optionalAccess', _74 => _74.limit]),order_by:_optionalChain([r, 'optionalAccess', _75 => _75.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ns(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunkZYPBABLQjs.Z.from(t).toStringLong(),s=_chunkZYPBABLQjs.Z.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _76 => _76.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _77 => _77.tokenStandard])});let c={query:Uo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _78 => _78.offset]),limit:_optionalChain([i, 'optionalAccess', _79 => _79.limit]),order_by:_optionalChain([i, 'optionalAccess', _80 => _80.orderBy])}};return(await T({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function rs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _81 => _81.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _82 => _82.tokenStandard])}});let s={query:Ko,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _83 => _83.offset]),limit:_optionalChain([r, 'optionalAccess', _84 => _84.limit]),order_by:_optionalChain([r, 'optionalAccess', _85 => _85.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function is(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:Do,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function os(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _86 => _86.where]),owner_address:{_eq:i}},s={query:Co,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _87 => _87.offset]),limit:_optionalChain([r, 'optionalAccess', _88 => _88.limit]),order_by:_optionalChain([r, 'optionalAccess', _89 => _89.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function ss(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:vo,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function as(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}},s={query:pr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _90 => _90.offset]),limit:_optionalChain([r, 'optionalAccess', _91 => _91.limit]),order_by:_optionalChain([r, 'optionalAccess', _92 => _92.orderBy])}};return(await T({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function cs(n){let{aptosConfig:e,privateKey:t}=n,r=new O(t.publicKey());if(t instanceof Ne){let o=B.fromPublicKey({publicKey:r}).derivedAddress();return De.fromPrivateKey({privateKey:t,address:o})}if(t instanceof q){let i=B.fromPublicKey({publicKey:r});if(await Jo({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return De.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=B.fromPublicKey({publicKey:r.publicKey});if(await Jo({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return De.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function Jo(n){let{aptosConfig:e,authKey:t}=n,r=await jt({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await ke({aptosConfig:e,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function ui(n){let{aptosConfig:e,options:t}=n;return er({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _93 => _93.offset]),limit:_optionalChain([t, 'optionalAccess', _94 => _94.limit])}})}async function hr(n){let{aptosConfig:e}=n;return Ce(async()=>{let{data:t}=await L({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function us(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await L({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function Sn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await L({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function ds(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await Sn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _95 => _95.status])===404)return!0;throw r}}async function Qc(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await L({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function Jt(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _96 => _96.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _97 => _97.checkSuccess]), () => (!0)),s=!0,a=0,c,d,y=200,h=1.5;function p(l){if(!(l instanceof ye)||(d=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await Sn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(l){p(l)}if(s){let l=Date.now();try{c=await Qc({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-l)/1e3}for(;s&&!(a>=i);){try{if(c=await Sn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(l){p(l)}await _chunkZYPBABLQjs._.call(void 0, y),a+=y/1e3,y*=h}if(c===void 0)throw d||new Ar(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Ar(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new ci(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Tr(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await gr({aptosConfig:e}):s=(await mr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkZYPBABLQjs._.call(void 0, 200)}}var Ar=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},ci=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function ps(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await L({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _98 => _98.withTransactions])}});return gs({block:i,...n})}async function ls(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await L({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _99 => _99.withTransactions])}});return gs({block:i,...n})}async function gs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _100 => _100.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _101 => _101.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let d=[],y=100n;for(let p=c+1n;p<s;p+=BigInt(100))d.push(ui({aptosConfig:e,options:{offset:p,limit:Math.min(Number(y),Number(s-p+1n))}}));let h=await Promise.all(d);for(let p of h)t.transactions.push(...p)}return t}async function S(n){n.minimumLedgerVersion!==void 0&&await Tr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}function ms(n){return typeof n=="boolean"}function Ye(n){return typeof n=="string"}function jc(n){return typeof n=="number"}function br(n){if(jc(n))return n;if(Ye(n)&&n!=="")return Number.parseInt(n,10)}function wr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function ys(n){return n==null}function fs(n){return di(n)||li(n)||gi(n)||mi(n)||yi(n)||fi(n)||Ai(n)||Sr(n)||pi(n)||Jc(n)||n instanceof _||n instanceof X}function di(n){return n instanceof U}function Sr(n){return n instanceof _chunkZYPBABLQjs.Z}function pi(n){return n instanceof E}function Jc(n){return n instanceof pt}function li(n){return n instanceof J}function gi(n){return n instanceof we}function mi(n){return n instanceof Se}function yi(n){return n instanceof W}function fi(n){return n instanceof _e}function Ai(n){return n instanceof le}function As(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function hs(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}function Ts(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function bs(n){return!!n.match(/\s/)}function Xc(n){return!!n.match(/^T[0-9]+$/)}function Yc(n){return!!n.match(/^&.+$/)}function Zc(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function eu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!bs(r))break}return t}var tu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(tu||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Oe(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _102 => _102.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let b=_n(a,i,t);o.push(b)}let y=r.pop();if(y===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:p,savedExpectedTypes:l}=y;i=o,o=p,a=h,c=l}else if(d===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let y=_n(a,i,t);i=[],o.push(y),a="",c+=1}else if(bs(d)){let y=!1;if(a.length!==0){let p=_n(a,i,t);i=[],o.push(p),a="",y=!0}s=eu(n,s);let h=n[s];if(s<n.length&&y&&h!==","&&h!==">")throw new $(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return _n(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function _n(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Zc(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Tt;case"bool":return new V;case"address":return new F;case"u8":return new ue;case"u16":return new Le;case"u32":return new He;case"u64":return new j;case"u128":return new $e;case"u256":return new We;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new v(e[0]);default:if(Yc(r)){let a=r.substring(1);return new rr(_n(a,e,t))}if(Xc(r)){if(t)return new G(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunkZYPBABLQjs.Z.fromString(o[0])}catch (e3){throw new $(n,"struct address must be valid")}if(!Ts(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!Ts(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new A(new ze(s,new K(o[1]),new K(o[2]),e))}}var nu=new TextEncoder;function Xt(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _103 => _103.map, 'call', _104 => _104(e=>Ye(e)?Oe(e):e)]), () => ([]))}async function Ti(n,e,t,r){let i=await fr({aptosConfig:r,accountAddress:n,moduleName:e});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===t)}async function ws(n,e,t,r){let i=await Ti(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(Oe(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Ss(n,e,t,r){let i=await Ti(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=hs(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Oe(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function _s(n,e,t,r){let i=await Ti(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Oe(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Oe(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Ps(n,e,t,r,i){return n instanceof _chunkZYPBABLQjs.X?n:_chunkZYPBABLQjs.X.newBytes(_r(e,t,n,r,i).bcsToBytes())}function _r(n,e,t,r,i){if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);let o=e.parameters[r];return Kt(t,o,r,i)}function Kt(n,e,t,r){return fs(n)?(hi(e,n,t),n):ru(n,e,t,r)}function ru(n,e,t,r){if(e.isBool()){if(ms(n))return new U(n);if(Ye(n)){if(n==="true")return new U(!0);if(n==="false")return new U(!1)}D("boolean",t)}if(e.isAddress()){if(Ye(n))return _chunkZYPBABLQjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let i=br(n);if(i!==void 0)return new J(i);D("number | string",t)}if(e.isU16()){let i=br(n);if(i!==void 0)return new we(i);D("number | string",t)}if(e.isU32()){let i=br(n);if(i!==void 0)return new Se(i);D("number | string",t)}if(e.isU64()){if(wr(n))return new W(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(wr(n))return new _e(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(wr(n))return new le(BigInt(n));D("bigint | number | string",t)}if(e.isGeneric()){let i=e.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Kt(n,r[i],t,r)}if(e.isVector()){if(e.value.isU8()){if(Ye(n))return _.U8(nu.encode(n));if(n instanceof Uint8Array)return _.U8(n);if(n instanceof ArrayBuffer)return _.U8(new Uint8Array(n))}if(Ye(n)&&n.startsWith("["))return Kt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new _(n.map(i=>Kt(i,e.value,t,r)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(Ye(n))return new E(n);D("string",t)}if(e.isObject()){if(Ye(n))return _chunkZYPBABLQjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isOption()){if(ys(n)){let i=e.value.typeArgs[0];return i instanceof V?new X(null):i instanceof F?new X(null):i instanceof ue?new X(null):i instanceof Le?new X(null):i instanceof He?new X(null):i instanceof j?new X(null):i instanceof $e?new X(null):i instanceof We?new X(null):new X(null)}return new X(Kt(n,e.value.typeArgs[0],t,r))}throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function hi(n,e,t){if(n.isBool()){if(di(e))return;D("Bool",t)}if(n.isAddress()){if(Sr(e))return;D("AccountAddress",t)}if(n.isU8()){if(li(e))return;D("U8",t)}if(n.isU16()){if(gi(e))return;D("U16",t)}if(n.isU32()){if(mi(e))return;D("U32",t)}if(n.isU64()){if(yi(e))return;D("U64",t)}if(n.isU128()){if(fi(e))return;D("U128",t)}if(n.isU256()){if(Ai(e))return;D("U256",t)}if(n.isVector()){if(e instanceof _){e.values.length>0&&hi(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof A){if(n.isString()){if(pi(e))return;D("MoveString",t)}if(n.isObject()){if(Sr(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof X){e.value!==void 0&&hi(n.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Pr(n){if(As(n))return au(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunkZYPBABLQjs.ha.call(void 0, n.function),i=await vs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ss});return ou({...n,abi:i})}function ou(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, n.function),o=Xt(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>_r(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=St.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunkZYPBABLQjs.Z.from(n.multisigAddress);return new fn(new hn(c,new Tn(a)))}return new yn(a)}async function Es(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunkZYPBABLQjs.ha.call(void 0, n.function),i=await vs({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:_s});return su({abi:i,...n})}function su(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, n.function),o=Xt(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _105 => _105.functionArguments, 'optionalAccess', _106 => _106.map, 'call', _107 => _107((a,c)=>_r(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return St.build(`${t}::${r}`,i,o,s)}function au(n){return new wt(new An(_chunkZYPBABLQjs.j.fromHexInput(n.bytecode).toUint8Array(),Xt(n.typeArguments),n.functionArguments))}async function bi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>Wr[e.network]?{chainId:Wr[e.network]}:{chainId:(await lr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _108 => _108.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await hr({aptosConfig:e})).gas_estimate},c=async()=>{let R=async()=>_optionalChain([i, 'optionalAccess', _109 => _109.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await ke({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunkZYPBABLQjs.Z.from(o).equals(_chunkZYPBABLQjs.Z.ZERO))try{return await R()}catch (e4){return 0}else return R()},[{chainId:d},{gasEstimate:y},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:l,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _110 => _110.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _111 => _111.gasUnitPrice]), () => (BigInt(y))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _112 => _112.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new fe(_chunkZYPBABLQjs.Z.from(t),BigInt(h),r,BigInt(p),BigInt(l),BigInt(b),new qt(d))}async function wi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await bi({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _113 => _113.secondarySignerAddresses, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(c=>_chunkZYPBABLQjs.Z.from(c))]), () => ([]));return new ar(s,a,n.feePayerAddress?_chunkZYPBABLQjs.Z.from(n.feePayerAddress):void 0)}return new Lt(s,n.feePayerAddress?_chunkZYPBABLQjs.Z.from(n.feePayerAddress):void 0)}function xs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Yt(e);if(t.feePayerAddress){let a=new Pt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>Yt(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Yt(void 0)));let d=Yt(i),y=new It(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new je(a.raw_txn,y).bcsToBytes()}if(t.secondarySignerAddresses){let a=new _t(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(y=>Yt(y)):c=Array.from({length:t.secondarySignerAddresses.length},()=>Yt(void 0));let d=new xt(o,t.secondarySignerAddresses,c);return new je(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof xe)s=new Et(o.public_key,o.signature);else if(o instanceof ie||o instanceof Ue)s=new ot(o);else if(o instanceof Vt)s=new ot(o);else throw new Error("Invalid public key");return new je(t.rawTransaction,s).bcsToBytes()}function Yt(n){if(!n)return new Vt;let t=k.isInstance(n)||te.isInstance(n)||Fe.isInstance(n)?new O(n):n,r=new I(new Uint8Array(64));if(x.isInstance(t))return new xe(t,r);if(O.isInstance(t))return k.isInstance(t.publicKey)?new ie(t,new H(Me.getSimulationSignature())):new ie(t,new H(r));if(Re.isInstance(t))return new Ue(t,new qe({signatures:t.publicKeys.map(()=>new H(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Si(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=lo(Q,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new It(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new xt(i,e.secondarySignerAddresses,r)}else i instanceof xe?o=new Et(i.public_key,i.signature):o=new ot(i);return new je(e.rawTransaction,o).bcsToBytes()}function Is(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var cu=Is(["APTOS::Transaction"]);function Pb(n){let e=Si(n);return new (0, _chunkZYPBABLQjs.j)(Is([cu,new Uint8Array([0]),e])).toString()}async function vs({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ce(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var Er=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await Promise.resolve().then(() => _interopRequireWildcard(require("@aptos-labs/script-composer-pack"))),{TransactionComposer:t,initSync:r}=e;_scriptcomposerpack.ScriptComposerWasm.isInitialized||_scriptcomposerpack.ScriptComposerWasm.init(),r({module:_scriptcomposerpack.ScriptComposerWasm.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=_chunkZYPBABLQjs.ha.call(void 0, e.function),o=this.config.getRequestUrl("Fullnode");await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0&&await Promise.all(e.typeArguments.map(d=>this.builder.load_type_tag(o,d.toString())));let s=Xt(e.typeArguments),a=await ws(t,r,i,this.config);if(s.length!==a.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${a.typeParameters.length}, received ${s.length}`);let c=e.functionArguments.map((d,y)=>Ps(d,i,a,y,s));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(d=>d.toString()),c)}build(){return this.builder.generate_batched_calls(!0)}};async function oe(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Es({...t,aptosConfig:e}),o=new _chunkZYPBABLQjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await it({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _116 => _116.ledgerVersion])},body:s});return a}async function Cs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await it({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _117 => _117.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function w(n){let e=await uu(n);return du(n,e)}async function uu(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Pr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Pr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Pr(r)),i}async function du(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(pu(n)&&(o=_chunkZYPBABLQjs.Z.ZERO.toString()),lu(n)){let{secondarySignerAddresses:s}=n;return wi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return wi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function pu(n){return n.withFeePayer===!0}function lu(n){return"secondarySignerAddresses"in n}function Ks(n){let{transaction:e}=n;return Je(e)}function xr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Ir(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,xr({signer:e,transaction:t})}async function Pi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=xs({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await it({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _118 => _118.options, 'optionalAccess', _119 => _119.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _120 => _120.options, 'optionalAccess', _121 => _121.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _122 => _122.options, 'optionalAccess', _123 => _123.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Pn(n){let{aptosConfig:e}=n,t=Si({...n});try{let{data:r}=await it({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=je.deserialize(new C(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof k||i.authenticator.sender.public_key.publicKey instanceof te)&&await pe.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function En(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;cr(t)&&await t.checkKeylessAccountValidity(e),cr(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Ir({signer:r,transaction:i}),s=xr({signer:t,transaction:i});return Pn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function Rs(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;cr(r)&&await r.checkKeylessAccountValidity(e);let o=Ir({signer:r,transaction:i});return Pn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var gu={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Us(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>_.U8(a));return w({aptosConfig:e,sender:_chunkZYPBABLQjs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[_.U8(r),new _(s)],abi:gu},options:o})}var mu={typeParameters:[],parameters:[new ue,v.u8(),new ue,v.u8(),v.u8(),v.u8()]};async function zs(n){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:r}=n,i=await ke({aptosConfig:e,accountAddress:t.accountAddress}),o=De.fromPrivateKey({privateKey:r,legacy:!0}),a=new or({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunkZYPBABLQjs.Z.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a),y=await w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new J(t.signingScheme),_.U8(t.publicKey.toUint8Array()),new J(o.signingScheme),_.U8(o.publicKey.toUint8Array()),_.U8(c.toUint8Array()),_.U8(d.toUint8Array())],abi:mu}});return En({aptosConfig:e,signer:t,transaction:y})}async function Ds(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkZYPBABLQjs.ha.call(void 0, r);return w({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(P()),new A(P())]}},options:i})}async function ks(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkZYPBABLQjs.ha.call(void 0, r);return w({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(P()),new A(P())]}},options:i})}async function Os(n){let{aptosConfig:e,sender:t,options:r}=n;return w({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Rt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunkZYPBABLQjs.ha.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _124 => _124.some, 'call', _125 => _125(s=>_chunkZYPBABLQjs.Z.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)]), () => (!1))};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ds({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return ks({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Os({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await oe({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunkZYPBABLQjs.Z.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunkZYPBABLQjs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var xn=class{constructor(e){this.config=e;this.abstraction=new Rt(e)}async getAccountInfo(e){return ke({aptosConfig:this.config,...e})}async getAccountModules(e){return Xo({aptosConfig:this.config,...e})}async getAccountModule(e){return fr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Yo({aptosConfig:this.config,...e})}async getAccountResources(e){return Zo({aptosConfig:this.config,...e})}async getAccountResource(e){return ai({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return jt({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),es({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ts({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ns({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),rs({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),is({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),os({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ss({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:At,faMetadataAddress:co,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
|
|
480
478
|
compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
|
|
481
|
-
will be removed in the near future`);let s=n;n===void 0&&i!==void 0&&(s=await Ke(async()=>{try{let p=(await we({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunkIHUCZKG2js.j.call(void 0, p.vec[0]))return _chunkIHUCZKG2js.i.call(void 0, p.vec[0])}catch (e5){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(n!==void 0&&i!==void 0)a=u.from(i).toStringLong();else if(n!==void 0&&i===void 0)n===bt?a=u.A.toStringLong():a=sn(u.A,n).toStringLong();else if(n===void 0&&i!==void 0){let p=u.from(i);a=p.toStringLong(),p===u.A&&(s=bt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await we({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await we({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),cs({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return us({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Cn=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _124 => _124.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _125 => _125.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _126 => _126.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _127 => _127.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _128 => _128.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _129 => _129.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _130 => _130.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _131 => _131.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _132 => _132.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _133 => _133.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _134 => _134.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return ao[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return co[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return so[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return jn[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return Jn[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return jn[this.network]===e}isProverServiceRequest(e){return Jn[this.network]===e}};async function _(r){let e=await au(r);return cu(r,e)}async function au(r){let{aptosConfig:e,data:t}=r,n,i;return"bytecode"in t?i=await In(t):"multisigAddress"in t?(n={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await In(n)):(n={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await In(n)),i}async function cu(r,e){let{aptosConfig:t,sender:n,options:i}=r,o;if(uu(r)&&(o=u.ZERO.toString()),pu(r)){let{secondarySignerAddresses:s}=r;return Ei({aptosConfig:t,sender:n,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Ei({aptosConfig:t,sender:n,payload:e,options:i,feePayerAddress:o})}function uu(r){return r.withFeePayer===!0}function pu(r){return"secondarySignerAddresses"in r}function Rs(r){let{transaction:e}=r;return qt(e)}function Rn(r){let{signer:e,transaction:t}=r;return e.signTransactionWithAuthenticator(t)}function Kn(r){let{signer:e,transaction:t}=r;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Rn({signer:e,transaction:t})}async function vi(r){let{aptosConfig:e,transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=r,a=Ps({transaction:t,signerPublicKey:n,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await ot({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([r, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([r, 'access', _137 => _137.options, 'optionalAccess', _138 => _138.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([r, 'access', _139 => _139.options, 'optionalAccess', _140 => _140.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Pr(r){let{aptosConfig:e}=r,t=Pi({...r});try{let{data:n}=await ot({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return n}catch(n){let i=Je.deserialize(new D(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof O||i.authenticator.sender.public_key.publicKey instanceof re)&&await le.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),n}}async function vr(r){let{aptosConfig:e,signer:t,feePayer:n,transaction:i}=r;gn(t)&&await t.checkKeylessAccountValidity(e),gn(n)&&await n.checkKeylessAccountValidity(e);let o=r.feePayerAuthenticator||n&&Kn({signer:n,transaction:i}),s=Rn({signer:t,transaction:i});return Pr({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function Ks(r){let{aptosConfig:e,senderAuthenticator:t,feePayer:n,transaction:i}=r;gn(n)&&await n.checkKeylessAccountValidity(e);let o=Kn({signer:n,transaction:i});return Pr({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var du={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Us(r){let{aptosConfig:e,account:t,metadataBytes:n,moduleBytecode:i,options:o}=r,s=i.map(a=>S.U8(a));return _({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(n),new S(s)],abi:du},options:o})}var lu={typeParameters:[],parameters:[new pe,C.u8(),new pe,C.u8(),C.u8(),C.u8()]};async function ks(r){let{aptosConfig:e,fromAccount:t,toNewPrivateKey:n}=r,i=await Oe({aptosConfig:e,accountAddress:t.accountAddress}),o=at.fromPrivateKey({privateKey:n,legacy:!0}),a=new un({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),p=o.sign(a),l=await _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new X(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new X(o.signingScheme),S.U8(o.publicKey.toUint8Array()),S.U8(c.toUint8Array()),S.U8(p.toUint8Array())],abi:lu}});return vr({aptosConfig:e,signer:t,transaction:l})}var gu={typeParameters:[{constraints:[]}],parameters:[new ee,new j]};async function zs(r){let{aptosConfig:e,sender:t,recipient:n,amount:i,coinType:o,options:s}=r;return _({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (bt))],functionArguments:[n,i],abi:gu},options:s})}var Ir=class{constructor(e){this.config=e}async transferCoinTransaction(e){return zs({aptosConfig:this.config,...e})}};var ut={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Se="0x4::token::Token";async function Ds(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()}};return(await T({aptosConfig:e,query:{query:$o,variables:{where_condition:n}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Os(r){let{aptosConfig:e,digitalAssetAddress:t}=r,n={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await T({aptosConfig:e,query:{query:di,variables:{where_condition:n}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Ns(r){let{aptosConfig:e,ownerAddress:t,options:n}=r,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:di,variables:{where_condition:i,offset:_optionalChain([n, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([n, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([n, 'optionalAccess', _143 => _143.orderBy])}};return(await T({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Fs(r){let{aptosConfig:e,digitalAssetAddress:t,options:n}=r,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:qo,variables:{where_condition:i,offset:_optionalChain([n, 'optionalAccess', _144 => _144.offset]),limit:_optionalChain([n, 'optionalAccess', _145 => _145.limit]),order_by:_optionalChain([n, 'optionalAccess', _146 => _146.orderBy])}};return(await T({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var yu={typeParameters:[],parameters:[new A(v()),new j,new A(v()),new A(v()),new M,new M,new M,new M,new M,new M,new M,new M,new M,new j,new j]};async function Gs(r){let{aptosConfig:e,options:t,creator:n}=r;return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new x(r.description),new Q(_nullishCoalesce(r.maxSupply, () => (gt))),new x(r.name),new x(r.uri),new U(_nullishCoalesce(r.mutableDescription, () => (!0))),new U(_nullishCoalesce(r.mutableRoyalty, () => (!0))),new U(_nullishCoalesce(r.mutableURI, () => (!0))),new U(_nullishCoalesce(r.mutableTokenDescription, () => (!0))),new U(_nullishCoalesce(r.mutableTokenName, () => (!0))),new U(_nullishCoalesce(r.mutableTokenProperties, () => (!0))),new U(_nullishCoalesce(r.mutableTokenURI, () => (!0))),new U(_nullishCoalesce(r.tokensBurnableByCreator, () => (!0))),new U(_nullishCoalesce(r.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(r.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(r.royaltyDenominator, () => (1)))],abi:yu},options:t})}async function Zt(r){let{aptosConfig:e,options:t}=r,n=_optionalChain([t, 'optionalAccess', _147 => _147.where]);_optionalChain([t, 'optionalAccess', _148 => _148.tokenStandard])&&(n.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.tokenStandard]), () => ("v2"))});let i={query:No,variables:{where_condition:n,offset:_optionalChain([t, 'optionalAccess', _150 => _150.offset]),limit:_optionalChain([t, 'optionalAccess', _151 => _151.limit])}};return(await T({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function Bs(r){let{aptosConfig:e,creatorAddress:t,collectionName:n,options:i}=r,o=u.from(t),s={collection_name:{_eq:n},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _152 => _152.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...i,where:s}})}async function Ms(r){let{aptosConfig:e,creatorAddress:t,options:n}=r,o={creator_address:{_eq:u.from(t).toStringLong()}};return _optionalChain([n, 'optionalAccess', _154 => _154.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...n,where:o}})}async function Ls(r){let{aptosConfig:e,collectionId:t,options:n}=r,o={collection_id:{_eq:u.from(t).toStringLong()}};return _optionalChain([n, 'optionalAccess', _156 => _156.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _157 => _157.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...n,where:o}})}async function Vs(r){let{creatorAddress:e,collectionName:t,options:n,aptosConfig:i}=r,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([n, 'optionalAccess', _158 => _158.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([n, 'optionalAccess', _159 => _159.tokenStandard]), () => ("v2"))}),(await Zt({aptosConfig:i,options:{where:s}})).collection_id}var mu={typeParameters:[],parameters:[new A(v()),new A(v()),new A(v()),new A(v()),new C(new A(v())),new C(new A(v())),new C(C.u8())]};async function Hs(r){let{aptosConfig:e,options:t,creator:n,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:l}=r,h=_optionalChain([p, 'optionalAccess', _160 => _160.map, 'call', _161 => _161(g=>ut[g])]);return _({aptosConfig:e,sender:n.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new x(i),new x(o),new x(s),new x(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(h, () => ([]))),ia(_nullishCoalesce(l, () => ([])),_nullishCoalesce(h, () => ([])))],abi:mu},options:t})}var fu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new ee]};async function qs(r){let{aptosConfig:e,sender:t,digitalAssetAddress:n,recipient:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[u.from(n),u.from(i)],abi:fu},options:s})}var Au={typeParameters:[],parameters:[new A(v()),new A(v()),new A(v()),new A(v()),new C(new A(v())),new C(new A(v())),new C(C.u8()),new ee]};async function $s(r){let{aptosConfig:e,account:t,collection:n,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:l,options:h}=r;if(_optionalChain([c, 'optionalAccess', _162 => _162.length])!==_optionalChain([l, 'optionalAccess', _163 => _163.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _164 => _164.length])!==_optionalChain([l, 'optionalAccess', _165 => _165.length]))throw new Error("Property types and property values counts do not match");let g=_optionalChain([p, 'optionalAccess', _166 => _166.map, 'call', _167 => _167(d=>ut[d])]);return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[n,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(g, () => ([]))),ia(_nullishCoalesce(l, () => ([])),_nullishCoalesce(g, () => ([]))),a],abi:Au},options:h})}var hu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Ws(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[u.from(n)],abi:hu},options:o})}var Tu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Qs(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[n],abi:Tu},options:o})}var bu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function js(r){let{aptosConfig:e,creator:t,digitalAssetAddress:n,digitalAssetType:i,options:o}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[n],abi:bu},options:o})}var wu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function Js(r){let{aptosConfig:e,creator:t,description:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:wu},options:s})}var Su={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function Xs(r){let{aptosConfig:e,creator:t,name:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:Su},options:s})}var _u={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function Ys(r){let{aptosConfig:e,creator:t,uri:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:_u},options:s})}var xu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v()),new A(v()),C.u8()]};async function Zs(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[u.from(s),new x(n),new x(ut[i]),S.U8(Ii(o,ut[i]))],abi:xu},options:c})}var Eu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v())]};async function ea(r){let{aptosConfig:e,creator:t,propertyKey:n,digitalAssetAddress:i,digitalAssetType:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[u.from(i),new x(n)],abi:Eu},options:s})}var Pu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(v()),new A(v()),C.u8()]};async function ta(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[u.from(s),new x(n),new x(ut[i]),Ii(o,ut[i])],abi:Pu},options:c})}var vu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(v()),new G(1)]};async function ra(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),ut[i]],functionArguments:[u.from(s),new x(n),o],abi:vu},options:c})}var Iu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(v()),new G(1)]};async function na(r){let{aptosConfig:e,creator:t,propertyKey:n,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),ut[i]],functionArguments:[u.from(s),new x(n),o],abi:Iu},options:c})}function ia(r,e){let t=new Array;return e.forEach((n,i)=>{t.push(Ii(r[i],n))}),t}function Ii(r,e){let t=Ye(e);return Xt(r,t,0,[]).bcsToBytes()}var Cr=class{constructor(e){this.config=e}async getCollectionData(e){await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:n,options:i}=e,o=u.from(t),s={collection_name:{_eq:n},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _168 => _168.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _169 => _169.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Bs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ms({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getCollectionId(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ds({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Os({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ns({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Fs({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Gs({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Hs({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return qs({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return $s({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Ws({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Qs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return js({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Js({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Xs({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Ys({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Zs({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return ea({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return ta({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return ra({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return na({aptosConfig:this.config,...e})}};var oa=300,Cu=r=>{if(r&&r.length>oa)throw new Error(`Event type length exceeds the maximum length of ${oa}`)};async function sa(r){let{aptosConfig:e,eventType:t,options:n}=r,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return Rr({aptosConfig:e,options:{...n,where:i}})}async function aa(r){let{accountAddress:e,aptosConfig:t,creationNumber:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},creation_number:{_eq:n}};return Rr({aptosConfig:t,options:{...i,where:s}})}async function ca(r){let{accountAddress:e,aptosConfig:t,eventType:n,options:i}=r,s={account_address:{_eq:u.from(e).toStringLong()},indexed_type:{_eq:n}};return Rr({aptosConfig:t,options:{...i,where:s}})}async function Rr(r){let{aptosConfig:e,options:t}=r;Cu(_optionalChain([t, 'optionalAccess', _170 => _170.where, 'optionalAccess', _171 => _171.indexed_type, 'optionalAccess', _172 => _172._eq]));let n={query:Bo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _173 => _173.where]),offset:_optionalChain([t, 'optionalAccess', _174 => _174.offset]),limit:_optionalChain([t, 'optionalAccess', _175 => _175.limit]),order_by:_optionalChain([t, 'optionalAccess', _176 => _176.orderBy])}};return(await T({aptosConfig:e,query:n,originMethod:"getEvents"})).events}var Kr=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),sa({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),aa({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ca({aptosConfig:this.config,...e})}async getEvents(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _177 => _177.minimumLedgerVersion]),processorType:"events_processor"}),Rr({aptosConfig:this.config,...e})}};async function ua(r){let{aptosConfig:e,accountAddress:t,amount:n,options:i}=r,o=_optionalChain([i, 'optionalAccess', _178 => _178.timeoutSecs])||20,{data:s}=await ho({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:n},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Jt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _179 => _179.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Ur=class{constructor(e){this.config=e}async fundAccount(e){let t=await ua({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _180 => _180.options, 'optionalAccess', _181 => _181.waitForIndexer])===void 0||_optionalChain([e, 'access', _182 => _182.options, 'optionalAccess', _183 => _183.waitForIndexer]))&&await _n({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Un(r){let{aptosConfig:e,options:t}=r,n={query:Lo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _184 => _184.where]),limit:_optionalChain([t, 'optionalAccess', _185 => _185.limit]),offset:_optionalChain([t, 'optionalAccess', _186 => _186.offset])}};return(await T({aptosConfig:e,query:n,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function pa(r){let{aptosConfig:e,options:t}=r,n={query:Mo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _187 => _187.where]),limit:_optionalChain([t, 'optionalAccess', _188 => _188.limit]),offset:_optionalChain([t, 'optionalAccess', _189 => _189.offset])}};return(await T({aptosConfig:e,query:n,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function da(r){let{aptosConfig:e,options:t}=r,n={query:Fo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _190 => _190.where]),limit:_optionalChain([t, 'optionalAccess', _191 => _191.limit]),offset:_optionalChain([t, 'optionalAccess', _192 => _192.offset])}};return(await T({aptosConfig:e,query:n,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Ru={typeParameters:[{constraints:[]}],parameters:[Ye("0x1::object::Object"),new ee,new j]};async function la(r){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:n,recipient:i,amount:o,options:s}=r;return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[n,i,o],abi:Ru},options:s})}var kr=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Un({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _194 => _194.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Un({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _195 => _195.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Un({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _196 => _196.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),pa({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _197 => _197.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),da({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return la({aptosConfig:this.config,...e})}};var zr=class{constructor(e){this.config=e}async getLedgerInfo(){return fn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return ls({aptosConfig:this.config,...e})}async getBlockByHeight(e){return gs({aptosConfig:this.config,...e})}async view(e){return we({aptosConfig:this.config,...e})}async viewJson(e){return Cs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Wo({aptosConfig:this.config,...e})}async queryIndexer(e){return T({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return An({aptosConfig:this.config})}async getProcessorStatus(e){return hn({aptosConfig:this.config,processorType:e})}};var ga=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function ya(r){return!(!r||r.length<3||r.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(r))}function pt(r){let[e,t,...n]=r.replace(/\.apt$/,"").split(".");if(n.length>0)throw new Error(`${r} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!ya(e))throw new Error(`${e} is not valid. ${ga}`);if(t&&!ya(t))throw new Error(`${t} is not valid. ${ga}`);return{domainName:t||e,subdomainName:t?e:void 0}}function ma(r){if(!r)return!1;let e=new Date(r.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(r.expiration_timestamp).getTime()<Date.now();return r.subdomain&&e?!1:r.subdomain&&r.subdomain_expiration_policy===1?!0:!t}var Ku="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Uu={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ku,custom:null,devnet:null};function Ze(r){let e=Uu[r.network];if(!e)throw new Error(`The ANS contract is not deployed to ${r.network}`);return e}var kn=r=>{if(r&&typeof r=="object"&&"vec"in r&&Array.isArray(r.vec))return r.vec[0]};async function fa(r){let{aptosConfig:e,name:t}=r,n=Ze(e),{domainName:i,subdomainName:o}=pt(t),s=await we({aptosConfig:e,payload:{function:`${n}::router::get_owner_addr`,functionArguments:[i,o]}}),a=kn(s[0]);return a?u.from(a):void 0}async function Aa(r){let{aptosConfig:e,expiration:t,name:n,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=r,p=Ze(e),{domainName:l,subdomainName:h}=pt(n),g=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!g)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(g&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let te=_nullishCoalesce(t.years, () => (1));if(te!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ut=te*31536e3;return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[l,Ut,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let d=await Ci({aptosConfig:e,name:l});if(!d)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:d;if(b>d)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await _({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[l,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function Ci(r){let{aptosConfig:e,name:t}=r,n=Ze(e),{domainName:i,subdomainName:o}=pt(t);try{let s=await we({aptosConfig:e,payload:{function:`${n}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function ha(r){let{aptosConfig:e,address:t}=r,n=Ze(e),i=await we({aptosConfig:e,payload:{function:`${n}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=kn(i[1]),s=kn(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Ta(r){let{aptosConfig:e,sender:t,name:n,options:i}=r,o=Ze(e);if(!n)return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=pt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function ba(r){let{aptosConfig:e,name:t}=r,n=Ze(e),{domainName:i,subdomainName:o}=pt(t),s=await we({aptosConfig:e,payload:{function:`${n}::router::get_target_addr`,functionArguments:[i,o]}}),a=kn(s[0]);return a?u.from(a):void 0}async function wa(r){let{aptosConfig:e,sender:t,name:n,address:i,options:o}=r,s=Ze(e),{domainName:a,subdomainName:c}=pt(n);return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Sa(r){let{aptosConfig:e,name:t}=r,{domainName:n,subdomainName:i=""}=pt(t),a=(await T({aptosConfig:e,query:{query:Qt,variables:{where_condition:{domain:{_eq:n},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Dr(a)),ma(a)?a:void 0}async function _a(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Ri({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountNames",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _198 => _198.limit]),offset:_optionalChain([t, 'optionalAccess', _199 => _199.offset]),order_by:_optionalChain([t, 'optionalAccess', _200 => _200.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Dr)}async function xa(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Ri({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _203 => _203.limit]),offset:_optionalChain([t, 'optionalAccess', _204 => _204.offset]),order_by:_optionalChain([t, 'optionalAccess', _205 => _205.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _206 => _206.options, 'optionalAccess', _207 => _207.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Dr)}async function Ea(r){let{aptosConfig:e,options:t,accountAddress:n}=r,i=await Ri({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _208 => _208.limit]),offset:_optionalChain([t, 'optionalAccess', _209 => _209.offset]),order_by:_optionalChain([t, 'optionalAccess', _210 => _210.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _211 => _211.options, 'optionalAccess', _212 => _212.where]), () => ({})),owner_address:{_eq:n.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Dr)}async function Pa(r){let{aptosConfig:e,options:t,domain:n}=r;return(await T({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _213 => _213.limit]),offset:_optionalChain([t, 'optionalAccess', _214 => _214.offset]),order_by:_optionalChain([t, 'optionalAccess', _215 => _215.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([r, 'access', _216 => _216.options, 'optionalAccess', _217 => _217.where]), () => ({})),domain:{_eq:n},subdomain:{_neq:""}}}}})).current_aptos_names.map(Dr).filter(ma)}async function Ri(r){let{aptosConfig:e}=r,t=Ze(e),[n]=await we({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=n/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function va(r){let{aptosConfig:e,sender:t,name:n,years:i=1,options:o}=r,s=Ze(e),a=i*31536e3,{domainName:c,subdomainName:p}=pt(n);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await _({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Dr(r){return{...r,expiration_timestamp:new Date(r.expiration_timestamp).getTime()}}var Or=class{constructor(e){this.config=e}async getOwnerAddress(e){return fa({aptosConfig:this.config,...e})}async getExpiration(e){return Ci({aptosConfig:this.config,...e})}async getTargetAddress(e){return ba({aptosConfig:this.config,...e})}async setTargetAddress(e){return wa({aptosConfig:this.config,...e})}async getPrimaryName(e){return ha({aptosConfig:this.config,...e})}async setPrimaryName(e){return Ta({aptosConfig:this.config,...e})}async registerName(e){return Aa({aptosConfig:this.config,...e})}async renewDomain(e){return va({aptosConfig:this.config,...e})}async getName(e){return Sa({aptosConfig:this.config,...e})}async getAccountNames(e){return _a({aptosConfig:this.config,...e})}async getAccountDomains(e){return xa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Ea({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Pa({aptosConfig:this.config,...e})}};async function Ia(r){let{aptosConfig:e,poolAddress:t}=r,n=u.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:ui,variables:{where_condition:{pool_address:{_eq:n}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ca(r){let{aptosConfig:e,options:t}=r,n={query:ui,variables:{order_by:_optionalChain([t, 'optionalAccess', _218 => _218.orderBy])}};return(await T({aptosConfig:e,query:n})).num_active_delegator_per_pool}async function Ra(r){let{aptosConfig:e,delegatorAddress:t,poolAddress:n}=r,i={query:Go,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(n).toStringLong()}};return(await T({aptosConfig:e,query:i})).delegated_staking_activities}var Nr=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _219 => _219.minimumLedgerVersion]),processorType:"stake_processor"}),Ia({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _220 => _220.minimumLedgerVersion]),processorType:"stake_processor"}),Ca({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await w({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _221 => _221.minimumLedgerVersion]),processorType:"stake_processor"}),Ra({aptosConfig:this.config,...e})}};var zn=class{constructor(e){this.config=e}async simple(e){return _({aptosConfig:this.config,...e})}async multiAgent(e){return _({aptosConfig:this.config,...e})}};function Ki(r,e,t){let n=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return n.apply(this,i)},t}function Ui(r,e,t){let n=t.value;return t.value=async function(...i){return n.apply(this,i)},t}var er=class{constructor(e){this.config=e}async simple(e){return vi({aptosConfig:this.config,...e})}async multiAgent(e){return vi({aptosConfig:this.config,...e})}};_chunkIHUCZKG2js.a.call(void 0, [Ui],er.prototype,"simple",1),_chunkIHUCZKG2js.a.call(void 0, [Ui],er.prototype,"multiAgent",1);var tr=class{constructor(e){this.config=e}async simple(e){return Pr({aptosConfig:this.config,...e})}async multiAgent(e){return Pr({aptosConfig:this.config,...e})}};_chunkIHUCZKG2js.a.call(void 0, [Ki],tr.prototype,"simple",1),_chunkIHUCZKG2js.a.call(void 0, [Ki],tr.prototype,"multiAgent",1);var Dn=class{constructor(e,t,n,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=n,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkIHUCZKG2js.b.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkIHUCZKG2js.d.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkIHUCZKG2js.b.call(void 0, this.sleepTime),_chunkIHUCZKG2js.d.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await Oe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Oe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkIHUCZKG2js.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkIHUCZKG2js.d.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkIHUCZKG2js.d.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkIHUCZKG2js.b.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var rr=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _222 => _222.pendingDequeue, 'access', _223 => _223.shift, 'call', _224 => _224(), 'optionalAccess', _225 => _225.resolve, 'call', _226 => _226(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new nr("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},nr=class extends Error{};var Ka="fulfilled",Ua= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Ua||{}),On= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,n,i=30,o=100,s=10){super();this.taskQueue=new rr;this.transactionsQueue=new rr;this.outstandingTransactions=new rr;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=n,this.started=!1,this.accountSequnceNumber=new Dn(t,n,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let n=await this.generateNextTransaction(this.account,t);if(!n)return;let i=vr({aptosConfig:this.aptosConfig,transaction:n,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof nr)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],n=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),n.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),n.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<n.length;a+=1){let c=s[a];o=n[a],c.status===Ka?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof nr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,n){try{let i=[];i.push(Jt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===Ka?(this.executedTransactions.push([a.value.hash,n,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,n,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,n){this.transactionsQueue.enqueue([t,n])}async generateNextTransaction(t,n){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return _({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:n}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Nn=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new On(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:n}=e;for(let i of t)this.transactionWorker.push(i,n)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:n,options:i}=e;this.start({sender:t}),this.push({data:n,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Fr=class{constructor(e){this.config=e,this.build=new zn(this.config),this.simulate=new er(this.config),this.submit=new tr(this.config),this.batch=new Nn(this.config)}async getTransactions(e){return yi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ps({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Sr({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ds({aptosConfig:this.config,...e})}async waitForTransaction(e){return Jt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Sn({aptosConfig:this.config})}getSigningMessage(e){return Rs(e)}async publishPackageTransaction(e){return Us({aptosConfig:this.config,...e})}async rotateAuthKey(e){return ks({aptosConfig:this.config,...e})}sign(e){return Rn({...e})}signAsFeePayer(e){return Kn({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:n,options:i}=e;this.batch.forSingleAccount({sender:t,data:n,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return vr({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Ks({aptosConfig:this.config,...e})}};var Gr=class{constructor(e){this.config=e}async getTableItem(e){return Tn({aptosConfig:this.config,...e})}async getTableItemsData(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Qo({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),jo({aptosConfig:this.config,...e})}};async function Fn(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,uidKey:i="sub",derivationPath:o}=r,s={jwt_b64:t,epk:n.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,epk_blinder:m.fromHexInput(n.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await To({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return m.fromHexInput(a.pepper).toUint8Array()}async function ki(r){let{aptosConfig:e,jwt:t,ephemeralKeyPair:n,pepper:i=await Fn(r),uidKey:o="sub",maxExpHorizonSecs:s=(await gr({aptosConfig:e})).maxExpHorizonSecs}=r;if(m.fromHexInput(i).toUint8Array().length!==Xe.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Xe.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<n.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:n.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:m.fromHexInput(n.blinder).toStringWithoutPrefix(),exp_date_secs:n.expiryDateSecs,exp_horizon_secs:s,pepper:m.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await bo({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=p.proof,h=new Bt({a:l.a,b:l.b,c:l.c});return new ve({proof:new Mt(h,0),trainingWheelsSignature:Re.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function ka(r){let{aptosConfig:e,jwt:t,jwkAddress:n,uidKey:i,proofFetchCallback:o,pepper:s=await Fn(r)}=r,{verificationKey:a,maxExpHorizonSecs:c}=await gr({aptosConfig:e}),p=ki({...r,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(n!==void 0){let d=re.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:n,uidKey:i}),b=await jt({aptosConfig:e,authenticationKey:d.authKey().derivedAddress()});return Kt.create({...r,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:n,verificationKey:a})}let h=O.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),g=await jt({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return Xe.create({...r,address:g,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function za(r){let{aptosConfig:e,sender:t,iss:n,options:i}=r,{jwksUrl:o}=r;o===void 0&&(yo.test(n)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=n.endsWith("/")?`${n}.well-known/jwks.json`:`${n}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let p;throw c instanceof Error?p=`${c.message}`:p=`error unknown - ${c}`,k.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${p}`})}let a=await s.json();return _({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[n,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var Br=class{constructor(e){this.config=e}async getPepper(e){return Fn({aptosConfig:this.config,...e})}async getProof(e){return ki({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return ka({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return za({aptosConfig:this.config,...e})}};async function Ou(r){let{aptosConfig:e,options:t}=r,n={query:mn,variables:{where_condition:_optionalChain([t, 'optionalAccess', _227 => _227.where]),offset:_optionalChain([t, 'optionalAccess', _228 => _228.offset]),limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),order_by:_optionalChain([t, 'optionalAccess', _230 => _230.orderBy])}};return(await T({aptosConfig:e,query:n,originMethod:"getObjectData"})).current_objects}async function Da(r){let{aptosConfig:e,objectAddress:t,options:n}=r,o={object_address:{_eq:u.from(t).toStringLong()}};return(await Ou({aptosConfig:e,options:{...n,where:o}}))[0]}var Mr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await w({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Da({aptosConfig:this.config,...e})}};var ne=class{constructor(e){this.config=new Cn(e),this.account=new Er(this.config),this.ans=new Or(this.config),this.coin=new Ir(this.config),this.digitalAsset=new Cr(this.config),this.event=new Kr(this.config),this.faucet=new Ur(this.config),this.fungibleAsset=new kr(this.config),this.general=new zr(this.config),this.staking=new Nr(this.config),this.transaction=new Fr(this.config),this.table=new Gr(this.config),this.keyless=new Br(this.config),this.object=new Mr(this.config)}};function ge(r,e,t){Object.getOwnPropertyNames(e.prototype).forEach(n=>{let i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&(i.value=function(...o){return this[t][n](...o)},Object.defineProperty(r.prototype,n,i))})}ge(ne,Er,"account");ge(ne,Or,"ans");ge(ne,Ir,"coin");ge(ne,Cr,"digitalAsset");ge(ne,Kr,"event");ge(ne,Ur,"faucet");ge(ne,kr,"fungibleAsset");ge(ne,zr,"general");ge(ne,Nr,"staking");ge(ne,Fr,"transaction");ge(ne,Gr,"table");ge(ne,Br,"keyless");ge(ne,Mr,"object");exports.APTOS_BIP44_REGEX = Qa; exports.APTOS_COIN = bt; exports.APTOS_FA = lo; exports.APTOS_HARDENED_REGEX = Wa; exports.AbstractKeylessAccount = le; exports.Account = at; exports.AccountAddress = u; exports.AccountAuthenticator = Z; exports.AccountAuthenticatorEd25519 = Ie; exports.AccountAuthenticatorMultiEd25519 = on; exports.AccountAuthenticatorMultiKey = ze; exports.AccountAuthenticatorNoAccountAuthenticator = Lt; exports.AccountAuthenticatorSingleKey = ae; exports.AccountAuthenticatorVariant = Vi; exports.AccountPublicKey = se; exports.AccountSequenceNumber = Dn; exports.AccountUtils = Io; exports.AddressInvalidReason = Va; exports.AnyPublicKey = N; exports.AnyPublicKeyVariant = sr; exports.AnySignature = $; exports.AnySignatureVariant = Hi; exports.Aptos = ne; exports.AptosApiError = Ae; exports.AptosApiType = Ft; exports.AptosConfig = Cn; exports.AuthenticationKey = L; exports.Bool = U; exports.CKDPriv = Zi; exports.ChainId = Vt; exports.DEFAULT_MAX_GAS_AMOUNT = uo; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = po; exports.DEFAULT_TXN_TIMEOUT_SEC = Zr; exports.DeriveScheme = Wi; exports.Deserializer = D; exports.EPK_HORIZON_SECS = vg; exports.Ed25519Account = Te; exports.Ed25519PrivateKey = H; exports.Ed25519PublicKey = P; exports.Ed25519Signature = I; exports.EntryFunction = xt; exports.EntryFunctionBytes = $r; exports.EphemeralCertificate = Gt; exports.EphemeralCertificateVariant = Mn; exports.EphemeralKeyPair = Rt; exports.EphemeralPublicKey = Tt; exports.EphemeralPublicKeyVariant = Bn; exports.EphemeralSignature = Re; exports.EphemeralSignatureVariant = qi; exports.FIREBASE_AUTH_ISS_PATTERN = yo; exports.FederatedKeylessAccount = Kt; exports.FederatedKeylessPublicKey = re; exports.FeePayerRawTransaction = Pt; exports.FixedBytes = mt; exports.Groth16VerificationKey = ii; exports.Groth16Zkp = Bt; exports.HARDENED_OFFSET = Ji; exports.Hex = m; exports.HexInvalidReason = Fa; exports.Identifier = R; exports.KeyType = ja; exports.KeylessAccount = Xe; exports.KeylessConfiguration = ni; exports.KeylessError = k; exports.KeylessErrorCategory = wc; exports.KeylessErrorResolutionTip = Sc; exports.KeylessErrorType = en; exports.KeylessPublicKey = O; exports.KeylessSignature = Le; exports.MAX_AUD_VAL_BYTES = vc; exports.MAX_COMMITED_EPK_BYTES = Kg; exports.MAX_EXTRA_FIELD_BYTES = Cg; exports.MAX_ISS_VAL_BYTES = Ig; exports.MAX_JWT_HEADER_B64_BYTES = Rg; exports.MAX_UID_KEY_BYTES = Ic; exports.MAX_UID_VAL_BYTES = Cc; exports.MimeType = Wr; exports.ModuleId = yr; exports.MoveAbility = $i; exports.MoveFunctionVisibility = Ba; exports.MoveJWK = oi; exports.MoveOption = Y; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = Et; exports.MultiAgentTransaction = ln; exports.MultiEd25519PublicKey = Ot; exports.MultiEd25519Signature = At; exports.MultiKey = ke; exports.MultiKeyAccount = wr; exports.MultiKeySignature = He; exports.MultiSig = Tr; exports.MultiSigTransactionPayload = br; exports.Network = Xn; exports.NetworkToChainId = Yn; exports.NetworkToFaucetAPI = co; exports.NetworkToIndexerAPI = so; exports.NetworkToNetworkName = wl; exports.NetworkToNodeAPI = ao; exports.NetworkToPepperAPI = jn; exports.NetworkToProverAPI = Jn; exports.ParsingError = J; exports.PrivateKey = nt; exports.PrivateKeyVariants = Qr; exports.ProcessorType = Be; exports.PublicKey = ft; exports.RAW_TRANSACTION_SALT = go; exports.RAW_TRANSACTION_WITH_DATA_SALT = Zn; exports.RawTransaction = he; exports.RawTransactionWithData = cn; exports.RoleType = Ma; exports.RotationProofChallenge = un; exports.Script = hr; exports.ScriptTransactionArgumentVariants = or; exports.Secp256k1PrivateKey = Ge; exports.Secp256k1PublicKey = Fe; exports.Secp256k1Signature = ht; exports.Serializable = y; exports.Serialized = ar; exports.Serializer = B; exports.Signature = V; exports.SignedTransaction = Je; exports.SigningScheme = oe; exports.SigningSchemeInput = Hn; exports.SimpleTransaction = dn; exports.SingleKeyAccount = be; exports.StructTag = De; exports.TransactionAndProof = ci; exports.TransactionAuthenticator = je; exports.TransactionAuthenticatorEd25519 = vt; exports.TransactionAuthenticatorFeePayer = Ct; exports.TransactionAuthenticatorMultiAgent = It; exports.TransactionAuthenticatorMultiEd25519 = pn; exports.TransactionAuthenticatorSingleSender = st; exports.TransactionAuthenticatorVariant = Li; exports.TransactionPayload = _t; exports.TransactionPayloadEntryFunction = fr; exports.TransactionPayloadMultiSig = Ar; exports.TransactionPayloadScript = mr; exports.TransactionPayloadVariants = Bi; exports.TransactionResponseType = Vn; exports.TransactionVariants = Mi; exports.TransactionWorker = On; exports.TransactionWorkerEventsEnum = Ua; exports.TypeTag = F; exports.TypeTagAddress = ee; exports.TypeTagBool = M; exports.TypeTagGeneric = G; exports.TypeTagParserError = W; exports.TypeTagParserErrorType = Xc; exports.TypeTagReference = an; exports.TypeTagSigner = St; exports.TypeTagStruct = A; exports.TypeTagU128 = We; exports.TypeTagU16 = qe; exports.TypeTagU256 = Qe; exports.TypeTagU32 = $e; exports.TypeTagU64 = j; exports.TypeTagU8 = pe; exports.TypeTagVariants = Gi; exports.TypeTagVector = C; exports.U128 = Ee; exports.U16 = _e; exports.U256 = ye; exports.U32 = xe; exports.U64 = Q; exports.U8 = X; exports.ZeroKnowledgeSig = ve; exports.ZkProof = Mt; exports.ZkpVariant = Ln; exports.aptosCoinStructTag = ym; exports.aptosRequest = tn; exports.base64UrlDecode = _chunkIHUCZKG2js.f; exports.bigIntToBytesLE = io; exports.buildTransaction = Ei; exports.bytesToBigIntLE = pr; exports.checkOrConvertArgument = Xt; exports.convertAmountFromHumanReadableToOnChain = _chunkIHUCZKG2js.g; exports.convertAmountFromOnChainToHumanReadable = _chunkIHUCZKG2js.h; exports.convertArgument = xi; exports.convertNumber = xn; exports.createObjectAddress = sn; exports.createResourceAddress = Hy; exports.createTokenAddress = qy; exports.deriveKey = qn; exports.deriveTransactionType = si; exports.deserializeFromScriptArgument = zc; exports.ensureBoolean = Gn; exports.fetchEntryFunctionAbi = _s; exports.fetchFunctionAbi = Ss; exports.fetchViewFunctionAbi = xs; exports.findFirstNonSignerArg = Ts; exports.floorToWholeHour = _chunkIHUCZKG2js.e; exports.generateRawTransaction = iu; exports.generateSignedTransaction = Pi; exports.generateSignedTransactionForSimulation = Ps; exports.generateSigningMessage = Ht; exports.generateSigningMessageForSerializable = vf; exports.generateSigningMessageForTransaction = qt; exports.generateTransactionPayload = In; exports.generateTransactionPayloadWithABI = tu; exports.generateUserTransactionHash = pb; exports.generateViewFunctionPayload = Es; exports.generateViewFunctionPayloadWithABI = ru; exports.get = rn; exports.getAptosFullNode = q; exports.getAptosPepperService = Ql; exports.getAuthenticatorForSimulation = Yt; exports.getErrorMessage = _chunkIHUCZKG2js.c; exports.getFunctionParts = _r; exports.getIssAudAndUidVal = Ve; exports.getKeylessConfig = gr; exports.getKeylessJWKs = _o; exports.hashStrToField = Xr; exports.hashValues = vs; exports.hexToAsciiString = Fi; exports.isBcsAddress = Pn; exports.isBcsBool = mi; exports.isBcsFixedBytes = $c; exports.isBcsString = fi; exports.isBcsU128 = wi; exports.isBcsU16 = hi; exports.isBcsU256 = Si; exports.isBcsU32 = Ti; exports.isBcsU64 = bi; exports.isBcsU8 = Ai; exports.isBlockEpilogueTransactionResponse = lp; exports.isBlockMetadataTransactionResponse = up; exports.isBool = ms; exports.isCanonicalEd25519Signature = Xa; exports.isEd25519Signature = gp; exports.isEmptyOption = fs; exports.isEncodedEntryFunctionArgument = As; exports.isEncodedStruct = _chunkIHUCZKG2js.j; exports.isFeePayerSignature = fp; exports.isGenesisTransactionResponse = cp; exports.isKeylessSigner = gn; exports.isLargeNumber = En; exports.isMultiAgentSignature = mp; exports.isMultiEd25519Signature = Ap; exports.isNumber = qc; exports.isPendingTransactionResponse = sp; exports.isScriptDataInput = hs; exports.isSecp256k1Signature = yp; exports.isSingleKeySigner = ai; exports.isStateCheckpointTransactionResponse = pp; exports.isString = ct; exports.isUserTransactionResponse = ap; exports.isValidBIP44Path = Xi; exports.isValidHardenedPath = Yi; exports.isValidatorTransactionResponse = dp; exports.mnemonicToSeed = jr; exports.normalizeBundle = mo; exports.nowInSeconds = _chunkIHUCZKG2js.d; exports.objectStructTag = de; exports.optionStructTag = mm; exports.outOfRangeErrorMessage = Ga; exports.padAndPackBytesWithLen = Qn; exports.paginateWithCursor = nn; exports.paginateWithObfuscatedCursor = ti; exports.parseEncodedStruct = _chunkIHUCZKG2js.i; exports.parseJwtHeader = Uc; exports.parseTypeTag = Ye; exports.poseidonHash = dr; exports.post = lr; exports.postAptosFaucet = ho; exports.postAptosFullNode = ot; exports.postAptosIndexer = Ao; exports.postAptosPepperService = To; exports.postAptosProvingService = bo; exports.promiseFulfilledStatus = Ka; exports.request = Ec; exports.sleep = _chunkIHUCZKG2js.b; exports.splitPath = eo; exports.standardizeTypeTags = vn; exports.stringStructTag = v; exports.throwTypeMismatch = z; exports.validateNumberInRange = tt;
|
|
479
|
+
will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await Ce(async()=>{try{let d=(await oe({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(d.vec.length>0&&_chunkZYPBABLQjs.ga.call(void 0, d.vec[0]))return _chunkZYPBABLQjs.fa.call(void 0, d.vec[0])}catch (e5){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunkZYPBABLQjs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===At?a=_chunkZYPBABLQjs.Z.A.toStringLong():a=tr(_chunkZYPBABLQjs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=_chunkZYPBABLQjs.Z.from(i);a=d.toStringLong(),d===_chunkZYPBABLQjs.Z.A&&(s=At)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[d]=await oe({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(d,10)}let[c]=await oe({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),as({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return cs({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var vr=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _126 => _126.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _127 => _127.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _128 => _128.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _129 => _129.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _130 => _130.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _131 => _131.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _132 => _132.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _133 => _133.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _134 => _134.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _135 => _135.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _136 => _136.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return io[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return oo[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return ro[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return Lr[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return Hr[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Lr[this.network]===e}isProverServiceRequest(e){return Hr[this.network]===e}};var fu={typeParameters:[{constraints:[]}],parameters:[new F,new j]};async function Fs(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return w({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (At))],functionArguments:[r,i],abi:fu},options:s})}var In=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Fs({aptosConfig:this.config,...e})}};var st={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Te="0x4::token::Token";async function Ns(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return(await T({aptosConfig:e,query:{query:Ho,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Gs(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}};return(await T({aptosConfig:e,query:{query:si,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Bs(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()},amount:{_gt:0}},o={query:si,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _137 => _137.offset]),limit:_optionalChain([r, 'optionalAccess', _138 => _138.limit]),order_by:_optionalChain([r, 'optionalAccess', _139 => _139.orderBy])}};return(await T({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ms(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}},o={query:Lo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _140 => _140.offset]),limit:_optionalChain([r, 'optionalAccess', _141 => _141.limit]),order_by:_optionalChain([r, 'optionalAccess', _142 => _142.orderBy])}};return(await T({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Au={typeParameters:[],parameters:[new A(P()),new j,new A(P()),new A(P()),new V,new V,new V,new V,new V,new V,new V,new V,new V,new j,new j]};async function Vs(n){let{aptosConfig:e,options:t,creator:r}=n;return w({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new E(n.description),new W(_nullishCoalesce(n.maxSupply, () => (_chunkZYPBABLQjs.e))),new E(n.name),new E(n.uri),new U(_nullishCoalesce(n.mutableDescription, () => (!0))),new U(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new U(_nullishCoalesce(n.mutableURI, () => (!0))),new U(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new U(_nullishCoalesce(n.mutableTokenName, () => (!0))),new U(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new U(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new U(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new U(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new W(_nullishCoalesce(n.royaltyNumerator, () => (0))),new W(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Au},options:t})}async function Zt(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _143 => _143.where]);_optionalChain([t, 'optionalAccess', _144 => _144.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _145 => _145.tokenStandard]), () => ("v2"))});let i={query:Oo,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _146 => _146.offset]),limit:_optionalChain([t, 'optionalAccess', _147 => _147.limit])}};return(await T({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function qs(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunkZYPBABLQjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _148 => _148.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _149 => _149.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...i,where:s}})}async function Ls(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _150 => _150.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _151 => _151.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...r,where:o}})}async function Hs(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _152 => _152.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:e,options:{...r,where:o}})}async function $s(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunkZYPBABLQjs.Z.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _154 => _154.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),(await Zt({aptosConfig:i,options:{where:s}})).collection_id}var hu={typeParameters:[],parameters:[new A(P()),new A(P()),new A(P()),new A(P()),new v(new A(P())),new v(new A(P())),new v(v.u8())]};async function Ws(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:y}=n,h=_optionalChain([d, 'optionalAccess', _156 => _156.map, 'call', _157 => _157(p=>st[p])]);return w({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new E(i),new E(o),new E(s),new E(a),_.MoveString(_nullishCoalesce(c, () => ([]))),_.MoveString(_nullishCoalesce(h, () => ([]))),aa(_nullishCoalesce(y, () => ([])),_nullishCoalesce(h, () => ([])))],abi:hu},options:t})}var Tu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new F]};async function Qs(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(r),_chunkZYPBABLQjs.Z.from(i)],abi:Tu},options:s})}var bu={typeParameters:[],parameters:[new A(P()),new A(P()),new A(P()),new A(P()),new v(new A(P())),new v(new A(P())),new v(v.u8()),new F]};async function js(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:y,options:h}=n;if(_optionalChain([c, 'optionalAccess', _158 => _158.length])!==_optionalChain([y, 'optionalAccess', _159 => _159.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _160 => _160.length])!==_optionalChain([y, 'optionalAccess', _161 => _161.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _162 => _162.map, 'call', _163 => _163(l=>st[l])]);return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,_.MoveString(_nullishCoalesce(c, () => ([]))),_.MoveString(_nullishCoalesce(p, () => ([]))),aa(_nullishCoalesce(y, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:bu},options:h})}var wu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Js(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(r)],abi:wu},options:o})}var Su={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Xs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Te))],functionArguments:[r],abi:Su},options:o})}var _u={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0)))]};async function Ys(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Te))],functionArguments:[r],abi:_u},options:o})}var Pu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function Zs(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:Pu},options:s})}var Eu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function ea(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:Eu},options:s})}var xu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function ta(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:xu},options:s})}var Iu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P()),new A(P()),v.u8()]};async function na(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),new E(st[i]),_.U8(Ei(o,st[i]))],abi:Iu},options:c})}var vu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P())]};async function ra(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(i),new E(r)],abi:vu},options:s})}var Cu={typeParameters:[{constraints:["key"]}],parameters:[new A(de(new G(0))),new A(P()),new A(P()),v.u8()]};async function ia(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Te))],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),new E(st[i]),Ei(o,st[i])],abi:Cu},options:c})}var Ku={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(P()),new G(1)]};async function oa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Te)),st[i]],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),o],abi:Ku},options:c})}var Ru={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(de(new G(0))),new A(P()),new G(1)]};async function sa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Te)),st[i]],functionArguments:[_chunkZYPBABLQjs.Z.from(s),new E(r),o],abi:Ru},options:c})}function aa(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Ei(n[i],r))}),t}function Ei(n,e){let t=Oe(e);return Kt(n,t,0,[]).bcsToBytes()}var vn=class{constructor(e){this.config=e}async getCollectionData(e){await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunkZYPBABLQjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _164 => _164.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _165 => _165.tokenStandard]), () => ("v2"))}),Zt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),qs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),$s({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ns({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Gs({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Bs({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ms({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Vs({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Ws({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Qs({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return js({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Js({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Xs({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Ys({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Zs({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ea({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ta({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return na({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return ra({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return ia({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return oa({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return sa({aptosConfig:this.config,...e})}};var ca=300,Uu=n=>{if(n&&n.length>ca)throw new Error(`Event type length exceeds the maximum length of ${ca}`)};async function ua(n){let{aptosConfig:e,eventType:t,options:r}=n,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return Cn({aptosConfig:e,options:{...r,where:i}})}async function da(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunkZYPBABLQjs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Cn({aptosConfig:t,options:{...i,where:s}})}async function pa(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunkZYPBABLQjs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Cn({aptosConfig:t,options:{...i,where:s}})}async function Cn(n){let{aptosConfig:e,options:t}=n;Uu(_optionalChain([t, 'optionalAccess', _166 => _166.where, 'optionalAccess', _167 => _167.indexed_type, 'optionalAccess', _168 => _168._eq]));let r={query:Go,variables:{where_condition:_optionalChain([t, 'optionalAccess', _169 => _169.where]),offset:_optionalChain([t, 'optionalAccess', _170 => _170.offset]),limit:_optionalChain([t, 'optionalAccess', _171 => _171.limit]),order_by:_optionalChain([t, 'optionalAccess', _172 => _172.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Kn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ua({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),da({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),pa({aptosConfig:this.config,...e})}async getEvents(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _173 => _173.minimumLedgerVersion]),processorType:"events_processor"}),Cn({aptosConfig:this.config,...e})}};async function la(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _174 => _174.timeoutSecs])||20,{data:s}=await yo({aptosConfig:e,path:"fund",body:{address:_chunkZYPBABLQjs.Z.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Jt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _175 => _175.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Rn=class{constructor(e){this.config=e}async fundAccount(e){let t=await la({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _176 => _176.options, 'optionalAccess', _177 => _177.waitForIndexer])===void 0||_optionalChain([e, 'access', _178 => _178.options, 'optionalAccess', _179 => _179.waitForIndexer]))&&await Tr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Cr(n){let{aptosConfig:e,options:t}=n,r={query:Mo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _180 => _180.where]),limit:_optionalChain([t, 'optionalAccess', _181 => _181.limit]),offset:_optionalChain([t, 'optionalAccess', _182 => _182.offset])}};return(await T({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function ga(n){let{aptosConfig:e,options:t}=n,r={query:Bo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _183 => _183.where]),limit:_optionalChain([t, 'optionalAccess', _184 => _184.limit]),offset:_optionalChain([t, 'optionalAccess', _185 => _185.offset])}};return(await T({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ma(n){let{aptosConfig:e,options:t}=n,r={query:Fo,variables:{where_condition:_optionalChain([t, 'optionalAccess', _186 => _186.where]),limit:_optionalChain([t, 'optionalAccess', _187 => _187.limit]),offset:_optionalChain([t, 'optionalAccess', _188 => _188.offset])}};return(await T({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var zu={typeParameters:[{constraints:[]}],parameters:[Oe("0x1::object::Object"),new F,new j]};async function ya(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:zu},options:s})}var Un=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _189 => _189.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Cr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _190 => _190.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Cr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _191 => _191.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Cr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunkZYPBABLQjs.Z.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _192 => _192.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ga({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ma({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ya({aptosConfig:this.config,...e})}};var zn=class{constructor(e){this.config=e}async getLedgerInfo(){return lr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return ps({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ls({aptosConfig:this.config,...e})}async view(e){return oe({aptosConfig:this.config,...e})}async viewJson(e){return Cs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return $o({aptosConfig:this.config,...e})}async queryIndexer(e){return T({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return gr({aptosConfig:this.config})}async getProcessorStatus(e){return mr({aptosConfig:this.config,processorType:e})}};var fa=["A name must be between 3 and 63 characters long,","and can only contain lowercase a-z, 0-9, and hyphens.","A name may not start or end with a hyphen."].join(" ");function Aa(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function at(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Aa(e))throw new Error(`${e} is not valid. ${fa}`);if(t&&!Aa(t))throw new Error(`${t} is not valid. ${fa}`);return{domainName:t||e,subdomainName:t?e:void 0}}function ha(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var Du="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",ku={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Du,custom:null,devnet:null};function Ze(n){let e=ku[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Kr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ta(n){let{aptosConfig:e,name:t}=n,r=Ze(e),{domainName:i,subdomainName:o}=at(t),s=await oe({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Kr(s[0]);return a?_chunkZYPBABLQjs.Z.from(a):void 0}async function ba(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=Ze(e),{domainName:y,subdomainName:h}=at(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let ee=_nullishCoalesce(t.years, () => (1));if(ee!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ut=ee*31536e3;return await w({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[y,Ut,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let l=await xi({aptosConfig:e,name:y});if(!l)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:l;if(b>l)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await w({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[y,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function xi(n){let{aptosConfig:e,name:t}=n,r=Ze(e),{domainName:i,subdomainName:o}=at(t);try{let s=await oe({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function wa(n){let{aptosConfig:e,address:t}=n,r=Ze(e),i=await oe({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunkZYPBABLQjs.Z.from(t).toString()]}}),o=Kr(i[1]),s=Kr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Sa(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=Ze(e);if(!r)return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=at(r);return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function _a(n){let{aptosConfig:e,name:t}=n,r=Ze(e),{domainName:i,subdomainName:o}=at(t),s=await oe({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Kr(s[0]);return a?_chunkZYPBABLQjs.Z.from(a):void 0}async function Pa(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=Ze(e),{domainName:a,subdomainName:c}=at(r);return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ea(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=at(t),a=(await T({aptosConfig:e,query:{query:Qt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Dn(a)),ha(a)?a:void 0}async function xa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ii({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountNames",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _194 => _194.limit]),offset:_optionalChain([t, 'optionalAccess', _195 => _195.offset]),order_by:_optionalChain([t, 'optionalAccess', _196 => _196.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _197 => _197.options, 'optionalAccess', _198 => _198.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Dn)}async function Ia(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ii({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _199 => _199.limit]),offset:_optionalChain([t, 'optionalAccess', _200 => _200.offset]),order_by:_optionalChain([t, 'optionalAccess', _201 => _201.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Dn)}async function va(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ii({aptosConfig:e});return(await T({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _204 => _204.limit]),offset:_optionalChain([t, 'optionalAccess', _205 => _205.offset]),order_by:_optionalChain([t, 'optionalAccess', _206 => _206.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _207 => _207.options, 'optionalAccess', _208 => _208.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Dn)}async function Ca(n){let{aptosConfig:e,options:t,domain:r}=n;return(await T({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Qt,variables:{limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),offset:_optionalChain([t, 'optionalAccess', _210 => _210.offset]),order_by:_optionalChain([t, 'optionalAccess', _211 => _211.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _212 => _212.options, 'optionalAccess', _213 => _213.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Dn).filter(ha)}async function Ii(n){let{aptosConfig:e}=n,t=Ze(e),[r]=await oe({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Ka(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=Ze(e),a=i*31536e3,{domainName:c,subdomainName:d}=at(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await w({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Dn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var kn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ta({aptosConfig:this.config,...e})}async getExpiration(e){return xi({aptosConfig:this.config,...e})}async getTargetAddress(e){return _a({aptosConfig:this.config,...e})}async setTargetAddress(e){return Pa({aptosConfig:this.config,...e})}async getPrimaryName(e){return wa({aptosConfig:this.config,...e})}async setPrimaryName(e){return Sa({aptosConfig:this.config,...e})}async registerName(e){return ba({aptosConfig:this.config,...e})}async renewDomain(e){return Ka({aptosConfig:this.config,...e})}async getName(e){return Ea({aptosConfig:this.config,...e})}async getAccountNames(e){return xa({aptosConfig:this.config,...e})}async getAccountDomains(e){return Ia({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return va({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Ca({aptosConfig:this.config,...e})}};async function Ra(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunkZYPBABLQjs.Z.from(t).toStringLong(),o=await T({aptosConfig:e,query:{query:ii,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function Ua(n){let{aptosConfig:e,options:t}=n,r={query:ii,variables:{order_by:_optionalChain([t, 'optionalAccess', _214 => _214.orderBy])}};return(await T({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function za(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:No,variables:{delegatorAddress:_chunkZYPBABLQjs.Z.from(t).toStringLong(),poolAddress:_chunkZYPBABLQjs.Z.from(r).toStringLong()}};return(await T({aptosConfig:e,query:i})).delegated_staking_activities}var On=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _215 => _215.minimumLedgerVersion]),processorType:"stake_processor"}),Ra({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _216 => _216.minimumLedgerVersion]),processorType:"stake_processor"}),Ua({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await S({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"stake_processor"}),za({aptosConfig:this.config,...e})}};var Rr=class{constructor(e){this.config=e}async simple(e){return w({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Er(this.config);await t.init();let i=(await e.builder(t)).build(),o=await bi({aptosConfig:this.config,payload:wt.load(new C(i)),...e});return new Lt(o,e.withFeePayer===!0?_chunkZYPBABLQjs.Z.ZERO:void 0)}async multiAgent(e){return w({aptosConfig:this.config,...e})}};function vi(n,e,t){let r=t.value;return t.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},t}function Ci(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var en=class{constructor(e){this.config=e}async simple(e){return Pi({aptosConfig:this.config,...e})}async multiAgent(e){return Pi({aptosConfig:this.config,...e})}};_chunkZYPBABLQjs.a.call(void 0, [Ci],en.prototype,"simple",1),_chunkZYPBABLQjs.a.call(void 0, [Ci],en.prototype,"multiAgent",1);var tn=class{constructor(e){this.config=e}async simple(e){return Pn({aptosConfig:this.config,...e})}async multiAgent(e){return Pn({aptosConfig:this.config,...e})}};_chunkZYPBABLQjs.a.call(void 0, [vi],tn.prototype,"simple",1),_chunkZYPBABLQjs.a.call(void 0, [vi],tn.prototype,"multiAgent",1);var Ur=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkZYPBABLQjs._.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkZYPBABLQjs.aa.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkZYPBABLQjs._.call(void 0, this.sleepTime),_chunkZYPBABLQjs.aa.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await ke({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await ke({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkZYPBABLQjs._.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkZYPBABLQjs.aa.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkZYPBABLQjs.aa.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkZYPBABLQjs._.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var nn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _218 => _218.pendingDequeue, 'access', _219 => _219.shift, 'call', _220 => _220(), 'optionalAccess', _221 => _221.resolve, 'call', _222 => _222(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new rn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},rn=class extends Error{};var Da="fulfilled",ka= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(ka||{}),zr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new nn;this.transactionsQueue=new nn;this.outstandingTransactions=new nn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Ur(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=En({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof rn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Da?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof rn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Jt({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===Da?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return w({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Dr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new zr(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var Fn=class{constructor(e){this.config=e,this.build=new Rr(this.config),this.simulate=new en(this.config),this.submit=new tn(this.config),this.batch=new Dr(this.config)}async getTransactions(e){return ui({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return us({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Sn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ds({aptosConfig:this.config,...e})}async waitForTransaction(e){return Jt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return hr({aptosConfig:this.config})}getSigningMessage(e){return Ks(e)}async publishPackageTransaction(e){return Us({aptosConfig:this.config,...e})}async rotateAuthKey(e){return zs({aptosConfig:this.config,...e})}sign(e){return xr({...e})}signAsFeePayer(e){return Ir({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return En({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return Rs({aptosConfig:this.config,...e})}};var Nn=class{constructor(e){this.config=e}async getTableItem(e){return yr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Wo({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Qo({aptosConfig:this.config,...e})}};async function kr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:_chunkZYPBABLQjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await fo({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunkZYPBABLQjs.j.fromHexInput(a.pepper).toUint8Array()}async function Ki(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await kr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await ln({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunkZYPBABLQjs.j.fromHexInput(i).toUint8Array().length!==Xe.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Xe.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunkZYPBABLQjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunkZYPBABLQjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await Ao({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),y=d.proof,h=new Bt({a:y.a,b:y.b,c:y.c});return new Ee({proof:new Mt(h,0),trainingWheelsSignature:ve.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Oa(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await kr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await ln({aptosConfig:e}),d=Ki({...n,pepper:s,maxExpHorizonSecs:c}),y=o?d:await d;if(r!==void 0){let l=te.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await jt({aptosConfig:e,authenticationKey:l.authKey().derivedAddress()});return Ct.create({...n,address:b,proof:y,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let h=k.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await jt({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return Xe.create({...n,address:p,proof:y,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Fa(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(po.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,z.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return w({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,_.MoveString(a.keys.map(c=>c.kid)),_.MoveString(a.keys.map(c=>c.alg)),_.MoveString(a.keys.map(c=>c.e)),_.MoveString(a.keys.map(c=>c.n))]},options:i})}var Gn=class{constructor(e){this.config=e}async getPepper(e){return kr({aptosConfig:this.config,...e})}async getProof(e){return Ki({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Oa({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Fa({aptosConfig:this.config,...e})}};async function Gu(n){let{aptosConfig:e,options:t}=n,r={query:pr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _223 => _223.where]),offset:_optionalChain([t, 'optionalAccess', _224 => _224.offset]),limit:_optionalChain([t, 'optionalAccess', _225 => _225.limit]),order_by:_optionalChain([t, 'optionalAccess', _226 => _226.orderBy])}};return(await T({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Na(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunkZYPBABLQjs.Z.from(t).toStringLong()}};return(await Gu({aptosConfig:e,options:{...r,where:o}}))[0]}var Bn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Na({aptosConfig:this.config,...e})}};var Z=class{constructor(e){this.config=new vr(e),this.account=new xn(this.config),this.abstraction=new Rt(this.config),this.ans=new kn(this.config),this.coin=new In(this.config),this.digitalAsset=new vn(this.config),this.event=new Kn(this.config),this.faucet=new Rn(this.config),this.fungibleAsset=new Un(this.config),this.general=new zn(this.config),this.staking=new On(this.config),this.transaction=new Fn(this.config),this.table=new Nn(this.config),this.keyless=new Gn(this.config),this.object=new Bn(this.config)}};function se(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}se(Z,xn,"account");se(Z,Rt,"abstraction");se(Z,kn,"ans");se(Z,In,"coin");se(Z,vn,"digitalAsset");se(Z,Kn,"event");se(Z,Rn,"faucet");se(Z,Un,"fungibleAsset");se(Z,zn,"general");se(Z,On,"staking");se(Z,Fn,"transaction");se(Z,Nn,"table");se(Z,Gn,"keyless");se(Z,Bn,"object");exports.APTOS_BIP44_REGEX = Ya; exports.APTOS_COIN = At; exports.APTOS_FA = co; exports.APTOS_HARDENED_REGEX = Xa; exports.AbstractKeylessAccount = pe; exports.AbstractedAccount = Io; exports.Account = De; exports.AccountAddress = _chunkZYPBABLQjs.Z; exports.AccountAuthenticator = Q; exports.AccountAuthenticatorAbstraction = gn; exports.AccountAuthenticatorEd25519 = xe; exports.AccountAuthenticatorMultiEd25519 = nr; exports.AccountAuthenticatorMultiKey = Ue; exports.AccountAuthenticatorNoAccountAuthenticator = Vt; exports.AccountAuthenticatorSingleKey = ie; exports.AccountAuthenticatorVariant = _chunkZYPBABLQjs.w; exports.AccountPublicKey = Y; exports.AccountSequenceNumber = Ur; exports.AccountUtils = Eo; exports.AddressInvalidReason = _chunkZYPBABLQjs.Y; exports.AnyPublicKey = O; exports.AnyPublicKeyVariant = _chunkZYPBABLQjs.y; exports.AnySignature = H; exports.AnySignatureVariant = _chunkZYPBABLQjs.z; exports.Aptos = Z; exports.AptosApiError = ye; exports.AptosApiType = ft; exports.AptosConfig = vr; exports.AptosScriptComposer = Er; exports.AuthenticationKey = B; exports.Bool = U; exports.CKDPriv = Ji; exports.CallArgument = _chunkZYPBABLQjs.X; exports.ChainId = qt; exports.DEFAULT_MAX_GAS_AMOUNT = so; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = ao; exports.DEFAULT_TXN_TIMEOUT_SEC = Jn; exports.DeriveScheme = _chunkZYPBABLQjs.W; exports.Deserializer = C; exports.EPK_HORIZON_SECS = mg; exports.Ed25519Account = Ae; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = x; exports.Ed25519Signature = I; exports.EntryFunction = St; exports.EntryFunctionBytes = Hn; exports.EphemeralCertificate = Gt; exports.EphemeralCertificateVariant = _chunkZYPBABLQjs.C; exports.EphemeralKeyPair = vt; exports.EphemeralPublicKey = yt; exports.EphemeralPublicKeyVariant = _chunkZYPBABLQjs.A; exports.EphemeralSignature = ve; exports.EphemeralSignatureVariant = _chunkZYPBABLQjs.B; exports.FIREBASE_AUTH_ISS_PATTERN = po; exports.FederatedKeylessAccount = Ct; exports.FederatedKeylessPublicKey = te; exports.FeePayerRawTransaction = Pt; exports.FixedBytes = pt; exports.Groth16VerificationKey = Zr; exports.Groth16Zkp = Bt; exports.HARDENED_OFFSET = Wi; exports.Hex = _chunkZYPBABLQjs.j; exports.HexInvalidReason = _chunkZYPBABLQjs.i; exports.Identifier = K; exports.KeyType = Za; exports.KeylessAccount = Xe; exports.KeylessConfiguration = Yr; exports.KeylessError = z; exports.KeylessErrorCategory = Ec; exports.KeylessErrorResolutionTip = xc; exports.KeylessErrorType = Xn; exports.KeylessPublicKey = k; exports.KeylessSignature = Me; exports.MAX_AUD_VAL_BYTES = Rc; exports.MAX_COMMITED_EPK_BYTES = hg; exports.MAX_EXTRA_FIELD_BYTES = fg; exports.MAX_ISS_VAL_BYTES = yg; exports.MAX_JWT_HEADER_B64_BYTES = Ag; exports.MAX_UID_KEY_BYTES = Uc; exports.MAX_UID_VAL_BYTES = zc; exports.MimeType = _chunkZYPBABLQjs.q; exports.ModuleId = mn; exports.MoveAbility = _chunkZYPBABLQjs.S; exports.MoveFunctionVisibility = _chunkZYPBABLQjs.R; exports.MoveJWK = ei; exports.MoveOption = X; exports.MoveString = E; exports.MoveVector = _; exports.MultiAgentRawTransaction = _t; exports.MultiAgentTransaction = ar; exports.MultiEd25519PublicKey = Ft; exports.MultiEd25519Signature = gt; exports.MultiKey = Re; exports.MultiKeyAccount = bn; exports.MultiKeySignature = qe; exports.MultiSig = hn; exports.MultiSigTransactionPayload = Tn; exports.Network = $r; exports.NetworkToChainId = Wr; exports.NetworkToFaucetAPI = oo; exports.NetworkToIndexerAPI = ro; exports.NetworkToNetworkName = cl; exports.NetworkToNodeAPI = io; exports.NetworkToPepperAPI = Lr; exports.NetworkToProverAPI = Hr; exports.ParsingError = _chunkZYPBABLQjs.h; exports.PrivateKey = nt; exports.PrivateKeyVariants = _chunkZYPBABLQjs.x; exports.ProcessorType = Ge; exports.PublicKey = lt; exports.RAW_TRANSACTION_SALT = uo; exports.RAW_TRANSACTION_WITH_DATA_SALT = Qr; exports.RawTransaction = fe; exports.RawTransactionWithData = ir; exports.RoleType = _chunkZYPBABLQjs.T; exports.RotationProofChallenge = or; exports.Script = An; exports.ScriptTransactionArgumentVariants = _chunkZYPBABLQjs.s; exports.Secp256k1PrivateKey = Ne; exports.Secp256k1PublicKey = Fe; exports.Secp256k1Signature = mt; exports.Serializable = _chunkZYPBABLQjs.l; exports.Serialized = sn; exports.Serializer = _chunkZYPBABLQjs.m; exports.Signature = M; exports.SignedTransaction = je; exports.SigningScheme = _chunkZYPBABLQjs.U; exports.SigningSchemeInput = _chunkZYPBABLQjs.V; exports.SimpleTransaction = Lt; exports.SingleKeyAccount = he; exports.StructTag = ze; exports.TransactionAndProof = ri; exports.TransactionAuthenticator = Qe; exports.TransactionAuthenticatorEd25519 = Et; exports.TransactionAuthenticatorFeePayer = It; exports.TransactionAuthenticatorMultiAgent = xt; exports.TransactionAuthenticatorMultiEd25519 = sr; exports.TransactionAuthenticatorSingleSender = ot; exports.TransactionAuthenticatorVariant = _chunkZYPBABLQjs.v; exports.TransactionPayload = bt; exports.TransactionPayloadEntryFunction = yn; exports.TransactionPayloadMultiSig = fn; exports.TransactionPayloadScript = wt; exports.TransactionPayloadVariants = _chunkZYPBABLQjs.t; exports.TransactionResponseType = _chunkZYPBABLQjs.E; exports.TransactionVariants = _chunkZYPBABLQjs.u; exports.TransactionWorker = zr; exports.TransactionWorkerEventsEnum = ka; exports.TypeTag = N; exports.TypeTagAddress = F; exports.TypeTagBool = V; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = tu; exports.TypeTagReference = rr; exports.TypeTagSigner = Tt; exports.TypeTagStruct = A; exports.TypeTagU128 = $e; exports.TypeTagU16 = Le; exports.TypeTagU256 = We; exports.TypeTagU32 = He; exports.TypeTagU64 = j; exports.TypeTagU8 = ue; exports.TypeTagVariants = _chunkZYPBABLQjs.r; exports.TypeTagVector = v; exports.U128 = _e; exports.U16 = we; exports.U256 = le; exports.U32 = Se; exports.U64 = W; exports.U8 = J; exports.ZeroKnowledgeSig = Ee; exports.ZkProof = Mt; exports.ZkpVariant = _chunkZYPBABLQjs.D; exports.aptosCoinStructTag = cy; exports.aptosRequest = Yn; exports.base64UrlDecode = _chunkZYPBABLQjs.ca; exports.bigIntToBytesLE = to; exports.buildTransaction = wi; exports.bytesToBigIntLE = un; exports.checkOrConvertArgument = Kt; exports.convertAmountFromHumanReadableToOnChain = _chunkZYPBABLQjs.da; exports.convertAmountFromOnChainToHumanReadable = _chunkZYPBABLQjs.ea; exports.convertArgument = _r; exports.convertCallArgument = Ps; exports.convertNumber = br; exports.createObjectAddress = tr; exports.createResourceAddress = Am; exports.createTokenAddress = hm; exports.deriveKey = Br; exports.deriveTransactionType = ti; exports.deserializeFromScriptArgument = Nc; exports.ensureBoolean = _chunkZYPBABLQjs.n; exports.fetchEntryFunctionAbi = Ss; exports.fetchFunctionAbi = Ti; exports.fetchMoveFunctionAbi = ws; exports.fetchViewFunctionAbi = _s; exports.findFirstNonSignerArg = hs; exports.floorToWholeHour = _chunkZYPBABLQjs.ba; exports.generateRawTransaction = bi; exports.generateSignedTransaction = Si; exports.generateSignedTransactionForSimulation = xs; exports.generateSigningMessage = Ht; exports.generateSigningMessageForSerializable = wf; exports.generateSigningMessageForTransaction = Je; exports.generateTransactionPayload = Pr; exports.generateTransactionPayloadWithABI = ou; exports.generateUserTransactionHash = Pb; exports.generateViewFunctionPayload = Es; exports.generateViewFunctionPayloadWithABI = su; exports.get = Zn; exports.getAptosFullNode = L; exports.getAptosPepperService = kl; exports.getAuthenticatorForSimulation = Yt; exports.getErrorMessage = _chunkZYPBABLQjs.$; exports.getFunctionParts = _chunkZYPBABLQjs.ha; exports.getIssAudAndUidVal = Ve; exports.getKeylessConfig = ln; exports.getKeylessJWKs = bo; exports.hashStrToField = Qn; exports.hashValues = Is; exports.hexToAsciiString = _chunkZYPBABLQjs.k; exports.isBcsAddress = Sr; exports.isBcsBool = di; exports.isBcsFixedBytes = Jc; exports.isBcsString = pi; exports.isBcsU128 = fi; exports.isBcsU16 = gi; exports.isBcsU256 = Ai; exports.isBcsU32 = mi; exports.isBcsU64 = yi; exports.isBcsU8 = li; exports.isBlockEpilogueTransactionResponse = _chunkZYPBABLQjs.L; exports.isBlockMetadataTransactionResponse = _chunkZYPBABLQjs.I; exports.isBool = ms; exports.isCanonicalEd25519Signature = tc; exports.isEd25519Signature = _chunkZYPBABLQjs.M; exports.isEmptyOption = ys; exports.isEncodedEntryFunctionArgument = fs; exports.isEncodedStruct = _chunkZYPBABLQjs.ga; exports.isFeePayerSignature = _chunkZYPBABLQjs.P; exports.isGenesisTransactionResponse = _chunkZYPBABLQjs.H; exports.isKeylessSigner = cr; exports.isLargeNumber = wr; exports.isMultiAgentSignature = _chunkZYPBABLQjs.O; exports.isMultiEd25519Signature = _chunkZYPBABLQjs.Q; exports.isNumber = jc; exports.isPendingTransactionResponse = _chunkZYPBABLQjs.F; exports.isScriptDataInput = As; exports.isSecp256k1Signature = _chunkZYPBABLQjs.N; exports.isSingleKeySigner = ni; exports.isStateCheckpointTransactionResponse = _chunkZYPBABLQjs.J; exports.isString = Ye; exports.isUserTransactionResponse = _chunkZYPBABLQjs.G; exports.isValidBIP44Path = Qi; exports.isValidFunctionInfo = _chunkZYPBABLQjs.ia; exports.isValidHardenedPath = ji; exports.isValidatorTransactionResponse = _chunkZYPBABLQjs.K; exports.mnemonicToSeed = $n; exports.normalizeBundle = lo; exports.nowInSeconds = _chunkZYPBABLQjs.aa; exports.objectStructTag = de; exports.optionStructTag = uy; exports.outOfRangeErrorMessage = _chunkZYPBABLQjs.o; exports.padAndPackBytesWithLen = qr; exports.paginateWithCursor = er; exports.paginateWithObfuscatedCursor = Jr; exports.parseEncodedStruct = _chunkZYPBABLQjs.fa; exports.parseJwtHeader = Oc; exports.parseTypeTag = Oe; exports.poseidonHash = dn; exports.post = pn; exports.postAptosFaucet = yo; exports.postAptosFullNode = it; exports.postAptosIndexer = mo; exports.postAptosPepperService = fo; exports.postAptosProvingService = Ao; exports.promiseFulfilledStatus = Da; exports.request = Cc; exports.sleep = _chunkZYPBABLQjs._; exports.splitPath = Xi; exports.standardizeTypeTags = Xt; exports.stringStructTag = P; exports.throwTypeMismatch = D; exports.validateNumberInRange = _chunkZYPBABLQjs.p;
|
|
482
480
|
//# sourceMappingURL=index.js.map
|