@aptos-labs/ts-sdk 1.39.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/{chunk-66TIRJFD.js → chunk-ZMDE3DNL.js} +3 -3
- package/dist/common/{chunk-66TIRJFD.js.map → chunk-ZMDE3DNL.js.map} +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/index.d.ts +1 -102
- package/dist/common/index.js +31 -31
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +0 -1
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +0 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +0 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +0 -1
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.d.mts +0 -1
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +0 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +0 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +0 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +0 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.d.mts +0 -1
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +0 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +0 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +0 -1
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.d.mts +0 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.d.mts +0 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.d.mts +0 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +0 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +0 -2
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +0 -1
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +0 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +0 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +0 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +0 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +0 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +0 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +0 -2
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +0 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +0 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +0 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +0 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +0 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +0 -66
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +0 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +0 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +0 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +0 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +0 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +0 -1
- package/dist/esm/bcs/deserializer.d.mts +0 -1
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.d.mts +0 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +0 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +0 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +0 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +0 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +0 -1
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-KAYKTT4S.mjs → chunk-2UBI3AZJ.mjs} +2 -2
- package/dist/esm/{chunk-3IHKQH5O.mjs → chunk-34R7FSQF.mjs} +2 -2
- package/dist/esm/{chunk-V7U5Y4AU.mjs → chunk-4JT5AESZ.mjs} +2 -2
- package/dist/esm/{chunk-V7U5Y4AU.mjs.map → chunk-4JT5AESZ.mjs.map} +1 -1
- package/dist/esm/chunk-5YLNYSBT.mjs +4 -0
- package/dist/esm/chunk-5YLNYSBT.mjs.map +1 -0
- package/dist/esm/{chunk-25O4L7YR.mjs → chunk-6UZHMEK3.mjs} +2 -2
- package/dist/esm/{chunk-6Y6ZO7TS.mjs → chunk-6WDVDEQZ.mjs} +2 -2
- package/dist/esm/{chunk-YFFDF22R.mjs → chunk-7DQDJ2SA.mjs} +2 -2
- package/dist/esm/{chunk-ZMT2M6YT.mjs → chunk-B563XRSZ.mjs} +2 -2
- package/dist/esm/{chunk-JGFKIUG5.mjs → chunk-DLIBG6H7.mjs} +2 -2
- package/dist/esm/{chunk-NJN3EAOM.mjs → chunk-EBMEXURY.mjs} +2 -2
- package/dist/esm/{chunk-FBCXUC7J.mjs → chunk-EF4FA5I6.mjs} +2 -2
- package/dist/esm/chunk-FD6FGKYY.mjs +1 -0
- package/dist/esm/{chunk-6PKBXYG3.mjs → chunk-FGFLPH5K.mjs} +2 -2
- package/dist/esm/{chunk-SOJ3OG6X.mjs → chunk-G6HENV5D.mjs} +2 -2
- package/dist/esm/{chunk-WTLQD6MR.mjs → chunk-G7WH6GQP.mjs} +2 -2
- package/dist/esm/chunk-HLF3U7IS.mjs +2 -0
- package/dist/esm/{chunk-L33JDCWL.mjs.map → chunk-HLF3U7IS.mjs.map} +1 -1
- package/dist/esm/{chunk-BUUV6B4P.mjs → chunk-HNBVYE3N.mjs} +2 -2
- package/dist/esm/{chunk-GJ7STZEW.mjs → chunk-HW7TSJI2.mjs} +2 -2
- package/dist/esm/{chunk-YQIAWAPY.mjs → chunk-K43K3YG7.mjs} +2 -2
- package/dist/esm/{chunk-YQIAWAPY.mjs.map → chunk-K43K3YG7.mjs.map} +1 -1
- package/dist/esm/{chunk-ARNW34PP.mjs → chunk-MA4QUN6P.mjs} +2 -2
- package/dist/esm/{chunk-WLUXOUZH.mjs → chunk-MT2RJ7H3.mjs} +2 -2
- package/dist/esm/{chunk-PRUQZNAP.mjs → chunk-N6YTF76Q.mjs} +2 -2
- package/dist/esm/{chunk-C6JRJNK3.mjs → chunk-ORMOQWWH.mjs} +2 -2
- package/dist/esm/{chunk-GYVSI3TS.mjs → chunk-RGKRCZ36.mjs} +2 -2
- package/dist/esm/chunk-RIRJNQ7B.mjs +2 -0
- package/dist/esm/{chunk-P237G6YB.mjs → chunk-SE2VS7WM.mjs} +2 -2
- package/dist/esm/{chunk-GQ557FEA.mjs → chunk-TDGLYA35.mjs} +2 -2
- package/dist/esm/{chunk-XF6BISPI.mjs → chunk-TLFZOAAB.mjs} +2 -2
- package/dist/esm/{chunk-IXYGZ57N.mjs → chunk-TOBQ5UE6.mjs} +2 -2
- package/dist/esm/{chunk-GLFZJNF3.mjs → chunk-USB3LA6B.mjs} +2 -2
- package/dist/esm/{chunk-Z6KQX6VX.mjs → chunk-WCMW2L3P.mjs} +2 -2
- package/dist/esm/{chunk-BYINW7I2.mjs → chunk-WSR5EBJM.mjs} +2 -2
- package/dist/esm/chunk-XJJVJOX5.mjs +2 -0
- package/dist/esm/{chunk-OYH2T6V5.mjs → chunk-XKUIMGKU.mjs} +2 -2
- package/dist/esm/chunk-XTMUMN74.mjs +2 -0
- package/dist/esm/chunk-XTMUMN74.mjs.map +1 -0
- package/dist/esm/{chunk-BXRBOMHW.mjs → chunk-ZNLOQO4Q.mjs} +2 -2
- package/dist/esm/cli/index.d.mts +0 -1
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +0 -1
- package/dist/esm/client/core.d.mts +0 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +0 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +0 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +0 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +0 -1
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +0 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +0 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +0 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +0 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.d.mts +0 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +0 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +0 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +0 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +0 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +0 -1
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +0 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +0 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +0 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +0 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +0 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +0 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +0 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +0 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/utils.d.mts +0 -1
- package/dist/esm/core/hex.d.mts +0 -1
- package/dist/esm/core/index.d.mts +0 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +0 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/index.d.mts +2 -4
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.d.mts +0 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +0 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +0 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +0 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +0 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +0 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +0 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +0 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +0 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +0 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +0 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +0 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +0 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +0 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +0 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +0 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +0 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.d.mts +0 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +0 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +0 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +0 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +2 -4
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +0 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +0 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +0 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +0 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +0 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +0 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +0 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +0 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +0 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +0 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +0 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +0 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +0 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +0 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +0 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -2
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -13
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +0 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +0 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +0 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +0 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +1 -10
- package/dist/esm/types/index.d.mts +0 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +0 -1
- package/dist/esm/utils/helpers.d.mts +0 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +0 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +0 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -3
- package/src/api/aptosConfig.ts +9 -0
- package/src/api/transactionSubmission/build.ts +2 -85
- package/src/core/crypto/ed25519.ts +1 -1
- package/src/core/crypto/secp256k1.ts +1 -1
- package/src/transactions/index.ts +0 -1
- package/src/transactions/transactionBuilder/remoteAbi.ts +1 -26
- package/src/transactions/types.ts +0 -11
- package/src/types/index.ts +0 -1
- package/src/version.ts +1 -1
- package/dist/esm/chunk-3OLFJ65O.mjs +0 -2
- package/dist/esm/chunk-3OLFJ65O.mjs.map +0 -1
- package/dist/esm/chunk-F2ZTBAJJ.mjs +0 -2
- package/dist/esm/chunk-F2ZTBAJJ.mjs.map +0 -1
- package/dist/esm/chunk-L33JDCWL.mjs +0 -2
- package/dist/esm/chunk-OYUW6ZN2.mjs +0 -2
- package/dist/esm/chunk-TAEOFYOF.mjs +0 -4
- package/dist/esm/chunk-TAEOFYOF.mjs.map +0 -1
- package/dist/esm/chunk-TUZHLTDU.mjs +0 -2
- package/dist/esm/transactions/scriptComposer/index.d.mts +0 -53
- package/dist/esm/transactions/scriptComposer/index.mjs +0 -2
- package/src/transactions/scriptComposer/index.ts +0 -102
- /package/dist/esm/{chunk-KAYKTT4S.mjs.map → chunk-2UBI3AZJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-3IHKQH5O.mjs.map → chunk-34R7FSQF.mjs.map} +0 -0
- /package/dist/esm/{chunk-25O4L7YR.mjs.map → chunk-6UZHMEK3.mjs.map} +0 -0
- /package/dist/esm/{chunk-6Y6ZO7TS.mjs.map → chunk-6WDVDEQZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-YFFDF22R.mjs.map → chunk-7DQDJ2SA.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZMT2M6YT.mjs.map → chunk-B563XRSZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-JGFKIUG5.mjs.map → chunk-DLIBG6H7.mjs.map} +0 -0
- /package/dist/esm/{chunk-NJN3EAOM.mjs.map → chunk-EBMEXURY.mjs.map} +0 -0
- /package/dist/esm/{chunk-FBCXUC7J.mjs.map → chunk-EF4FA5I6.mjs.map} +0 -0
- /package/dist/esm/{transactions/scriptComposer/index.mjs.map → chunk-FD6FGKYY.mjs.map} +0 -0
- /package/dist/esm/{chunk-6PKBXYG3.mjs.map → chunk-FGFLPH5K.mjs.map} +0 -0
- /package/dist/esm/{chunk-SOJ3OG6X.mjs.map → chunk-G6HENV5D.mjs.map} +0 -0
- /package/dist/esm/{chunk-WTLQD6MR.mjs.map → chunk-G7WH6GQP.mjs.map} +0 -0
- /package/dist/esm/{chunk-BUUV6B4P.mjs.map → chunk-HNBVYE3N.mjs.map} +0 -0
- /package/dist/esm/{chunk-GJ7STZEW.mjs.map → chunk-HW7TSJI2.mjs.map} +0 -0
- /package/dist/esm/{chunk-ARNW34PP.mjs.map → chunk-MA4QUN6P.mjs.map} +0 -0
- /package/dist/esm/{chunk-WLUXOUZH.mjs.map → chunk-MT2RJ7H3.mjs.map} +0 -0
- /package/dist/esm/{chunk-PRUQZNAP.mjs.map → chunk-N6YTF76Q.mjs.map} +0 -0
- /package/dist/esm/{chunk-C6JRJNK3.mjs.map → chunk-ORMOQWWH.mjs.map} +0 -0
- /package/dist/esm/{chunk-GYVSI3TS.mjs.map → chunk-RGKRCZ36.mjs.map} +0 -0
- /package/dist/esm/{chunk-TUZHLTDU.mjs.map → chunk-RIRJNQ7B.mjs.map} +0 -0
- /package/dist/esm/{chunk-P237G6YB.mjs.map → chunk-SE2VS7WM.mjs.map} +0 -0
- /package/dist/esm/{chunk-GQ557FEA.mjs.map → chunk-TDGLYA35.mjs.map} +0 -0
- /package/dist/esm/{chunk-XF6BISPI.mjs.map → chunk-TLFZOAAB.mjs.map} +0 -0
- /package/dist/esm/{chunk-IXYGZ57N.mjs.map → chunk-TOBQ5UE6.mjs.map} +0 -0
- /package/dist/esm/{chunk-GLFZJNF3.mjs.map → chunk-USB3LA6B.mjs.map} +0 -0
- /package/dist/esm/{chunk-Z6KQX6VX.mjs.map → chunk-WCMW2L3P.mjs.map} +0 -0
- /package/dist/esm/{chunk-BYINW7I2.mjs.map → chunk-WSR5EBJM.mjs.map} +0 -0
- /package/dist/esm/{chunk-OYUW6ZN2.mjs.map → chunk-XJJVJOX5.mjs.map} +0 -0
- /package/dist/esm/{chunk-OYH2T6V5.mjs.map → chunk-XKUIMGKU.mjs.map} +0 -0
- /package/dist/esm/{chunk-BXRBOMHW.mjs.map → chunk-ZNLOQO4Q.mjs.map} +0 -0
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
throwTypeMismatch,
|
|
46
46
|
convertNumber,
|
|
47
47
|
} from "./helpers";
|
|
48
|
-
import {
|
|
48
|
+
import { MoveFunction, MoveModule } from "../../types";
|
|
49
49
|
|
|
50
50
|
const TEXT_ENCODER = new TextEncoder();
|
|
51
51
|
|
|
@@ -228,31 +228,6 @@ export async function fetchViewFunctionAbi(
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
/**
|
|
232
|
-
* @deprecated Handle this inline
|
|
233
|
-
*
|
|
234
|
-
* @example
|
|
235
|
-
* ```typescript
|
|
236
|
-
* const callArgument = argument instanceof CallArgument ? argument : CallArgument.newBytes(
|
|
237
|
-
* convertArgument(functionName, functionAbi, argument, position, genericTypeParams).bcsToBytes()
|
|
238
|
-
* );
|
|
239
|
-
* ```
|
|
240
|
-
*/
|
|
241
|
-
export function convertCallArgument(
|
|
242
|
-
argument: CallArgument | EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes,
|
|
243
|
-
functionName: string,
|
|
244
|
-
functionAbi: FunctionABI,
|
|
245
|
-
position: number,
|
|
246
|
-
genericTypeParams: Array<TypeTag>,
|
|
247
|
-
): CallArgument {
|
|
248
|
-
if (argument instanceof CallArgument) {
|
|
249
|
-
return argument;
|
|
250
|
-
}
|
|
251
|
-
return CallArgument.newBytes(
|
|
252
|
-
convertArgument(functionName, functionAbi, argument, position, genericTypeParams).bcsToBytes(),
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
231
|
/**
|
|
257
232
|
* Converts a non-BCS encoded argument into BCS encoded, if necessary.
|
|
258
233
|
* This function checks the provided argument against the expected parameter type and converts it accordingly.
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright © Aptos Foundation
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CallArgument } from "@aptos-labs/script-composer-pack";
|
|
5
4
|
import { AptosConfig } from "../api/aptosConfig";
|
|
6
5
|
import { MoveOption, MoveString, MoveVector } from "../bcs/serializable/moveStructs";
|
|
7
6
|
import { Bool, U128, U16, U256, U32, U64, U8 } from "../bcs/serializable/movePrimitives";
|
|
@@ -193,16 +192,6 @@ export type InputMultiSigDataWithABI = {
|
|
|
193
192
|
* @category Transactions
|
|
194
193
|
*/
|
|
195
194
|
export type InputEntryFunctionDataWithRemoteABI = InputEntryFunctionData & { aptosConfig: AptosConfig };
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* The data needed to generate a batched function payload
|
|
199
|
-
*/
|
|
200
|
-
export type InputBatchedFunctionData = {
|
|
201
|
-
function: MoveFunctionId;
|
|
202
|
-
typeArguments?: Array<TypeArgument>;
|
|
203
|
-
functionArguments: Array<EntryFunctionArgumentTypes | CallArgument | SimpleEntryFunctionArgumentTypes>;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
195
|
/**
|
|
207
196
|
* The data needed to generate a Multi Sig payload
|
|
208
197
|
* @group Implementation
|
package/src/types/index.ts
CHANGED
package/src/version.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export * from \"./indexer\";\nexport * from \"./types\";\nexport { CallArgument } from \"@aptos-labs/script-composer-pack\";\n"],"mappings":"AAEA,OAAS,gBAAAA,MAAoB","names":["CallArgument"]}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as o,b as n,c as i,d as r,e as t}from"./chunk-4RXKALLC.mjs";import f from"@aptos-labs/aptos-client";var s=class{constructor(e){this.network=e?.network??"devnet",this.fullnode=e?.fullnode,this.faucet=e?.faucet,this.pepper=e?.pepper,this.prover=e?.prover,this.indexer=e?.indexer,this.client=e?.client??{provider:f},this.clientConfig=e?.clientConfig??{},this.fullnodeConfig=e?.fullnodeConfig??{},this.indexerConfig=e?.indexerConfig??{},this.faucetConfig=e?.faucetConfig??{}}getRequestUrl(e){switch(e){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return n[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 i[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return o[this.network];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 r[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 t[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return r[this.network]===e}isProverServiceRequest(e){return t[this.network]===e}};export{s as a};
|
|
2
|
-
//# sourceMappingURL=chunk-F2ZTBAJJ.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/aptosConfig.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport aptosClient from \"@aptos-labs/aptos-client\";\nimport { AptosSettings, ClientConfig, Client, FullNodeConfig, IndexerConfig, FaucetConfig } from \"../types\";\nimport {\n NetworkToNodeAPI,\n NetworkToFaucetAPI,\n NetworkToIndexerAPI,\n Network,\n NetworkToPepperAPI,\n NetworkToProverAPI,\n} from \"../utils/apiEndpoints\";\nimport { AptosApiType } from \"../utils/const\";\n\n/**\n * Represents the configuration settings for an Aptos SDK client instance.\n * This class allows customization of various endpoints and client settings.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a configuration for connecting to the Aptos testnet\n * const config = new AptosConfig({ network: Network.TESTNET });\n *\n * // Initialize the Aptos client with the configuration\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\nexport class AptosConfig {\n /**\n * The Network that this SDK is associated with. Defaults to DEVNET\n * @group Client\n */\n readonly network: Network;\n\n /**\n * The client instance the SDK uses. Defaults to `@aptos-labs/aptos-client\n * @group Client\n */\n readonly client: Client;\n\n /**\n * The optional hardcoded fullnode URL to send requests to instead of using the network\n * @group Client\n */\n readonly fullnode?: string;\n\n /**\n * The optional hardcoded faucet URL to send requests to instead of using the network\n * @group Client\n */\n readonly faucet?: string;\n\n /**\n * The optional hardcoded pepper service URL to send requests to instead of using the network\n * @group Client\n */\n readonly pepper?: string;\n\n /**\n * The optional hardcoded prover service URL to send requests to instead of using the network\n * @group Client\n */\n readonly prover?: string;\n\n /**\n * The optional hardcoded indexer URL to send requests to instead of using the network\n * @group Client\n */\n readonly indexer?: string;\n\n /**\n * Optional client configurations\n * @group Client\n */\n readonly clientConfig?: ClientConfig;\n\n /**\n * Optional specific Fullnode configurations\n * @group Client\n */\n readonly fullnodeConfig?: FullNodeConfig;\n\n /**\n * Optional specific Indexer configurations\n * @group Client\n */\n readonly indexerConfig?: IndexerConfig;\n\n /**\n * Optional specific Faucet configurations\n * @group Client\n */\n readonly faucetConfig?: FaucetConfig;\n\n /**\n * Initializes an instance of the Aptos client with the specified settings.\n * This allows users to configure various aspects of the client, such as network and endpoints.\n *\n * @param settings - Optional configuration settings for the Aptos client.\n * @param settings.network - The network to connect to, defaults to `Network.DEVNET`.\n * @param settings.fullnode - The fullnode endpoint to use for requests.\n * @param settings.faucet - The faucet endpoint for obtaining test tokens.\n * @param settings.pepper - The pepper used for transaction signing.\n * @param settings.prover - The prover endpoint for transaction verification.\n * @param settings.indexer - The indexer endpoint for querying blockchain data.\n * @param settings.client - Custom client settings, defaults to a standard Aptos client.\n * @param settings.clientConfig - Additional configuration for the client.\n * @param settings.fullnodeConfig - Additional configuration for the fullnode.\n * @param settings.indexerConfig - Additional configuration for the indexer.\n * @param settings.faucetConfig - Additional configuration for the faucet.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * async function runExample() {\n * // Create a new Aptos client with default settings\n * const config = new AptosConfig({ network: Network.TESTNET }); // Specify the network\n * const aptos = new Aptos(config);\n *\n * console.log(\"Aptos client initialized:\", aptos);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n constructor(settings?: AptosSettings) {\n this.network = settings?.network ?? Network.DEVNET;\n this.fullnode = settings?.fullnode;\n this.faucet = settings?.faucet;\n this.pepper = settings?.pepper;\n this.prover = settings?.prover;\n this.indexer = settings?.indexer;\n this.client = settings?.client ?? { provider: aptosClient };\n this.clientConfig = settings?.clientConfig ?? {};\n this.fullnodeConfig = settings?.fullnodeConfig ?? {};\n this.indexerConfig = settings?.indexerConfig ?? {};\n this.faucetConfig = settings?.faucetConfig ?? {};\n }\n\n /**\n * Returns the URL endpoint to send the request to based on the specified API type.\n * If a custom URL was provided in the configuration, that URL is returned. Otherwise, the URL endpoint is derived from the network.\n *\n * @param apiType - The type of Aptos API to get the URL for. This can be one of the following: FULLNODE, FAUCET, INDEXER, PEPPER, PROVER.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network, AptosApiType } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * // Getting the request URL for the FULLNODE API\n * const url = config.getRequestUrl(AptosApiType.FULLNODE);\n * console.log(\"Request URL for FULLNODE:\", url);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n getRequestUrl(apiType: AptosApiType): string {\n switch (apiType) {\n case AptosApiType.FULLNODE:\n if (this.fullnode !== undefined) return this.fullnode;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom full node url\");\n return NetworkToNodeAPI[this.network];\n case AptosApiType.FAUCET:\n if (this.faucet !== undefined) return this.faucet;\n if (this.network === Network.TESTNET) {\n throw new Error(\n \"There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet\",\n );\n }\n if (this.network === Network.MAINNET) {\n throw new Error(\"There is no mainnet faucet\");\n }\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom faucet url\");\n return NetworkToFaucetAPI[this.network];\n case AptosApiType.INDEXER:\n if (this.indexer !== undefined) return this.indexer;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom indexer url\");\n return NetworkToIndexerAPI[this.network];\n case AptosApiType.PEPPER:\n if (this.pepper !== undefined) return this.pepper;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom pepper service url\");\n return NetworkToPepperAPI[this.network];\n case AptosApiType.PROVER:\n if (this.prover !== undefined) return this.prover;\n if (this.network === Network.CUSTOM) throw new Error(\"Please provide a custom prover service url\");\n return NetworkToProverAPI[this.network];\n default:\n throw Error(`apiType ${apiType} is not supported`);\n }\n }\n\n /**\n * Checks if the provided URL is a known pepper service endpoint.\n *\n * @param url - The URL to check against the known pepper service endpoints.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * async function runExample() {\n * const url = \"https://example.pepper.service\"; // replace with a real pepper service URL\n *\n * // Check if the URL is a known pepper service endpoint\n * const isPepperService = config.isPepperServiceRequest(url);\n *\n * console.log(`Is the URL a known pepper service? ${isPepperService}`);\n * }\n * runExample().catch(console.error);\n * ```\n * @group Client\n */\n isPepperServiceRequest(url: string): boolean {\n return NetworkToPepperAPI[this.network] === url;\n }\n\n /**\n * Checks if the provided URL is a known prover service endpoint.\n *\n * @param url - The URL to check against known prover service endpoints.\n * @returns A boolean indicating whether the URL is a known prover service endpoint.\n *\n * @example\n * ```typescript\n * import { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n *\n * const config = new AptosConfig({ network: Network.TESTNET });\n * const aptos = new Aptos(config);\n *\n * // Check if the URL is a known prover service endpoint\n * const url = \"https://prover.testnet.aptos.dev\"; // replace with a real URL if needed\n * const isProver = config.isProverServiceRequest(url);\n *\n * console.log(`Is the URL a known prover service? ${isProver}`);\n * ```\n * @group Client\n */\n isProverServiceRequest(url: string): boolean {\n return NetworkToProverAPI[this.network] === url;\n }\n}\n"],"mappings":"qEAGA,OAAOA,MAAiB,2BAiCjB,IAAMC,EAAN,KAAkB,CAmGvB,YAAYC,EAA0B,CACpC,KAAK,QAAUA,GAAU,SAAW,SACpC,KAAK,SAAWA,GAAU,SAC1B,KAAK,OAASA,GAAU,OACxB,KAAK,OAASA,GAAU,OACxB,KAAK,OAASA,GAAU,OACxB,KAAK,QAAUA,GAAU,QACzB,KAAK,OAASA,GAAU,QAAU,CAAE,SAAUC,CAAY,EAC1D,KAAK,aAAeD,GAAU,cAAgB,CAAC,EAC/C,KAAK,eAAiBA,GAAU,gBAAkB,CAAC,EACnD,KAAK,cAAgBA,GAAU,eAAiB,CAAC,EACjD,KAAK,aAAeA,GAAU,cAAgB,CAAC,CACjD,CAwBA,cAAcE,EAA+B,CAC3C,OAAQA,EAAS,CACf,eACE,GAAI,KAAK,WAAa,OAAW,OAAO,KAAK,SAC7C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,uCAAuC,EAC5F,OAAOC,EAAiB,KAAK,OAAO,EACtC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,UACnB,MAAM,IAAI,MACR,yHACF,EAEF,GAAI,KAAK,UAAY,UACnB,MAAM,IAAI,MAAM,4BAA4B,EAE9C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,oCAAoC,EACzF,OAAOC,EAAmB,KAAK,OAAO,EACxC,cACE,GAAI,KAAK,UAAY,OAAW,OAAO,KAAK,QAC5C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,qCAAqC,EAC1F,OAAOC,EAAoB,KAAK,OAAO,EACzC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,4CAA4C,EACjG,OAAOC,EAAmB,KAAK,OAAO,EACxC,aACE,GAAI,KAAK,SAAW,OAAW,OAAO,KAAK,OAC3C,GAAI,KAAK,UAAY,SAAgB,MAAM,IAAI,MAAM,4CAA4C,EACjG,OAAOC,EAAmB,KAAK,OAAO,EACxC,QACE,MAAM,MAAM,WAAWL,CAAO,mBAAmB,CACrD,CACF,CA0BA,uBAAuBM,EAAsB,CAC3C,OAAOF,EAAmB,KAAK,OAAO,IAAME,CAC9C,CAuBA,uBAAuBA,EAAsB,CAC3C,OAAOD,EAAmB,KAAK,OAAO,IAAMC,CAC9C,CACF","names":["aptosClient","AptosConfig","settings","aptosClient","apiType","NetworkToNodeAPI","NetworkToFaucetAPI","NetworkToIndexerAPI","NetworkToPepperAPI","NetworkToProverAPI","url"]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{a as Un,b as yr}from"./chunk-A5L76YP7.mjs";import{a as Ti}from"./chunk-XF6BISPI.mjs";import{a as kn,b as Ni}from"./chunk-3IHKQH5O.mjs";import{a as In}from"./chunk-OYH2T6V5.mjs";import{a as _}from"./chunk-PRUQZNAP.mjs";import{a as Te,b as Cn,c as Et,d as or,e as It}from"./chunk-GOXRBEIJ.mjs";import{a as ni}from"./chunk-OYUW6ZN2.mjs";import{a as Ft,b as nt,c as dr}from"./chunk-V7U5Y4AU.mjs";import{a as Ct,b as We}from"./chunk-WTLQD6MR.mjs";import{b as R,c as $,d as z}from"./chunk-YQIAWAPY.mjs";import{a as gr,b as mr}from"./chunk-W4BSN6SK.mjs";import{a as ir,b as ti}from"./chunk-FBCXUC7J.mjs";import{b as qe}from"./chunk-BYINW7I2.mjs";import{a as we}from"./chunk-Z6KQX6VX.mjs";import{a as Z}from"./chunk-6PKBXYG3.mjs";import{a as Ar}from"./chunk-ARNW34PP.mjs";import{a as Mi}from"./chunk-GLFZJNF3.mjs";import{a as h}from"./chunk-KAYKTT4S.mjs";import{a as Vi,b as Fn,c as Hi,d as Li,e as $i,g as je,h as qi,k as Wi,l as ji}from"./chunk-P237G6YB.mjs";import{a as kt}from"./chunk-YOZBVVKL.mjs";import{a as _n,b as Gi,c as w,e as Bi,f as zi}from"./chunk-BXRBOMHW.mjs";import{A as Oi,d as Si,e as Pi,f as xi,g as Ki,i as Ci,j as Ei,k as Ii,m as vi,n as _i,o as ki,p as Fi,q as Ui,r as Di,s as Ut,t as pr,u as vn,y as Ri,z as lr}from"./chunk-VHNX2NUR.mjs";import{b as tt,d as fi,e as cr,f as ur}from"./chunk-GJ7STZEW.mjs";import{b as _t,d as hi,e as bi,f as wi}from"./chunk-GQ557FEA.mjs";import{a as ui}from"./chunk-TUZHLTDU.mjs";import{a as Xr}from"./chunk-IXYGZ57N.mjs";import{a as wt}from"./chunk-WLUXOUZH.mjs";import{a as P,b as ei,c as v,d as J}from"./chunk-SOJ3OG6X.mjs";import{a as B,b as he,c as St,d as Pt,e as be,f as xt,g as Kt}from"./chunk-C6JRJNK3.mjs";import{a as L}from"./chunk-JGFKIUG5.mjs";import{d as b,e as Ai}from"./chunk-6Y6ZO7TS.mjs";import{a as Zt,b as di,c as ve,d as pi,e as li,f as gi,i as mi,j as yi,k as Y,l as vt}from"./chunk-YFFDF22R.mjs";import{a as En}from"./chunk-BUUV6B4P.mjs";import{b as c}from"./chunk-GYVSI3TS.mjs";import{a as Tt}from"./chunk-3OLFJ65O.mjs";import{E as Q}from"./chunk-ODAAZLPK.mjs";import{a as S,b as j}from"./chunk-NJN3EAOM.mjs";import{d as Zr}from"./chunk-56CNRT2K.mjs";import{b as T,c as Yr}from"./chunk-STY74NUA.mjs";import{a as Qi}from"./chunk-F2ZTBAJJ.mjs";import{g as sr}from"./chunk-4RXKALLC.mjs";import{b as ri,c as ii,d as oi,e as Ie,f as si,g as ai,h as ar,j as ci}from"./chunk-RJ7F4JDV.mjs";import{a as bt}from"./chunk-KDMSOCZY.mjs";import{jwtDecode as Ls}from"jwt-decode";import{sha3_256 as Qa}from"@noble/hashes/sha3";import{bn254 as fe}from"@noble/curves/bn254";import{bytesToNumberBE as Ja}from"@noble/curves/abstract/utils";var q=class n extends qe{constructor(e,t){super(),this.jwkAddress=c.from(e),this.keylessPublicKey=t}authKey(){let e=new j;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),Z.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Dn({...e,publicKey:this}),!0}catch{return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=c.deserialize(e),r=E.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return hr({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,E.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,E.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof c&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof E}};import{encode as Za}from"js-base64";var k=class n extends qe{constructor(e){if(super(),this.publicKey=e,e instanceof R)this.variant=0;else if(e instanceof Ft)this.variant=1;else if(e instanceof E)this.variant=3;else if(e instanceof q)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof E)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof O)){if(e.options?.throwErrorWithReason)throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return Z.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=R.deserialize(e);break;case 1:r=Ft.deserialize(e);break;case 3:r=E.deserialize(e);break;case 4:r=q.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 R}isSecp256k1PublicKey(){return this.publicKey instanceof Ft}static isInstance(e){return"publicKey"in e&&"variant"in e}},O=class n extends we{constructor(e){if(super(),this.signature=e,e instanceof z)this.variant=0;else if(e instanceof dr)this.variant=1;else if(e instanceof ue)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=z.deserialize(e);break;case 1:r=dr.deserialize(e);break;case 3:r=ue.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 $s(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Yt=class extends qe{constructor(e){super(),this.publicKeys=e.publicKeys}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 u=Math.floor(s/8),d=i[u];d|=r>>s%8,i[u]=d}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},Se=class n extends Yt{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),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 k?i:new k(i)),this.signaturesRequired=r}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Pe))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(e.options?.throwErrorWithReason)throw r;return!1}}authKey(){return Z.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(k),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof k?e:new k(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},re=class re extends we{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>re.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${re.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof O?o:new O(o)),!(r instanceof Uint8Array))this.bitmap=re.createBitmap({bits:r});else{if(r.length!==re.BITMAP_LEN)throw new Error(`"bitmap" length should be ${re.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+$s(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>=re.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${re.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),u=i[a];u|=r>>s%8,i[a]=u}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)(r&128>>i)!==0&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(O),r=e.deserializeBytes();return new re({signatures:t,bitmap:r})}};re.BITMAP_LEN=4,re.MAX_SIGNATURES_SUPPORTED=re.BITMAP_LEN*8;var Pe=re;var de=class de extends Yt{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>de.MAX_KEYS||t.length<de.MIN_KEYS)throw new Error(`Must have between ${de.MIN_KEYS} and ${de.MAX_KEYS} public keys, inclusive`);if(r<de.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${de.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof _e))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 u=o*8+s;i.push(u)}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}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return Z.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*R.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*R.LENGTH)}),e[this.publicKeys.length*R.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+=R.LENGTH){let s=o;i.push(new R(t.subarray(s,s+R.LENGTH)))}return new de({publicKeys:i,threshold:r})}getIndex(e){return super.getIndex(e)}};de.MAX_KEYS=32,de.MIN_KEYS=2,de.MIN_THRESHOLD=1;var Dt=de,ie=class ie extends we{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ie.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ie.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=ie.createBitmap({bits:r});else{if(r.length!==ie.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ie.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*z.LENGTH+ie.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*z.LENGTH)}),e.set(this.bitmap,this.signatures.length*z.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+=z.LENGTH){let s=o;i.push(new z(t.subarray(s,s+z.LENGTH)))}return new ie({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>=ie.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ie.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 u=Math.floor(s/8),d=i[u];d|=r>>s%8,i[u]=d}),i}};ie.MAX_SIGNATURES_SUPPORTED=32,ie.BITMAP_LEN=4;var _e=ie;var V=class extends S{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return me.load(e);case 1:return ke.load(e);case 2:return X.load(e);case 3:return xe.load(e);case 4:return Rt.load(e);case 5:return rt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof me}isMultiEd25519(){return this instanceof ke}isSingleKey(){return this instanceof X}isMultiKey(){return this instanceof xe}},me=class n extends V{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=R.deserialize(e),r=z.deserialize(e);return new n(t,r)}},ke=class n extends V{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=Dt.deserialize(e),r=_e.deserialize(e);return new n(t,r)}},X=class n extends V{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=k.deserialize(e),r=O.deserialize(e);return new n(t,r)}},xe=class n extends V{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=Se.deserialize(e),r=Pe.deserialize(e);return new n(t,r)}},Rt=class n extends V{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},rt=class n extends V{constructor(e,t,r,i){if(super(),!vt(e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=r,this.signingMessageDigest=T.fromHexInput(T.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=Y(this.functionInfo);c.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.authenticator):e.serializeFixedBytes(this.authenticator),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=c.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)}if(o===1){let s=e.deserializeBytes(),a=e.deserializeBytes(),u=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,u)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};import{sha3_256 as Ws}from"@noble/hashes/sha3";var Xt=class n extends S{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(c.fromString(t[0]),new _(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=c.deserialize(e),r=_.deserialize(e);return new n(t,r)}};var U=class n extends S{deserialize(e){let t=c.deserialize(e),r=_.deserialize(e),i=_.deserialize(e),o=e.deserializeVector(n);return new Ke(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return G.load(e);case 1:return oe.load(e);case 2:return H.load(e);case 3:return De.load(e);case 4:return F.load(e);case 5:return it.load(e);case 6:return K.load(e);case 7:return m.load(e);case 8:return Fe.load(e);case 9:return Ue.load(e);case 10:return Re.load(e);case 255:return D.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof G}isAddress(){return this instanceof F}isGeneric(){return this instanceof D}isSigner(){return this instanceof it}isVector(){return this instanceof K}isStruct(){return this instanceof m}isU8(){return this instanceof oe}isU16(){return this instanceof Fe}isU32(){return this instanceof Ue}isU64(){return this instanceof H}isU128(){return this instanceof De}isU256(){return this instanceof Re}isPrimitive(){return this instanceof it||this instanceof F||this instanceof G||this instanceof oe||this instanceof Fe||this instanceof Ue||this instanceof H||this instanceof De||this instanceof Re}},G=class n extends U{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},oe=class n extends U{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Fe=class n extends U{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Ue=class n extends U{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},H=class n extends U{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},De=class n extends U{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Re=class n extends U{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},F=class n extends U{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},it=class n extends U{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Rn=class n extends U{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=U.deserialize(t);return new n(r)}},D=class n extends U{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)}},K=class n extends U{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new oe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=U.deserialize(t);return new n(r)}},m=class n extends U{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=Ke.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(c.ONE,"string","String")}isOption(){return this.isTypeTag(c.ONE,"option","Option")}isObject(){return this.isTypeTag(c.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(c.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(c.ONE,"rate_limiter","RateLimiter")}},Ke=class n extends S{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=c.deserialize(e),r=_.deserialize(e),i=_.deserialize(e),o=e.deserializeVector(U);return new n(t,r,i,o)}};function Ju(){return new Ke(c.ONE,new _("aptos_coin"),new _("AptosCoin"),[])}function x(){return new Ke(c.ONE,new _("string"),new _("String"),[])}function Zu(n){return new Ke(c.ONE,new _("option"),new _("Option"),[n])}function se(n){return new Ke(c.ONE,new _("object"),new _("Object"),[n])}function qs(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return he.deserialize(n);case 1:return be.deserialize(n);case 2:return xt.deserialize(n);case 3:return c.deserialize(n);case 4:return P.deserialize(n,he);case 5:return B.deserialize(n);case 6:return St.deserialize(n);case 7:return Pt.deserialize(n);case 8:return Kt.deserialize(n);case 9:return ei.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var ot=class extends S{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return st.load(e);case 2:return en.load(e);case 3:return tn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},st=class n extends ot{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=nn.deserialize(e);return new n(t)}},en=class n extends ot{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=at.deserialize(e);return new n(t)}},tn=class n extends ot{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=rn.deserialize(e);return new n(t)}},at=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(Xt.fromStr(e),new _(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=Xt.deserialize(e),r=_.deserialize(e),i=e.deserializeVector(U),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let u=e.deserializeUleb128AsU32(),d=Xr.deserialize(e,u);s.push(d)}return new n(t,r,i,s)}},nn=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(U),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=qs(e);o.push(a)}return new n(t,r,o)}},rn=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=c.deserialize(e),r=e.deserializeBool(),i;return r&&(i=on.deserialize(e)),new n(t,i)}},on=class n extends S{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(at.deserialize(e))}};var pe=class n extends S{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=c.deserialize(e),r=e.deserializeU64(),i=ot.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),u=In.deserialize(e);return new n(t,r,i,o,s,a,u)}},On=class extends S{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ct.load(e);case 1:return ut.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},ct=class n extends On{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=pe.deserialize(e),r=e.deserializeVector(c);return new n(t,r)}},ut=class n extends On{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=pe.deserialize(e),r=e.deserializeVector(c),i=c.deserialize(e);return new n(t,r,i)}};var Oe=class extends S{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return dt.load(e);case 1:return Ot.load(e);case 2:return pt.load(e);case 3:return lt.load(e);case 4:return Qe.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof dt}isMultiEd25519(){return this instanceof Ot}isMultiAgent(){return this instanceof pt}isFeePayer(){return this instanceof lt}isSingleSender(){return this instanceof Qe}},dt=class n extends Oe{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=R.deserialize(e),r=z.deserialize(e);return new n(t,r)}},Ot=class n extends Oe{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=Dt.deserialize(e),r=_e.deserialize(e);return new n(t,r)}},pt=class n extends Oe{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=V.deserialize(e),r=e.deserializeVector(c),i=e.deserializeVector(V);return new n(t,r,i)}},lt=class n extends Oe{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=V.deserialize(e),r=e.deserializeVector(c),i=e.deserializeVector(V),o=c.deserialize(e),s=V.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},Qe=class n extends Oe{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=V.deserialize(e);return new n(t)}};var Ge=class n extends S{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=pe.deserialize(e),r=Oe.deserialize(e);return new n(t,r)}};var Gt=class n extends S{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=pe.deserialize(e),r=e.deserializeBool(),i;return r&&(i=c.deserialize(e)),new n(t,i)}};var Gn=class n extends S{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=pe.deserialize(e),r=e.deserializeVector(c),i=e.deserializeBool(),o;return i&&(o=c.deserialize(e)),new n(t,r,o)}};function Bn(n){return n.feePayerAddress?new ut(n.rawTransaction,n.secondarySignerAddresses??[],n.feePayerAddress):n.secondarySignerAddresses?new ct(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Je(n,e){let t=Ws.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 sp(n){return Je(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function ye(n){let e=Bn(n);return n.feePayerAddress?Je(e.bcsToBytes(),ar):n.secondarySignerAddresses?Je(e.bcsToBytes(),ar):Je(e.bcsToBytes(),ai)}var ee=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?c.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=$.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=$.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new me(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new me(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(ye(e))}};function br(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var le=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new k(t.publicKey()),this.accountAddress=r?c.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=$.generate();break;case 2:r=nt.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=$.fromDerivationPath(r,i);break;case 2:o=nt.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new X(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new X(this.publicKey,this.signTransaction(e))}sign(e){return new O(this.privateKey.sign(e))}signTransaction(e){return this.sign(ye(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var Be=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?ee.generate():le.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof $&&i?new ee({privateKey:t,address:r}):new le({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?ee.fromDerivationPath({mnemonic:r,path:i}):le.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};import{randomBytes as Qs}from"@noble/hashes/utils";var Js=1209600,Bt=class Bt extends S{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new Ct(t.publicKey()),this.expiryDateSecs=r||pi(ve()+Js),this.blinder=i!==void 0?T.fromHexInput(i).toUint8Array():Zs();let o=Cn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Et(this.blinder));let s=It(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=$.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Bt({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Bt.deserialize(new L(e))}static generate(e){let t;switch(e?.scheme){case 0:default:t=$.generate()}return new Bt({privateKey:t,expiryDateSecs:e?.expiryDateSecs})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new We(this.privateKey.sign(e))}};Bt.BLINDER_LENGTH=31;var gt=Bt;function Zs(){return Qs(gt.BLINDER_LENGTH)}import Xs from"eventemitter3";import{jwtDecode as ea}from"jwt-decode";function Nn(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var zt=class zt extends S{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:u,pepper:d,proof:l,proofFetchCallback:y,jwt:p,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?c.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=u,this.jwt=p,this.emitter=new Xs,this.proofOrPromise=l,l instanceof ae)this.proof=l;else{if(y===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async C=>{await y(C),this.emitter.removeAllListeners()}),this.init(l)}let f=T.fromHexInput(d).toUint8Array();if(f.length!==zt.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${zt.PEPPER_LENGTH}`);if(this.pepper=f,g!==void 0){if(T.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=T.hexInputToUint8Array(g)}}getAnyPublicKey(){return new k(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=c.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=gt.deserialize(t),u=ae.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:u,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new O(this.sign(t)),i=new k(this.publicKey);return new X(i,r)}signTransactionWithAuthenticator(t){let r=new O(this.signTransaction(t)),i=new k(this.publicKey);return new X(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw b.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw b.fromErrorType({type:2});let r=ea(this.jwt,{header:!0});if(r.kid===void 0)throw b.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 Mt({aptosConfig:t});if(T.hexInputToString(i.hash())!==T.hexInputToString(this.verificationKeyHash))throw b.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 zt.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw b.fromErrorType({type:0});if(this.proof===void 0)throw b.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 ue({jwtHeader:li(this.jwt.split(".")[0]),ephemeralCertificate:new Nt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw b.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=Bn(t),o=new zn(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw b.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=Bn(t);return new zn(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return wr(t)}};zt.PEPPER_LENGTH=31;var ce=zt,zn=class extends S{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 Je(this.bcsToBytes(),this.domainSeparator)}};var Ne=class n extends ce{constructor(e){let t=E.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:u}=ce.partialDeserialize(e),{iss:d,aud:l,uidVal:y}=ze({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:y,aud:l,pepper:a,jwt:o,verificationKeyHash:u})}static fromBytes(e){return n.deserialize(new L(T.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:u,verificationKey:d}=e,{iss:l,aud:y,uidVal:p}=ze({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:p,aud:y,pepper:s,jwt:i,proofFetchCallback:u,verificationKeyHash:d?d.hash():void 0})}};var mt=class n extends ce{constructor(e){let t=q.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=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:u}=ce.partialDeserialize(e),d=c.deserialize(e),{iss:l,aud:y,uidVal:p}=ze({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:p,aud:y,pepper:a,jwt:o,verificationKeyHash:u,jwkAddress:d})}static fromBytes(e){return n.deserialize(L.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:u="sub",proofFetchCallback:d,verificationKey:l}=e,{iss:y,aud:p,uidVal:g}=ze({jwt:i,uidKey:u});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:y,uidKey:u,uidVal:g,aud:p,pepper:s,jwkAddress:c.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:l?l.hash():void 0})}};var sn=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof ee?le.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?c.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,u)=>[a,o[u]]);s.sort((a,u)=>a[1]-u[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{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new Se({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new xe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new xe(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof ce).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof ce).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 Pe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Pe({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var Mn=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?c.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,u)=>[a,o[u]]);s.sort((a,u)=>a[1]-u[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ke(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ke(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new _e({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(ye(e))}};function Zi(n){let e=n.deserializeUleb128AsU32();if(!Object.values(Q).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:c.deserialize(n),signingScheme:e}}function Yi(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 Xi(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=gt.deserialize(n),o=ae.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var eo;(y=>{function n(p){let g=new j;switch(g.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(g),p.signingScheme){case 0:return p.privateKey.serialize(g),g.toUint8Array();case 2:{if(!br(p))throw new Error("Account is not a SingleKeySigner");let f=p.getAnyPublicKey();switch(g.serializeU32AsUleb128(f.variant),f.variant){case 3:return Yi(p,g),g.toUint8Array();case 4:{let C=p;return Yi(C,g),C.publicKey.jwkAddress.serialize(g),g.serializeBool(C.audless),g.toUint8Array()}case 1:case 0:return p.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${f.variant}`)}}case 3:{let f=p;return f.publicKey.serialize(g),g.serializeU32AsUleb128(f.signers.length),f.signers.forEach(C=>{g.serializeFixedBytes(n(C))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}y.toBytes=n;function e(p){return T.hexInputToStringWithoutPrefix(n(p))}y.toHexStringWithoutPrefix=e;function t(p){return T.hexInputToString(n(p))}y.toHexString=t;function r(p){let{address:g,signingScheme:f}=Zi(p);switch(f){case 0:{let C=$.deserialize(p);return new ee({privateKey:C,address:g})}case 2:{let C=p.deserializeUleb128AsU32();switch(C){case 0:{let M=$.deserialize(p);return new le({privateKey:M,address:g})}case 1:{let M=nt.deserialize(p);return new le({privateKey:M,address:g})}case 3:{let M=Xi(p),Ee=ze(M);return new Ne({...M,...Ee})}case 4:{let M=Xi(p),Ee=c.deserialize(p),Le=p.deserializeBool(),$e=ze(M);return new mt({...M,...$e,jwkAddress:Ee,audless:Le})}default:throw new Error(`Unsupported public key variant ${C}`)}}case 3:{let C=Se.deserialize(p),M=p.deserializeUleb128AsU32(),Ee=new Array;for(let Le=0;Le<M;Le+=1){let $e=r(p);if(!br($e)&&!($e instanceof ee))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Ee.push($e)}return new sn({multiKey:C,signers:Ee,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${f}`)}}y.deserialize=r;function i(p){let g=d(p);if(!(g instanceof Ne))throw new Error("Deserialization of KeylessAccount failed");return g}y.keylessAccountFromHex=i;function o(p){let g=d(p);if(!(g instanceof mt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}y.federatedKeylessAccountFromHex=o;function s(p){let g=d(p);if(!(g instanceof sn))throw new Error("Deserialization of MultiKeyAccount failed");return g}y.multiKeyAccountFromHex=s;function a(p){let g=d(p);if(!(g instanceof le))throw new Error("Deserialization of SingleKeyAccount failed");return g}y.singleKeyAccountFromHex=a;function u(p){let g=d(p);if(!(g instanceof ee))throw new Error("Deserialization of Ed25519Account failed");return g}y.ed25519AccountFromHex=u;function d(p){return r(L.fromHex(p))}y.fromHex=d;function l(p){return d(p)}y.fromBytes=l})(eo||(eo={}));import{sha3_256 as to}from"@noble/hashes/sha3";var Vn=class n extends Be{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!vt(i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new ti(this.accountAddress),this.sign=o=>new ir(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new j;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:r??t.accountAddress,authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new rt(this.authenticationFunction,to(t),this.sign(to(t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(ye(t))}signTransaction(t){return this.sign(ye(t))}setSigner(t){this.sign=r=>new ir(t(r))}};import{sha3_256 as Tr}from"@noble/hashes/sha3";var an=class an extends Vn{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new c(an.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!vt(e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=Tr.create(),a=new j;c.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let u=new j;return u.serializeBytes(t),s.update(u.toUint8Array()),s.update(new Uint8Array([an.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new rt(this.authenticationFunction,Tr(e),this.sign(Tr(e)).value,this.abstractPublicKey)}};an.ADDRESS_DOMAIN_SEPERATOR=5;var no=an;import{sha3_256 as da}from"@noble/hashes/sha3";function ro(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function io(n){return!!n.match(/\s/)}function ta(n){return!!n.match(/^T[0-9]+$/)}function na(n){return!!n.match(/^&.+$/)}function ra(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 ia(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!io(r))break}return t}var oa=(f=>(f.InvalidTypeTag="unknown type",f.UnexpectedGenericType="unexpected generic type",f.UnexpectedTypeArgumentClose="unexpected '>'",f.UnexpectedWhitespaceCharacter="unexpected whitespace character",f.UnexpectedComma="unexpected ','",f.TypeArgumentCountMismatch="type argument count doesn't match expected amount",f.MissingTypeArgumentClose="no matching '>' for '<'",f.MissingTypeArgument="no type argument before ','",f.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",f.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",f.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",f.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",f.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",f.InvalidAddress="struct address must be valid",f))(oa||{}),N=class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Ae(n,e){let t=e?.allowGenerics??!1,r=[],i=[],o=[],s=0,a="",u=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:u,savedStr:a,savedTypes:o}),a="",o=[],u=1;else if(d===">"){if(a!==""){let f=cn(a,i,t);o.push(f)}let l=r.pop();if(l===void 0)throw new N(n,"unexpected '>'");if(u!==o.length)throw new N(n,"type argument count doesn't match expected amount");let{savedStr:y,savedTypes:p,savedExpectedTypes:g}=l;i=o,o=p,a=y,u=g}else if(d===","){if(r.length===0)throw new N(n,"unexpected ','");if(a.length===0)throw new N(n,"no type argument before ','");let l=cn(a,i,t);i=[],o.push(l),a="",u+=1}else if(io(d)){let l=!1;if(a.length!==0){let p=cn(a,i,t);i=[],o.push(p),a="",l=!0}s=ia(n,s);let y=n[s];if(s<n.length&&l&&y!==","&&y!==">")throw new N(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new N(n,"no matching '>' for '<'");switch(o.length){case 0:return cn(a,i,t);case 1:if(a==="")return o[0];throw new N(n,"unexpected ','");default:throw new N(n,"unexpected whitespace character")}}function cn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(ra(i)&&e.length>0)throw new N(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new it;case"bool":return new G;case"address":return new F;case"u8":return new oe;case"u16":return new Fe;case"u32":return new Ue;case"u64":return new H;case"u128":return new De;case"u256":return new Re;case"vector":if(e.length!==1)throw new N(n,"vector type expected to have exactly one type argument");return new K(e[0]);default:if(na(r)){let a=r.substring(1);return new Rn(cn(a,e,t))}if(ta(r)){if(t)return new D(Number(r.split("T")[1]));throw new N(n,"unexpected generic type")}if(!r.match(/:/))throw new N(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new N(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=c.fromString(o[0])}catch{throw new N(n,"struct address must be valid")}if(!ro(o[1]))throw new N(n,"module name must only contain alphanumeric or '_' characters");if(!ro(o[2]))throw new N(n,"struct name must only contain alphanumeric or '_' characters");return new m(new Ke(s,new _(o[1]),new _(o[2]),e))}}function oo(n){return typeof n=="boolean"}function Me(n){return typeof n=="string"}function sa(n){return typeof n=="number"}function Hn(n){if(sa(n))return n;if(Me(n)&&n!=="")return Number.parseInt(n,10)}function Ln(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function so(n){return n==null}function ao(n){return Sr(n)||xr(n)||Kr(n)||Cr(n)||Er(n)||Ir(n)||vr(n)||$n(n)||Pr(n)||aa(n)||n instanceof P||n instanceof J}function Sr(n){return n instanceof B}function $n(n){return n instanceof c}function Pr(n){return n instanceof v}function aa(n){return n instanceof wt}function xr(n){return n instanceof he}function Kr(n){return n instanceof St}function Cr(n){return n instanceof Pt}function Er(n){return n instanceof be}function Ir(n){return n instanceof xt}function vr(n){return n instanceof Kt}function co(n){return"bytecode"in n}function I(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function uo(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var ca=new TextEncoder;function Vt(n){return n?.map(e=>Me(e)?Ae(e):e)??[]}async function kr(n,e,t){return(await qn({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Fr(n,e,t,r){let i=await kr(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function Am(n,e,t,r){let i=await Fr(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(Ae(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function po(n,e,t,r){let i=await Fr(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=uo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ae(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function lo(n,e,t,r){let i=await Fr(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(Ae(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ae(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function fm(n,e,t,r,i){return n instanceof Tt?n:Tt.newBytes(Ht(e,t,n,r,i).bcsToBytes())}function Ht(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(u=>u.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=Ae(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return yt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function yt(n,e,t,r,i,o){return ao(n)?(_r(e,n,t),n):ua(n,e,t,r,i,o)}function ua(n,e,t,r,i,o){if(e.isBool()){if(oo(n))return new B(n);if(Me(n)){if(n==="true")return new B(!0);if(n==="false")return new B(!1)}I("boolean",t)}if(e.isAddress()){if(Me(n))return c.fromString(n);I("string | AccountAddress",t)}if(e.isU8()){let s=Hn(n);if(s!==void 0)return new he(s);I("number | string",t)}if(e.isU16()){let s=Hn(n);if(s!==void 0)return new St(s);I("number | string",t)}if(e.isU32()){let s=Hn(n);if(s!==void 0)return new Pt(s);I("number | string",t)}if(e.isU64()){if(Ln(n))return new be(BigInt(n));I("bigint | number | string",t)}if(e.isU128()){if(Ln(n))return new xt(BigInt(n));I("bigint | number | string",t)}if(e.isU256()){if(Ln(n))return new Kt(BigInt(n));I("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return yt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(Me(n))return P.U8(ca.encode(n));if(n instanceof Uint8Array)return P.U8(n);if(n instanceof ArrayBuffer)return P.U8(new Uint8Array(n))}if(Me(n)&&n.startsWith("["))return yt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new P(n.map(s=>yt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(Me(n))return new v(n);I("string",t)}if(e.isObject()){if(Me(n))return c.fromString(n);I("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new wt(n);I("Uint8Array",t)}if(e.isOption()){if(so(n)){let a=e.value.typeArgs[0];return a instanceof G?new J(null):a instanceof F?new J(null):a instanceof oe?new J(null):a instanceof Fe?new J(null):a instanceof Ue?new J(null):a instanceof H?new J(null):a instanceof De?new J(null):a instanceof Re?new J(null):new J(null)}return new J(yt(n,e.value.typeArgs[0],t,r,i))}if(i?.structs.find(a=>a.name===e.value.name.identifier)?.fields.length===0&&n instanceof Uint8Array)return new wt(n);if(n instanceof Uint8Array&&o?.allowUnknownStructs)return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new wt(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 _r(n,e,t){if(n.isBool()){if(Sr(e))return;I("Bool",t)}if(n.isAddress()){if($n(e))return;I("AccountAddress",t)}if(n.isU8()){if(xr(e))return;I("U8",t)}if(n.isU16()){if(Kr(e))return;I("U16",t)}if(n.isU32()){if(Cr(e))return;I("U32",t)}if(n.isU64()){if(Er(e))return;I("U64",t)}if(n.isU128()){if(Ir(e))return;I("U128",t)}if(n.isU256()){if(vr(e))return;I("U256",t)}if(n.isVector()){if(e instanceof P){e.values.length>0&&_r(n.value,e.values[0],t);return}I("MoveVector",t)}if(n instanceof m){if(n.isString()){if(Pr(e))return;I("MoveString",t)}if(n.isObject()){if($n(e))return;I("AccountAddress",t)}if(n.isOption()){if(e instanceof J){e.value!==void 0&&_r(n.value.typeArgs[0],e.value,t);return}I("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Wn(n){if(co(n))return ga(n);let{moduleAddress:e,moduleName:t,functionName:r}=Y(n.function),i=await Ao({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:po});return pa({...n,abi:i})}function pa(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=Y(n.function),o=Vt(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((u,d)=>Ht(n.function,e,u,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=at.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let u=c.from(n.multisigAddress);return new tn(new rn(u,new on(a)))}return new en(a)}async function go(n){let{moduleAddress:e,moduleName:t,functionName:r}=Y(n.function),i=await Ao({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:lo});return la({abi:i,...n})}function la(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=Y(n.function),o=Vt(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((a,u)=>Ht(n.function,e,a,u,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 at.build(`${t}::${r}`,i,o,s)}function ga(n){return new st(new nn(T.fromHexInput(n.bytecode).toUint8Array(),Vt(n.typeArguments),n.functionArguments))}async function Ur(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>sr[e.network]?{chainId:sr[e.network]}:{chainId:(await _n({aptosConfig:e})).chain_id},a=async()=>i?.gasUnitPrice?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Fn({aptosConfig:e})).gas_estimate},u=async()=>{let C=async()=>i?.accountSequenceNumber!==void 0?i.accountSequenceNumber:(await kn({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&c.from(o).equals(c.ZERO))try{return await C()}catch{return 0}else return C()},[{chainId:d},{gasEstimate:l},y]=await Promise.all([s(),a(),u()]),{maxGasAmount:p,gasUnitPrice:g,expireTimestamp:f}={maxGasAmount:i?.maxGasAmount?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:i?.gasUnitPrice??BigInt(l),expireTimestamp:i?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+20)};return new pe(c.from(t),BigInt(y),r,BigInt(p),BigInt(g),BigInt(f),new In(d))}async function Dr(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Ur({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=n.secondarySignerAddresses?.map(u=>c.from(u))??[];return new Gn(s,a,n.feePayerAddress?c.from(n.feePayerAddress):void 0)}return new Gt(s,n.feePayerAddress?c.from(n.feePayerAddress):void 0)}function mo(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Lt(e);if(t.feePayerAddress){let a=new ut(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),u=[];t.secondarySignerAddresses&&(r?u=r.map(y=>Lt(y)):u=Array.from({length:t.secondarySignerAddresses.length},()=>Lt(void 0)));let d=Lt(i),l=new lt(o,t.secondarySignerAddresses??[],u,{address:t.feePayerAddress,authenticator:d});return new Ge(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new ct(t.rawTransaction,t.secondarySignerAddresses),u=[];r?u=r.map(l=>Lt(l)):u=Array.from({length:t.secondarySignerAddresses.length},()=>Lt(void 0));let d=new pt(o,t.secondarySignerAddresses,u);return new Ge(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof me)s=new dt(o.public_key,o.signature);else if(o instanceof X||o instanceof xe)s=new Qe(o);else if(o instanceof Rt)s=new Qe(o);else throw new Error("Invalid public key");return new Ge(t.rawTransaction,s).bcsToBytes()}function Lt(n){if(!n)return new Rt;let t=E.isInstance(n)||q.isInstance(n)||Ft.isInstance(n)?new k(n):n,r=new z(new Uint8Array(64));if(R.isInstance(t))return new me(t,r);if(k.isInstance(t))return E.isInstance(t.publicKey)?new X(t,new O(ue.getSimulationSignature())):new X(t,new O(r));if(Se.isInstance(t))return new xe(t,new Pe({signatures:t.publicKeys.map(i=>E.isInstance(i.publicKey)||q.isInstance(i.publicKey)?new O(ue.getSimulationSignature()):new O(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Rr(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=ui(V,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 lt(i,e.secondarySignerAddresses??[],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 pt(i,e.secondarySignerAddresses,r)}else i instanceof me?o=new dt(i.public_key,i.signature):i instanceof ke?o=new Ot(i.public_key,i.signature):o=new Qe(i);return new Ge(e.rawTransaction,o).bcsToBytes()}function yo(n){let e=da.create();for(let t of n)e.update(t);return e.digest()}var ma=yo(["APTOS::Transaction"]);function Vm(n){let e=Rr(n);return new T(yo([ma,new Uint8Array([0]),e])).toString()}async function Ao({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:kt(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}import{ScriptComposerWasm as Or}from"@aptos-labs/script-composer-pack";var jn=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await import("@aptos-labs/script-composer-pack"),{TransactionComposer:t,initSync:r}=e;Or.isInitialized||Or.init(),r({module:Or.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=Y(e.function),o=this.config.getRequestUrl("Fullnode");if(await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0)for(let l of e.typeArguments)await this.builder.load_type_tag(o,l.toString());let s=Vt(e.typeArguments),a=await kr(t,r,this.config);if(!a)throw new Error(`Could not find module ABI for '${t}::${r}'`);let u=a?.exposed_functions.find(l=>l.name===i);if(!u)throw new Error(`Could not find function ABI for '${t}::${r}::${i}'`);if(s.length!==u.generic_type_params.length)throw new Error(`Type argument count mismatch, expected ${u?.generic_type_params.length}, received ${s.length}`);let d=e.functionArguments.map((l,y)=>l instanceof Tt?l:Tt.newBytes(Ht(i,a,l,y,s,{allowUnknownStructs:!0}).bcsToBytes()));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(l=>l.toString()),d)}build(){return this.builder.generate_batched_calls(!0)}};async function A(n){let e=await Aa(n);return fa(n,e)}async function Aa(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Wn(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Wn(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Wn(r)),i}async function fa(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(ha(n)&&(o=c.ZERO.toString()),ba(n)){let{secondarySignerAddresses:s}=n;return Dr({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Dr({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function ha(n){return n.withFeePayer===!0}function ba(n){return"secondarySignerAddresses"in n}function fo(n){let{transaction:e}=n;return ye(e)}function Qn(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Jn(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,Qn({signer:e,transaction:t})}async function Gr(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=mo({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:u}=await _t({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:n.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:n.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:n.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return u}async function un(n){let{aptosConfig:e}=n,t=Rr({...n});try{let{data:r}=await _t({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=Ge.deserialize(new L(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof E||i.authenticator.sender.public_key.publicKey instanceof q)&&await ce.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function Ze(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;Nn(t)&&await t.checkKeylessAccountValidity(e),Nn(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Jn({signer:r,transaction:i}),s=Qn({signer:t,transaction:i});return un({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ho(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;Nn(r)&&await r.checkKeylessAccountValidity(e);let o=Jn({signer:r,transaction:i});return un({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var wa={typeParameters:[],parameters:[K.u8(),new K(K.u8())]};async function bo(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>P.U8(a));return A({aptosConfig:e,sender:c.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[P.U8(r),new P(s)],abi:wa},options:o})}async function At(n){return kn(n)}async function To(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return cr({aptosConfig:e,originMethod:"getModules",path:`accounts/${c.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??1e3}})}async function So(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await ur({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${c.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{modules:i.data,cursor:o}}async function qn(n){return Ni(n)}async function Po(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return fi({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${c.from(t).toString()}/transactions`,params:{start:r?.offset,limit:r?.limit}})}async function xo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return cr({aptosConfig:e,originMethod:"getResources",path:`accounts/${c.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??999}})}async function Ko(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await ur({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${c.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{resources:i.data,cursor:o}}async function zr(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await tt({aptosConfig:e,originMethod:"getResource",path:`accounts/${c.from(t).toString()}/resource/${r}`,params:{ledger_version:i?.ledgerVersion}});return o.data}async function $t(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await zr({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=c.from(t);try{let a=await Mi({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return c.from(a)}catch(a){if(a instanceof Ai&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Co(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:c.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Ei,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 Eo(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:c.from(t).toStringLong()},amount:{_gt:0}};r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard});let s={query:Ki,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Io(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=c.from(t).toStringLong(),s=c.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};i?.tokenStandard&&(a.token_standard={_eq:i?.tokenStandard});let u={query:Ci,variables:{where_condition:a,offset:i?.offset,limit:i?.limit,order_by:i?.orderBy}};return(await w({aptosConfig:e,query:u,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function vo(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:c.from(t).toStringLong()}};r?.tokenStandard&&(o.current_collection={token_standard:{_eq:r?.tokenStandard}});let s={query:xi,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function _o(n){let{aptosConfig:e,accountAddress:t}=n,r=c.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Ii,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Wy(n){let{aptosConfig:e,accountAddress:t,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=c.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Ie?s=c.A.toStringLong():s=En(c.A,r).toStringLong();else if(r===void 0&&i!==void 0){let l=c.from(i);s=l.toStringLong(),l===c.A&&(o=Ie)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=c.from(t).toStringLong(),u={asset_type:{_eq:s}};o!==void 0&&(u={asset_type:{_in:[o,s]}});let d=await Nr({aptosConfig:e,accountAddress:a,options:{where:u}});return d[0]?d[0].amount:0}async function Nr(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=c.from(t).toStringLong(),o={...r?.where,owner_address:{_eq:i}},s={query:Pi,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function ko(n){let{aptosConfig:e,accountAddress:t}=n,r=c.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Si,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 Fo(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:c.from(t).toStringLong()}},s={query:vn,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Uo(n){let{aptosConfig:e,privateKey:t}=n,r=new k(t.publicKey());if(t instanceof nt){let o=Z.fromPublicKey({publicKey:r}).derivedAddress();return Be.fromPrivateKey({privateKey:t,address:o})}if(t instanceof $){let i=Z.fromPublicKey({publicKey:r.publicKey});if(await wo({authKey:i,aptosConfig:e})){let u=i.derivedAddress();return Be.fromPrivateKey({privateKey:t,address:u,legacy:!0})}let s=Z.fromPublicKey({publicKey:r});if(await wo({authKey:s,aptosConfig:e})){let u=s.derivedAddress();return Be.fromPrivateKey({privateKey:t,address:u,legacy:!1})}}throw new Error(`Can't derive account from private key ${t}`)}async function wo(n){let{aptosConfig:e,authKey:t}=n,r=await $t({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await At({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()}`)}}var Ta={typeParameters:[],parameters:[new oe,K.u8(),new oe,K.u8(),K.u8(),K.u8()]};async function Do(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r}=n;if("toNewPrivateKey"in n)return Br({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey});let i;if("toAccount"in n){if(n.toAccount instanceof ee)return Br({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof Mn)return Br({aptosConfig:e,fromAccount:t,toAccount:n.toAccount});i=n.toAccount.publicKey.authKey()}else if("toAuthKey"in n)i=n.toAuthKey;else throw new Error("Invalid arguments");let o=await Pa({aptosConfig:e,fromAccount:t,toAuthKey:i});if(r===!0)return o;let s=await je({aptosConfig:e,transactionHash:o.hash});if(!s.success)throw new Error(`Failed to rotate authentication key - ${s}`);let a=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return Ze({aptosConfig:e,signer:n.toAccount,transaction:a})}async function Br(n){let{aptosConfig:e,fromAccount:t}=n,r=await At({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=Be.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new Ti({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:c.from(r.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),a=t.sign(s),u=i.sign(s),d=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new he(t.signingScheme),P.U8(t.publicKey.toUint8Array()),new he(i.signingScheme),P.U8(i.publicKey.toUint8Array()),P.U8(a.toUint8Array()),P.U8(u.toUint8Array())],abi:Ta}});return Ze({aptosConfig:e,signer:t,transaction:d})}var Sa={typeParameters:[],parameters:[K.u8()]};async function Pa(n){let{aptosConfig:e,fromAccount:t,toAuthKey:r}=n,i=r,o=await A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[P.U8(i.toUint8Array())],abi:Sa}});return Ze({aptosConfig:e,signer:t,transaction:o})}async function te(n){let{aptosConfig:e,payload:t,options:r}=n,i=await go({...t,aptosConfig:e}),o=new j;i.serialize(o);let s=o.toUint8Array(),{data:a}=await _t({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:r?.ledgerVersion},body:s});return a}async function Ro(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await _t({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:r?.ledgerVersion},body:{function:t.function,type_arguments:t.typeArguments??[],arguments:t.functionArguments??[]}});return i}async function Oo(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=Y(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new m(x()),new m(x())]}},options:i})}async function Go(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=Y(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new m(x()),new m(x())]}},options:i})}async function Bo(n){let{aptosConfig:e,sender:t,options:r}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var ft=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=Y(e.authenticationFunction);return t?.some(s=>c.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 Oo({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Go({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Bo({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await te({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[c.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:c.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var dn=class{constructor(e){this.config=e;this.abstraction=new ft(e)}async getAccountInfo(e){return At({aptosConfig:this.config,...e})}async getAccountModules(e){return To({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return So({aptosConfig:this.config,...e})}async getAccountModule(e){return qn({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Po({aptosConfig:this.config,...e})}async getAccountResources(e){return xo({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Ko({aptosConfig:this.config,...e})}async getAccountResource(e){return zr({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return $t({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Co({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Eo({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Io({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),vo({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),_o({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Nr({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ko({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Ie,faMetadataAddress:si,...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
|
|
2
|
-
compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
|
|
3
|
-
will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await kt(async()=>{try{let d=(await te({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(d.vec.length>0&&yi(d.vec[0]))return mi(d.vec[0])}catch{}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=c.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Ie?a=c.A.toStringLong():a=En(c.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=c.from(i);a=d.toStringLong(),d===c.A&&(s=Ie)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[d]=await te({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(d,10)}let[u]=await te({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(u,10)}async getAccountOwnedObjects(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Fo({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return Uo({aptosConfig:this.config,...e})}};var xa={typeParameters:[{constraints:[]}],parameters:[new F,new H]};async function zo(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[o??Ie],functionArguments:[r,i],abi:xa},options:s})}var pn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return zo({aptosConfig:this.config,...e})}};var Ye={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},ge="0x4::token::Token";async function No(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:c.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:Oi,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Mo(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:c.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:lr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Vo(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:c.from(t).toStringLong()},amount:{_gt:0}},o={query:lr,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ho(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:c.from(t).toStringLong()}},o={query:Ri,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ka={typeParameters:[],parameters:[new m(x()),new H,new m(x()),new m(x()),new G,new G,new G,new G,new G,new G,new G,new G,new G,new H,new H]};async function Lo(n){let{aptosConfig:e,options:t,creator:r}=n;return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new v(n.description),new be(n.maxSupply??Zr),new v(n.name),new v(n.uri),new B(n.mutableDescription??!0),new B(n.mutableRoyalty??!0),new B(n.mutableURI??!0),new B(n.mutableTokenDescription??!0),new B(n.mutableTokenName??!0),new B(n.mutableTokenProperties??!0),new B(n.mutableTokenURI??!0),new B(n.tokensBurnableByCreator??!0),new B(n.tokensFreezableByCreator??!0),new be(n.royaltyNumerator??0),new be(n.royaltyDenominator??1)],abi:Ka},options:t})}async function Wt(n){let{aptosConfig:e,options:t}=n,r=t?.where;t?.tokenStandard&&(r.token_standard={_eq:t?.tokenStandard??"v2"});let i={query:vi,variables:{where_condition:r,offset:t?.offset,limit:t?.limit}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function $o(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=c.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),Wt({aptosConfig:e,options:{...i,where:s}})}async function qo(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:c.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),Wt({aptosConfig:e,options:{...r,where:o}})}async function Wo(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:c.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),Wt({aptosConfig:e,options:{...r,where:o}})}async function jo(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=c.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return r?.tokenStandard&&(s.token_standard={_eq:r?.tokenStandard??"v2"}),(await Wt({aptosConfig:i,options:{where:s}})).collection_id}var Ca={typeParameters:[],parameters:[new m(x()),new m(x()),new m(x()),new m(x()),new K(new m(x())),new K(new m(x())),new K(K.u8())]};async function Qo(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:u,propertyTypes:d,propertyValues:l}=n,y=d?.map(p=>Ye[p]);return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new v(i),new v(o),new v(s),new v(a),P.MoveString(u??[]),P.MoveString(y??[]),us(l??[],y??[])],abi:Ca},options:t})}var Ea={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new F]};async function Jo(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[o??ge],functionArguments:[c.from(r),c.from(i)],abi:Ea},options:s})}var Ia={typeParameters:[],parameters:[new m(x()),new m(x()),new m(x()),new m(x()),new K(new m(x())),new K(new m(x())),new K(K.u8()),new F]};async function Zo(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:u,propertyTypes:d,propertyValues:l,options:y}=n;if(u?.length!==l?.length)throw new Error("Property keys and property values counts do not match");if(d?.length!==l?.length)throw new Error("Property types and property values counts do not match");let p=d?.map(g=>Ye[g]);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,P.MoveString(u??[]),P.MoveString(p??[]),us(l??[],p??[]),a],abi:Ia},options:y})}var va={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0)))]};async function Yo(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[i??ge],functionArguments:[c.from(r)],abi:va},options:o})}var _a={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0)))]};async function Xo(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[i??ge],functionArguments:[r],abi:_a},options:o})}var ka={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0)))]};async function es(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[i??ge],functionArguments:[r],abi:ka},options:o})}var Fa={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function ts(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[o??ge],functionArguments:[c.from(i),new v(r)],abi:Fa},options:s})}var Ua={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function ns(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[o??ge],functionArguments:[c.from(i),new v(r)],abi:Ua},options:s})}var Da={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function rs(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[o??ge],functionArguments:[c.from(i),new v(r)],abi:Da},options:s})}var Ra={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x()),new m(x()),K.u8()]};async function is(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:u}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[a??ge],functionArguments:[c.from(s),new v(r),new v(Ye[i]),P.U8(Mr(o,Ye[i]))],abi:Ra},options:u})}var Oa={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x())]};async function os(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[o??ge],functionArguments:[c.from(i),new v(r)],abi:Oa},options:s})}var Ga={typeParameters:[{constraints:["key"]}],parameters:[new m(se(new D(0))),new m(x()),new m(x()),K.u8()]};async function ss(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:u}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[a??ge],functionArguments:[c.from(s),new v(r),new v(Ye[i]),Mr(o,Ye[i])],abi:Ga},options:u})}var Ba={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(se(new D(0))),new m(x()),new D(1)]};async function as(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:u}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[a??ge,Ye[i]],functionArguments:[c.from(s),new v(r),o],abi:Ba},options:u})}var za={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(se(new D(0))),new m(x()),new D(1)]};async function cs(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:u}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[a??ge,Ye[i]],functionArguments:[c.from(s),new v(r),o],abi:za},options:u})}function us(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Mr(n[i],r))}),t}function Mr(n,e){let t=Ae(e);return yt(n,t,0,[]).bcsToBytes()}var ln=class{constructor(e){this.config=e}async getCollectionData(e){await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=c.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),Wt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),$o({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),qo({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Wo({aptosConfig:this.config,...e})}async getCollectionId(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),jo({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),No({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Mo({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vo({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ho({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Lo({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Qo({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Jo({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Zo({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Yo({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Xo({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return es({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return ts({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ns({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return rs({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return is({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return os({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return ss({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return as({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return cs({aptosConfig:this.config,...e})}};var ds=300,Na=n=>{if(n&&n.length>ds)throw new Error(`Event type length exceeds the maximum length of ${ds}`)};async function ps(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 gn({aptosConfig:e,options:{...r,where:i}})}async function ls(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:c.from(e).toStringLong()},creation_number:{_eq:r}};return gn({aptosConfig:t,options:{...i,where:s}})}async function gs(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:c.from(e).toStringLong()},indexed_type:{_eq:r}};return gn({aptosConfig:t,options:{...i,where:s}})}async function gn(n){let{aptosConfig:e,options:t}=n;Na(t?.where?.indexed_type?._eq);let r={query:Fi,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var mn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ps({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),ls({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),gs({aptosConfig:this.config,...e})}async getEvents(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"events_processor"}),gn({aptosConfig:this.config,...e})}};async function ms(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=i?.timeoutSecs||20,{data:s}=await hi({aptosConfig:e,path:"fund",body:{address:c.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],u=await je({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:i?.checkSuccess}});if(u.type==="user_transaction")return u;throw new Error(`Unexpected transaction received for fund account: ${u.type}`)}var yn=class{constructor(e){this.config=e}async fundAccount(e){let t=await ms({aptosConfig:this.config,...e});return(e.options?.waitForIndexer===void 0||e.options?.waitForIndexer)&&await qi({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Zn(n){let{aptosConfig:e,options:t}=n,r={query:Di,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function ys(n){let{aptosConfig:e,options:t}=n,r={query:Ui,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function As(n){let{aptosConfig:e,options:t}=n,r={query:_i,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var fs={typeParameters:[{constraints:[]}],parameters:[Ae("0x1::object::Object"),new F,new H]};async function hs(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:fs},options:s})}async function bs(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:fs},options:s})}var An=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Zn({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await Zn({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),await Zn({aptosConfig:this.config,options:{where:{creator_address:{_eq:c.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ys({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),As({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return hs({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return bs({aptosConfig:this.config,...e})}};var fn=class{constructor(e){this.config=e}async getLedgerInfo(){return _n({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Wi({aptosConfig:this.config,...e})}async getBlockByHeight(e){return ji({aptosConfig:this.config,...e})}async view(e){return te({aptosConfig:this.config,...e})}async viewJson(e){return Ro({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Gi({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Bi({aptosConfig:this.config})}async getProcessorStatus(e){return zi({aptosConfig:this.config,processorType:e})}};var ws=["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 Ts(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Xe(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(!Ts(e))throw new Error(`${e} is not valid. ${ws}`);if(t&&!Ts(t))throw new Error(`${t} is not valid. ${ws}`);return{domainName:t||e,subdomainName:t?e:void 0}}var Ma=(t=>(t[t.Independent=0]="Independent",t[t.FollowsDomain=1]="FollowsDomain",t))(Ma||{});function Ss(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 ch="0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",Va="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Ha={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Va,custom:null,devnet:null};function Ve(n){let e=Ha[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Yn=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ps(n){let{aptosConfig:e,name:t}=n,r=Ve(e),{domainName:i,subdomainName:o}=Xe(t),s=await te({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Yn(s[0]);return a?c.from(a):void 0}async function xs(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:u}=n,d=Ve(e),{domainName:l,subdomainName:y}=Xe(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(y&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!y)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let M=t.years??1;if(M!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Le=M*31536e3;return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[l,Le,o,s]},options:a})}if(!y)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await Vr({aptosConfig:e,name:l});if(!g)throw new Error("The domain does not exist");let f=t.policy==="subdomain:independent"?t.expirationDate:g;if(f>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await A({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[l,y,Math.round(f/1e3),t.policy==="subdomain:follow-domain"?1:0,!!u,o,s]},options:a})}async function Vr(n){let{aptosConfig:e,name:t}=n,r=Ve(e),{domainName:i,subdomainName:o}=Xe(t);try{let s=await te({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch{return}}async function Ks(n){let{aptosConfig:e,address:t}=n,r=Ve(e),i=await te({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[c.from(t).toString()]}}),o=Yn(i[1]),s=Yn(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Cs(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=Ve(e);if(!r)return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Xe(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Es(n){let{aptosConfig:e,name:t}=n,r=Ve(e),{domainName:i,subdomainName:o}=Xe(t),s=await te({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Yn(s[0]);return a?c.from(a):void 0}async function Is(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=Ve(e),{domainName:a,subdomainName:u}=Xe(r);return await A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,u,i]},options:o})}async function vs(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=Xe(t),a=(await w({aptosConfig:e,query:{query:Ut,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=hn(a)),Ss(a)?a:void 0}async function _s(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Hr({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:Ut,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(hn)}async function ks(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Hr({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Ut,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(hn)}async function Fs(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Hr({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Ut,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(hn)}async function Us(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Ut,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{...n.options?.where??{},domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(hn).filter(Ss)}async function Hr(n){let{aptosConfig:e}=n,t=Ve(e),[r]=await te({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 Ds(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=Ve(e),a=i*31536e3,{domainName:u,subdomainName:d}=Xe(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 A({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[u,a]},options:o})}function hn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var bn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ps({aptosConfig:this.config,...e})}async getExpiration(e){return Vr({aptosConfig:this.config,...e})}async getTargetAddress(e){return Es({aptosConfig:this.config,...e})}async setTargetAddress(e){return Is({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ks({aptosConfig:this.config,...e})}async setPrimaryName(e){return Cs({aptosConfig:this.config,...e})}async registerName(e){return xs({aptosConfig:this.config,...e})}async renewDomain(e){return Ds({aptosConfig:this.config,...e})}async getName(e){return vs({aptosConfig:this.config,...e})}async getAccountNames(e){return _s({aptosConfig:this.config,...e})}async getAccountDomains(e){return ks({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Fs({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Us({aptosConfig:this.config,...e})}};async function Rs(n){let{aptosConfig:e,poolAddress:t}=n,r=c.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:pr,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 Os(n){let{aptosConfig:e,options:t}=n,r={query:pr,variables:{order_by:t?.orderBy}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Gs(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:ki,variables:{delegatorAddress:c.from(t).toStringLong(),poolAddress:c.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var wn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Rs({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Os({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await h({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Gs({aptosConfig:this.config,...e})}};var Xn=class{constructor(e){this.config=e}async simple(e){return A({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new jn(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Ur({aptosConfig:this.config,payload:st.load(new L(i)),...e});return new Gt(o,e.withFeePayer===!0?c.ZERO:void 0)}async multiAgent(e){return A({aptosConfig:this.config,...e})}};var jt=class{constructor(e){this.config=e}async simple(e){return Gr({aptosConfig:this.config,...e})}async multiAgent(e){return Gr({aptosConfig:this.config,...e})}};bt([mr],jt.prototype,"simple",1),bt([mr],jt.prototype,"multiAgent",1);var Qt=class{constructor(e){this.config=e}async simple(e){return un({aptosConfig:this.config,...e})}async multiAgent(e){return un({aptosConfig:this.config,...e})}};bt([gr],Qt.prototype,"simple",1),bt([gr],Qt.prototype,"multiAgent",1);import $a from"eventemitter3";var er=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 Zt(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=ve();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await Zt(this.sleepTime),ve()-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 At({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await At({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 Zt(this.sleepTime);this.lock=!0;try{await this.update();let e=ve();for(;this.lastUncommintedNumber!==this.currentNumber;)ve()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await Zt(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}}}};import La from"eventemitter3";var Bs="fulfilled",zs=(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(zs||{}),tr=class extends La{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Un;this.transactionsQueue=new Un;this.outstandingTransactions=new Un;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new er(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=Ze({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof yr)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 u=s[a];o=r[a],u.status===Bs?(this.sentTransactions.push([u.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${u.value.hash} has been committed to chain`,transactionHash:u.value.hash}),await this.checkTransaction(u,o)):(this.sentTransactions.push([u.status,o,u.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${u.reason}`,error:u.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof yr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(je({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===Bs?(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 A({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 nr=class extends $a{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new tr(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 Tn=class{constructor(e){this.config=e,this.build=new Xn(this.config),this.simulate=new jt(this.config),this.submit=new Qt(this.config),this.batch=new nr(this.config)}async getTransactions(e){return Vi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Hi({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Li({aptosConfig:this.config,...e})}async isPendingTransaction(e){return $i({aptosConfig:this.config,...e})}async waitForTransaction(e){return je({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Fn({aptosConfig:this.config})}getSigningMessage(e){return fo(e)}async publishPackageTransaction(e){return bo({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Do({aptosConfig:this.config,...e})}sign(e){return Qn({...e})}signAsFeePayer(e){return Jn({...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 Ze({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ho({aptosConfig:this.config,...e})}};import{jwtDecode as Wa}from"jwt-decode";async function rr(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:T.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await bi({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return T.fromHexInput(a.pepper).toUint8Array()}async function Lr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await rr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Mt({aptosConfig:e})).maxExpHorizonSecs}=n;if(T.fromHexInput(i).toUint8Array().length!==Ne.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Ne.PEPPER_LENGTH} bytes`);let a=Wa(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 u={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:T.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:T.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await wi({aptosConfig:e,path:"prove",body:u,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,y=new et({a:l.a,b:l.b,c:l.c});return new ae({proof:new Jt(y,0),trainingWheelsSignature:We.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Ns(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await rr(n)}=n,{verificationKey:a,maxExpHorizonSecs:u}=await Mt({aptosConfig:e}),d=Lr({...n,pepper:s,maxExpHorizonSecs:u}),l=o?d:await d;if(r!==void 0){let g=q.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),f=await $t({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return mt.create({...n,address:f,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let y=E.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await $t({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return Ne.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Ms(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(ci.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(u){let d;throw u instanceof Error?d=`${u.message}`:d=`error unknown - ${u}`,b.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,P.MoveString(a.keys.map(u=>u.kid)),P.MoveString(a.keys.map(u=>u.alg)),P.MoveString(a.keys.map(u=>u.e)),P.MoveString(a.keys.map(u=>u.n))]},options:i})}var Sn=class{constructor(e){this.config=e}async getPepper(e){return rr({aptosConfig:this.config,...e})}async getProof(e){return Lr({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Ns({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Ms({aptosConfig:this.config,...e})}};async function ja(n){let{aptosConfig:e,options:t}=n,r={query:vn,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Vs(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:c.from(t).toStringLong()}};return(await ja({aptosConfig:e,options:{...r,where:o}}))[0]}var Pn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await h({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Vs({aptosConfig:this.config,...e})}};var W=class{constructor(e){this.config=new Qi(e),this.account=new dn(this.config),this.abstraction=new ft(this.config),this.ans=new bn(this.config),this.coin=new pn(this.config),this.digitalAsset=new ln(this.config),this.event=new mn(this.config),this.faucet=new yn(this.config),this.fungibleAsset=new An(this.config),this.general=new fn(this.config),this.staking=new wn(this.config),this.transaction=new Tn(this.config),this.table=new Ar(this.config),this.keyless=new Sn(this.config),this.object=new Pn(this.config)}};function ne(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))})}ne(W,dn,"account");ne(W,ft,"abstraction");ne(W,bn,"ans");ne(W,pn,"coin");ne(W,ln,"digitalAsset");ne(W,mn,"event");ne(W,yn,"faucet");ne(W,An,"fungibleAsset");ne(W,fn,"general");ne(W,wn,"staking");ne(W,Tn,"transaction");ne(W,Ar,"table");ne(W,Sn,"keyless");ne(W,Pn,"object");var Ya=1e7,$r=120,Xa=30,ec=330,tc=120,nc=350,rc=300,ic=93,Ce=class Ce extends qe{constructor(e,t){super();let r=T.fromHexInput(t).toUint8Array();if(r.length!==Ce.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ce.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new j;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),Z.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Dn({...e,publicKey:this}),!0}catch(t){if(t instanceof b)return!1;throw t}}async verifySignatureAsync(e){return hr({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ce(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ce(t,r)}static isPublicKey(e){return e instanceof Ce}static create(e){return Hs(e),new Ce(e.iss,Hs(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=Ls(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 Ce.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}};Ce.ID_COMMITMENT_LENGTH=32;var E=Ce;async function hr(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Mt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof ue))throw b.fromErrorType({type:26,details:"Not a keyless signature"});return Dn({message:r,publicKey:t,signature:i,jwk:o||await wr({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(u){if(a?.throwErrorWithReason)throw u;return!1}}function Dn(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:u}=i;if(!(r instanceof ue))throw b.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ae))throw b.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof et))throw b.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<ve())throw b.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw b.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw b.fromErrorType({type:29});let y=oc({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:y,groth16Proof:l}))throw b.fromErrorType({type:32});if(u){if(!d.trainingWheelsSignature)throw b.fromErrorType({type:30});let p=new Wr(l,y);if(!u.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw b.fromErrorType({type:31})}}function oc(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof E?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ae))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Cn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Et(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Te(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Te(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Te(" ",i.maxExtraFieldBytes))),a.push(Te(Za(t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Te(s.overrideAudVal,$r)),a.push(1n)):(a.push(Te("",$r)),a.push(0n)),It(a)}async function wr(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof E?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof q?t.jwkAddress:void 0;try{s=await cc({aptosConfig:e,jwkAddr:a})}catch(l){throw b.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let u=s.get(o);if(u===void 0)throw b.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=u.find(l=>l.kid===r);if(d===void 0)throw b.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function Hs(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Et(T.fromHexInput(i).toUint8Array()),Te(r,$r),Te(t,ec),Te(e,Xa)];return or(It(o),E.ID_COMMITMENT_LENGTH)}var ue=class n extends we{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 dc(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=Nt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=Ct.deserialize(e),s=We.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Nt(new ae({proof:new Jt(new et({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new Ct(new R(new Uint8Array(32))),ephemeralSignature:new We(new z(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Nt=class n extends we{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(ae.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},xn=class xn extends S{constructor(e){if(super(),this.data=T.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 xn(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=fe.fields,i=r.create(qr(e)),o=r.sqrt(r.add(r.pow(i,3n),xn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return fe.G1.ProjectivePoint.fromAffine({x:i,y:a})}};xn.B=fe.fields.Fp.create(3n);var He=xn;function qr(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,Ja(e)}var Kn=class Kn extends S{constructor(e){if(super(),this.data=T.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 Kn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=fe.fields,s=o.fromBigTuple([qr(t),qr(r)]),a=o.sqrt(o.add(o.pow(s,3n),Kn.B)),u=o.neg(a),l=(a.c1>u.c1||a.c1===u.c1&&a.c0>u.c0)===(i===1)?a:u;return fe.G2.ProjectivePoint.fromAffine({x:s,y:l})}};Kn.B=fe.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var ht=Kn,et=class n extends ni{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new He(t),this.b=new ht(r),this.c=new He(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=He.deserialize(e).bcsToBytes(),r=ht.deserialize(e).bcsToBytes(),i=He.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},Wr=class n extends S{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?or(r,32):T.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(et.deserialize(t),t.deserializeFixedBytes(32))}hash(){return Je(this.bcsToBytes(),this.domainSeparator)}},Jt=class n extends S{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(et.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ae=class n extends we{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 L(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=Jt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(We);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},jr=class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Ya,maxExtraFieldBytes:o=nc,maxJwtHeaderB64Bytes:s=rc,maxIssValBytes:a=tc,maxCommitedEpkBytes:u=ic}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new Ct(new R(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=u}static create(e,t){return new n({verificationKey:new Qr({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},Qr=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new He(t),this.betaG2=new ht(r),this.deltaG2=new ht(i),this.gammaAbcG1=[new He(o[0]),new He(o[1])],this.gammaG2=new ht(s)}hash(){let e=new j;return this.serialize(e),Qa.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})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),u=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),y=this.gammaAbcG1.map($e=>$e.toProjectivePoint()),{Fp12:p}=fe.fields,g=y[0].add(y[1].multiply(t)),f=fe.pairing(g,d),C=fe.pairing(i,o),M=fe.pairing(a,u),Ee=fe.pairing(s,l),Le=p.mul(M,p.mul(f,Ee));return p.eql(C,Le)}catch(i){throw b.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Mt(n){let{aptosConfig:e}=n;try{return await kt(async()=>{let[t,r]=await Promise.all([sc(n),ac(n)]);return jr.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof b?t:b.fromErrorType({type:25,error:t})}}function ze(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=Ls(e)}catch(o){throw b.fromErrorType({type:12,details:`Failed to parse JWT - ${di(o)}`})}if(typeof r.iss!="string")throw b.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw b.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 sc(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await tt({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${c.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw b.fromErrorType({type:22,error:i})}}async function ac(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await tt({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${c.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw b.fromErrorType({type:23,error:i})}}async function cc(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await tt({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${c.from(t).toString()}/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await tt({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let u of s.jwks){let{data:d}=u.variant,l=new L(T.fromHexInput(d).toUint8Array()),y=Jr.deserialize(l);a.push(y)}o.set(Yr(s.issuer),a)}return o}var Jr=class n extends S{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 L(T.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw b.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=gi(this.n),r=uc(e.reverse()).map(i=>Et(i));return r.push(256n),It(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:s,e:o})}};function uc(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function dc(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch{throw new Error("Failed to parse JWT header.")}}export{Ya as a,$r as b,Xa as c,ec as d,tc as e,nc as f,rc as g,ic as h,E as i,hr as j,Dn as k,wr as l,ue as m,Nt as n,et as o,Wr as p,Jt as q,ae as r,jr as s,Qr as t,Mt as u,ze as v,cc as w,Jr as x,dc as y,q as z,k as A,O as B,Yt as C,Se as D,Pe as E,Dt as F,_e as G,V as H,me as I,ke as J,X as K,xe as L,Rt as M,rt as N,Xt as O,U as P,G as Q,oe as R,Fe as S,Ue as T,H as U,De as V,Re as W,F as X,it as Y,Rn as Z,D as _,K as $,m as aa,Ke as ba,Ju as ca,x as da,Zu as ea,se as fa,qs as ga,ot as ha,st as ia,en as ja,tn as ka,at as la,nn as ma,rn as na,on as oa,pe as pa,On as qa,ct as ra,ut as sa,Oe as ta,dt as ua,Ot as va,pt as wa,lt as xa,Qe as ya,Ge as za,Gt as Aa,Gn as Ba,Bn as Ca,Je as Da,sp as Ea,ye as Fa,ee as Ga,br as Ha,le as Ia,Be as Ja,gt as Ka,Nn as La,ce as Ma,zn as Na,Ne as Oa,mt as Pa,sn as Qa,Mn as Ra,Zi as Sa,eo as Ta,Vn as Ua,no as Va,oa as Wa,N as Xa,Ae as Ya,oo as Za,Me as _a,sa as $a,Hn as ab,Ln as bb,so as cb,ao as db,Sr as eb,$n as fb,Pr as gb,aa as hb,xr as ib,Kr as jb,Cr as kb,Er as lb,Ir as mb,vr as nb,co as ob,I as pb,uo as qb,Vt as rb,kr as sb,Fr as tb,Am as ub,po as vb,lo as wb,fm as xb,Ht as yb,yt as zb,Wn as Ab,pa as Bb,go as Cb,la as Db,Ur as Eb,Dr as Fb,mo as Gb,Lt as Hb,Rr as Ib,yo as Jb,Vm as Kb,jn as Lb,A as Mb,Aa as Nb,fa as Ob,fo as Pb,Qn as Qb,Jn as Rb,Gr as Sb,un as Tb,Ze as Ub,ho as Vb,bo as Wb,At as Xb,To as Yb,So as Zb,qn as _b,Po as $b,xo as ac,Ko as bc,zr as cc,$t as dc,Co as ec,Eo as fc,Io as gc,vo as hc,_o as ic,Wy as jc,Nr as kc,ko as lc,Fo as mc,Uo as nc,wo as oc,Do as pc,te as qc,Ro as rc,Oo as sc,Go as tc,Bo as uc,ft as vc,dn as wc,zo as xc,pn as yc,No as zc,Mo as Ac,Vo as Bc,Ho as Cc,Lo as Dc,Wt as Ec,$o as Fc,qo as Gc,Wo as Hc,jo as Ic,Qo as Jc,Jo as Kc,Zo as Lc,Yo as Mc,Xo as Nc,es as Oc,ts as Pc,ns as Qc,rs as Rc,is as Sc,os as Tc,ss as Uc,as as Vc,cs as Wc,ln as Xc,ps as Yc,ls as Zc,gs as _c,gn as $c,mn as ad,ms as bd,yn as cd,Zn as dd,ys as ed,As as fd,hs as gd,bs as hd,An as id,fn as jd,ws as kd,Ts as ld,Xe as md,Ma as nd,Ss as od,ch as pd,Va as qd,Ps as rd,xs as sd,Vr as td,Ks as ud,Cs as vd,Es as wd,Is as xd,vs as yd,_s as zd,ks as Ad,Fs as Bd,Us as Cd,Ds as Dd,bn as Ed,Rs as Fd,Os as Gd,Gs as Hd,wn as Id,Xn as Jd,jt as Kd,Qt as Ld,er as Md,Bs as Nd,zs as Od,tr as Pd,nr as Qd,Tn as Rd,rr as Sd,Lr as Td,Ns as Ud,Ms as Vd,Sn as Wd,ja as Xd,Vs as Yd,Pn as Zd,W as _d};
|
|
4
|
-
//# sourceMappingURL=chunk-TAEOFYOF.mjs.map
|