@aptos-labs/ts-sdk 5.1.2 → 5.1.4
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/{account-147vfOGb.d.ts → account-DefhsHe3.d.ts} +325 -1
- package/dist/common/chunk-HO5ESTN4.js +4 -0
- package/dist/common/chunk-HO5ESTN4.js.map +1 -0
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +34 -34
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-CPwej6wB.d.mts → Ed25519Account-CVg5T_jc.d.mts} +1 -1
- package/dist/esm/account/AbstractKeylessAccount.d.mts +3 -3
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +2 -2
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +2 -2
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +3 -3
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.d.mts +2 -2
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +2 -2
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.d.mts +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +3 -3
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +3 -3
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.d.mts +2 -2
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +3 -3
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +2 -2
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +3 -3
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.d.mts +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/{account-BortO8g2.d.mts → account-DOs8SpoQ.d.mts} +325 -1
- package/dist/esm/api/account/abstraction.d.mts +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.d.mts +2 -2
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +2 -2
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +3 -3
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +1 -1
- package/dist/esm/api/coin.d.mts +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/faucet.d.mts +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +2 -2
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +3 -3
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +3 -3
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.d.mts +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.d.mts +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.d.mts +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +2 -2
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/helpers.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +1 -1
- package/dist/esm/api/utils.d.mts +1 -1
- package/dist/esm/api/utils.mjs +1 -1
- package/dist/esm/bcs/consts.d.mts +14 -2
- package/dist/esm/bcs/consts.mjs +1 -1
- package/dist/esm/bcs/deserializer.d.mts +1 -1
- package/dist/esm/bcs/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.d.mts +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.d.mts +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.d.mts +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.d.mts +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +1 -1
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/chunk-3JDGB4IL.mjs +2 -0
- package/dist/esm/chunk-3JDGB4IL.mjs.map +1 -0
- package/dist/esm/{chunk-N6YTF76Q.mjs → chunk-3P474TWM.mjs} +2 -2
- package/dist/esm/{chunk-TOBQ5UE6.mjs → chunk-43LWUUXS.mjs} +2 -2
- package/dist/esm/chunk-5ABS6RDR.mjs +2 -0
- package/dist/esm/chunk-5ABS6RDR.mjs.map +1 -0
- package/dist/esm/{chunk-WSR5EBJM.mjs → chunk-5FNZUL2Y.mjs} +2 -2
- package/dist/esm/{chunk-XKUIMGKU.mjs → chunk-6IWGTO2J.mjs} +2 -2
- package/dist/esm/{chunk-2OPKZKOB.mjs → chunk-7WIDI4FZ.mjs} +2 -2
- package/dist/esm/{chunk-626KB2UQ.mjs → chunk-AVOTC5EI.mjs} +2 -2
- package/dist/esm/{chunk-Q4W3WJ2U.mjs → chunk-BIQOJ3OK.mjs} +2 -2
- package/dist/esm/{chunk-ZYE7UTJZ.mjs → chunk-C5UZZHA4.mjs} +2 -2
- package/dist/esm/{chunk-MT2RJ7H3.mjs → chunk-DIFSO4N6.mjs} +2 -2
- package/dist/esm/{chunk-YZHAI55C.mjs → chunk-G3HAIETV.mjs} +2 -2
- package/dist/esm/{chunk-RQX6JOEN.mjs → chunk-GRF3NBRO.mjs} +2 -2
- package/dist/esm/{chunk-R7FWJP3N.mjs → chunk-GTRHYHQK.mjs} +2 -2
- package/dist/esm/chunk-I42Z32Q2.mjs +2 -0
- package/dist/esm/chunk-I42Z32Q2.mjs.map +1 -0
- package/dist/esm/{chunk-V74WPKSY.mjs → chunk-IKTH33UN.mjs} +2 -2
- package/dist/esm/chunk-IQPLJ32K.mjs +4 -0
- package/dist/esm/chunk-IQPLJ32K.mjs.map +1 -0
- package/dist/esm/{chunk-LAPXUUHK.mjs → chunk-IXRGCQQU.mjs} +2 -2
- package/dist/esm/{chunk-E2U27PNC.mjs → chunk-JYDVO4K3.mjs} +2 -2
- package/dist/esm/chunk-KUF4DKN5.mjs +2 -0
- package/dist/esm/chunk-LD3I4CYO.mjs +2 -0
- package/dist/esm/{chunk-RGKRCZ36.mjs → chunk-MEG27LEV.mjs} +2 -2
- package/dist/esm/{chunk-LA56UDUK.mjs → chunk-PYVKCTUN.mjs} +2 -2
- package/dist/esm/{chunk-WCMW2L3P.mjs → chunk-QDJDZ3ON.mjs} +2 -2
- package/dist/esm/{chunk-FGFLPH5K.mjs → chunk-RYOICF37.mjs} +2 -2
- package/dist/esm/{chunk-AQW4BUKF.mjs → chunk-SGZPRMLE.mjs} +2 -2
- package/dist/esm/{chunk-QNARIAVM.mjs → chunk-VO3JD6U6.mjs} +2 -2
- package/dist/esm/{chunk-GQ3UIDPQ.mjs → chunk-VS5NYRHW.mjs} +2 -2
- package/dist/esm/{chunk-FC72YL4B.mjs → chunk-VV6OTOMS.mjs} +2 -2
- package/dist/esm/chunk-WGRSKMNQ.mjs +2 -0
- package/dist/esm/{chunk-H3EP5CGP.mjs.map → chunk-WGRSKMNQ.mjs.map} +1 -1
- package/dist/esm/{chunk-PSSIJHHC.mjs → chunk-WOEH45Q2.mjs} +2 -2
- package/dist/esm/chunk-X2TPNKLV.mjs +2 -0
- package/dist/esm/chunk-X2TPNKLV.mjs.map +1 -0
- package/dist/esm/{chunk-YS5IUILF.mjs → chunk-X5BUBEJH.mjs} +2 -2
- package/dist/esm/{chunk-FLZPUYXQ.mjs → chunk-Y426VCPM.mjs} +2 -2
- package/dist/esm/{chunk-FLZPUYXQ.mjs.map → chunk-Y426VCPM.mjs.map} +1 -1
- package/dist/esm/cli/index.d.mts +1 -1
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.mjs +1 -1
- package/dist/esm/cli/move.d.mts +1 -1
- package/dist/esm/client/core.d.mts +1 -1
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/index.d.mts +1 -1
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.d.mts +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.d.mts +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.d.mts +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.d.mts +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.d.mts +1 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/deserializationUtils.d.mts +1 -1
- package/dist/esm/core/crypto/deserializationUtils.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +2 -2
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +2 -2
- package/dist/esm/core/crypto/keyless.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.d.mts +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +1 -1
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/privateKey.d.mts +1 -1
- package/dist/esm/core/crypto/privateKey.mjs +1 -1
- package/dist/esm/core/crypto/proof.d.mts +1 -1
- package/dist/esm/core/crypto/proof.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.d.mts +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.d.mts +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/secp256r1.d.mts +1 -1
- package/dist/esm/core/crypto/secp256r1.mjs +1 -1
- package/dist/esm/core/crypto/signature.d.mts +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/crypto/types.d.mts +1 -1
- package/dist/esm/core/crypto/utils.d.mts +1 -1
- package/dist/esm/core/crypto/utils.mjs +1 -1
- package/dist/esm/core/hex.d.mts +1 -1
- package/dist/esm/core/index.d.mts +2 -2
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.d.mts +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/{federatedKeyless-CTzDAQTu.d.mts → federatedKeyless-CxdU4W95.d.mts} +1 -1
- package/dist/esm/index.d.mts +3 -3
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.d.mts +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +2 -2
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +2 -2
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/faucet.d.mts +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +2 -2
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +3 -3
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.d.mts +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.d.mts +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.d.mts +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +2 -2
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.d.mts +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.d.mts +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.d.mts +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.d.mts +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.d.mts +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.d.mts +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.d.mts +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.d.mts +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.d.mts +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.d.mts +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionArgument.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +2 -2
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +2 -2
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +2 -2
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.d.mts +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.d.mts +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +1 -1
- package/dist/esm/types/index.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +1 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +1 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +19 -18
- package/src/bcs/consts.ts +15 -1
- package/src/bcs/deserializer.ts +105 -0
- package/src/bcs/serializable/movePrimitives.ts +237 -1
- package/src/bcs/serializer.ts +111 -0
- package/src/transactions/typeTag/index.ts +173 -1
- package/src/transactions/typeTag/parser.ts +24 -0
- package/src/types/types.ts +36 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-347THBDE.js +0 -4
- package/dist/common/chunk-347THBDE.js.map +0 -1
- package/dist/esm/chunk-56CNRT2K.mjs +0 -2
- package/dist/esm/chunk-56CNRT2K.mjs.map +0 -1
- package/dist/esm/chunk-CW35YAMN.mjs +0 -2
- package/dist/esm/chunk-EBMEXURY.mjs +0 -2
- package/dist/esm/chunk-EBMEXURY.mjs.map +0 -1
- package/dist/esm/chunk-H3EP5CGP.mjs +0 -2
- package/dist/esm/chunk-MCFQE4GC.mjs +0 -2
- package/dist/esm/chunk-MCFQE4GC.mjs.map +0 -1
- package/dist/esm/chunk-ORMOQWWH.mjs +0 -2
- package/dist/esm/chunk-ORMOQWWH.mjs.map +0 -1
- package/dist/esm/chunk-PJTG745G.mjs +0 -4
- package/dist/esm/chunk-PJTG745G.mjs.map +0 -1
- package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
- /package/dist/esm/{chunk-N6YTF76Q.mjs.map → chunk-3P474TWM.mjs.map} +0 -0
- /package/dist/esm/{chunk-TOBQ5UE6.mjs.map → chunk-43LWUUXS.mjs.map} +0 -0
- /package/dist/esm/{chunk-WSR5EBJM.mjs.map → chunk-5FNZUL2Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-XKUIMGKU.mjs.map → chunk-6IWGTO2J.mjs.map} +0 -0
- /package/dist/esm/{chunk-2OPKZKOB.mjs.map → chunk-7WIDI4FZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-626KB2UQ.mjs.map → chunk-AVOTC5EI.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q4W3WJ2U.mjs.map → chunk-BIQOJ3OK.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZYE7UTJZ.mjs.map → chunk-C5UZZHA4.mjs.map} +0 -0
- /package/dist/esm/{chunk-MT2RJ7H3.mjs.map → chunk-DIFSO4N6.mjs.map} +0 -0
- /package/dist/esm/{chunk-YZHAI55C.mjs.map → chunk-G3HAIETV.mjs.map} +0 -0
- /package/dist/esm/{chunk-RQX6JOEN.mjs.map → chunk-GRF3NBRO.mjs.map} +0 -0
- /package/dist/esm/{chunk-R7FWJP3N.mjs.map → chunk-GTRHYHQK.mjs.map} +0 -0
- /package/dist/esm/{chunk-V74WPKSY.mjs.map → chunk-IKTH33UN.mjs.map} +0 -0
- /package/dist/esm/{chunk-LAPXUUHK.mjs.map → chunk-IXRGCQQU.mjs.map} +0 -0
- /package/dist/esm/{chunk-E2U27PNC.mjs.map → chunk-JYDVO4K3.mjs.map} +0 -0
- /package/dist/esm/{chunk-XJJVJOX5.mjs.map → chunk-KUF4DKN5.mjs.map} +0 -0
- /package/dist/esm/{chunk-CW35YAMN.mjs.map → chunk-LD3I4CYO.mjs.map} +0 -0
- /package/dist/esm/{chunk-RGKRCZ36.mjs.map → chunk-MEG27LEV.mjs.map} +0 -0
- /package/dist/esm/{chunk-LA56UDUK.mjs.map → chunk-PYVKCTUN.mjs.map} +0 -0
- /package/dist/esm/{chunk-WCMW2L3P.mjs.map → chunk-QDJDZ3ON.mjs.map} +0 -0
- /package/dist/esm/{chunk-FGFLPH5K.mjs.map → chunk-RYOICF37.mjs.map} +0 -0
- /package/dist/esm/{chunk-AQW4BUKF.mjs.map → chunk-SGZPRMLE.mjs.map} +0 -0
- /package/dist/esm/{chunk-QNARIAVM.mjs.map → chunk-VO3JD6U6.mjs.map} +0 -0
- /package/dist/esm/{chunk-GQ3UIDPQ.mjs.map → chunk-VS5NYRHW.mjs.map} +0 -0
- /package/dist/esm/{chunk-FC72YL4B.mjs.map → chunk-VV6OTOMS.mjs.map} +0 -0
- /package/dist/esm/{chunk-PSSIJHHC.mjs.map → chunk-WOEH45Q2.mjs.map} +0 -0
- /package/dist/esm/{chunk-YS5IUILF.mjs.map → chunk-X5BUBEJH.mjs.map} +0 -0
package/dist/common/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunk347THBDEjs = require('./chunk-347THBDE.js');var v=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunk347THBDEjs.j.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}assertFinished(){if(this.remaining()!==0)throw new Error("Buffer has remaining bytes")}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunk347THBDEjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),(r&128)===0)break;t+=7}if(e>_chunk347THBDEjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var Ke=class n extends _chunk347THBDEjs.l{constructor(e){super(),this.value=_chunk347THBDEjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var ar=class n extends _chunk347THBDEjs.l{constructor(e){super(),this.value=new Ke(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ke.deserialize(e,t);return new n(r.value)}};var D=class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.n.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new we(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},Z= exports.U8 =class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.p.call(void 0, e,0,_chunk347THBDEjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},Re= exports.U16 =class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.p.call(void 0, e,0,_chunk347THBDEjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},Ue= exports.U32 =class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.p.call(void 0, e,0,_chunk347THBDEjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},$= exports.U64 =class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.p.call(void 0, e,BigInt(0),_chunk347THBDEjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ke= exports.U128 =class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.p.call(void 0, e,BigInt(0),_chunk347THBDEjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},we= exports.U256 =class n extends _chunk347THBDEjs.l{constructor(e){super(),_chunk347THBDEjs.p.call(void 0, e,BigInt(0),_chunk347THBDEjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var S=class n extends _chunk347THBDEjs.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof Z)){new _n(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunk347THBDEjs.j.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new Z(r)))}static U16(e){return new n(e.map(t=>new Re(t)))}static U32(e){return new n(e.map(t=>new Ue(t)))}static U64(e){return new n(e.map(t=>new $(t)))}static U128(e){return new n(e.map(t=>new ke(t)))}static U256(e){return new n(e.map(t=>new we(t)))}static Bool(e){return new n(e.map(t=>new D(t)))}static MoveString(e){return new n(e.map(t=>new C(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},_n= exports.Serialized =class n extends _chunk347THBDEjs.l{constructor(e){super(),this.value=_chunk347THBDEjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new v(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new S(r)}},C= exports.MoveString =class n extends _chunk347THBDEjs.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);S.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},ne= exports.MoveOption =class n extends _chunk347THBDEjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new Z(e):void 0)}static U16(e){return new n(e!=null?new Re(e):void 0)}static U32(e){return new n(e!=null?new Ue(e):void 0)}static U64(e){return new n(e!=null?new $(e):void 0)}static U128(e){return new n(e!=null?new ke(e):void 0)}static U256(e){return new n(e!=null?new we(e):void 0)}static Bool(e){return new n(e!=null?new D(e):void 0)}static MoveString(e){return new n(e!=null?new C(e):void 0)}static deserialize(e,t){let r=S.deserialize(e,t);return new n(r.values[0])}};var _sha3 = require('@noble/hashes/sha3');var ht=class ht extends _chunk347THBDEjs.l{constructor(e){super();let{data:t}=e,r=_chunk347THBDEjs.j.fromHexInput(t);if(r.toUint8Array().length!==ht.LENGTH)throw new Error(`Authentication Key length should be ${ht.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(ht.LENGTH);return new ht({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunk347THBDEjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new ht({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunk347THBDEjs.ba)(this.data.toUint8Array())}};ht.LENGTH=32;var V=ht;var Ze=class extends _chunk347THBDEjs.l{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk347THBDEjs.j.fromHexInput(e).toString()}},ae= exports.AccountPublicKey =class extends Ze{};var F=class extends _chunk347THBDEjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk347THBDEjs.j.fromHexInput(e).toString()}};var xn=class n extends F{constructor(e){super(),this.value=_chunk347THBDEjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},cr= exports.AbstractPublicKey =class extends ae{constructor(e){super(),this.accountAddress=e}authKey(){return new V({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var _ed25519 = require('@noble/curves/ed25519');var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Uo = _interopRequireWildcard(_bip39);var Fc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Oc= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Gc= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Gc||{}),ko= exports.HARDENED_OFFSET =2147483648;function zo(n){return Oc.test(n)}function No(n){return Fc.test(n)}var gi=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Do= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return gi(e,s)},Bc=n=>n.replace(/'/g,""),Fo= exports.splitPath =n=>n.split("/").slice(1).map(Bc),ur= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return Uo.mnemonicToSeedSync(e)};var In=class In{static formatPrivateKey(e,t){let r=In.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk347THBDEjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=In.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk347THBDEjs.j.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunk347THBDEjs.j.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunk347THBDEjs.j.fromHexInput(e);return i}};In.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-",secp256r1:"secp256r1-priv-"};var Se=In;var _jwtdecode = require('jwt-decode');var bt=class n extends Ze{constructor(e){super();let t=e.constructor.name;switch(t){case E.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof E)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(E.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},He= exports.EphemeralSignature =class n extends F{constructor(e){super();let t=e.constructor.name;switch(t){case R.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunk347THBDEjs.j.fromHexInput(e),r=new v(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof R)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(R.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var yi=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],Go=31,ru=16,Oo=(ru-1)*Go;function Le(n,e){let r=new TextEncoder().encode(n);return iu(r,e)}function iu(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=Cn(n,e);return Kt(t)}function ou(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=cu(n,e);return su(t)}function Cn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return ou(n,e).concat([BigInt(n.length)])}function su(n){if(n.length>Oo)throw new Error(`Can't pack more than ${Oo}. Was given ${n.length} bytes`);return au(n,Go).map(e=>vt(e))}function au(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function vt(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function mi(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function cu(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Kt(n){if(n.length>yi.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${yi.length}`);return yi[n.length-1](n)}var dr=class extends _chunk347THBDEjs.l{};var Bo="5.1.2";var Mo={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",shelbynet:"https://api.shelbynet.shelby.xyz/v1/graphql",netna:"https://api.netna.staging.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Vo= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",shelbynet:"https://api.shelbynet.shelby.xyz/v1",netna:"https://api.netna.staging.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ho= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",shelbynet:"https://faucet.shelbynet.shelby.xyz",netna:"https://faucet-dev-netna-us-central1-410192433417.us-central1.run.app",local:"http://127.0.0.1:8081"},fi= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/pepper/v0",netna:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Ai= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/prover/v0",netna:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},hi= exports.Network =(a=>(a.MAINNET="mainnet",a.TESTNET="testnet",a.DEVNET="devnet",a.SHELBYNET="shelbynet",a.NETNA="netna",a.LOCAL="local",a.CUSTOM="custom",a))(hi||{}),bi= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Gl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",shelbynet:"shelbynet",netna:"netna",local:"local",custom:"custom"};var Qt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(Qt||{}),Lo= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,qo= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,pr= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Rt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",$o= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Wo= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Ti= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Qo= exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT ="APTOS::AASigningData",Tt= exports.ProcessorType =(d=>(d.ACCOUNT_RESTORATION_PROCESSOR="account_restoration_processor",d.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",d.DEFAULT="default_processor",d.EVENTS_PROCESSOR="events_processor",d.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",d.STAKE_PROCESSOR="stake_processor",d.TOKEN_V2_PROCESSOR="token_v2_processor",d.USER_TRANSACTION_PROCESSOR="user_transaction_processor",d.OBJECT_PROCESSOR="objects_processor",d))(Tt||{}),jo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Jo(n,e){let t=e.bcsToBytes(),r=new v(t);return n.deserialize(r)}var uu=(s=>(s[s.API_ERROR=0]="API_ERROR",s[s.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",s[s.SESSION_EXPIRED=2]="SESSION_EXPIRED",s[s.INVALID_STATE=3]="INVALID_STATE",s[s.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",s[s.UNKNOWN=5]="UNKNOWN",s))(uu||{}),du= exports.KeylessErrorResolutionTip =(d=>(d.REAUTHENTICATE="Re-authentiate to continue using your keyless account",d.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",d.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",d.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",d.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",d.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",d.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d))(du||{}),lr= exports.KeylessErrorType =(m=>(m[m.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",m[m.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",m[m.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",m[m.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",m[m.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",m[m.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",m[m.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",m[m.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",m[m.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",m[m.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",m[m.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",m[m.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",m[m.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",m[m.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",m[m.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",m[m.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",m[m.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",m[m.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",m[m.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",m[m.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",m[m.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",m[m.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",m[m.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",m[m.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",m[m.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",m[m.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",m[m.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",m[m.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",m[m.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",m[m.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",m[m.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",m[m.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",m[m.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",m[m.UNKNOWN=33]="UNKNOWN",m))(lr||{}),Xo={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},_= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=Xo[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkHO5ESTN4js = require('./chunk-HO5ESTN4.js');var C=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunkHO5ESTN4js.v.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}assertFinished(){if(this.remaining()!==0)throw new Error("Buffer has remaining bytes")}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeI8(){return new DataView(this.read(1)).getInt8(0)}deserializeI16(){return new DataView(this.read(2)).getInt16(0,!0)}deserializeI32(){return new DataView(this.read(4)).getInt32(0,!0)}deserializeI64(){let e=this.deserializeU32(),t=this.deserializeU32(),r=BigInt(BigInt(t)<<BigInt(32)|BigInt(e)),i=BigInt(1)<<BigInt(63);return r>=i?r-(BigInt(1)<<BigInt(64)):r}deserializeI128(){let e=this.deserializeU64(),t=this.deserializeU64(),r=BigInt(t<<BigInt(64)|e),i=BigInt(1)<<BigInt(127);return r>=i?r-(BigInt(1)<<BigInt(128)):r}deserializeI256(){let e=this.deserializeU128(),t=this.deserializeU128(),r=BigInt(t<<BigInt(128)|e),i=BigInt(1)<<BigInt(255);return r>=i?r-(BigInt(1)<<BigInt(256)):r}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunkHO5ESTN4js.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),(r&128)===0)break;t+=7}if(e>_chunkHO5ESTN4js.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var Re=class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.value=_chunkHO5ESTN4js.v.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var gr=class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.value=new Re(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Re.deserialize(e,t);return new n(r.value)}};var F=class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.z.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new Se(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},Z= exports.U8 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,0,_chunkHO5ESTN4js.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},Ue= exports.U16 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,0,_chunkHO5ESTN4js.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},ze= exports.U32 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,0,_chunkHO5ESTN4js.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},$= exports.U64 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,BigInt(0),_chunkHO5ESTN4js.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ke= exports.U128 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,BigInt(0),_chunkHO5ESTN4js.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},Se= exports.U256 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,BigInt(0),_chunkHO5ESTN4js.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}},Jo= exports.I8 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,_chunkHO5ESTN4js.h,_chunkHO5ESTN4js.i),this.value=e}serialize(e){e.serializeI8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}static deserialize(e){return new n(e.deserializeI8())}},Xo= exports.I16 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,_chunkHO5ESTN4js.j,_chunkHO5ESTN4js.k),this.value=e}serialize(e){e.serializeI16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}static deserialize(e){return new n(e.deserializeI16())}},Yo= exports.I32 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,_chunkHO5ESTN4js.l,_chunkHO5ESTN4js.m),this.value=e}serialize(e){e.serializeI32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}static deserialize(e){return new n(e.deserializeI32())}},Zo= exports.I64 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,_chunkHO5ESTN4js.n,_chunkHO5ESTN4js.o),this.value=BigInt(e)}serialize(e){e.serializeI64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}static deserialize(e){return new n(e.deserializeI64())}},es= exports.I128 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,_chunkHO5ESTN4js.p,_chunkHO5ESTN4js.q),this.value=BigInt(e)}serialize(e){e.serializeI128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}static deserialize(e){return new n(e.deserializeI128())}},ts= exports.I256 =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),_chunkHO5ESTN4js.B.call(void 0, e,_chunkHO5ESTN4js.r,_chunkHO5ESTN4js.s),this.value=BigInt(e)}serialize(e){e.serializeI256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}static deserialize(e){return new n(e.deserializeI256())}};var S=class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof Z)){new Rn(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunkHO5ESTN4js.v.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new Z(r)))}static U16(e){return new n(e.map(t=>new Ue(t)))}static U32(e){return new n(e.map(t=>new ze(t)))}static U64(e){return new n(e.map(t=>new $(t)))}static U128(e){return new n(e.map(t=>new ke(t)))}static U256(e){return new n(e.map(t=>new Se(t)))}static Bool(e){return new n(e.map(t=>new F(t)))}static MoveString(e){return new n(e.map(t=>new v(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},Rn= exports.Serialized =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.value=_chunkHO5ESTN4js.v.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new C(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new S(r)}},v= exports.MoveString =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);S.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},ne= exports.MoveOption =class n extends _chunkHO5ESTN4js.x{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new Z(e):void 0)}static U16(e){return new n(e!=null?new Ue(e):void 0)}static U32(e){return new n(e!=null?new ze(e):void 0)}static U64(e){return new n(e!=null?new $(e):void 0)}static U128(e){return new n(e!=null?new ke(e):void 0)}static U256(e){return new n(e!=null?new Se(e):void 0)}static Bool(e){return new n(e!=null?new F(e):void 0)}static MoveString(e){return new n(e!=null?new v(e):void 0)}static deserialize(e,t){let r=S.deserialize(e,t);return new n(r.values[0])}};var _sha3 = require('@noble/hashes/sha3');var bt=class bt extends _chunkHO5ESTN4js.x{constructor(e){super();let{data:t}=e,r=_chunkHO5ESTN4js.v.fromHexInput(t);if(r.toUint8Array().length!==bt.LENGTH)throw new Error(`Authentication Key length should be ${bt.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(bt.LENGTH);return new bt({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunkHO5ESTN4js.v.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new bt({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunkHO5ESTN4js.na)(this.data.toUint8Array())}};bt.LENGTH=32;var V=bt;var et=class extends _chunkHO5ESTN4js.x{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkHO5ESTN4js.v.fromHexInput(e).toString()}},ae= exports.AccountPublicKey =class extends et{};var O=class extends _chunkHO5ESTN4js.x{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkHO5ESTN4js.v.fromHexInput(e).toString()}};var Un=class n extends O{constructor(e){super(),this.value=_chunkHO5ESTN4js.v.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},yr= exports.AbstractPublicKey =class extends ae{constructor(e){super(),this.accountAddress=e}authKey(){return new V({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var _ed25519 = require('@noble/curves/ed25519');var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var ns = _interopRequireWildcard(_bip39);var au=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,cu= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,uu= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(uu||{}),rs= exports.HARDENED_OFFSET =2147483648;function is(n){return cu.test(n)}function os(n){return au.test(n)}var bi=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},ss= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return bi(e,s)},du=n=>n.replace(/'/g,""),as= exports.splitPath =n=>n.split("/").slice(1).map(du),mr= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return ns.mnemonicToSeedSync(e)};var zn=class zn{static formatPrivateKey(e,t){let r=zn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunkHO5ESTN4js.v.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=zn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunkHO5ESTN4js.v.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunkHO5ESTN4js.v.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunkHO5ESTN4js.v.fromHexInput(e);return i}};zn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-",secp256r1:"secp256r1-priv-"};var Pe=zn;var _jwtdecode = require('jwt-decode');var Tt=class n extends et{constructor(e){super();let t=e.constructor.name;switch(t){case E.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof E)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(E.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Le= exports.EphemeralSignature =class n extends O{constructor(e){super();let t=e.constructor.name;switch(t){case R.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunkHO5ESTN4js.v.fromHexInput(e),r=new C(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof R)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(R.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _poseidonlite = require('poseidon-lite');var Ti=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],us=31,xu=16,cs=(xu-1)*us;function qe(n,e){let r=new TextEncoder().encode(n);return vu(r,e)}function vu(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=kn(n,e);return Kt(t)}function Cu(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Uu(n,e);return Ku(t)}function kn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Cu(n,e).concat([BigInt(n.length)])}function Ku(n){if(n.length>cs)throw new Error(`Can't pack more than ${cs}. Was given ${n.length} bytes`);return Ru(n,us).map(e=>Ct(e))}function Ru(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function Ct(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function wi(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Uu(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Kt(n){if(n.length>Ti.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${Ti.length}`);return Ti[n.length-1](n)}var fr=class extends _chunkHO5ESTN4js.x{};var ds="5.1.4";var ps={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",shelbynet:"https://api.shelbynet.shelby.xyz/v1/graphql",netna:"https://api.netna.staging.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},ls= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",shelbynet:"https://api.shelbynet.shelby.xyz/v1",netna:"https://api.netna.staging.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},gs= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",shelbynet:"https://faucet.shelbynet.shelby.xyz",netna:"https://faucet-dev-netna-us-central1-410192433417.us-central1.run.app",local:"http://127.0.0.1:8081"},Si= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/pepper/v0",netna:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},Pi= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",shelbynet:"https://api.shelbynet.aptoslabs.com/keyless/prover/v0",netna:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},Ei= exports.Network =(a=>(a.MAINNET="mainnet",a.TESTNET="testnet",a.DEVNET="devnet",a.SHELBYNET="shelbynet",a.NETNA="netna",a.LOCAL="local",a.CUSTOM="custom",a))(Ei||{}),_i= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},lg= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",shelbynet:"shelbynet",netna:"netna",local:"local",custom:"custom"};var en=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(en||{}),ys= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,ms= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Ar= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Rt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",fs= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",As= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Ii= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",hs= exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT ="APTOS::AASigningData",wt= exports.ProcessorType =(d=>(d.ACCOUNT_RESTORATION_PROCESSOR="account_restoration_processor",d.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",d.DEFAULT="default_processor",d.EVENTS_PROCESSOR="events_processor",d.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",d.STAKE_PROCESSOR="stake_processor",d.TOKEN_V2_PROCESSOR="token_v2_processor",d.USER_TRANSACTION_PROCESSOR="user_transaction_processor",d.OBJECT_PROCESSOR="objects_processor",d))(wt||{}),bs= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Ts(n,e){let t=e.bcsToBytes(),r=new C(t);return n.deserialize(r)}var zu=(s=>(s[s.API_ERROR=0]="API_ERROR",s[s.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",s[s.SESSION_EXPIRED=2]="SESSION_EXPIRED",s[s.INVALID_STATE=3]="INVALID_STATE",s[s.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",s[s.UNKNOWN=5]="UNKNOWN",s))(zu||{}),ku= exports.KeylessErrorResolutionTip =(d=>(d.REAUTHENTICATE="Re-authentiate to continue using your keyless account",d.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",d.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",d.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",d.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",d.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",d.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",d))(ku||{}),hr= exports.KeylessErrorType =(f=>(f[f.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",f[f.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",f[f.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",f[f.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",f[f.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",f[f.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",f[f.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",f[f.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",f[f.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",f[f.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",f[f.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",f[f.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",f[f.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",f[f.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",f[f.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",f[f.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",f[f.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",f[f.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",f[f.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",f[f.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",f[f.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",f[f.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",f[f.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",f[f.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",f[f.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",f[f.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",f[f.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",f[f.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",f[f.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",f[f.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",f[f.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",f[f.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",f[f.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",f[f.UNKNOWN=33]="UNKNOWN",f))(hr||{}),ws={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},_= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=ws[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
|
|
2
2
|
Message: ${e}`;return i&&(o+=`
|
|
3
|
-
Details: ${i}`),r instanceof
|
|
3
|
+
Details: ${i}`),r instanceof Ee?o+=`
|
|
4
4
|
AptosApiError: ${r.message}`:r!==void 0&&(o+=`
|
|
5
|
-
Error: ${
|
|
6
|
-
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Xo[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Pe= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(pu({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function pu({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _2 => _2.headers, 'optionalAccess', _3 => _3.traceparent, 'optionalAccess', _4 => _4.split, 'call', _5 => _5("-"), 'access', _6 => _6[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.errors, 'optionalAccess', _9 => _9[0], 'optionalAccess', _10 => _10.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.message])!=null&&_optionalChain([t, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${lu(t.data)}`}var wi=400;function lu(n){let e=JSON.stringify(n);return e.length<=wi?e:`truncated(original_size:${e.length}): ${e.slice(0,wi/2)}...${e.slice(-wi/2)}`}async function gu(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _15 => _15.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Bo}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _16 => _16.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _17 => _17.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _18 => _18.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _19 => _19.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a})}async function gr(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await gu({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Pe({apiType:t,aptosRequest:n,aptosResponse:a})}async function yr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return gr({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function H(n){let{aptosConfig:e}=n;return yr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _20 => _20.clientConfig, 'optionalAccess', _21 => _21.HEADERS]),..._optionalChain([e, 'access', _22 => _22.fullnodeConfig, 'optionalAccess', _23 => _23.HEADERS])}}})}async function lg(n){return yr({...n,type:"Pepper"})}async function mr(n){let e=new Array(0),t,r=n.params;do{let i=await yr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function Si(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await fr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _24 => _24.params])&&(n.params.start=t),i!==void 0){let a=i-e.length;if(a<=0)break;r.limit=a}}while(t!=null);return e}async function fr(n){let e,t={};typeof _optionalChain([n, 'access', _25 => _25.params, 'optionalAccess', _26 => _26.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _27 => _27.params, 'optionalAccess', _28 => _28.limit])=="number"&&(t.limit=n.params.limit);let r=await yr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:t,overrides:n.overrides});return e=r.headers["x-aptos-cursor"],{response:r,cursor:e}}async function vn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:d}=n,y=c.getRequestUrl(e);return gr({url:y,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function wt(n){let{aptosConfig:e}=n;return vn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _29 => _29.clientConfig, 'optionalAccess', _30 => _30.HEADERS]),..._optionalChain([e, 'access', _31 => _31.fullnodeConfig, 'optionalAccess', _32 => _32.HEADERS])}}})}async function Yo(n){let{aptosConfig:e}=n;return vn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _33 => _33.clientConfig, 'optionalAccess', _34 => _34.HEADERS]),..._optionalChain([e, 'access', _35 => _35.indexerConfig, 'optionalAccess', _36 => _36.HEADERS])}}})}async function Zo(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _37 => _37.clientConfig, 'optionalAccess', _38 => delete _38.API_KEY]),vn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _39 => _39.clientConfig, 'optionalAccess', _40 => _40.HEADERS]),..._optionalChain([t, 'access', _41 => _41.faucetConfig, 'optionalAccess', _42 => _42.HEADERS])}}})}async function es(n){return vn({...n,type:"Pepper"})}async function ts(n){return vn({...n,type:"Prover"})}var Pi=new Map;function qe(n,e,t){return async(...r)=>{if(Pi.has(e)){let{value:o,timestamp:s}=Pi.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return Pi.set(e,{value:i,timestamp:Date.now()}),i}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var Au=1e7,Ei= exports.MAX_AUD_VAL_BYTES =120,hu= exports.MAX_UID_KEY_BYTES =30,bu= exports.MAX_UID_VAL_BYTES =330,Tu= exports.MAX_ISS_VAL_BYTES =120,wu= exports.MAX_EXTRA_FIELD_BYTES =350,Su= exports.MAX_JWT_HEADER_B64_BYTES =300,Pu= exports.MAX_COMMITED_EPK_BYTES =93,$e=class $e extends ae{constructor(e,t){super();let r=_chunk347THBDEjs.j.fromHexInput(t).toUint8Array();if(r.length!==$e.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${$e.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunk347THBDEjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),V.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Ar({...e,publicKey:this}),!0}catch(t){if(t instanceof _)return!1;throw t}}async verifySignatureAsync(e){return Ki({...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 $e(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new $e(t,r)}static isPublicKey(e){return e instanceof $e}static create(e){return ns(e),new $e(e.iss,ns(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return $e.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}};$e.ID_COMMITMENT_LENGTH=32;var K=$e;async function Ki(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof ce))throw _.fromErrorType({type:26,details:"Not a keyless signature"});return Ar({message:r,publicKey:t,signature:i,jwk:o||await Ri({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _43 => _43.throwErrorWithReason]))throw c;return!1}}function Ar(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof ce))throw _.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof me))throw _.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof St))throw _.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let y=d.proof.proof;if(r.expiryDateSecs<_chunk347THBDEjs.ia.call(void 0, ))throw _.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw _.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw _.fromErrorType({type:29});let A=Eu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:A,groth16Proof:y}))throw _.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw _.fromErrorType({type:30});let p=new xi(y,A);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw _.fromErrorType({type:31})}}function Eu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof K?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof me))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(vt(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Le(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Le(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Le(" ",i.maxExtraFieldBytes))),a.push(Le(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Le(s.overrideAudVal,Ei)),a.push(1n)):(a.push(Le("",Ei)),a.push(0n)),Kt(a)}async function Ri(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof K?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof L?t.jwkAddress:void 0;try{s=await Iu({aptosConfig:e,jwkAddr:a})}catch(y){throw _.fromErrorType({type:24,error:y,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw _.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(y=>y.kid===r);if(d===void 0)throw _.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function ns(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[vt(_chunk347THBDEjs.j.fromHexInput(i).toUint8Array()),Le(r,Ei),Le(t,bu),Le(e,hu)];return mi(Kt(o),K.ID_COMMITMENT_LENGTH)}var ce=class n extends F{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 vu(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=jt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=bt.deserialize(e),s=He.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new jt(new me({proof:new Jt(new St({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new bt(new E(new Uint8Array(32))),ephemeralSignature:new He(new R(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},jt= exports.EphemeralCertificate =class n extends F{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(me.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Kn=class Kn extends _chunk347THBDEjs.l{constructor(e){if(super(),this.data=_chunk347THBDEjs.j.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new Kn(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}=_bn254.bn254.fields,i=r.create(_i(e)),o=r.sqrt(r.add(r.pow(i,3n),Kn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Kn.B=_bn254.bn254.fields.Fp.create(3n);var et=Kn;function _i(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,_utils.bytesToNumberBE.call(void 0, e)}var Rn=class Rn extends _chunk347THBDEjs.l{constructor(e){if(super(),this.data=_chunk347THBDEjs.j.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new Rn(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}=_bn254.bn254.fields,s=o.fromBigTuple([_i(t),_i(r)]),a=o.sqrt(o.add(o.pow(s,3n),Rn.B)),c=o.neg(a),y=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return _bn254.bn254.G2.ProjectivePoint.fromAffine({x:s,y})}};Rn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var Ut=Rn,St= exports.Groth16Zkp =class n extends dr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new et(t),this.b=new Ut(r),this.c=new et(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=et.deserialize(e).bcsToBytes(),r=Ut.deserialize(e).bcsToBytes(),i=et.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()}}},xi= exports.Groth16ProofAndStatement =class n extends _chunk347THBDEjs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?mi(r,32):_chunk347THBDEjs.j.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(St.deserialize(t),t.deserializeFixedBytes(32))}hash(){return We(this.bcsToBytes(),this.domainSeparator)}},Jt= exports.ZkProof =class n extends _chunk347THBDEjs.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(St.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},me= exports.ZeroKnowledgeSig =class n extends F{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 v(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(He);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},Ii= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Au,maxExtraFieldBytes:o=wu,maxJwtHeaderB64Bytes:s=Su,maxIssValBytes:a=Tu,maxCommitedEpkBytes:c=Pu}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new bt(new E(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new Ci({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})}},Ci= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new et(t),this.betaG2=new Ut(r),this.deltaG2=new Ut(i),this.gammaAbcG1=[new et(o[0]),new et(o[1])],this.gammaG2=new Ut(s)}hash(){let e=new _chunk347THBDEjs.m;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}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(),c=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),y=this.deltaG2.toProjectivePoint(),A=this.gammaAbcG1.map(ft=>ft.toProjectivePoint()),{Fp12:p}=_bn254.bn254.fields,g=A[0].add(A[1].multiply(t)),b=_bn254.bn254.pairing(g,d),N=_bn254.bn254.pairing(i,o),q=_bn254.bn254.pairing(a,c),se=_bn254.bn254.pairing(s,y),Xe=p.mul(q,p.mul(b,se));return p.eql(N,Xe)}catch(i){throw _.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 Xt(n){let{aptosConfig:e}=n;try{return await qe(async()=>{let[t,r]=await Promise.all([_u(n),xu(n)]);return Ii.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof _?t:_.fromErrorType({type:25,error:t})}}function tt(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw _.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunk347THBDEjs.ha.call(void 0, o)}`})}if(typeof r.iss!="string")throw _.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw _.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 _u(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await H({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk347THBDEjs.ba.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _44 => _44.ledgerVersion])}});return i.data}catch(i){throw _.fromErrorType({type:22,error:i})}}async function xu(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await H({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk347THBDEjs.ba.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}catch(i){throw _.fromErrorType({type:23,error:i})}}async function Iu(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await H({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _46 => _46.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await H({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _47 => _47.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,y=new v(_chunk347THBDEjs.j.fromHexInput(d).toUint8Array()),A=vi.deserialize(y);a.push(A)}o.set(_chunk347THBDEjs.k.call(void 0, s.issuer),a)}return o}var vi=class n extends _chunk347THBDEjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new v(_chunk347THBDEjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw _.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunk347THBDEjs.la.call(void 0, this.n),r=Cu(e.reverse()).map(i=>vt(i));return r.push(256n),Kt(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 Cu(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 vu(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var L=class n extends ae{constructor(e,t){super(),this.jwkAddress=_chunk347THBDEjs.ba.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk347THBDEjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),V.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Ar({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=K.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ki({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,K.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,K.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk347THBDEjs.ba&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof K}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ne=class Ne extends Ze{constructor(t){super();this.keyType="secp256k1";let r=_chunk347THBDEjs.j.fromHexInput(t),{length:i}=r.toUint8Array();if(i===Ne.LENGTH)this.key=r;else if(i===Ne.COMPRESSED_LENGTH){let o=_secp256k1.secp256k1.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunk347THBDEjs.j.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ne.LENGTH} or ${Ne.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=Zt(r),s=_chunk347THBDEjs.j.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.key.toUint8Array()}serialize(t){t.serializeBytes(this.key.toUint8Array())}deserialize(t){let r=t.deserializeBytes();return new rt(r)}static deserialize(t){let r=t.deserializeBytes();return new Ne(r)}static isPublicKey(t){return t instanceof Ne}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _48 => _48.key, 'optionalAccess', _49 => _49.data, 'optionalAccess', _50 => _50.length])===Ne.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};Ne.LENGTH=65,Ne.COMPRESSED_LENGTH=33;var De=Ne,Qe=class Qe extends _chunk347THBDEjs.l{constructor(e,t){super();let r=Se.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Qe.LENGTH)throw new Error(`PrivateKey length should be ${Qe.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Qe(e,!1)}static fromDerivationPath(e,t){if(!zo(e))throw new Error(`Invalid derivation path ${e}`);return Qe.fromDerivationPathInner(e,ur(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Qe(r,!1)}sign(e){let t=Zt(e),r=_chunk347THBDEjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new rt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new De(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return Se.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Qe(t,!1)}static isPrivateKey(e){return e instanceof Qe}};Qe.LENGTH=32;var nt=Qe,Yt=class Yt extends F{constructor(e){super();let t=_chunk347THBDEjs.j.fromHexInput(e);if(t.toUint8Array().length!==Yt.LENGTH)throw new Error(`Signature length should be ${Yt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Yt(t)}};Yt.LENGTH=64;var rt=Yt;var _nistjs = require('@noble/curves/nist.js');var Ee=class Ee extends Ze{constructor(t){super();this.keyType="secp256r1";let r=_chunk347THBDEjs.j.fromHexInput(t),i=r.toUint8Array().length;if(i!==Ee.LENGTH&&i!==Ee.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${Ee.LENGTH} or ${Ee.COMPRESSED_LENGTH}, received ${i}`);if(i===Ee.COMPRESSED_LENGTH){let o=_nistjs.p256.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunk347THBDEjs.j.fromHexInput(o.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){let t=new _chunk347THBDEjs.m;return this.serialize(t),t.toUint8Array()}verifySignature(t){let{message:r,signature:i}=t,o=_chunk347THBDEjs.j.fromHexInput(r).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=i.toUint8Array();return _nistjs.p256.verify(a,s,this.toUint8Array())}async verifySignatureAsync(t){return this.verifySignature({message:t.message,signature:t.signature})}serialize(t){t.serializeBytes(this.key.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new Ee(r)}static load(t){let r=t.deserializeBytes();return new Ee(r)}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _51 => _51.key, 'optionalAccess', _52 => _52.data, 'optionalAccess', _53 => _53.length])===Ee.LENGTH&&"keyType"in t&&t.keyType==="secp256r1"}authKey(){let t=new _chunk347THBDEjs.m;return t.serializeU32AsUleb128(2),t.serializeFixedBytes(this.bcsToBytes()),V.fromSchemeAndBytes({scheme:2,input:t.toUint8Array()})}};Ee.LENGTH=65,Ee.COMPRESSED_LENGTH=33;var nn=Ee,kt=class kt extends Se{constructor(e,t){super();let r=Se.parseHexInput(e,"secp256r1",t),i=r.toUint8Array().length;if(i!==kt.LENGTH)throw new Error(`PrivateKey length should be ${kt.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return Se.formatPrivateKey(this.key.toString(),"secp256r1")}toHexString(){return this.key.toString()}sign(e){let t=_chunk347THBDEjs.j.fromHexInput(e),r=_sha3.sha3_256.call(void 0, t.toUint8Array()),i=_nistjs.p256.sign(r,this.key.toUint8Array());return new Ui(i.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new kt(t)}static generate(){let e=_nistjs.p256.utils.randomPrivateKey();return new kt(e)}publicKey(){let e=_nistjs.p256.getPublicKey(this.key.toUint8Array(),!1);return new nn(e)}};kt.LENGTH=32;var os=kt,kn= exports.WebAuthnSignature =class n extends F{constructor(e,t,r){super(),this.signature=_chunk347THBDEjs.j.fromHexInput(e),this.authenticatorData=_chunk347THBDEjs.j.fromHexInput(t),this.clientDataJSON=_chunk347THBDEjs.j.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.signature.toUint8Array()),e.serializeBytes(this.authenticatorData.toUint8Array()),e.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){let e=new _chunk347THBDEjs.m;return this.serialize(e),e.toUint8Array()}bcsToHex(){return _chunk347THBDEjs.j.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return _chunk347THBDEjs.j.fromHexInput(this.bcsToBytes()).toString()}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Invalid id for WebAuthnSignature: ${t}`);let r=e.deserializeBytes(),i=e.deserializeBytes(),o=e.deserializeBytes();return new n(r,i,o)}},en=class en extends F{constructor(e){super();let t=_chunk347THBDEjs.j.fromHexInput(e),r=t.toUint8Array().length;if(r!==en.LENGTH)throw new Error(`Signature length should be ${en.LENGTH}, received ${r}`);let i=_nistjs.p256.Signature.fromCompact(t.toUint8Array()).normalizeS().toCompactRawBytes();this.data=_chunk347THBDEjs.j.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new en(t)}};en.LENGTH=64;var Ui=en;var x=class n extends ae{constructor(e){if(super(),this.publicKey=e,e instanceof E)this.variant=0;else if(e instanceof De)this.variant=1;else if(e instanceof nn)this.variant=2;else if(e instanceof K)this.variant=3;else if(e instanceof L)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof K)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(_optionalChain([e, 'access', _54 => _54.options, 'optionalAccess', _55 => _55.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 V.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=E.deserialize(e);break;case 1:r=De.deserialize(e);break;case 2:r=nn.deserialize(e);break;case 3:r=K.deserialize(e);break;case 4:r=L.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 E}isSecp256k1PublicKey(){return this.publicKey instanceof De}static isInstance(e){return"publicKey"in e&&"variant"in e}},O= exports.AnySignature =class n extends F{constructor(e){if(super(),this.signature=e,e instanceof R)this.variant=0;else if(e instanceof rt)this.variant=1;else if(e instanceof kn)this.variant=2;else if(e instanceof ce)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=R.deserialize(e);break;case 1:r=rt.deserialize(e);break;case 2:r=kn.deserialize(e);break;case 3:r=ce.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 Ru(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var hr=3,Fe= exports.AbstractMultiKey =class extends ae{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 c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=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}`)}},W= exports.MultiKey =class n extends Fe{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`);if(this.publicKeys=t.map(i=>i instanceof x?i:new x(i)),r>hr&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>hr)throw new Error(`Construction of MultiKey with more than ${hr} keyless public keys is not allowed when signaturesRequired
|
|
7
|
-
is greater than ${
|
|
8
|
-
K-of-N MultiKey transaction.`);this.signaturesRequired=r}getSignaturesRequired(){return this.signaturesRequired}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 _e))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(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.throwErrorWithReason]))throw r;return!1}}authKey(){return V.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(x),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof x?e:new x(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},fe=class fe extends F{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>fe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${fe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof O?o:new O(o)),!(r instanceof Uint8Array))this.bitmap=fe.createBitmap({bits:r});else{if(r.length!==fe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${fe.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Ru(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>=fe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${fe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}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 fe({signatures:t,bitmap:r})}};fe.BITMAP_LEN=4,fe.MAX_SIGNATURES_SUPPORTED=fe.BITMAP_LEN*8;var _e=fe;var Ae=class Ae extends Fe{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>Ae.MAX_KEYS||t.length<Ae.MIN_KEYS)throw new Error(`Must have between ${Ae.MIN_KEYS} and ${Ae.MAX_KEYS} public keys, inclusive`);if(r<Ae.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${Ae.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Oe))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return V.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*E.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*E.LENGTH)}),e[this.publicKeys.length*E.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+=E.LENGTH){let s=o;i.push(new E(t.subarray(s,s+E.LENGTH)))}return new Ae({publicKeys:i,threshold:r})}static deserializeWithoutLength(e){let t=e.remaining(),r=e.deserializeFixedBytes(t),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=E.LENGTH){let a=s;o.push(new E(r.subarray(a,a+E.LENGTH)))}return new Ae({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};Ae.MAX_KEYS=32,Ae.MIN_KEYS=2,Ae.MIN_THRESHOLD=1;var ie=Ae,he=class he extends F{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>he.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${he.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=he.createBitmap({bits:r});else{if(r.length!==he.BITMAP_LEN)throw new Error(`"bitmap" length should be ${he.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*R.LENGTH+he.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*R.LENGTH)}),e.set(this.bitmap,this.signatures.length*R.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+=R.LENGTH){let s=o;i.push(new R(t.subarray(s,s+R.LENGTH)))}return new he({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>=he.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${he.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};he.MAX_SIGNATURES_SUPPORTED=32,he.BITMAP_LEN=4;var Oe=he;var Zt=n=>typeof n=="string"?_chunk347THBDEjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n,ki=n=>{if(n instanceof E||n instanceof x||n instanceof ie||n instanceof W)return n;if(n instanceof K||n instanceof L)return new x(n);throw new Error(`Unknown account public key: ${n}`)},as=n=>{let e=ki(n);if(e instanceof E)return 0;if(e instanceof x)return 2;if(e instanceof ie)return 1;if(e instanceof W)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var zi=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Uu(n){let e=n.toUint8Array().slice(32);for(let t=zi.length-1;t>=0;t-=1){if(e[t]<zi[t])return!0;if(e[t]>zi[t])return!1}return!1}var Pt=class Pt extends ae{constructor(e){super();let t=_chunk347THBDEjs.j.fromHexInput(e);if(t.toUint8Array().length!==Pt.LENGTH)throw new Error(`PublicKey length should be ${Pt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!Uu(r))return!1;let i=Zt(t),o=_chunk347THBDEjs.j.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return V.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Pt(t)}static isPublicKey(e){return e instanceof Pt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _58 => _58.key, 'optionalAccess', _59 => _59.data, 'optionalAccess', _60 => _60.length])===Pt.LENGTH}};Pt.LENGTH=32;var E=Pt,xe=class xe extends _chunk347THBDEjs.l{constructor(e,t){super();let r=Se.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==xe.LENGTH)throw new Error(`PrivateKey length should be ${xe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new xe(e,!1)}static fromDerivationPath(e,t){if(!No(e))throw new Error(`Invalid derivation path ${e}`);return xe.fromDerivationPathInner(e,ur(t))}static fromDerivationPathInner(e,t,r=ko){let{key:i,chainCode:o}=gi(xe.SLIP_0010_SEED,t),s=Fo(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>Do(c,d+r),{key:i,chainCode:o});return new xe(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new E(e)}sign(e){let t=Zt(e),r=_chunk347THBDEjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new R(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return Se.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new xe(t,!1)}static isPrivateKey(e){return e instanceof xe}};xe.LENGTH=32,xe.SLIP_0010_SEED="ed25519 seed";var J=xe,rn=class rn extends F{constructor(e){super();let t=_chunk347THBDEjs.j.fromHexInput(e);if(t.toUint8Array().length!==rn.LENGTH)throw new Error(`Signature length should be ${rn.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new rn(t)}};rn.LENGTH=64;var R=rn;var Tr="Multiple possible deserializations found";function nf(n){let e=[E,x,ie,W,K,L,De],t;for(let r of e)try{let i=v.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Tr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Tr))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function rf(n){let e=[R,O,Oe,_e,ce,rt],t;for(let r of e)try{let i=v.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Tr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Tr))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var ee=class extends _chunk347THBDEjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ge.load(e);case 1:return it.load(e);case 2:return ue.load(e);case 3:return je.load(e);case 4:return on.load(e);case 5:return zt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ge}isMultiEd25519(){return this instanceof it}isSingleKey(){return this instanceof ue}isMultiKey(){return this instanceof je}},Ge= exports.AccountAuthenticatorEd25519 =class n extends ee{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=E.deserialize(e),r=R.deserialize(e);return new n(t,r)}},it= exports.AccountAuthenticatorMultiEd25519 =class n extends ee{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=ie.deserialize(e),r=Oe.deserialize(e);return new n(t,r)}},ue= exports.AccountAuthenticatorSingleKey =class n extends ee{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=x.deserialize(e),r=O.deserialize(e);return new n(t,r)}},je= exports.AccountAuthenticatorMultiKey =class n extends ee{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=W.deserialize(e),r=_e.deserialize(e);return new n(t,r)}},on= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends ee{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},zt= exports.AccountAuthenticatorAbstraction =class n extends ee{constructor(e,t,r,i){if(super(),!_chunk347THBDEjs.ra.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=_chunk347THBDEjs.j.fromHexInput(_chunk347THBDEjs.j.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk347THBDEjs.qa.call(void 0, this.functionInfo);_chunk347THBDEjs.ba.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.abstractionSignature):e.serializeFixedBytes(this.abstractionSignature),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32(),s=e.deserializeBytes();if(o===0){let a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}},wr= exports.AccountAbstractionMessage =class n extends _chunk347THBDEjs.l{constructor(e,t){super(),this.originalSigningMessage=_chunk347THBDEjs.j.fromHexInput(_chunk347THBDEjs.j.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=_chunk347THBDEjs.qa.call(void 0, this.functionInfo);_chunk347THBDEjs.ba.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i)}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Unknown variant index for AccountAbstractionMessage: ${t}`);let r=e.deserializeBytes(),i=_chunk347THBDEjs.ba.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};var sn=class n extends _chunk347THBDEjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var k=class n extends _chunk347THBDEjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var zn=class n extends _chunk347THBDEjs.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(_chunk347THBDEjs.ba.fromString(t[0]),new k(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=k.deserialize(e);return new n(t,r)}};var B=class n extends _chunk347THBDEjs.l{deserialize(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(n);return new Je(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Q.load(e);case 1:return de.load(e);case 2:return te.load(e);case 3:return at.load(e);case 4:return G.load(e);case 5:return Nt.load(e);case 6:return U.load(e);case 7:return h.load(e);case 8:return ot.load(e);case 9:return st.load(e);case 10:return ct.load(e);case 255:return M.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof Q}isAddress(){return this instanceof G}isGeneric(){return this instanceof M}isSigner(){return this instanceof Nt}isVector(){return this instanceof U}isStruct(){return this instanceof h}isU8(){return this instanceof de}isU16(){return this instanceof ot}isU32(){return this instanceof st}isU64(){return this instanceof te}isU128(){return this instanceof at}isU256(){return this instanceof ct}isPrimitive(){return this instanceof Nt||this instanceof G||this instanceof Q||this instanceof de||this instanceof ot||this instanceof st||this instanceof te||this instanceof at||this instanceof ct}},Q= exports.TypeTagBool =class n extends B{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},de= exports.TypeTagU8 =class n extends B{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},ot= exports.TypeTagU16 =class n extends B{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},st= exports.TypeTagU32 =class n extends B{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},te= exports.TypeTagU64 =class n extends B{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},at= exports.TypeTagU128 =class n extends B{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},ct= exports.TypeTagU256 =class n extends B{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},G= exports.TypeTagAddress =class n extends B{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Nt= exports.TypeTagSigner =class n extends B{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},Sr= exports.TypeTagReference =class n extends B{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=B.deserialize(t);return new n(r)}},M= exports.TypeTagGeneric =class n extends B{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)}},U= exports.TypeTagVector =class n extends B{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new de)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=B.deserialize(t);return new n(r)}},h= exports.TypeTagStruct =class n extends B{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=Je.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(_chunk347THBDEjs.ba.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk347THBDEjs.ba.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk347THBDEjs.ba.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk347THBDEjs.ba.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk347THBDEjs.ba.ONE,"rate_limiter","RateLimiter")}},Je= exports.StructTag =class n extends _chunk347THBDEjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(B);return new n(t,r,i,o)}};function rA(){return new Je(_chunk347THBDEjs.ba.ONE,new k("aptos_coin"),new k("AptosCoin"),[])}function I(){return new Je(_chunk347THBDEjs.ba.ONE,new k("string"),new k("String"),[])}function iA(n){return new Je(_chunk347THBDEjs.ba.ONE,new k("option"),new k("Option"),[n])}function be(n){return new Je(_chunk347THBDEjs.ba.ONE,new k("object"),new k("Object"),[n])}function ku(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Z.deserialize(n);case 1:return $.deserialize(n);case 2:return ke.deserialize(n);case 3:return _chunk347THBDEjs.ba.deserialize(n);case 4:return S.deserialize(n,Z);case 5:return D.deserialize(n);case 6:return Re.deserialize(n);case 7:return Ue.deserialize(n);case 8:return we.deserialize(n);case 9:return _n.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Et=class extends _chunk347THBDEjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return an.load(e);case 2:return cn.load(e);case 3:return un.load(e);case 4:return Pr.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},an= exports.TransactionPayloadScript =class n extends Et{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=dn.deserialize(e);return new n(t)}},cn= exports.TransactionPayloadEntryFunction =class n extends Et{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=ut.deserialize(e);return new n(t)}},un= exports.TransactionPayloadMultiSig =class n extends Et{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Nn.deserialize(e);return new n(t)}},ut= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(zn.fromStr(e),new k(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=zn.deserialize(e),r=k.deserialize(e),i=e.deserializeVector(B),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=ar.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},dn= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(B),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=ku(e);o.push(a)}return new n(t,r,o)}},Nn= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Dn.deserialize(e)),new n(t,i)}},Dn= exports.MultiSigTransactionPayload =class n extends _chunk347THBDEjs.l{constructor(e){super(),this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(ut.deserialize(e))}},Pr= exports.TransactionInnerPayload =class extends Et{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Dt.load(e);default:throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}}},Dt= exports.TransactionInnerPayloadV1 =class n extends Pr{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(e){let t=pn.deserialize(e),r=Er.deserialize(e);return new n(t,r)}},pn= exports.TransactionExecutable =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Fn.load(e);case 1:return ln.load(e);case 2:return On.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},Fn= exports.TransactionExecutableScript =class n extends pn{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=dn.deserialize(e);return new n(t)}},ln= exports.TransactionExecutableEntryFunction =class n extends pn{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=ut.deserialize(e);return new n(t)}},On= exports.TransactionExecutableEmpty =class n extends pn{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Er= exports.TransactionExtraConfig =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ft.load(e);default:throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}}},Ft= exports.TransactionExtraConfigV1 =class n extends Er{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=t!==void 0?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(this.replayProtectionNonce!==void 0?new $(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(_chunk347THBDEjs.ba),r=e.deserializeOption($);return new n(t,_optionalChain([r, 'optionalAccess', _61 => _61.value]))}};var Ie=class n extends _chunk347THBDEjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=_chunk347THBDEjs.ba.deserialize(e),r=e.deserializeU64(),i=Et.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=sn.deserialize(e);return new n(t,r,i,o,s,a,c)}},_r= exports.RawTransactionWithData =class extends _chunk347THBDEjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ot.load(e);case 1:return Gt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Ot= exports.MultiAgentRawTransaction =class n extends _r{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=Ie.deserialize(e),r=e.deserializeVector(_chunk347THBDEjs.ba);return new n(t,r)}},Gt= exports.FeePayerRawTransaction =class n extends _r{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=Ie.deserialize(e),r=e.deserializeVector(_chunk347THBDEjs.ba),i=_chunk347THBDEjs.ba.deserialize(e);return new n(t,r,i)}};var xr=class extends _chunk347THBDEjs.l{constructor(t){super();this.accountAddress=_chunk347THBDEjs.ba.ONE;this.moduleName=new C("account");this.structName=new C("RotationProofChallenge");this.sequenceNumber=new $(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var dt=class extends _chunk347THBDEjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Bt.load(e);case 1:return gn.load(e);case 2:return Mt.load(e);case 3:return Vt.load(e);case 4:return _t.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Bt}isMultiEd25519(){return this instanceof gn}isMultiAgent(){return this instanceof Mt}isFeePayer(){return this instanceof Vt}isSingleSender(){return this instanceof _t}},Bt= exports.TransactionAuthenticatorEd25519 =class n extends dt{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=E.deserialize(e),r=R.deserialize(e);return new n(t,r)}},gn= exports.TransactionAuthenticatorMultiEd25519 =class n extends dt{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=ie.deserialize(e),r=Oe.deserialize(e);return new n(t,r)}},Mt= exports.TransactionAuthenticatorMultiAgent =class n extends dt{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=ee.deserialize(e),r=e.deserializeVector(_chunk347THBDEjs.ba),i=e.deserializeVector(ee);return new n(t,r,i)}},Vt= exports.TransactionAuthenticatorFeePayer =class n extends dt{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=ee.deserialize(e),r=e.deserializeVector(_chunk347THBDEjs.ba),i=e.deserializeVector(ee),o=_chunk347THBDEjs.ba.deserialize(e),s=ee.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},_t= exports.TransactionAuthenticatorSingleSender =class n extends dt{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=ee.deserialize(e);return new n(t)}};var pt=class n extends _chunk347THBDEjs.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=Ie.deserialize(e),r=dt.deserialize(e);return new n(t,r)}};var Ir=class n extends _chunk347THBDEjs.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=Ie.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk347THBDEjs.ba.deserialize(e)),new n(t,i)}};var Cr=class n extends _chunk347THBDEjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=Ie.deserialize(e),r=e.deserializeVector(_chunk347THBDEjs.ba),i=e.deserializeBool(),o;return i&&(o=_chunk347THBDEjs.ba.deserialize(e)),new n(t,r,o)}};function vr(n){return n.feePayerAddress?new Gt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Ot(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function We(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function Ah(n){return We(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Be(n){let e=vr(n);return n.feePayerAddress?We(e.bcsToBytes(),Ti):n.secondarySignerAddresses?We(e.bcsToBytes(),Ti):We(e.bcsToBytes(),Wo)}var oe=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk347THBDEjs.ba.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=J.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=J.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 Ge(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ge(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Be(e))}};function Ni(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var pe=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new x(t.publicKey()),this.accountAddress=r?_chunk347THBDEjs.ba.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=J.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=J.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 ue(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ue(this.publicKey,this.signTransaction(e))}sign(e){return new O(this.privateKey.sign(e))}signTransaction(e){return this.sign(Be(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var lt=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?oe.generate():pe.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof J&&i?new oe({privateKey:t,address:r}):new pe({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?oe.fromDerivationPath({mnemonic:r,path:i}):pe.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)}};var _utils3 = require('@noble/hashes/utils');var Du=1209600,yn=class yn extends _chunk347THBDEjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new bt(t.publicKey()),this.expiryDateSecs=r||_chunk347THBDEjs.ja.call(void 0, _chunk347THBDEjs.ia.call(void 0, )+Du),this.blinder=i!==void 0?_chunk347THBDEjs.j.fromHexInput(i).toUint8Array():Fu();let o=Cn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(vt(this.blinder));let s=Kt(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=J.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new yn({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return yn.deserialize(new v(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _62 => _62.scheme])){case 0:default:t=J.generate()}return new yn({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _63 => _63.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new He(this.privateKey.sign(e))}};yn.BLINDER_LENGTH=31;var Ht=yn;function Fu(){return _utils3.randomBytes.call(void 0, Ht.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function Rr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var mn=class mn extends _chunk347THBDEjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:y,proofFetchCallback:A,jwt:p,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunk347THBDEjs.ba.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new _eventemitter32.default,this.proofOrPromise=y,y instanceof me)this.proof=y;else{if(A===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async N=>{await A(N),this.emitter.removeAllListeners()}),this.init(y)}let b=_chunk347THBDEjs.j.fromHexInput(d).toUint8Array();if(b.length!==mn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${mn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunk347THBDEjs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk347THBDEjs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new x(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=_chunk347THBDEjs.ba.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Ht.deserialize(t),c=me.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new O(this.sign(t)),i=new x(this.publicKey);return new ue(i,r)}signTransactionWithAuthenticator(t){let r=new O(this.signTransaction(t)),i=new x(this.publicKey);return new ue(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw _.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw _.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw _.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 Xt({aptosConfig:t});if(_chunk347THBDEjs.j.hexInputToString(i.hash())!==_chunk347THBDEjs.j.hexInputToString(this.verificationKeyHash))throw _.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 mn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw _.fromErrorType({type:0});if(this.proof===void 0)throw _.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 ce({jwtHeader:_chunk347THBDEjs.ka.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new jt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw _.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=vr(t),o=new Kr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw _.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=vr(t);return new Kr(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 Ri(t)}};mn.PEPPER_LENGTH=31;var Te=mn,Kr= exports.TransactionAndProof =class extends _chunk347THBDEjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return We(this.bcsToBytes(),this.domainSeparator)}};var Ce=class n extends Te{constructor(e){let t=K.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=Te.partialDeserialize(e),{iss:d,aud:y,uidVal:A}=tt({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:A,aud:y,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new v(_chunk347THBDEjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d,verificationKeyHash:y}=e;if(y&&d)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:A,aud:p,uidVal:g}=tt({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:A,uidKey:a,uidVal:g,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:_nullishCoalesce(y, () => ((d?d.hash():void 0)))})}};var Me=class n extends Te{constructor(e){let t=L.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=Te.partialDeserialize(e),d=_chunk347THBDEjs.ba.deserialize(e),{iss:y,aud:A,uidVal:p}=tt({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:y,uidKey:s,uidVal:p,aud:A,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(v.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:y,verificationKeyHash:A}=e;if(A&&y)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:g,uidVal:b}=tt({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:b,aud:g,pepper:s,jwkAddress:_chunk347THBDEjs.ba.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:_nullishCoalesce(A, () => ((y?y.hash():void 0)))})}};var gt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof oe?pe.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?_chunk347THBDEjs.ba.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new W({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new je(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new je(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof Te).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof Te).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 _e({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new _e({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var Gn=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk347THBDEjs.ba.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,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[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 it(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new it(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Oe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Be(e))}};function cs(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk347THBDEjs.Z).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk347THBDEjs.ba.deserialize(n),signingScheme:e}}function us(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 ds(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Ht.deserialize(n),o=me.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var ps;(A=>{function n(p){let g=new _chunk347THBDEjs.m;switch(g.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(g),p.signingScheme){case 0:return p.privateKey.serialize(g),g.toUint8Array();case 2:{if(!Ni(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return us(p,g),g.toUint8Array();case 4:{let N=p;return us(N,g),N.publicKey.jwkAddress.serialize(g),g.serializeBool(N.audless),g.toUint8Array()}case 1:case 0:return p.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(g),g.serializeU32AsUleb128(b.signers.length),b.signers.forEach(N=>{g.serializeFixedBytes(n(N))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}A.toBytes=n;function e(p){return _chunk347THBDEjs.j.hexInputToStringWithoutPrefix(n(p))}A.toHexStringWithoutPrefix=e;function t(p){return _chunk347THBDEjs.j.hexInputToString(n(p))}A.toHexString=t;function r(p){let{address:g,signingScheme:b}=cs(p);switch(b){case 0:{let N=J.deserialize(p);return new oe({privateKey:N,address:g})}case 2:{let N=p.deserializeUleb128AsU32();switch(N){case 0:{let q=J.deserialize(p);return new pe({privateKey:q,address:g})}case 1:{let q=nt.deserialize(p);return new pe({privateKey:q,address:g})}case 3:{let q=ds(p),se=tt(q);return new Ce({...q,...se})}case 4:{let q=ds(p),se=_chunk347THBDEjs.ba.deserialize(p),Xe=p.deserializeBool(),ft=tt(q);return new Me({...q,...ft,jwkAddress:se,audless:Xe})}default:throw new Error(`Unsupported public key variant ${N}`)}}case 3:{let N=W.deserialize(p),q=p.deserializeUleb128AsU32(),se=new Array;for(let Xe=0;Xe<q;Xe+=1){let ft=r(p);if(!Ni(ft)&&!(ft instanceof oe))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");se.push(ft)}return new gt({multiKey:N,signers:se,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}A.deserialize=r;function i(p){let g=d(p);if(!(g instanceof Ce))throw new Error("Deserialization of KeylessAccount failed");return g}A.keylessAccountFromHex=i;function o(p){let g=d(p);if(!(g instanceof Me))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}A.federatedKeylessAccountFromHex=o;function s(p){let g=d(p);if(!(g instanceof gt))throw new Error("Deserialization of MultiKeyAccount failed");return g}A.multiKeyAccountFromHex=s;function a(p){let g=d(p);if(!(g instanceof pe))throw new Error("Deserialization of SingleKeyAccount failed");return g}A.singleKeyAccountFromHex=a;function c(p){let g=d(p);if(!(g instanceof oe))throw new Error("Deserialization of Ed25519Account failed");return g}A.ed25519AccountFromHex=c;function d(p){return r(v.fromHex(p))}A.fromHex=d;function y(p){return d(p)}A.fromBytes=y})(ps||(ps= exports.AccountUtils ={}));var Ur=class n extends lt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk347THBDEjs.ra.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new cr(this.accountAddress),this.sign=o=>new xn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk347THBDEjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new wr(t,r);return We(i.bcsToBytes(),Qo)}signWithAuthenticator(t){return new zt(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(Be(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(Be(t))}setSigner(t){this.sign=r=>new xn(t(r))}};var Bn=class Bn extends Ur{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunk347THBDEjs.ba)(Bn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunk347THBDEjs.ra.call(void 0, e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=_sha3.sha3_256.create(),a=new _chunk347THBDEjs.m;_chunk347THBDEjs.ba.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunk347THBDEjs.m;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([Bn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new zt(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};Bn.ADDRESS_DOMAIN_SEPERATOR=5;var gs=Bn;var Bu=`
|
|
5
|
+
Error: ${_chunkHO5ESTN4js.ta.call(void 0, r)}`),o+=`
|
|
6
|
+
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=ws[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Ee= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(Nu({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function Nu({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _2 => _2.headers, 'optionalAccess', _3 => _3.traceparent, 'optionalAccess', _4 => _4.split, 'call', _5 => _5("-"), 'access', _6 => _6[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _7 => _7.data, 'optionalAccess', _8 => _8.errors, 'optionalAccess', _9 => _9[0], 'optionalAccess', _10 => _10.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _11 => _11.data, 'optionalAccess', _12 => _12.message])!=null&&_optionalChain([t, 'access', _13 => _13.data, 'optionalAccess', _14 => _14.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${Du(t.data)}`}var xi=400;function Du(n){let e=JSON.stringify(n);return e.length<=xi?e:`truncated(original_size:${e.length}): ${e.slice(0,xi/2)}...${e.slice(-xi/2)}`}async function Fu(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,d={..._optionalChain([a, 'optionalAccess', _15 => _15.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${ds}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _16 => _16.AUTH_TOKEN])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _17 => _17.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _18 => _18.API_KEY])&&(d.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _19 => _19.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:d,overrides:a})}async function br(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Fu({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Ee({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Ee({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Ee({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Ee({apiType:t,aptosRequest:n,aptosResponse:a})}async function Tr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,d=e.getRequestUrl(c);return br({url:d,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function H(n){let{aptosConfig:e}=n;return Tr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _20 => _20.clientConfig, 'optionalAccess', _21 => _21.HEADERS]),..._optionalChain([e, 'access', _22 => _22.fullnodeConfig, 'optionalAccess', _23 => _23.HEADERS])}}})}async function Bg(n){return Tr({...n,type:"Pepper"})}async function wr(n){let e=new Array(0),t,r=n.params;do{let i=await Tr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function vi(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await Sr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _24 => _24.params])&&(n.params.start=t),i!==void 0){let a=i-e.length;if(a<=0)break;r.limit=a}}while(t!=null);return e}async function Sr(n){let e,t={};typeof _optionalChain([n, 'access', _25 => _25.params, 'optionalAccess', _26 => _26.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _27 => _27.params, 'optionalAccess', _28 => _28.limit])=="number"&&(t.limit=n.params.limit);let r=await Tr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:t,overrides:n.overrides});return e=r.headers["x-aptos-cursor"],{response:r,cursor:e}}async function Nn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:d}=n,m=c.getRequestUrl(e);return br({url:m,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:d},c,n.type)}async function St(n){let{aptosConfig:e}=n;return Nn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _29 => _29.clientConfig, 'optionalAccess', _30 => _30.HEADERS]),..._optionalChain([e, 'access', _31 => _31.fullnodeConfig, 'optionalAccess', _32 => _32.HEADERS])}}})}async function Ss(n){let{aptosConfig:e}=n;return Nn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _33 => _33.clientConfig, 'optionalAccess', _34 => _34.HEADERS]),..._optionalChain([e, 'access', _35 => _35.indexerConfig, 'optionalAccess', _36 => _36.HEADERS])}}})}async function Ps(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _37 => _37.clientConfig, 'optionalAccess', _38 => delete _38.API_KEY]),Nn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _39 => _39.clientConfig, 'optionalAccess', _40 => _40.HEADERS]),..._optionalChain([t, 'access', _41 => _41.faucetConfig, 'optionalAccess', _42 => _42.HEADERS])}}})}async function Es(n){return Nn({...n,type:"Pepper"})}async function _s(n){return Nn({...n,type:"Prover"})}var Ci=new Map;function $e(n,e,t){return async(...r)=>{if(Ci.has(e)){let{value:o,timestamp:s}=Ci.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return Ci.set(e,{value:i,timestamp:Date.now()}),i}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var Mu=1e7,Ki= exports.MAX_AUD_VAL_BYTES =120,Vu= exports.MAX_UID_KEY_BYTES =30,Hu= exports.MAX_UID_VAL_BYTES =330,Lu= exports.MAX_ISS_VAL_BYTES =120,qu= exports.MAX_EXTRA_FIELD_BYTES =350,$u= exports.MAX_JWT_HEADER_B64_BYTES =300,Wu= exports.MAX_COMMITED_EPK_BYTES =93,We=class We extends ae{constructor(e,t){super();let r=_chunkHO5ESTN4js.v.fromHexInput(t).toUint8Array();if(r.length!==We.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${We.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunkHO5ESTN4js.y;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),V.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Pr({...e,publicKey:this}),!0}catch(t){if(t instanceof _)return!1;throw t}}async verifySignatureAsync(e){return Di({...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 We(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new We(t,r)}static isPublicKey(e){return e instanceof We}static create(e){return Is(e),new We(e.iss,Is(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return We.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}};We.ID_COMMITMENT_LENGTH=32;var K=We;async function Di(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await rn({aptosConfig:e}),options:a}=n;try{if(!(i instanceof ce))throw _.fromErrorType({type:26,details:"Not a keyless signature"});return Pr({message:r,publicKey:t,signature:i,jwk:o||await Fi({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _43 => _43.throwErrorWithReason]))throw c;return!1}}function Pr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof ce))throw _.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof fe))throw _.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof Pt))throw _.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let m=d.proof.proof;if(r.expiryDateSecs<_chunkHO5ESTN4js.ua.call(void 0, ))throw _.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw _.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw _.fromErrorType({type:29});let A=Qu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:A,groth16Proof:m}))throw _.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw _.fromErrorType({type:30});let p=new Ui(m,A);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw _.fromErrorType({type:31})}}function Qu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof K?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof fe))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...kn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Ct(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(qe(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(qe(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(qe(" ",i.maxExtraFieldBytes))),a.push(qe(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(qe(s.overrideAudVal,Ki)),a.push(1n)):(a.push(qe("",Ki)),a.push(0n)),Kt(a)}async function Fi(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof K?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof L?t.jwkAddress:void 0;try{s=await Xu({aptosConfig:e,jwkAddr:a})}catch(m){throw _.fromErrorType({type:24,error:m,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw _.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(m=>m.kid===r);if(d===void 0)throw _.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function Is(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Ct(_chunkHO5ESTN4js.v.fromHexInput(i).toUint8Array()),qe(r,Ki),qe(t,Hu),qe(e,Vu)];return wi(Kt(o),K.ID_COMMITMENT_LENGTH)}var ce=class n extends O{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 Zu(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=tn.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=Tt.deserialize(e),s=Le.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new tn(new fe({proof:new nn(new Pt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new Tt(new E(new Uint8Array(32))),ephemeralSignature:new Le(new R(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},tn= exports.EphemeralCertificate =class n extends O{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(fe.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},Dn=class Dn extends _chunkHO5ESTN4js.x{constructor(e){if(super(),this.data=_chunkHO5ESTN4js.v.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 Dn(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}=_bn254.bn254.fields,i=r.create(Ri(e)),o=r.sqrt(r.add(r.pow(i,3n),Dn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Dn.B=_bn254.bn254.fields.Fp.create(3n);var tt=Dn;function Ri(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,_utils.bytesToNumberBE.call(void 0, e)}var Fn=class Fn extends _chunkHO5ESTN4js.x{constructor(e){if(super(),this.data=_chunkHO5ESTN4js.v.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 Fn(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}=_bn254.bn254.fields,s=o.fromBigTuple([Ri(t),Ri(r)]),a=o.sqrt(o.add(o.pow(s,3n),Fn.B)),c=o.neg(a),m=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return _bn254.bn254.G2.ProjectivePoint.fromAffine({x:s,y:m})}};Fn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var Ut=Fn,Pt= exports.Groth16Zkp =class n extends fr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new tt(t),this.b=new Ut(r),this.c=new tt(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=tt.deserialize(e).bcsToBytes(),r=Ut.deserialize(e).bcsToBytes(),i=tt.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()}}},Ui= exports.Groth16ProofAndStatement =class n extends _chunkHO5ESTN4js.x{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?wi(r,32):_chunkHO5ESTN4js.v.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(Pt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return Qe(this.bcsToBytes(),this.domainSeparator)}},nn= exports.ZkProof =class n extends _chunkHO5ESTN4js.x{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(Pt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},fe= exports.ZeroKnowledgeSig =class n extends O{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new C(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=nn.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Le);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},zi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Mu,maxExtraFieldBytes:o=qu,maxJwtHeaderB64Bytes:s=$u,maxIssValBytes:a=Lu,maxCommitedEpkBytes:c=Wu}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new Tt(new E(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new ki({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})}},ki= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new tt(t),this.betaG2=new Ut(r),this.deltaG2=new Ut(i),this.gammaAbcG1=[new tt(o[0]),new tt(o[1])],this.gammaG2=new Ut(s)}hash(){let e=new _chunkHO5ESTN4js.y;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}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(),c=this.betaG2.toProjectivePoint(),d=this.gammaG2.toProjectivePoint(),m=this.deltaG2.toProjectivePoint(),A=this.gammaAbcG1.map(At=>At.toProjectivePoint()),{Fp12:p}=_bn254.bn254.fields,g=A[0].add(A[1].multiply(t)),b=_bn254.bn254.pairing(g,d),D=_bn254.bn254.pairing(i,o),q=_bn254.bn254.pairing(a,c),se=_bn254.bn254.pairing(s,m),Ye=p.mul(q,p.mul(b,se));return p.eql(D,Ye)}catch(i){throw _.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 rn(n){let{aptosConfig:e}=n;try{return await $e(async()=>{let[t,r]=await Promise.all([ju(n),Ju(n)]);return zi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof _?t:_.fromErrorType({type:25,error:t})}}function nt(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw _.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunkHO5ESTN4js.ta.call(void 0, o)}`})}if(typeof r.iss!="string")throw _.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw _.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 ju(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await H({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunkHO5ESTN4js.na.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _44 => _44.ledgerVersion])}});return i.data}catch(i){throw _.fromErrorType({type:22,error:i})}}async function Ju(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await H({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunkHO5ESTN4js.na.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}catch(i){throw _.fromErrorType({type:23,error:i})}}async function Xu(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await H({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _46 => _46.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await H({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _47 => _47.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,m=new C(_chunkHO5ESTN4js.v.fromHexInput(d).toUint8Array()),A=Ni.deserialize(m);a.push(A)}o.set(_chunkHO5ESTN4js.w.call(void 0, s.issuer),a)}return o}var Ni=class n extends _chunkHO5ESTN4js.x{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new C(_chunkHO5ESTN4js.v.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw _.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunkHO5ESTN4js.xa.call(void 0, this.n),r=Yu(e.reverse()).map(i=>Ct(i));return r.push(256n),Kt(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 Yu(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 Zu(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var L=class n extends ae{constructor(e,t){super(),this.jwkAddress=_chunkHO5ESTN4js.na.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunkHO5ESTN4js.y;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),V.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Pr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunkHO5ESTN4js.na.deserialize(e),r=K.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Di({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,K.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,K.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunkHO5ESTN4js.na&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof K}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var De=class De extends et{constructor(t){super();this.keyType="secp256k1";let r=_chunkHO5ESTN4js.v.fromHexInput(t),{length:i}=r.toUint8Array();if(i===De.LENGTH)this.key=r;else if(i===De.COMPRESSED_LENGTH){let o=_secp256k1.secp256k1.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunkHO5ESTN4js.v.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${De.LENGTH} or ${De.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=sn(r),s=_chunkHO5ESTN4js.v.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(t){return this.verifySignature(t)}toUint8Array(){return this.key.toUint8Array()}serialize(t){t.serializeBytes(this.key.toUint8Array())}deserialize(t){let r=t.deserializeBytes();return new it(r)}static deserialize(t){let r=t.deserializeBytes();return new De(r)}static isPublicKey(t){return t instanceof De}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _48 => _48.key, 'optionalAccess', _49 => _49.data, 'optionalAccess', _50 => _50.length])===De.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};De.LENGTH=65,De.COMPRESSED_LENGTH=33;var Fe=De,je=class je extends _chunkHO5ESTN4js.x{constructor(e,t){super();let r=Pe.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==je.LENGTH)throw new Error(`PrivateKey length should be ${je.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new je(e,!1)}static fromDerivationPath(e,t){if(!is(e))throw new Error(`Invalid derivation path ${e}`);return je.fromDerivationPathInner(e,mr(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new je(r,!1)}sign(e){let t=sn(e),r=_chunkHO5ESTN4js.v.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new it(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Fe(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.key.toString()}toAIP80String(){return Pe.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new je(t,!1)}static isPrivateKey(e){return e instanceof je}};je.LENGTH=32;var rt=je,on=class on extends O{constructor(e){super();let t=_chunkHO5ESTN4js.v.fromHexInput(e);if(t.toUint8Array().length!==on.LENGTH)throw new Error(`Signature length should be ${on.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new on(t)}};on.LENGTH=64;var it=on;var _nistjs = require('@noble/curves/nist.js');var _e=class _e extends et{constructor(t){super();this.keyType="secp256r1";let r=_chunkHO5ESTN4js.v.fromHexInput(t),i=r.toUint8Array().length;if(i!==_e.LENGTH&&i!==_e.COMPRESSED_LENGTH)throw new Error(`PublicKey length should be ${_e.LENGTH} or ${_e.COMPRESSED_LENGTH}, received ${i}`);if(i===_e.COMPRESSED_LENGTH){let o=_nistjs.p256.ProjectivePoint.fromHex(r.toUint8Array());this.key=_chunkHO5ESTN4js.v.fromHexInput(o.toRawBytes(!1))}else this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}bcsToBytes(){let t=new _chunkHO5ESTN4js.y;return this.serialize(t),t.toUint8Array()}verifySignature(t){let{message:r,signature:i}=t,o=_chunkHO5ESTN4js.v.fromHexInput(r).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=i.toUint8Array();return _nistjs.p256.verify(a,s,this.toUint8Array())}async verifySignatureAsync(t){return this.verifySignature({message:t.message,signature:t.signature})}serialize(t){t.serializeBytes(this.key.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new _e(r)}static load(t){let r=t.deserializeBytes();return new _e(r)}static isInstance(t){return"key"in t&&_optionalChain([t, 'access', _51 => _51.key, 'optionalAccess', _52 => _52.data, 'optionalAccess', _53 => _53.length])===_e.LENGTH&&"keyType"in t&&t.keyType==="secp256r1"}authKey(){let t=new _chunkHO5ESTN4js.y;return t.serializeU32AsUleb128(2),t.serializeFixedBytes(this.bcsToBytes()),V.fromSchemeAndBytes({scheme:2,input:t.toUint8Array()})}};_e.LENGTH=65,_e.COMPRESSED_LENGTH=33;var un=_e,zt=class zt extends Pe{constructor(e,t){super();let r=Pe.parseHexInput(e,"secp256r1",t),i=r.toUint8Array().length;if(i!==zt.LENGTH)throw new Error(`PrivateKey length should be ${zt.LENGTH}, received ${i}`);this.key=r}toUint8Array(){return this.key.toUint8Array()}toString(){return Pe.formatPrivateKey(this.key.toString(),"secp256r1")}toHexString(){return this.key.toString()}sign(e){let t=_chunkHO5ESTN4js.v.fromHexInput(e),r=_sha3.sha3_256.call(void 0, t.toUint8Array()),i=_nistjs.p256.sign(r,this.key.toUint8Array());return new Oi(i.toCompactRawBytes())}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new zt(t)}static generate(){let e=_nistjs.p256.utils.randomPrivateKey();return new zt(e)}publicKey(){let e=_nistjs.p256.getPublicKey(this.key.toUint8Array(),!1);return new un(e)}};zt.LENGTH=32;var Cs=zt,Bn= exports.WebAuthnSignature =class n extends O{constructor(e,t,r){super(),this.signature=_chunkHO5ESTN4js.v.fromHexInput(e),this.authenticatorData=_chunkHO5ESTN4js.v.fromHexInput(t),this.clientDataJSON=_chunkHO5ESTN4js.v.fromHexInput(r)}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.signature.toUint8Array()),e.serializeBytes(this.authenticatorData.toUint8Array()),e.serializeBytes(this.clientDataJSON.toUint8Array())}bcsToBytes(){let e=new _chunkHO5ESTN4js.y;return this.serialize(e),e.toUint8Array()}bcsToHex(){return _chunkHO5ESTN4js.v.fromHexInput(this.bcsToBytes())}toStringWithoutPrefix(){return _chunkHO5ESTN4js.v.fromHexInput(this.bcsToBytes()).toString()}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Invalid id for WebAuthnSignature: ${t}`);let r=e.deserializeBytes(),i=e.deserializeBytes(),o=e.deserializeBytes();return new n(r,i,o)}},an=class an extends O{constructor(e){super();let t=_chunkHO5ESTN4js.v.fromHexInput(e),r=t.toUint8Array().length;if(r!==an.LENGTH)throw new Error(`Signature length should be ${an.LENGTH}, received ${r}`);let i=_nistjs.p256.Signature.fromCompact(t.toUint8Array()).normalizeS().toCompactRawBytes();this.data=_chunkHO5ESTN4js.v.fromHexInput(i)}toUint8Array(){return this.data.toUint8Array()}toString(){return this.data.toString()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new an(t)}};an.LENGTH=64;var Oi=an;var I=class n extends ae{constructor(e){if(super(),this.publicKey=e,e instanceof E)this.variant=0;else if(e instanceof Fe)this.variant=1;else if(e instanceof un)this.variant=2;else if(e instanceof K)this.variant=3;else if(e instanceof L)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof K)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 B)){if(_optionalChain([e, 'access', _54 => _54.options, 'optionalAccess', _55 => _55.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 V.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=E.deserialize(e);break;case 1:r=Fe.deserialize(e);break;case 2:r=un.deserialize(e);break;case 3:r=K.deserialize(e);break;case 4:r=L.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 E}isSecp256k1PublicKey(){return this.publicKey instanceof Fe}static isInstance(e){return"publicKey"in e&&"variant"in e}},B= exports.AnySignature =class n extends O{constructor(e){if(super(),this.signature=e,e instanceof R)this.variant=0;else if(e instanceof it)this.variant=1;else if(e instanceof Bn)this.variant=2;else if(e instanceof ce)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=R.deserialize(e);break;case 1:r=it.deserialize(e);break;case 2:r=Bn.deserialize(e);break;case 3:r=ce.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 td(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Er=3,Oe= exports.AbstractMultiKey =class extends ae{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 c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=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}`)}},W= exports.MultiKey =class n extends Oe{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`);if(this.publicKeys=t.map(i=>i instanceof I?i:new I(i)),r>Er&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>Er)throw new Error(`Construction of MultiKey with more than ${Er} keyless public keys is not allowed when signaturesRequired
|
|
7
|
+
is greater than ${Er}. This is because a maximum of 3 keyless signatures are supported for a
|
|
8
|
+
K-of-N MultiKey transaction.`);this.signaturesRequired=r}getSignaturesRequired(){return this.signaturesRequired}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 Ie))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(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.throwErrorWithReason]))throw r;return!1}}authKey(){return V.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(I),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof I?e:new I(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},Ae=class Ae extends O{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>Ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${Ae.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof B?o:new B(o)),!(r instanceof Uint8Array))this.bitmap=Ae.createBitmap({bits:r});else{if(r.length!==Ae.BITMAP_LEN)throw new Error(`"bitmap" length should be ${Ae.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+td(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>=Ae.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${Ae.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),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(B),r=e.deserializeBytes();return new Ae({signatures:t,bitmap:r})}};Ae.BITMAP_LEN=4,Ae.MAX_SIGNATURES_SUPPORTED=Ae.BITMAP_LEN*8;var Ie=Ae;var he=class he extends Oe{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>he.MAX_KEYS||t.length<he.MIN_KEYS)throw new Error(`Must have between ${he.MIN_KEYS} and ${he.MAX_KEYS} public keys, inclusive`);if(r<he.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${he.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Be))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return V.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*E.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*E.LENGTH)}),e[this.publicKeys.length*E.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+=E.LENGTH){let s=o;i.push(new E(t.subarray(s,s+E.LENGTH)))}return new he({publicKeys:i,threshold:r})}static deserializeWithoutLength(e){let t=e.remaining(),r=e.deserializeFixedBytes(t),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=E.LENGTH){let a=s;o.push(new E(r.subarray(a,a+E.LENGTH)))}return new he({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};he.MAX_KEYS=32,he.MIN_KEYS=2,he.MIN_THRESHOLD=1;var ie=he,be=class be extends O{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>be.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${be.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=be.createBitmap({bits:r});else{if(r.length!==be.BITMAP_LEN)throw new Error(`"bitmap" length should be ${be.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*R.LENGTH+be.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*R.LENGTH)}),e.set(this.bitmap,this.signatures.length*R.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+=R.LENGTH){let s=o;i.push(new R(t.subarray(s,s+R.LENGTH)))}return new be({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>=be.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${be.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),d=i[c];d|=r>>s%8,i[c]=d}),i}};be.MAX_SIGNATURES_SUPPORTED=32,be.BITMAP_LEN=4;var Be=be;var sn=n=>typeof n=="string"?_chunkHO5ESTN4js.v.isValid(n).valid?n:new TextEncoder().encode(n):n,Bi=n=>{if(n instanceof E||n instanceof I||n instanceof ie||n instanceof W)return n;if(n instanceof K||n instanceof L)return new I(n);throw new Error(`Unknown account public key: ${n}`)},Rs=n=>{let e=Bi(n);if(e instanceof E)return 0;if(e instanceof I)return 2;if(e instanceof ie)return 1;if(e instanceof W)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var Gi=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function nd(n){let e=n.toUint8Array().slice(32);for(let t=Gi.length-1;t>=0;t-=1){if(e[t]<Gi[t])return!0;if(e[t]>Gi[t])return!1}return!1}var Et=class Et extends ae{constructor(e){super();let t=_chunkHO5ESTN4js.v.fromHexInput(e);if(t.toUint8Array().length!==Et.LENGTH)throw new Error(`PublicKey length should be ${Et.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!nd(r))return!1;let i=sn(t),o=_chunkHO5ESTN4js.v.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return V.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Et(t)}static isPublicKey(e){return e instanceof Et}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _58 => _58.key, 'optionalAccess', _59 => _59.data, 'optionalAccess', _60 => _60.length])===Et.LENGTH}};Et.LENGTH=32;var E=Et,xe=class xe extends _chunkHO5ESTN4js.x{constructor(e,t){super();let r=Pe.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==xe.LENGTH)throw new Error(`PrivateKey length should be ${xe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new xe(e,!1)}static fromDerivationPath(e,t){if(!os(e))throw new Error(`Invalid derivation path ${e}`);return xe.fromDerivationPathInner(e,mr(t))}static fromDerivationPathInner(e,t,r=rs){let{key:i,chainCode:o}=bi(xe.SLIP_0010_SEED,t),s=as(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,d)=>ss(c,d+r),{key:i,chainCode:o});return new xe(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new E(e)}sign(e){let t=sn(e),r=_chunkHO5ESTN4js.v.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new R(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toAIP80String()}toHexString(){return this.signingKey.toString()}toAIP80String(){return Pe.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new xe(t,!1)}static isPrivateKey(e){return e instanceof xe}};xe.LENGTH=32,xe.SLIP_0010_SEED="ed25519 seed";var J=xe,dn=class dn extends O{constructor(e){super();let t=_chunkHO5ESTN4js.v.fromHexInput(e);if(t.toUint8Array().length!==dn.LENGTH)throw new Error(`Signature length should be ${dn.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new dn(t)}};dn.LENGTH=64;var R=dn;var Ir="Multiple possible deserializations found";function Kf(n){let e=[E,I,ie,W,K,L,Fe],t;for(let r of e)try{let i=C.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Ir}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Ir))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function Rf(n){let e=[R,B,Be,Ie,ce,it],t;for(let r of e)try{let i=C.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${Ir}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(Ir))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var ee=class extends _chunkHO5ESTN4js.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ge.load(e);case 1:return ot.load(e);case 2:return ue.load(e);case 3:return Je.load(e);case 4:return pn.load(e);case 5:return kt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ge}isMultiEd25519(){return this instanceof ot}isSingleKey(){return this instanceof ue}isMultiKey(){return this instanceof Je}},Ge= exports.AccountAuthenticatorEd25519 =class n extends ee{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=E.deserialize(e),r=R.deserialize(e);return new n(t,r)}},ot= exports.AccountAuthenticatorMultiEd25519 =class n extends ee{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=ie.deserialize(e),r=Be.deserialize(e);return new n(t,r)}},ue= exports.AccountAuthenticatorSingleKey =class n extends ee{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=I.deserialize(e),r=B.deserialize(e);return new n(t,r)}},Je= exports.AccountAuthenticatorMultiKey =class n extends ee{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=W.deserialize(e),r=Ie.deserialize(e);return new n(t,r)}},pn= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends ee{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},kt= exports.AccountAuthenticatorAbstraction =class n extends ee{constructor(e,t,r,i){if(super(),!_chunkHO5ESTN4js.Da.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=_chunkHO5ESTN4js.v.fromHexInput(_chunkHO5ESTN4js.v.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunkHO5ESTN4js.Ca.call(void 0, this.functionInfo);_chunkHO5ESTN4js.na.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.abstractionSignature):e.serializeFixedBytes(this.abstractionSignature),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunkHO5ESTN4js.na.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32(),s=e.deserializeBytes();if(o===0){let a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}},xr= exports.AccountAbstractionMessage =class n extends _chunkHO5ESTN4js.x{constructor(e,t){super(),this.originalSigningMessage=_chunkHO5ESTN4js.v.fromHexInput(_chunkHO5ESTN4js.v.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=_chunkHO5ESTN4js.Ca.call(void 0, this.functionInfo);_chunkHO5ESTN4js.na.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i)}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t!==0)throw new Error(`Unknown variant index for AccountAbstractionMessage: ${t}`);let r=e.deserializeBytes(),i=_chunkHO5ESTN4js.na.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};var ln=class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var k=class n extends _chunkHO5ESTN4js.x{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var Gn=class n extends _chunkHO5ESTN4js.x{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(_chunkHO5ESTN4js.na.fromString(t[0]),new k(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunkHO5ESTN4js.na.deserialize(e),r=k.deserialize(e);return new n(t,r)}};var U=class n extends _chunkHO5ESTN4js.x{deserialize(e){let t=_chunkHO5ESTN4js.na.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(n);return new Xe(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Q.load(e);case 1:return de.load(e);case 2:return te.load(e);case 3:return ct.load(e);case 4:return G.load(e);case 5:return Mt.load(e);case 6:return z.load(e);case 7:return h.load(e);case 8:return st.load(e);case 9:return at.load(e);case 10:return ut.load(e);case 11:return Nt.load(e);case 12:return Dt.load(e);case 13:return Ft.load(e);case 14:return Ot.load(e);case 15:return Bt.load(e);case 16:return Gt.load(e);case 255:return M.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof Q}isAddress(){return this instanceof G}isGeneric(){return this instanceof M}isSigner(){return this instanceof Mt}isVector(){return this instanceof z}isStruct(){return this instanceof h}isU8(){return this instanceof de}isU16(){return this instanceof st}isU32(){return this instanceof at}isU64(){return this instanceof te}isU128(){return this instanceof ct}isU256(){return this instanceof ut}isI8(){return this instanceof Nt}isI16(){return this instanceof Dt}isI32(){return this instanceof Ft}isI64(){return this instanceof Ot}isI128(){return this instanceof Bt}isI256(){return this instanceof Gt}isPrimitive(){return this instanceof Mt||this instanceof G||this instanceof Q||this instanceof de||this instanceof st||this instanceof at||this instanceof te||this instanceof ct||this instanceof ut||this instanceof Nt||this instanceof Dt||this instanceof Ft||this instanceof Ot||this instanceof Bt||this instanceof Gt}},Q= exports.TypeTagBool =class n extends U{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},de= exports.TypeTagU8 =class n extends U{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Nt= exports.TypeTagI8 =class n extends U{toString(){return"i8"}serialize(e){e.serializeU32AsUleb128(11)}static load(e){return new n}},st= exports.TypeTagU16 =class n extends U{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Dt= exports.TypeTagI16 =class n extends U{toString(){return"i16"}serialize(e){e.serializeU32AsUleb128(12)}static load(e){return new n}},at= exports.TypeTagU32 =class n extends U{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},Ft= exports.TypeTagI32 =class n extends U{toString(){return"i32"}serialize(e){e.serializeU32AsUleb128(13)}static load(e){return new n}},te= exports.TypeTagU64 =class n extends U{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Ot= exports.TypeTagI64 =class n extends U{toString(){return"i64"}serialize(e){e.serializeU32AsUleb128(14)}static load(e){return new n}},ct= exports.TypeTagU128 =class n extends U{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Bt= exports.TypeTagI128 =class n extends U{toString(){return"i128"}serialize(e){e.serializeU32AsUleb128(15)}static load(e){return new n}},ut= exports.TypeTagU256 =class n extends U{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},Gt= exports.TypeTagI256 =class n extends U{toString(){return"i256"}serialize(e){e.serializeU32AsUleb128(16)}static load(e){return new n}},G= exports.TypeTagAddress =class n extends U{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Mt= exports.TypeTagSigner =class n extends U{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},vr= exports.TypeTagReference =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)}},M= exports.TypeTagGeneric =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)}},z= exports.TypeTagVector =class n extends U{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new de)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=U.deserialize(t);return new n(r)}},h= exports.TypeTagStruct =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=Xe.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(_chunkHO5ESTN4js.na.ONE,"string","String")}isOption(){return this.isTypeTag(_chunkHO5ESTN4js.na.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunkHO5ESTN4js.na.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunkHO5ESTN4js.na.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunkHO5ESTN4js.na.ONE,"rate_limiter","RateLimiter")}},Xe= exports.StructTag =class n extends _chunkHO5ESTN4js.x{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=_chunkHO5ESTN4js.na.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(U);return new n(t,r,i,o)}};function KA(){return new Xe(_chunkHO5ESTN4js.na.ONE,new k("aptos_coin"),new k("AptosCoin"),[])}function x(){return new Xe(_chunkHO5ESTN4js.na.ONE,new k("string"),new k("String"),[])}function RA(n){return new Xe(_chunkHO5ESTN4js.na.ONE,new k("option"),new k("Option"),[n])}function Te(n){return new Xe(_chunkHO5ESTN4js.na.ONE,new k("object"),new k("Object"),[n])}function rd(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Z.deserialize(n);case 1:return $.deserialize(n);case 2:return ke.deserialize(n);case 3:return _chunkHO5ESTN4js.na.deserialize(n);case 4:return S.deserialize(n,Z);case 5:return F.deserialize(n);case 6:return Ue.deserialize(n);case 7:return ze.deserialize(n);case 8:return Se.deserialize(n);case 9:return Rn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var _t=class extends _chunkHO5ESTN4js.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return gn.load(e);case 2:return yn.load(e);case 3:return mn.load(e);case 4:return Cr.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},gn= exports.TransactionPayloadScript =class n extends _t{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=fn.deserialize(e);return new n(t)}},yn= exports.TransactionPayloadEntryFunction =class n extends _t{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=dt.deserialize(e);return new n(t)}},mn= exports.TransactionPayloadMultiSig =class n extends _t{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Mn.deserialize(e);return new n(t)}},dt= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(Gn.fromStr(e),new k(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=Gn.deserialize(e),r=k.deserialize(e),i=e.deserializeVector(U),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=gr.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},fn= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(U),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=rd(e);o.push(a)}return new n(t,r,o)}},Mn= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=_chunkHO5ESTN4js.na.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Vn.deserialize(e)),new n(t,i)}},Vn= exports.MultiSigTransactionPayload =class n extends _chunkHO5ESTN4js.x{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(dt.deserialize(e))}},Cr= exports.TransactionInnerPayload =class extends _t{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Vt.load(e);default:throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}}},Vt= exports.TransactionInnerPayloadV1 =class n extends Cr{constructor(e,t){super(),this.executable=e,this.extra_config=t}serialize(e){e.serializeU32AsUleb128(4),e.serializeU32AsUleb128(0),this.executable.serialize(e),this.extra_config.serialize(e)}static load(e){let t=An.deserialize(e),r=Kr.deserialize(e);return new n(t,r)}},An= exports.TransactionExecutable =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Hn.load(e);case 1:return hn.load(e);case 2:return Ln.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},Hn= exports.TransactionExecutableScript =class n extends An{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=fn.deserialize(e);return new n(t)}},hn= exports.TransactionExecutableEntryFunction =class n extends An{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=dt.deserialize(e);return new n(t)}},Ln= exports.TransactionExecutableEmpty =class n extends An{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Kr= exports.TransactionExtraConfig =class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ht.load(e);default:throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}}},Ht= exports.TransactionExtraConfigV1 =class n extends Kr{constructor(e,t){super(),this.multisigAddress=e,this.replayProtectionNonce=t!==void 0?BigInt(t):void 0}serialize(e){e.serializeU32AsUleb128(0),e.serializeOption(this.multisigAddress),e.serializeOption(this.replayProtectionNonce!==void 0?new $(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(_chunkHO5ESTN4js.na),r=e.deserializeOption($);return new n(t,_optionalChain([r, 'optionalAccess', _61 => _61.value]))}};var ve=class n extends _chunkHO5ESTN4js.x{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=_chunkHO5ESTN4js.na.deserialize(e),r=e.deserializeU64(),i=_t.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=ln.deserialize(e);return new n(t,r,i,o,s,a,c)}},Rr= exports.RawTransactionWithData =class extends _chunkHO5ESTN4js.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Lt.load(e);case 1:return qt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Lt= exports.MultiAgentRawTransaction =class n extends Rr{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=ve.deserialize(e),r=e.deserializeVector(_chunkHO5ESTN4js.na);return new n(t,r)}},qt= exports.FeePayerRawTransaction =class n extends Rr{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=ve.deserialize(e),r=e.deserializeVector(_chunkHO5ESTN4js.na),i=_chunkHO5ESTN4js.na.deserialize(e);return new n(t,r,i)}};var Ur=class extends _chunkHO5ESTN4js.x{constructor(t){super();this.accountAddress=_chunkHO5ESTN4js.na.ONE;this.moduleName=new v("account");this.structName=new v("RotationProofChallenge");this.sequenceNumber=new $(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var pt=class extends _chunkHO5ESTN4js.x{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return $t.load(e);case 1:return bn.load(e);case 2:return Wt.load(e);case 3:return Qt.load(e);case 4:return It.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof $t}isMultiEd25519(){return this instanceof bn}isMultiAgent(){return this instanceof Wt}isFeePayer(){return this instanceof Qt}isSingleSender(){return this instanceof It}},$t= exports.TransactionAuthenticatorEd25519 =class n extends pt{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=E.deserialize(e),r=R.deserialize(e);return new n(t,r)}},bn= exports.TransactionAuthenticatorMultiEd25519 =class n extends pt{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=ie.deserialize(e),r=Be.deserialize(e);return new n(t,r)}},Wt= exports.TransactionAuthenticatorMultiAgent =class n extends pt{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=ee.deserialize(e),r=e.deserializeVector(_chunkHO5ESTN4js.na),i=e.deserializeVector(ee);return new n(t,r,i)}},Qt= exports.TransactionAuthenticatorFeePayer =class n extends pt{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=ee.deserialize(e),r=e.deserializeVector(_chunkHO5ESTN4js.na),i=e.deserializeVector(ee),o=_chunkHO5ESTN4js.na.deserialize(e),s=ee.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},It= exports.TransactionAuthenticatorSingleSender =class n extends pt{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=ee.deserialize(e);return new n(t)}};var lt=class n extends _chunkHO5ESTN4js.x{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=ve.deserialize(e),r=pt.deserialize(e);return new n(t,r)}};var zr=class n extends _chunkHO5ESTN4js.x{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=ve.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunkHO5ESTN4js.na.deserialize(e)),new n(t,i)}};var kr=class n extends _chunkHO5ESTN4js.x{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=ve.deserialize(e),r=e.deserializeVector(_chunkHO5ESTN4js.na),i=e.deserializeBool(),o;return i&&(o=_chunkHO5ESTN4js.na.deserialize(e)),new n(t,r,o)}};function Nr(n){return n.feePayerAddress?new qt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Lt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Qe(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function Lh(n){return Qe(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Me(n){let e=Nr(n);return n.feePayerAddress?Qe(e.bcsToBytes(),Ii):n.secondarySignerAddresses?Qe(e.bcsToBytes(),Ii):Qe(e.bcsToBytes(),As)}var oe=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunkHO5ESTN4js.na.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=J.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=J.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 Ge(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ge(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Me(e))}};function Mi(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var pe=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new I(t.publicKey()),this.accountAddress=r?_chunkHO5ESTN4js.na.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=J.generate();break;case 2:r=rt.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=J.fromDerivationPath(r,i);break;case 2:o=rt.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 ue(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ue(this.publicKey,this.signTransaction(e))}sign(e){return new B(this.privateKey.sign(e))}signTransaction(e){return this.sign(Me(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var gt=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?oe.generate():pe.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof J&&i?new oe({privateKey:t,address:r}):new pe({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?oe.fromDerivationPath({mnemonic:r,path:i}):pe.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)}};var _utils3 = require('@noble/hashes/utils');var sd=1209600,Tn=class Tn extends _chunkHO5ESTN4js.x{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new Tt(t.publicKey()),this.expiryDateSecs=r||_chunkHO5ESTN4js.va.call(void 0, _chunkHO5ESTN4js.ua.call(void 0, )+sd),this.blinder=i!==void 0?_chunkHO5ESTN4js.v.fromHexInput(i).toUint8Array():ad();let o=kn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Ct(this.blinder));let s=Kt(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=J.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new Tn({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return Tn.deserialize(new C(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _62 => _62.scheme])){case 0:default:t=J.generate()}return new Tn({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _63 => _63.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Le(this.privateKey.sign(e))}};Tn.BLINDER_LENGTH=31;var jt=Tn;function ad(){return _utils3.randomBytes.call(void 0, jt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function Fr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var wn=class wn extends _chunkHO5ESTN4js.x{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:m,proofFetchCallback:A,jwt:p,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunkHO5ESTN4js.na.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new _eventemitter32.default,this.proofOrPromise=m,m instanceof fe)this.proof=m;else{if(A===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async D=>{await A(D),this.emitter.removeAllListeners()}),this.init(m)}let b=_chunkHO5ESTN4js.v.fromHexInput(d).toUint8Array();if(b.length!==wn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${wn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunkHO5ESTN4js.v.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunkHO5ESTN4js.v.hexInputToUint8Array(g)}}getAnyPublicKey(){return new I(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=_chunkHO5ESTN4js.na.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=jt.deserialize(t),c=fe.deserialize(t),d=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:d}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new B(this.sign(t)),i=new I(this.publicKey);return new ue(i,r)}signTransactionWithAuthenticator(t){let r=new B(this.signTransaction(t)),i=new I(this.publicKey);return new ue(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw _.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw _.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw _.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 rn({aptosConfig:t});if(_chunkHO5ESTN4js.v.hexInputToString(i.hash())!==_chunkHO5ESTN4js.v.hexInputToString(this.verificationKeyHash))throw _.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 wn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw _.fromErrorType({type:0});if(this.proof===void 0)throw _.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 ce({jwtHeader:_chunkHO5ESTN4js.wa.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new tn(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw _.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=Nr(t),o=new Dr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw _.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=Nr(t);return new Dr(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 Fi(t)}};wn.PEPPER_LENGTH=31;var we=wn,Dr= exports.TransactionAndProof =class extends _chunkHO5ESTN4js.x{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 Qe(this.bcsToBytes(),this.domainSeparator)}};var Ce=class n extends we{constructor(e){let t=K.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=we.partialDeserialize(e),{iss:d,aud:m,uidVal:A}=nt({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:A,aud:m,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new C(_chunkHO5ESTN4js.v.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d,verificationKeyHash:m}=e;if(m&&d)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:A,aud:p,uidVal:g}=nt({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:A,uidKey:a,uidVal:g,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:_nullishCoalesce(m, () => ((d?d.hash():void 0)))})}};var Ve=class n extends we{constructor(e){let t=L.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=we.partialDeserialize(e),d=_chunkHO5ESTN4js.na.deserialize(e),{iss:m,aud:A,uidVal:p}=nt({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:m,uidKey:s,uidVal:p,aud:A,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(C.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:m,verificationKeyHash:A}=e;if(A&&m)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:g,uidVal:b}=nt({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:b,aud:g,pepper:s,jwkAddress:_chunkHO5ESTN4js.na.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:_nullishCoalesce(A, () => ((m?m.hash():void 0)))})}};var yt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof oe?pe.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?_chunkHO5ESTN4js.na.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new W({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Je(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Je(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof we).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof we).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 Ie({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Ie({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var qn=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunkHO5ESTN4js.na.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,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[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 ot(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ot(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Be({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Me(e))}};function Us(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunkHO5ESTN4js.ja).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunkHO5ESTN4js.na.deserialize(n),signingScheme:e}}function zs(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 ks(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=jt.deserialize(n),o=fe.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Ns;(A=>{function n(p){let g=new _chunkHO5ESTN4js.y;switch(g.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(g),p.signingScheme){case 0:return p.privateKey.serialize(g),g.toUint8Array();case 2:{if(!Mi(p))throw new Error("Account is not a SingleKeySigner");let b=p.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return zs(p,g),g.toUint8Array();case 4:{let D=p;return zs(D,g),D.publicKey.jwkAddress.serialize(g),g.serializeBool(D.audless),g.toUint8Array()}case 1:case 0:return p.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=p;return b.publicKey.serialize(g),g.serializeU32AsUleb128(b.signers.length),b.signers.forEach(D=>{g.serializeFixedBytes(n(D))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}A.toBytes=n;function e(p){return _chunkHO5ESTN4js.v.hexInputToStringWithoutPrefix(n(p))}A.toHexStringWithoutPrefix=e;function t(p){return _chunkHO5ESTN4js.v.hexInputToString(n(p))}A.toHexString=t;function r(p){let{address:g,signingScheme:b}=Us(p);switch(b){case 0:{let D=J.deserialize(p);return new oe({privateKey:D,address:g})}case 2:{let D=p.deserializeUleb128AsU32();switch(D){case 0:{let q=J.deserialize(p);return new pe({privateKey:q,address:g})}case 1:{let q=rt.deserialize(p);return new pe({privateKey:q,address:g})}case 3:{let q=ks(p),se=nt(q);return new Ce({...q,...se})}case 4:{let q=ks(p),se=_chunkHO5ESTN4js.na.deserialize(p),Ye=p.deserializeBool(),At=nt(q);return new Ve({...q,...At,jwkAddress:se,audless:Ye})}default:throw new Error(`Unsupported public key variant ${D}`)}}case 3:{let D=W.deserialize(p),q=p.deserializeUleb128AsU32(),se=new Array;for(let Ye=0;Ye<q;Ye+=1){let At=r(p);if(!Mi(At)&&!(At instanceof oe))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");se.push(At)}return new yt({multiKey:D,signers:se,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}A.deserialize=r;function i(p){let g=d(p);if(!(g instanceof Ce))throw new Error("Deserialization of KeylessAccount failed");return g}A.keylessAccountFromHex=i;function o(p){let g=d(p);if(!(g instanceof Ve))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}A.federatedKeylessAccountFromHex=o;function s(p){let g=d(p);if(!(g instanceof yt))throw new Error("Deserialization of MultiKeyAccount failed");return g}A.multiKeyAccountFromHex=s;function a(p){let g=d(p);if(!(g instanceof pe))throw new Error("Deserialization of SingleKeyAccount failed");return g}A.singleKeyAccountFromHex=a;function c(p){let g=d(p);if(!(g instanceof oe))throw new Error("Deserialization of Ed25519Account failed");return g}A.ed25519AccountFromHex=c;function d(p){return r(C.fromHex(p))}A.fromHex=d;function m(p){return d(p)}A.fromBytes=m})(Ns||(Ns= exports.AccountUtils ={}));var Or=class n extends gt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunkHO5ESTN4js.Da.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new yr(this.accountAddress),this.sign=o=>new Un(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunkHO5ESTN4js.y;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new xr(t,r);return Qe(i.bcsToBytes(),hs)}signWithAuthenticator(t){return new kt(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(Me(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(Me(t))}setSigner(t){this.sign=r=>new Un(t(r))}};var $n=class $n extends Or{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunkHO5ESTN4js.na)($n.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunkHO5ESTN4js.Da.call(void 0, e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=_sha3.sha3_256.create(),a=new _chunkHO5ESTN4js.y;_chunkHO5ESTN4js.na.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunkHO5ESTN4js.y;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([$n.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new kt(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};$n.ADDRESS_DOMAIN_SEPERATOR=5;var Fs=$n;var dd=`
|
|
9
9
|
fragment TokenActivitiesFields on token_activities_v2 {
|
|
10
10
|
after_value
|
|
11
11
|
before_value
|
|
@@ -23,7 +23,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
23
23
|
transaction_version
|
|
24
24
|
type
|
|
25
25
|
}
|
|
26
|
-
`,
|
|
26
|
+
`,pd=`
|
|
27
27
|
fragment AnsTokenFragment on current_aptos_names {
|
|
28
28
|
domain
|
|
29
29
|
expiration_timestamp
|
|
@@ -35,7 +35,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
35
35
|
subdomain_expiration_policy
|
|
36
36
|
domain_expiration_timestamp
|
|
37
37
|
}
|
|
38
|
-
`,
|
|
38
|
+
`,Br=`
|
|
39
39
|
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
|
|
40
40
|
token_standard
|
|
41
41
|
token_properties_mutated_v1
|
|
@@ -82,7 +82,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
`,
|
|
85
|
+
`,Os=`
|
|
86
86
|
query getAccountAddressesForAuthKey($where_condition: auth_key_account_addresses_bool_exp, $order_by: [auth_key_account_addresses_order_by!]) {
|
|
87
87
|
auth_key_account_addresses(where: $where_condition, order_by: $order_by) {
|
|
88
88
|
auth_key
|
|
@@ -91,7 +91,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
91
91
|
is_auth_key_used
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
`,
|
|
94
|
+
`,Bs=`
|
|
95
95
|
query getAccountCoinsCount($address: String) {
|
|
96
96
|
current_fungible_asset_balances_aggregate(
|
|
97
97
|
where: {owner_address: {_eq: $address}}
|
|
@@ -101,7 +101,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
`,
|
|
104
|
+
`,Gs=`
|
|
105
105
|
query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
|
|
106
106
|
current_fungible_asset_balances(
|
|
107
107
|
where: $where_condition
|
|
@@ -134,7 +134,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
`,
|
|
137
|
+
`,Ms=`
|
|
138
138
|
query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
|
|
139
139
|
current_collection_ownership_v2_view(
|
|
140
140
|
where: $where_condition
|
|
@@ -168,7 +168,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
168
168
|
single_token_uri
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
`,
|
|
171
|
+
`,Vs=`
|
|
172
172
|
query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
173
173
|
current_token_ownerships_v2(
|
|
174
174
|
where: $where_condition
|
|
@@ -179,7 +179,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
179
179
|
...CurrentTokenOwnershipFields
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
${
|
|
182
|
+
${Br}`,Fw=`
|
|
183
183
|
query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
184
184
|
current_token_ownerships_v2(
|
|
185
185
|
where: $where_condition
|
|
@@ -190,7 +190,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
190
190
|
...CurrentTokenOwnershipFields
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
${
|
|
193
|
+
${Br}`,Hs=`
|
|
194
194
|
query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
195
195
|
current_token_ownerships_v2(
|
|
196
196
|
where: $where_condition
|
|
@@ -201,7 +201,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
201
201
|
...CurrentTokenOwnershipFields
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
${
|
|
204
|
+
${Br}`,Ls=`
|
|
205
205
|
query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
|
|
206
206
|
current_token_ownerships_v2_aggregate(
|
|
207
207
|
where: $where_condition
|
|
@@ -213,7 +213,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
`,
|
|
216
|
+
`,qs=`
|
|
217
217
|
query getAccountTransactionsCount($address: String) {
|
|
218
218
|
account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
|
|
219
219
|
aggregate {
|
|
@@ -221,7 +221,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
`,$s=`
|
|
225
225
|
query getAuthKeysForPublicKey($where_condition: public_key_auth_keys_bool_exp, $order_by: [public_key_auth_keys_order_by!]) {
|
|
226
226
|
public_key_auth_keys(where: $where_condition, order_by: $order_by) {
|
|
227
227
|
public_key
|
|
@@ -233,13 +233,13 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
233
233
|
signature_type
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
`,
|
|
236
|
+
`,Ws=`
|
|
237
237
|
query getChainTopUserTransactions($limit: Int) {
|
|
238
238
|
user_transactions(limit: $limit, order_by: {version: desc}) {
|
|
239
239
|
version
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
`,
|
|
242
|
+
`,Qs=`
|
|
243
243
|
query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
|
|
244
244
|
current_collections_v2(where: $where_condition) {
|
|
245
245
|
uri
|
|
@@ -269,7 +269,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
|
-
`,
|
|
272
|
+
`,js=`
|
|
273
273
|
query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
|
|
274
274
|
current_fungible_asset_balances(
|
|
275
275
|
where: $where_condition
|
|
@@ -287,7 +287,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
287
287
|
token_standard
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
|
-
`,
|
|
290
|
+
`,Js=`
|
|
291
291
|
query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
|
|
292
292
|
delegated_staking_activities(
|
|
293
293
|
where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
|
|
@@ -300,7 +300,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
300
300
|
transaction_version
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
`;var
|
|
303
|
+
`;var Xs=`
|
|
304
304
|
query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
|
|
305
305
|
fungible_asset_activities(
|
|
306
306
|
where: $where_condition
|
|
@@ -325,7 +325,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
325
325
|
type
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
`,
|
|
328
|
+
`,Ys=`
|
|
329
329
|
query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
|
|
330
330
|
fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
|
|
331
331
|
icon_uri
|
|
@@ -344,7 +344,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
344
344
|
maximum_v2
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
`,
|
|
347
|
+
`,Sn=`
|
|
348
348
|
query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
|
|
349
349
|
current_aptos_names(
|
|
350
350
|
limit: $limit
|
|
@@ -355,14 +355,14 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
355
355
|
...AnsTokenFragment
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
${
|
|
358
|
+
${pd}`,Hi=`
|
|
359
359
|
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
360
360
|
num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
|
|
361
361
|
num_active_delegator
|
|
362
362
|
pool_address
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
-
`,
|
|
365
|
+
`,Gr=`
|
|
366
366
|
query getObjectData($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
|
|
367
367
|
current_objects(
|
|
368
368
|
where: $where_condition
|
|
@@ -379,7 +379,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
379
379
|
is_deleted
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
|
-
`,
|
|
382
|
+
`,Li=`
|
|
383
383
|
query getProcessorStatus($where_condition: processor_status_bool_exp) {
|
|
384
384
|
processor_status(where: $where_condition) {
|
|
385
385
|
last_success_version
|
|
@@ -387,7 +387,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
387
387
|
last_updated
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
|
-
`,
|
|
390
|
+
`,Zs=`
|
|
391
391
|
query getTableItemsData($where_condition: table_items_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_items_order_by!]) {
|
|
392
392
|
table_items(
|
|
393
393
|
where: $where_condition
|
|
@@ -403,7 +403,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
403
403
|
write_set_change_index
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
`,
|
|
406
|
+
`,ea=`
|
|
407
407
|
query getTableItemsMetadata($where_condition: table_metadatas_bool_exp!, $offset: Int, $limit: Int, $order_by: [table_metadatas_order_by!]) {
|
|
408
408
|
table_metadatas(
|
|
409
409
|
where: $where_condition
|
|
@@ -416,7 +416,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
416
416
|
value_type
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
`,
|
|
419
|
+
`,ta=`
|
|
420
420
|
query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
|
|
421
421
|
token_activities_v2(
|
|
422
422
|
where: $where_condition
|
|
@@ -427,7 +427,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
427
427
|
...TokenActivitiesFields
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
-
${
|
|
430
|
+
${dd}`,qi=`
|
|
431
431
|
query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
432
432
|
current_token_ownerships_v2(
|
|
433
433
|
where: $where_condition
|
|
@@ -438,7 +438,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
438
438
|
...CurrentTokenOwnershipFields
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
${
|
|
441
|
+
${Br}`,na=`
|
|
442
442
|
query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
|
|
443
443
|
current_token_datas_v2(
|
|
444
444
|
where: $where_condition
|
|
@@ -478,5 +478,5 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
`;async function Nr(n){let{aptosConfig:e}=n,{data:t}=await H({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function ks(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Ps,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Yo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Vu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Oi},originMethod:"getProcessorStatuses"})).processor_status}async function Dr(n){let e=await Vu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Fr(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Oi,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Or(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await H({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}`});return r}async function Ns(n){return _optionalChain([n, 'access', _64 => _64.options, 'optionalAccess', _65 => _65.ledgerVersion])!==void 0?zs(n):qe(async()=>zs(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function zs(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await H({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _66 => _66.ledgerVersion])}});return o}async function Gr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await wt({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _67 => _67.ledgerVersion])},body:r})).data}async function Ds(n){let{aptosConfig:e,options:t}=n,r={query:vs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _68 => _68.where]),offset:_optionalChain([t, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([t, 'optionalAccess', _70 => _70.limit]),order_by:_optionalChain([t, 'optionalAccess', _71 => _71.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function Fs(n){let{aptosConfig:e,options:t}=n,r={query:Ks,variables:{where_condition:_optionalChain([t, 'optionalAccess', _72 => _72.where]),offset:_optionalChain([t, 'optionalAccess', _73 => _73.offset]),limit:_optionalChain([t, 'optionalAccess', _74 => _74.limit]),order_by:_optionalChain([t, 'optionalAccess', _75 => _75.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Mi(n){let{aptosConfig:e,options:t}=n;return mr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _76 => _76.offset]),limit:_optionalChain([t, 'optionalAccess', _77 => _77.limit])}})}async function Mr(n){let{aptosConfig:e}=n;return qe(async()=>{let{data:t}=await H({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function Os(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await H({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function Mn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await H({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function Gs(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await Mn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _78 => _78.status])===404)return!0;throw r}}async function Hu(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await H({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function An(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _79 => _79.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _80 => _80.checkSuccess]), () => (!0)),s=!0,a=0,c,d,y=200,A=1.5;function p(g){if(!(g instanceof Pe)||(d=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await Mn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){p(g)}if(s){let g=Date.now();try{c=await Hu({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await Mn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){p(g)}await _chunk347THBDEjs.ga.call(void 0, y),a+=y/1e3,y*=A}if(c===void 0)throw d||new Br(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Br(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Bi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Vr(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await Dr({aptosConfig:e}):s=(await Fr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk347THBDEjs.ga.call(void 0, 200)}}var Br=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Bi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function Bs(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await H({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _81 => _81.withTransactions])}});return Vs({block:i,...n})}async function Ms(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await H({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _82 => _82.withTransactions])}});return Vs({block:i,...n})}async function Vs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _83 => _83.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _84 => _84.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let d=[],y=100n;for(let p=c+1n;p<s;p+=BigInt(100))d.push(Mi({aptosConfig:e,options:{offset:p,limit:Math.min(Number(y),Number(s-p+1n))}}));let A=await Promise.all(d);for(let p of A)t.transactions.push(...p)}return t}function Hs(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Ls(n){return!!n.match(/\s/)}function Lu(n){return!!n.match(/^T[0-9]+$/)}function qu(n){return!!n.match(/^&.+$/)}function $u(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 Wu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Ls(r))break}return t}var Qu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(Qu||{}),X= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Ve(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _85 => _85.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let b=Vn(a,i,t);o.push(b)}let y=r.pop();if(y===void 0)throw new X(n,"unexpected '>'");if(c!==o.length)throw new X(n,"type argument count doesn't match expected amount");let{savedStr:A,savedTypes:p,savedExpectedTypes:g}=y;i=o,o=p,a=A,c=g}else if(d===","){if(r.length===0)throw new X(n,"unexpected ','");if(a.length===0)throw new X(n,"no type argument before ','");let y=Vn(a,i,t);i=[],o.push(y),a="",c+=1}else if(Ls(d)){let y=!1;if(a.length!==0){let p=Vn(a,i,t);i=[],o.push(p),a="",y=!0}s=Wu(n,s);let A=n[s];if(s<n.length&&y&&A!==","&&A!==">")throw new X(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new X(n,"no matching '>' for '<'");switch(o.length){case 0:return Vn(a,i,t);case 1:if(a==="")return o[0];throw new X(n,"unexpected ','");default:throw new X(n,"unexpected whitespace character")}}function Vn(n,e,t){let r=n.trim(),i=r.toLowerCase();if($u(i)&&e.length>0)throw new X(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Nt;case"bool":return new Q;case"address":return new G;case"u8":return new de;case"u16":return new ot;case"u32":return new st;case"u64":return new te;case"u128":return new at;case"u256":return new ct;case"vector":if(e.length!==1)throw new X(n,"vector type expected to have exactly one type argument");return new U(e[0]);default:if(qu(r)){let a=r.substring(1);return new Sr(Vn(a,e,t))}if(Lu(r)){if(t)return new M(Number(r.split("T")[1]));throw new X(n,"unexpected generic type")}if(!r.match(/:/))throw new X(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new X(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunk347THBDEjs.ba.fromString(o[0])}catch (e4){throw new X(n,"struct address must be valid")}if(!Hs(o[1]))throw new X(n,"module name must only contain alphanumeric or '_' characters");if(!Hs(o[2]))throw new X(n,"struct name must only contain alphanumeric or '_' characters");return new h(new Je(s,new k(o[1]),new k(o[2]),e))}}function qs(n){return typeof n=="boolean"}function yt(n){return typeof n=="string"}function ju(n){return typeof n=="number"}function Hr(n){if(ju(n))return n;if(yt(n)&&n!=="")return Number.parseInt(n,10)}function Lr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function $s(n){return n==null}function Ws(n){return Vi(n)||Li(n)||qi(n)||$i(n)||Wi(n)||Qi(n)||ji(n)||qr(n)||Hi(n)||Ju(n)||n instanceof S||n instanceof ne}function Vi(n){return n instanceof D}function qr(n){return n instanceof _chunk347THBDEjs.ba}function Hi(n){return n instanceof C}function Ju(n){return n instanceof Ke}function Li(n){return n instanceof Z}function qi(n){return n instanceof Re}function $i(n){return n instanceof Ue}function Wi(n){return n instanceof $}function Qi(n){return n instanceof ke}function ji(n){return n instanceof we}function Qs(n){return"bytecode"in n}function z(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function js(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Xu=new TextEncoder;function $r(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _86 => _86.map, 'call', _87 => _87(e=>yt(e)?Ve(e):e)]), () => ([]))}async function Yu(n,e,t){return(await Wr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Xi(n,e,t,r){let i=await Yu(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 Zw(n,e,t,r){let i=await Xi(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(Ve(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Js(n,e,t,r){let i=await Xi(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=js(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ve(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Xs(n,e,t,r){let i=await Xi(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(Ve(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ve(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Yi(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.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=Ve(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 Lt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Lt(n,e,t,r,i,o){return Ws(n)?(Ji(e,n,t),n):Zu(n,e,t,r,i,o)}function Zu(n,e,t,r,i,o){if(e.isBool()){if(qs(n))return new D(n);if(yt(n)){if(n==="true")return new D(!0);if(n==="false")return new D(!1)}z("boolean",t)}if(e.isAddress()){if(yt(n))return _chunk347THBDEjs.ba.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunk347THBDEjs.ba)(n.data);z("string | AccountAddress",t)}if(e.isU8()){let s=Hr(n);if(s!==void 0)return new Z(s);z("number | string",t)}if(e.isU16()){let s=Hr(n);if(s!==void 0)return new Re(s);z("number | string",t)}if(e.isU32()){let s=Hr(n);if(s!==void 0)return new Ue(s);z("number | string",t)}if(e.isU64()){if(Lr(n))return new $(BigInt(n));z("bigint | number | string",t)}if(e.isU128()){if(Lr(n))return new ke(BigInt(n));z("bigint | number | string",t)}if(e.isU256()){if(Lr(n))return new we(BigInt(n));z("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 Lt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(yt(n))return S.U8(Xu.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(yt(n)&&n.startsWith("["))return Lt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Lt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(yt(n))return new C(n);z("string",t)}if(e.isObject()){if(yt(n))return _chunk347THBDEjs.ba.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunk347THBDEjs.ba)(n.data);z("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Ke(n);z("Uint8Array",t)}if(e.isOption()){if($s(n)){let a=e.value.typeArgs[0];return a instanceof Q?new ne(null):a instanceof G?new ne(null):a instanceof de?new ne(null):a instanceof ot?new ne(null):a instanceof st?new ne(null):a instanceof te?new ne(null):a instanceof at?new ne(null):a instanceof ct?new ne(null):new ne(null)}return new ne(Lt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _88 => _88.structs, 'access', _89 => _89.find, 'call', _90 => _90(a=>a.name===e.value.name.identifier), 'optionalAccess', _91 => _91.fields, 'access', _92 => _92.length])===0&&n instanceof Uint8Array)return new Ke(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _93 => _93.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Ke(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 Ji(n,e,t){if(n.isBool()){if(Vi(e))return;z("Bool",t)}if(n.isAddress()){if(qr(e))return;z("AccountAddress",t)}if(n.isU8()){if(Li(e))return;z("U8",t)}if(n.isU16()){if(qi(e))return;z("U16",t)}if(n.isU32()){if($i(e))return;z("U32",t)}if(n.isU64()){if(Wi(e))return;z("U64",t)}if(n.isU128()){if(Qi(e))return;z("U128",t)}if(n.isU256()){if(ji(e))return;z("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Ji(n.value,e.values[0],t);return}z("MoveVector",t)}if(n instanceof h){if(n.isString()){if(Hi(e))return;z("MoveString",t)}if(n.isObject()){if(qr(e))return;z("AccountAddress",t)}if(n.isOption()){if(e instanceof ne){e.value!==void 0&&Ji(n.value.typeArgs[0],e.value,t);return}z("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Qr(n){if(Qs(n))return rd(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk347THBDEjs.qa.call(void 0, n.function),i=await ta({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Js});return td({...n,abi:i})}function td(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk347THBDEjs.qa.call(void 0, n.function),o=$r(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>Yi(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=ut.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunk347THBDEjs.ba.from(n.multisigAddress);return new un(new Nn(c,new Dn(a)))}return new cn(a)}async function Ys(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk347THBDEjs.qa.call(void 0, n.function),i=await ta({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Xs});return nd({abi:i,...n})}function nd(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk347THBDEjs.qa.call(void 0, n.function),o=$r(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _94 => _94.functionArguments, 'optionalAccess', _95 => _95.map, 'call', _96 => _96((a,c)=>Yi(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return ut.build(`${t}::${r}`,i,o,s)}function rd(n){return new an(new dn(_chunk347THBDEjs.j.fromHexInput(n.bytecode).toUint8Array(),$r(n.typeArguments),n.functionArguments))}async function id(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(_optionalChain([i, 'optionalAccess', _97 => _97.replayProtectionNonce])!==void 0&&_optionalChain([i, 'optionalAccess', _98 => _98.accountSequenceNumber])!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>bi[e.network]?{chainId:bi[e.network]}:{chainId:(await Nr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _99 => _99.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Mr({aptosConfig:e})).gas_estimate},c=async()=>{let se=async()=>_optionalChain([i, 'optionalAccess', _100 => _100.accountSequenceNumber])!==void 0?i.accountSequenceNumber:_optionalChain([i, 'optionalAccess', _101 => _101.replayProtectionNonce])!==void 0?0xdeadbeefn:(await Or({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk347THBDEjs.ba.from(o).equals(_chunk347THBDEjs.ba.ZERO))try{return await se()}catch (e5){return 0}else return se()},[{chainId:d},{gasEstimate:y},A]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:g,expireTimestamp:b,replayProtectionNonce:N}={maxGasAmount:_optionalChain([i, 'optionalAccess', _102 => _102.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _103 => _103.gasUnitPrice]), () => (BigInt(y))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _104 => _104.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()))),replayProtectionNonce:_optionalChain([i, 'optionalAccess', _105 => _105.replayProtectionNonce])?BigInt(i.replayProtectionNonce):void 0},q=r;return N!==void 0&&(q=od(r,N)),new Ie(_chunk347THBDEjs.ba.from(t),BigInt(A),q,BigInt(p),BigInt(g),BigInt(b),new sn(d))}function od(n,e){if(n instanceof an)return new Dt(new Fn(n.script),new Ft(void 0,e));if(n instanceof cn)return new Dt(new ln(n.entryFunction),new Ft(void 0,e));if(n instanceof un){let t=n.multiSig.transaction_payload,r;if(t===void 0||_optionalChain([t, 'optionalAccess', _106 => _106.transaction_payload])===void 0)r=new On;else if(t.transaction_payload instanceof ut)r=new ln(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new Dt(r,new Ft(n.multiSig.multisig_address,e))}else throw new Error(`Unsupported payload type: ${n}`)}async function Zi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await id({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _107 => _107.secondarySignerAddresses, 'optionalAccess', _108 => _108.map, 'call', _109 => _109(c=>_chunk347THBDEjs.ba.from(c))]), () => ([]));return new Cr(s,a,n.feePayerAddress?_chunk347THBDEjs.ba.from(n.feePayerAddress):void 0)}return new Ir(s,n.feePayerAddress?_chunk347THBDEjs.ba.from(n.feePayerAddress):void 0)}function Zs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=hn(e);if(t.feePayerAddress){let a=new Gt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(A=>hn(A)):c=Array.from({length:t.secondarySignerAddresses.length},()=>hn(void 0)));let d=hn(i),y=new Vt(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new pt(a.raw_txn,y).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Ot(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(y=>hn(y)):c=Array.from({length:t.secondarySignerAddresses.length},()=>hn(void 0));let d=new Mt(o,t.secondarySignerAddresses,c);return new pt(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Ge)s=new Bt(o.public_key,o.signature);else if(o instanceof ue||o instanceof je)s=new _t(o);else if(o instanceof on)s=new _t(o);else throw new Error("Invalid public key");return new pt(t.rawTransaction,s).bcsToBytes()}function hn(n){if(!n)return new on;let t=K.isInstance(n)||L.isInstance(n)||De.isInstance(n)?new x(n):n,r=new R(new Uint8Array(64));if(E.isInstance(t))return new Ge(t,r);if(x.isInstance(t))return K.isInstance(t.publicKey)?new ue(t,new O(ce.getSimulationSignature())):new ue(t,new O(r));if(W.isInstance(t))return new je(t,new _e({signatures:t.publicKeys.map(i=>K.isInstance(i.publicKey)||L.isInstance(i.publicKey)?new O(ce.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 eo(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Jo(ee,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 Vt(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Mt(i,e.secondarySignerAddresses,r)}else i instanceof Ge?o=new Bt(i.public_key,i.signature):i instanceof it?o=new gn(i.public_key,i.signature):o=new _t(i);return new pt(e.rawTransaction,o).bcsToBytes()}function ea(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var sd=ea(["APTOS::Transaction"]);function xS(n){let e=eo(n);return new (0, _chunk347THBDEjs.j)(ea([sd,new Uint8Array([0]),e])).toString()}async function ta({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:qe(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function T(n){let e=await ad(n);return cd(n,e)}async function ad(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Qr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Qr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Qr(r)),i}async function cd(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(ud(n)&&(o=_chunk347THBDEjs.ba.ZERO.toString()),dd(n)){let{secondarySignerAddresses:s}=n;return Zi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Zi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function ud(n){return n.withFeePayer===!0}function dd(n){return"secondarySignerAddresses"in n}function na(n){let{transaction:e}=n;return Be(e)}function jr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Jr(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,jr({signer:e,transaction:t})}async function to(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Zs({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await wt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _110 => _110.options, 'optionalAccess', _111 => _111.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _112 => _112.options, 'optionalAccess', _113 => _113.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _114 => _114.options, 'optionalAccess', _115 => _115.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Hn(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=eo({...n});try{let{data:o}=await wt({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=pt.deserialize(new v(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof K||s.authenticator.sender.public_key.publicKey instanceof L)&&await Te.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function Xr(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;Rr(t)&&await t.checkKeylessAccountValidity(e),Rr(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&Jr({signer:r,transaction:i}),a=jr({signer:t,transaction:i});return Hn({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function ra(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;Rr(r)&&await r.checkKeylessAccountValidity(e);let s=Jr({signer:r,transaction:i});return Hn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var pd={typeParameters:[],parameters:[U.u8(),new U(U.u8())]};async function ia(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>S.U8(a));return T({aptosConfig:e,sender:_chunk347THBDEjs.ba.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:pd},options:o})}async function bn(n){return Or(n)}async function oa(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Si({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _116 => _116.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _117 => _117.limit]), () => (1e3))}})}async function sa(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await fr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _118 => _118.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _119 => _119.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Wr(n){return Ns(n)}async function ro(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return mr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _121 => _121.offset]),limit:_optionalChain([r, 'optionalAccess', _122 => _122.limit])}})}async function io(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Si({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _123 => _123.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _124 => _124.limit]), () => (999))}})}async function aa(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await fr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _125 => _125.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _126 => _126.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _127 => _127.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function oo(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await H({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk347THBDEjs.ba.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _128 => _128.ledgerVersion])}});return o.data}async function Ln(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await oo({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunk347THBDEjs.ba.from(t);try{let a=await Gr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk347THBDEjs.ba.from(a)}catch(a){if(a instanceof Pe&&a.data.error_code==="table_item_not_found")return s;throw a}}async function ca(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Ts,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 ua(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _129 => _129.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _130 => _130.tokenStandard])});let s={query:hs,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _131 => _131.offset]),limit:_optionalChain([r, 'optionalAccess', _132 => _132.limit]),order_by:_optionalChain([r, 'optionalAccess', _133 => _133.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function da(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk347THBDEjs.ba.from(t).toStringLong(),s=_chunk347THBDEjs.ba.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _134 => _134.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _135 => _135.tokenStandard])});let c={query:bs,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _136 => _136.offset]),limit:_optionalChain([i, 'optionalAccess', _137 => _137.limit]),order_by:_optionalChain([i, 'optionalAccess', _138 => _138.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function pa(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _139 => _139.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _140 => _140.tokenStandard])}});let s={query:As,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([r, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([r, 'optionalAccess', _143 => _143.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function la(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk347THBDEjs.ba.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:ws,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function ga(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk347THBDEjs.ba.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _144 => _144.where]),owner_address:{_eq:i}},s={query:fs,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _145 => _145.offset]),limit:_optionalChain([r, 'optionalAccess', _146 => _146.limit]),order_by:_optionalChain([r, 'optionalAccess', _147 => _147.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function ya(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk347THBDEjs.ba.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:ms,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 ma(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await H({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?_chunk347THBDEjs.ba.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function so(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}},s={query:zr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _148 => _148.offset]),limit:_optionalChain([r, 'optionalAccess', _149 => _149.limit]),order_by:_optionalChain([r, 'optionalAccess', _150 => _150.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function fa(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _151 => _151.throwIfNoAccountFound]), () => (!1)),o=await Yr({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return lt.fromPrivateKey({privateKey:t})}return o[0]}async function ld(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([io({aptosConfig:e,accountAddress:t}),so({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!_optionalChain([r, 'optionalAccess', _152 => _152.withAuthKey]))return!0;let a;return s?a=s.data.authentication_key:a=t.toStringLong(),a===r.withAuthKey.toString()}catch(i){throw new Error(`Error while checking if account exists at ${t.toString()}: ${i}`)}}var gd={typeParameters:[],parameters:[new de,U.u8(),new de,U.u8(),U.u8(),U.u8()]};async function Aa(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return no({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof oe?no({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):no({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function no(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await bn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=lt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new xr({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk347THBDEjs.ba.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new Z(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new Z(o.signingScheme),S.U8(o.publicKey.toUint8Array()),S.U8(c.toUint8Array()),S.U8(d.toUint8Array())],abi:gd},options:r})}var yd={typeParameters:[],parameters:[new de,U.u8()]};async function ha(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new Z(as(r)),S.U8(ki(r).toUint8Array())],abi:yd},options:i})}async function Zr(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _153 => _153.noMultiKey]), () => (!1));if(i&&t instanceof Fe)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof x&&t.publicKey instanceof E?o.push(t.publicKey):t instanceof E&&o.push(new x(t));let[s,a]=await Promise.all([Promise.all(o.map(async A=>{let p=await bd({aptosConfig:e,publicKey:A});if(p)return{...p,publicKey:A}})),!(t instanceof Fe)&&!i?fd({aptosConfig:e,publicKey:t,options:r}):Promise.resolve([])]),c=[];for(let A of s)A&&c.push(A);o.push(...a);let d=new Map(o.map(A=>[A.authKey().toString(),A])),y=await Ad({aptosConfig:e,authKeys:o.map(A=>A.authKey()),options:r});for(let A of y){if(c.find(g=>g.accountAddress===A.accountAddress))continue;let p=d.get(A.authKey.toString());if(!p)throw new Error(`No publicKey found for authentication key ${A.authKey}. This should never happen.`);c.push({accountAddress:A.accountAddress,publicKey:p,lastTransactionVersion:A.lastTransactionVersion})}return c.sort((A,p)=>p.lastTransactionVersion-A.lastTransactionVersion)}async function ao(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof J||t instanceof nt)return Yr({aptosConfig:e,privateKey:t,options:r});if(t instanceof oe||t instanceof pe)return Yr({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof Ce||t instanceof Me)return md({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof gt&&t.signers.length===1)return ao({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof Gn&&t.signers.length===1)return Yr({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function md(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await Zr({aptosConfig:e,publicKey:t.getAnyPublicKey(),options:r}),o={proof:t.proofOrPromise,jwt:t.jwt,ephemeralKeyPair:t.ephemeralKeyPair,pepper:t.pepper,verificationKeyHash:t.verificationKeyHash},s=[];for(let{accountAddress:a,publicKey:c}of i)if(c instanceof Fe){if(c.getSignaturesRequired()>1)continue;if(c instanceof ie)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof W&&s.push(new gt({multiKey:c,signers:[t],address:a}))}else t instanceof Me?s.push(Me.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(Ce.create({...o,address:a}));return s}async function Yr(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=lt.fromPrivateKey({privateKey:t,legacy:!1}),o=await Zr({aptosConfig:e,publicKey:new x(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof Fe){if(c.getSignaturesRequired()>1)continue;c instanceof ie?s.push(new Gn({publicKey:c,signers:[t],address:a})):c instanceof W&&s.push(new gt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof E;s.push(lt.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function fd(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof Fe)throw new Error("Public key is a multi-key.");let i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _154 => _154.includeUnverified]), () => (!1)),o=t instanceof x?t:new x(t),s=o.publicKey,a=_chunk347THBDEjs.C.call(void 0, o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:Ss,variables:{where_condition:c}},{public_key_auth_keys:y}=await w({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return y.map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return ie.deserializeWithoutLength(v.fromHex(p.account_public_key));case"multi_key_signature":return W.deserialize(v.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function Ad(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _155 => _155.includeUnverified]), () => (!1));if(t.length===0)throw new Error("No authentication keys provided");let o={auth_key:{_in:t.map(c=>c.toString())},...i?{}:{is_auth_key_used:{_eq:!0}}},s={query:ys,variables:{where_condition:o,order_by:[{last_transaction_version:"desc"}]}},{auth_key_account_addresses:a}=await w({aptosConfig:e,query:s,originMethod:"getAccountAddressesForAuthKeys"});return a.map(c=>({authKey:new V({data:c.auth_key}),accountAddress:new (0, _chunk347THBDEjs.ba)(_chunk347THBDEjs.j.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function hd(n){let{aptosConfig:e,accountAddress:t}=n,r=await ro({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function bd(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([hd({aptosConfig:e,accountAddress:r}),ld({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function P(n){n.minimumLedgerVersion!==void 0&&await Vr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function le(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Ys({...t,aptosConfig:e}),o=new _chunk347THBDEjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await wt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _156 => _156.ledgerVersion])},body:s});return a}async function ba(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await wt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _157 => _157.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function Ta(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk347THBDEjs.qa.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new G,new h(I()),new h(I())]}},options:i})}async function wa(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk347THBDEjs.qa.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new G,new h(I()),new h(I())]}},options:i})}async function Sa(n){let{aptosConfig:e,sender:t,options:r}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var qt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk347THBDEjs.qa.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _158 => _158.some, 'call', _159 => _159(s=>_chunk347THBDEjs.ba.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 Ta({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return wa({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Sa({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await le({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk347THBDEjs.ba.from(t)],abi:{typeParameters:[],parameters:[new G],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk347THBDEjs.ba.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var qn=class{constructor(e){this.config=e;this.abstraction=new qt(e)}async getAccountInfo(e){return bn({aptosConfig:this.config,...e})}async getAccountModules(e){return oa({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return sa({aptosConfig:this.config,...e})}async getAccountModule(e){return Wr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return ro({aptosConfig:this.config,...e})}async getAccountResources(e){return io({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return aa({aptosConfig:this.config,...e})}async getAccountResource(e){return oo({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Ln({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),ca({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ua({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),da({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),pa({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),la({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ga({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ya({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Rt,faMetadataAddress:$o,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i}=e,o=r;r===void 0&&i!==void 0&&(o=await qe(async()=>{try{let c=(await le({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&_chunk347THBDEjs.pa.call(void 0, c.vec[0]))return _chunk347THBDEjs.oa.call(void 0, c.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=_chunk347THBDEjs.ba.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Rt?s=_chunk347THBDEjs.ba.A.toStringLong():s=_chunk347THBDEjs.ca.call(void 0, _chunk347THBDEjs.ba.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=_chunk347THBDEjs.ba.from(i);s=c.toStringLong(),c===_chunk347THBDEjs.ba.A&&(o=Rt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await le({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await le({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,s]}});return parseInt(a,10)}async getBalance(e){return ma({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),so({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),fa({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ao({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Zr({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var ei=class{constructor(e){if(_optionalChain([e, 'optionalAccess', _160 => _160.fullnode])||_optionalChain([e, 'optionalAccess', _161 => _161.indexer])||_optionalChain([e, 'optionalAccess', _162 => _162.faucet])||_optionalChain([e, 'optionalAccess', _163 => _163.pepper])||_optionalChain([e, 'optionalAccess', _164 => _164.prover])){if(_optionalChain([e, 'optionalAccess', _165 => _165.network])==="custom")console.info("Note: using CUSTOM network will require queries to lookup ChainId");else if(!_optionalChain([e, 'optionalAccess', _166 => _166.network]))throw new Error("Custom endpoints require a network to be specified")}this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _167 => _167.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _168 => _168.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _169 => _169.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _170 => _170.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _171 => _171.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _172 => _172.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _173 => _173.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _174 => _174.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _175 => _175.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _176 => _176.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _177 => _177.faucetConfig]), () => ({})),this.transactionGenerationConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _178 => _178.transactionGenerationConfig]), () => ({})),this.pluginConfig=_optionalChain([e, 'optionalAccess', _179 => _179.pluginSettings])?{...e.pluginSettings,IGNORE_TRANSACTION_SUBMITTER:!1}:void 0}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 Vo[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 Ho[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 Mo[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 fi[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 Ai[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return fi[this.network]===e}isProverServiceRequest(e){return Ai[this.network]===e}getDefaultMaxGasAmount(){return _nullishCoalesce(_optionalChain([this, 'access', _180 => _180.transactionGenerationConfig, 'optionalAccess', _181 => _181.defaultMaxGasAmount]), () => (2e5))}getDefaultTxnExpirySecFromNow(){return _nullishCoalesce(_optionalChain([this, 'access', _182 => _182.transactionGenerationConfig, 'optionalAccess', _183 => _183.defaultTxnExpirySecFromNow]), () => (20))}setIgnoreTransactionSubmitter(e){this.pluginConfig&&(this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER=e)}getTransactionSubmitter(){if(this.pluginConfig!==void 0&&this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER!==!0)return this.pluginConfig.TRANSACTION_SUBMITTER}};var wd={typeParameters:[{constraints:[]}],parameters:[new G,new te]};async function Pa(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (Rt))],functionArguments:[r,i],abi:wd},options:s})}var $n=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Pa({aptosConfig:this.config,...e})}};var xt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},ve="0x4::token::Token";async function Ea(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:Us,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function _a(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Gi,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function xa(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()},amount:{_gt:0}},o={query:Gi,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _184 => _184.offset]),limit:_optionalChain([r, 'optionalAccess', _185 => _185.limit]),order_by:_optionalChain([r, 'optionalAccess', _186 => _186.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ia(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}},o={query:Rs,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _187 => _187.offset]),limit:_optionalChain([r, 'optionalAccess', _188 => _188.limit]),order_by:_optionalChain([r, 'optionalAccess', _189 => _189.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Sd={typeParameters:[],parameters:[new h(I()),new te,new h(I()),new h(I()),new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new te,new te]};async function Ca(n){let{aptosConfig:e,options:t,creator:r}=n;return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new C(n.description),new $(_nullishCoalesce(n.maxSupply, () => (_chunk347THBDEjs.e))),new C(n.name),new C(n.uri),new D(_nullishCoalesce(n.mutableDescription, () => (!0))),new D(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new D(_nullishCoalesce(n.mutableURI, () => (!0))),new D(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new D(_nullishCoalesce(n.mutableTokenName, () => (!0))),new D(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new D(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new D(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new D(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new $(_nullishCoalesce(n.royaltyNumerator, () => (0))),new $(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Sd},options:t})}async function Tn(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _190 => _190.where]);_optionalChain([t, 'optionalAccess', _191 => _191.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _192 => _192.tokenStandard]), () => ("v2"))});let i={query:Es,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _193 => _193.offset]),limit:_optionalChain([t, 'optionalAccess', _194 => _194.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function va(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk347THBDEjs.ba.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _195 => _195.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _196 => _196.tokenStandard]), () => ("v2"))}),Tn({aptosConfig:e,options:{...i,where:s}})}async function Ka(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _197 => _197.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _198 => _198.tokenStandard]), () => ("v2"))}),Tn({aptosConfig:e,options:{...r,where:o}})}async function Ra(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _199 => _199.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _200 => _200.tokenStandard]), () => ("v2"))}),Tn({aptosConfig:e,options:{...r,where:o}})}async function Ua(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk347THBDEjs.ba.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _201 => _201.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _202 => _202.tokenStandard]), () => ("v2"))}),(await Tn({aptosConfig:i,options:{where:s}})).collection_id}var Pd={typeParameters:[],parameters:[new h(I()),new h(I()),new h(I()),new h(I()),new U(new h(I())),new U(new h(I())),new U(U.u8())]};async function ka(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:y}=n,A=_optionalChain([d, 'optionalAccess', _203 => _203.map, 'call', _204 => _204(p=>xt[p])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new C(i),new C(o),new C(s),new C(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(A, () => ([]))),Wa(_nullishCoalesce(y, () => ([])),_nullishCoalesce(A, () => ([])))],abi:Pd},options:t})}var Ed={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new G]};async function za(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(r),_chunk347THBDEjs.ba.from(i)],abi:Ed},options:s})}var _d={typeParameters:[],parameters:[new h(I()),new h(I()),new h(I()),new h(I()),new U(new h(I())),new U(new h(I())),new U(U.u8()),new G]};async function Na(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:y,options:A}=n;if(_optionalChain([c, 'optionalAccess', _205 => _205.length])!==_optionalChain([y, 'optionalAccess', _206 => _206.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _207 => _207.length])!==_optionalChain([y, 'optionalAccess', _208 => _208.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _209 => _209.map, 'call', _210 => _210(g=>xt[g])]);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(p, () => ([]))),Wa(_nullishCoalesce(y, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:_d},options:A})}var xd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0)))]};async function Da(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(r)],abi:xd},options:o})}var Id={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0)))]};async function Fa(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (ve))],functionArguments:[r],abi:Id},options:o})}var Cd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0)))]};async function Oa(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (ve))],functionArguments:[r],abi:Cd},options:o})}var vd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new h(I())]};async function Ga(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(i),new C(r)],abi:vd},options:s})}var Kd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new h(I())]};async function Ba(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(i),new C(r)],abi:Kd},options:s})}var Rd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new h(I())]};async function Ma(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(i),new C(r)],abi:Rd},options:s})}var Ud={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new h(I()),new h(I()),U.u8()]};async function Va(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(s),new C(r),new C(xt[i]),S.U8(co(o,xt[i]))],abi:Ud},options:c})}var kd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new h(I())]};async function Ha(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(i),new C(r)],abi:kd},options:s})}var zd={typeParameters:[{constraints:["key"]}],parameters:[new h(be(new M(0))),new h(I()),new h(I()),U.u8()]};async function La(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (ve))],functionArguments:[_chunk347THBDEjs.ba.from(s),new C(r),new C(xt[i]),co(o,xt[i])],abi:zd},options:c})}var Nd={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(be(new M(0))),new h(I()),new M(1)]};async function qa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (ve)),xt[i]],functionArguments:[_chunk347THBDEjs.ba.from(s),new C(r),o],abi:Nd},options:c})}var Dd={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(be(new M(0))),new h(I()),new M(1)]};async function $a(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (ve)),xt[i]],functionArguments:[_chunk347THBDEjs.ba.from(s),new C(r),o],abi:Dd},options:c})}function Wa(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(co(n[i],r))}),t}function co(n,e){let t=Ve(e);return Lt(n,t,0,[]).bcsToBytes()}var Wn=class{constructor(e){this.config=e}async getCollectionData(e){await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunk347THBDEjs.ba.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _211 => _211.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _212 => _212.tokenStandard]), () => ("v2"))}),Tn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),va({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ka({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ra({aptosConfig:this.config,...e})}async getCollectionId(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ua({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ea({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),_a({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),xa({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ia({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Ca({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return ka({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return za({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Na({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Da({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return Fa({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return Oa({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Ga({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Ba({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Ma({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Va({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return Ha({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return La({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return qa({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return $a({aptosConfig:this.config,...e})}};async function Qa(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _213 => _213.timeoutSecs])||20,{data:s}=await Zo({aptosConfig:e,path:"fund",body:{address:_chunk347THBDEjs.ba.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await An({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _214 => _214.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Qn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Qa({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _215 => _215.options, 'optionalAccess', _216 => _216.waitForIndexer])===void 0||_optionalChain([e, 'access', _217 => _217.options, 'optionalAccess', _218 => _218.waitForIndexer]))&&await Vr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function ti(n){let{aptosConfig:e,options:t}=n,r={query:Cs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _219 => _219.where]),limit:_optionalChain([t, 'optionalAccess', _220 => _220.limit]),offset:_optionalChain([t, 'optionalAccess', _221 => _221.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function ja(n){let{aptosConfig:e,options:t}=n,r={query:Is,variables:{where_condition:_optionalChain([t, 'optionalAccess', _222 => _222.where]),limit:_optionalChain([t, 'optionalAccess', _223 => _223.limit]),offset:_optionalChain([t, 'optionalAccess', _224 => _224.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ja(n){let{aptosConfig:e,options:t}=n,r={query:_s,variables:{where_condition:_optionalChain([t, 'optionalAccess', _225 => _225.where]),limit:_optionalChain([t, 'optionalAccess', _226 => _226.limit]),offset:_optionalChain([t, 'optionalAccess', _227 => _227.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Xa={typeParameters:[{constraints:[]}],parameters:[Ve("0x1::object::Object"),new G,new te]};async function Ya(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:Xa},options:s})}async function Za(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:Xa},options:s})}var jn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _228 => _228.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ti({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _229 => _229.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await ti({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _230 => _230.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await ti({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk347THBDEjs.ba.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _231 => _231.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ja({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _232 => _232.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ja({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Ya({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Za({aptosConfig:this.config,...e})}};var Jn=class{constructor(e){this.config=e}async getLedgerInfo(){return Nr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return Bs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return Ms({aptosConfig:this.config,...e})}async view(e){return le({aptosConfig:this.config,...e})}async viewJson(e){return ba({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return ks({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Dr({aptosConfig:this.config})}async getProcessorStatus(e){return Fr({aptosConfig:this.config,processorType:e})}};var ec=["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 tc(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function It(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(!tc(e))throw new Error(`${e} is not valid. ${ec}`);if(t&&!tc(t))throw new Error(`${t} is not valid. ${ec}`);return{domainName:t||e,subdomainName:t?e:void 0}}function nc(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 Fd="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Od={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Fd,custom:null,devnet:null,shelbynet:null,netna:null};function mt(n){let e=Od[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var ni=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function rc(n){let{aptosConfig:e,name:t}=n,r=mt(e),{domainName:i,subdomainName:o}=It(t),s=await le({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=ni(s[0]);return a?_chunk347THBDEjs.ba.from(a):void 0}async function ic(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=mt(e),{domainName:y,subdomainName:A}=It(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(A&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!A)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let q=_nullishCoalesce(t.years, () => (1));if(q!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Xe=q*31536e3;return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[y,Xe,o,s]},options:a})}if(!A)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await uo({aptosConfig:e,name:y});if(!g)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:g;if(b>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[y,A,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function uo(n){let{aptosConfig:e,name:t}=n,r=mt(e),{domainName:i,subdomainName:o}=It(t);try{let s=await le({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function oc(n){let{aptosConfig:e,address:t}=n,r=mt(e),i=await le({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk347THBDEjs.ba.from(t).toString()]}}),o=ni(i[1]),s=ni(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function sc(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=mt(e);if(!r)return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=It(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function ac(n){let{aptosConfig:e,name:t}=n,r=mt(e),{domainName:i,subdomainName:o}=It(t),s=await le({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=ni(s[0]);return a?_chunk347THBDEjs.ba.from(a):void 0}async function cc(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=mt(e),{domainName:a,subdomainName:c}=It(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function uc(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=It(t),a=(await w({aptosConfig:e,query:{query:fn,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Xn(a)),nc(a)?a:void 0}async function dc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await po({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:fn,variables:{limit:_optionalChain([t, 'optionalAccess', _233 => _233.limit]),offset:_optionalChain([t, 'optionalAccess', _234 => _234.offset]),order_by:_optionalChain([t, 'optionalAccess', _235 => _235.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _236 => _236.options, 'optionalAccess', _237 => _237.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Xn)}async function pc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await po({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:fn,variables:{limit:_optionalChain([t, 'optionalAccess', _238 => _238.limit]),offset:_optionalChain([t, 'optionalAccess', _239 => _239.offset]),order_by:_optionalChain([t, 'optionalAccess', _240 => _240.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _241 => _241.options, 'optionalAccess', _242 => _242.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Xn)}async function lc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await po({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:fn,variables:{limit:_optionalChain([t, 'optionalAccess', _243 => _243.limit]),offset:_optionalChain([t, 'optionalAccess', _244 => _244.offset]),order_by:_optionalChain([t, 'optionalAccess', _245 => _245.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _246 => _246.options, 'optionalAccess', _247 => _247.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Xn)}async function gc(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:fn,variables:{limit:_optionalChain([t, 'optionalAccess', _248 => _248.limit]),offset:_optionalChain([t, 'optionalAccess', _249 => _249.offset]),order_by:_optionalChain([t, 'optionalAccess', _250 => _250.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _251 => _251.options, 'optionalAccess', _252 => _252.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Xn).filter(nc)}async function po(n){let{aptosConfig:e}=n,t=mt(e),[r]=await le({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 yc(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=mt(e),a=i*31536e3,{domainName:c,subdomainName:d}=It(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 T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Xn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var Yn=class{constructor(e){this.config=e}async getOwnerAddress(e){return rc({aptosConfig:this.config,...e})}async getExpiration(e){return uo({aptosConfig:this.config,...e})}async getTargetAddress(e){return ac({aptosConfig:this.config,...e})}async setTargetAddress(e){return cc({aptosConfig:this.config,...e})}async getPrimaryName(e){return oc({aptosConfig:this.config,...e})}async setPrimaryName(e){return sc({aptosConfig:this.config,...e})}async registerName(e){return ic({aptosConfig:this.config,...e})}async renewDomain(e){return yc({aptosConfig:this.config,...e})}async getName(e){return uc({aptosConfig:this.config,...e})}async getAccountNames(e){return dc({aptosConfig:this.config,...e})}async getAccountDomains(e){return pc({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return lc({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return gc({aptosConfig:this.config,...e})}};async function mc(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk347THBDEjs.ba.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Fi,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 fc(n){let{aptosConfig:e,options:t}=n,r={query:Fi,variables:{order_by:_optionalChain([t, 'optionalAccess', _253 => _253.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Ac(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:xs,variables:{delegatorAddress:_chunk347THBDEjs.ba.from(t).toStringLong(),poolAddress:_chunk347THBDEjs.ba.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var Zn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _254 => _254.minimumLedgerVersion]),processorType:"stake_processor"}),mc({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _255 => _255.minimumLedgerVersion]),processorType:"stake_processor"}),fc({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _256 => _256.minimumLedgerVersion]),processorType:"stake_processor"}),Ac({aptosConfig:this.config,...e})}};var ri=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function lo(n,e){if(!(n.getTransactionSubmitter()!==void 0||e.transactionSubmitter!==void 0)&&e.transaction.feePayerAddress&&!e.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator")}function go(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var wn=class{constructor(e){this.config=e}async simple(e){return to({aptosConfig:this.config,...e})}async multiAgent(e){return to({aptosConfig:this.config,...e})}};_chunk347THBDEjs.a.call(void 0, [go],wn.prototype,"simple",1),_chunk347THBDEjs.a.call(void 0, [go],wn.prototype,"multiAgent",1);var ii=class{constructor(e){this.config=e}async simple(e){return lo(this.config,e),Hn({aptosConfig:this.config,...e})}async multiAgent(e){return lo(this.config,e),Hn({aptosConfig:this.config,...e})}};var oi=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 _chunk347THBDEjs.ga.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunk347THBDEjs.ia.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk347THBDEjs.ga.call(void 0, this.sleepTime),_chunk347THBDEjs.ia.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await bn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await bn({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 _chunk347THBDEjs.ga.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk347THBDEjs.ia.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk347THBDEjs.ia.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunk347THBDEjs.ga.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var Sn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _257 => _257.pendingDequeue, 'access', _258 => _258.shift, 'call', _259 => _259(), 'optionalAccess', _260 => _260.resolve, 'call', _261 => _261(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new Pn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Pn=class extends Error{};var hc="fulfilled",bc= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(bc||{}),si= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new Sn;this.transactionsQueue=new Sn;this.outstandingTransactions=new Sn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new oi(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=Xr({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Pn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===hc?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Pn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(An({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===hc?(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 T({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r,replayProtectionNonce:void 0}})}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 ai=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new si(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 er=class{constructor(e){this.config=e,this.build=new ri(this.config),this.simulate=new wn(this.config),this.submit=new ii(this.config),this.batch=new ai(this.config)}async getTransactions(e){return Mi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Os({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Mn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return Gs({aptosConfig:this.config,...e})}async waitForTransaction(e){return An({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Mr({aptosConfig:this.config})}getSigningMessage(e){return na(e)}async publishPackageTransaction(e){return ia({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Aa({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return ha({aptosConfig:this.config,...e})}sign(e){return jr({...e})}signAsFeePayer(e){return Jr({...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 Xr({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ra({aptosConfig:this.config,...e})}};var tr=class{constructor(e){this.config=e}async getTableItem(e){return Gr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Ds({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Fs({aptosConfig:this.config,...e})}};async function ci(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:_chunk347THBDEjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await es({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunk347THBDEjs.j.fromHexInput(a.pepper).toUint8Array()}async function yo(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await ci(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk347THBDEjs.j.fromHexInput(i).toUint8Array().length!==Ce.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Ce.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunk347THBDEjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk347THBDEjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await ts({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),y=d.proof,A=new St({a:y.a,b:y.b,c:y.c});return new me({proof:new Jt(A,0),trainingWheelsSignature:He.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Tc(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await ci(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),d=yo({...n,pepper:s,maxExpHorizonSecs:c}),y=o?d:await d;if(r!==void 0){let g=L.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await Ln({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Me.create({...n,address:b,proof:y,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let A=K.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await Ln({aptosConfig:e,authenticationKey:A.authKey().derivedAddress()});return Ce.create({...n,address:p,proof:y,pepper:s,proofFetchCallback:o,verificationKey:a})}async function wc(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(jo.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,_.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var nr=class{constructor(e){this.config=e}async getPepper(e){return ci({aptosConfig:this.config,...e})}async getProof(e){return yo({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Tc({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return wc({aptosConfig:this.config,...e})}};async function Vd(n){let{aptosConfig:e,options:t}=n,r={query:zr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _262 => _262.where]),offset:_optionalChain([t, 'optionalAccess', _263 => _263.offset]),limit:_optionalChain([t, 'optionalAccess', _264 => _264.limit]),order_by:_optionalChain([t, 'optionalAccess', _265 => _265.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Sc(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk347THBDEjs.ba.from(t).toStringLong()}};return(await Vd({aptosConfig:e,options:{...r,where:o}}))[0]}var rr=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Sc({aptosConfig:this.config,...e})}};var re=class{constructor(e){this.config=_nullishCoalesce(e, () => (new ei)),this.account=new qn(this.config),this.abstraction=new qt(this.config),this.ans=new Yn(this.config),this.coin=new $n(this.config),this.digitalAsset=new Wn(this.config),this.faucet=new Qn(this.config),this.fungibleAsset=new jn(this.config),this.general=new Jn(this.config),this.staking=new Zn(this.config),this.transaction=new er(this.config),this.table=new tr(this.config),this.keyless=new nr(this.config),this.object=new rr(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function ge(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value:function(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}ge(re,qn,"account");ge(re,qt,"abstraction");ge(re,Yn,"ans");ge(re,$n,"coin");ge(re,Wn,"digitalAsset");ge(re,Event,"event");ge(re,Qn,"faucet");ge(re,jn,"fungibleAsset");ge(re,Jn,"general");ge(re,Zn,"staking");ge(re,er,"transaction");ge(re,tr,"table");ge(re,nr,"keyless");ge(re,rr,"object");exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT = Qo; exports.APTOS_BIP44_REGEX = Oc; exports.APTOS_COIN = Rt; exports.APTOS_FA = $o; exports.APTOS_HARDENED_REGEX = Fc; exports.AbstractKeylessAccount = Te; exports.AbstractMultiKey = Fe; exports.AbstractPublicKey = cr; exports.AbstractSignature = xn; exports.AbstractedAccount = Ur; exports.Account = lt; exports.AccountAbstractionMessage = wr; exports.AccountAddress = _chunk347THBDEjs.ba; exports.AccountAuthenticator = ee; exports.AccountAuthenticatorAbstraction = zt; exports.AccountAuthenticatorEd25519 = Ge; exports.AccountAuthenticatorMultiEd25519 = it; exports.AccountAuthenticatorMultiKey = je; exports.AccountAuthenticatorNoAccountAuthenticator = on; exports.AccountAuthenticatorSingleKey = ue; exports.AccountAuthenticatorVariant = _chunk347THBDEjs.z; exports.AccountPublicKey = ae; exports.AccountSequenceNumber = oi; exports.AccountUtils = ps; exports.AddressInvalidReason = _chunk347THBDEjs.aa; exports.AnyPublicKey = x; exports.AnyPublicKeyVariant = _chunk347THBDEjs.B; exports.AnySignature = O; exports.AnySignatureVariant = _chunk347THBDEjs.D; exports.Aptos = re; exports.AptosApiError = Pe; exports.AptosApiType = Qt; exports.AptosConfig = ei; exports.AuthenticationKey = V; exports.Bool = D; exports.CKDPriv = Do; exports.ChainId = sn; exports.DEFAULT_MAX_GAS_AMOUNT = Lo; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = qo; exports.DEFAULT_TXN_TIMEOUT_SEC = pr; exports.DerivableAbstractedAccount = gs; exports.DeriveScheme = _chunk347THBDEjs.$; exports.Deserializer = v; exports.EPK_HORIZON_SECS = Au; exports.Ed25519Account = oe; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = E; exports.Ed25519Signature = R; exports.EntryFunction = ut; exports.EntryFunctionBytes = ar; exports.EphemeralCertificate = jt; exports.EphemeralCertificateVariant = _chunk347THBDEjs.G; exports.EphemeralKeyPair = Ht; exports.EphemeralPublicKey = bt; exports.EphemeralPublicKeyVariant = _chunk347THBDEjs.E; exports.EphemeralSignature = He; exports.EphemeralSignatureVariant = _chunk347THBDEjs.F; exports.FIREBASE_AUTH_ISS_PATTERN = jo; exports.FederatedKeylessAccount = Me; exports.FederatedKeylessPublicKey = L; exports.FeePayerRawTransaction = Gt; exports.FixedBytes = Ke; exports.Groth16ProofAndStatement = xi; exports.Groth16VerificationKey = Ci; exports.Groth16Zkp = St; exports.HARDENED_OFFSET = ko; exports.Hex = _chunk347THBDEjs.j; exports.HexInvalidReason = _chunk347THBDEjs.i; exports.Identifier = k; exports.KeyType = Gc; exports.KeylessAccount = Ce; exports.KeylessConfiguration = Ii; exports.KeylessError = _; exports.KeylessErrorCategory = uu; exports.KeylessErrorResolutionTip = du; exports.KeylessErrorType = lr; exports.KeylessPublicKey = K; exports.KeylessSignature = ce; exports.MAX_AUD_VAL_BYTES = Ei; exports.MAX_COMMITED_EPK_BYTES = Pu; exports.MAX_EXTRA_FIELD_BYTES = wu; exports.MAX_ISS_VAL_BYTES = Tu; exports.MAX_JWT_HEADER_B64_BYTES = Su; exports.MAX_UID_KEY_BYTES = hu; exports.MAX_UID_VAL_BYTES = bu; exports.MimeType = _chunk347THBDEjs.q; exports.ModuleId = zn; exports.MoveAbility = _chunk347THBDEjs.X; exports.MoveFunctionVisibility = _chunk347THBDEjs.W; exports.MoveJWK = vi; exports.MoveOption = ne; exports.MoveString = C; exports.MoveVector = S; exports.MultiAgentRawTransaction = Ot; exports.MultiAgentTransaction = Cr; exports.MultiEd25519Account = Gn; exports.MultiEd25519PublicKey = ie; exports.MultiEd25519Signature = Oe; exports.MultiKey = W; exports.MultiKeyAccount = gt; exports.MultiKeySignature = _e; exports.MultiSig = Nn; exports.MultiSigTransactionPayload = Dn; exports.Network = hi; exports.NetworkToChainId = bi; exports.NetworkToFaucetAPI = Ho; exports.NetworkToIndexerAPI = Mo; exports.NetworkToNetworkName = Gl; exports.NetworkToNodeAPI = Vo; exports.NetworkToPepperAPI = fi; exports.NetworkToProverAPI = Ai; exports.ParsingError = _chunk347THBDEjs.h; exports.PrivateKey = Se; exports.PrivateKeyVariants = _chunk347THBDEjs.A; exports.ProcessorType = Tt; exports.PublicKey = Ze; exports.RAW_TRANSACTION_SALT = Wo; exports.RAW_TRANSACTION_WITH_DATA_SALT = Ti; exports.RawTransaction = Ie; exports.RawTransactionWithData = _r; exports.RoleType = _chunk347THBDEjs.Y; exports.RotationProofChallenge = xr; exports.Script = dn; exports.ScriptTransactionArgumentVariants = _chunk347THBDEjs.s; exports.Secp256k1PrivateKey = nt; exports.Secp256k1PublicKey = De; exports.Secp256k1Signature = rt; exports.Secp256r1PrivateKey = os; exports.Secp256r1PublicKey = nn; exports.Secp256r1Signature = Ui; exports.Serializable = _chunk347THBDEjs.l; exports.Serialized = _n; exports.Serializer = _chunk347THBDEjs.m; exports.Signature = F; exports.SignedTransaction = pt; exports.SigningScheme = _chunk347THBDEjs.Z; exports.SigningSchemeInput = _chunk347THBDEjs._; exports.SimpleTransaction = Ir; exports.SingleKeyAccount = pe; exports.StructTag = Je; exports.TransactionAndProof = Kr; exports.TransactionAuthenticator = dt; exports.TransactionAuthenticatorEd25519 = Bt; exports.TransactionAuthenticatorFeePayer = Vt; exports.TransactionAuthenticatorMultiAgent = Mt; exports.TransactionAuthenticatorMultiEd25519 = gn; exports.TransactionAuthenticatorSingleSender = _t; exports.TransactionAuthenticatorVariant = _chunk347THBDEjs.y; exports.TransactionExecutable = pn; exports.TransactionExecutableEmpty = On; exports.TransactionExecutableEntryFunction = ln; exports.TransactionExecutableScript = Fn; exports.TransactionExecutableVariants = _chunk347THBDEjs.v; exports.TransactionExtraConfig = Er; exports.TransactionExtraConfigV1 = Ft; exports.TransactionExtraConfigVariants = _chunk347THBDEjs.w; exports.TransactionInnerPayload = Pr; exports.TransactionInnerPayloadV1 = Dt; exports.TransactionInnerPayloadVariants = _chunk347THBDEjs.u; exports.TransactionPayload = Et; exports.TransactionPayloadEntryFunction = cn; exports.TransactionPayloadMultiSig = un; exports.TransactionPayloadScript = an; exports.TransactionPayloadVariants = _chunk347THBDEjs.t; exports.TransactionResponseType = _chunk347THBDEjs.I; exports.TransactionVariants = _chunk347THBDEjs.x; exports.TransactionWorker = si; exports.TransactionWorkerEventsEnum = bc; exports.TypeTag = B; exports.TypeTagAddress = G; exports.TypeTagBool = Q; exports.TypeTagGeneric = M; exports.TypeTagParserError = X; exports.TypeTagParserErrorType = Qu; exports.TypeTagReference = Sr; exports.TypeTagSigner = Nt; exports.TypeTagStruct = h; exports.TypeTagU128 = at; exports.TypeTagU16 = ot; exports.TypeTagU256 = ct; exports.TypeTagU32 = st; exports.TypeTagU64 = te; exports.TypeTagU8 = de; exports.TypeTagVariants = _chunk347THBDEjs.r; exports.TypeTagVector = U; exports.U128 = ke; exports.U16 = Re; exports.U256 = we; exports.U32 = Ue; exports.U64 = $; exports.U8 = Z; exports.WebAuthnSignature = kn; exports.ZeroKnowledgeSig = me; exports.ZkProof = Jt; exports.ZkpVariant = _chunk347THBDEjs.H; exports.anyPublicKeyVariantToString = _chunk347THBDEjs.C; exports.aptosCoinStructTag = rA; exports.aptosRequest = gr; exports.base64UrlDecode = _chunk347THBDEjs.ka; exports.base64UrlToBytes = _chunk347THBDEjs.la; exports.bigIntToBytesLE = mi; exports.buildTransaction = Zi; exports.bytesToBigIntLE = vt; exports.checkOrConvertArgument = Lt; exports.convertAmountFromHumanReadableToOnChain = _chunk347THBDEjs.ma; exports.convertAmountFromOnChainToHumanReadable = _chunk347THBDEjs.na; exports.convertArgument = Yi; exports.convertNumber = Hr; exports.convertPayloadToInnerPayload = od; exports.createObjectAddress = _chunk347THBDEjs.ca; exports.createResourceAddress = _chunk347THBDEjs.da; exports.createTokenAddress = _chunk347THBDEjs.fa; exports.createUserDerivedObjectAddress = _chunk347THBDEjs.ea; exports.deriveKey = gi; exports.deriveTransactionType = vr; exports.deserializeFromScriptArgument = ku; exports.deserializePublicKey = nf; exports.deserializeSignature = rf; exports.ensureBoolean = _chunk347THBDEjs.n; exports.fetchEntryFunctionAbi = Js; exports.fetchFunctionAbi = Xi; exports.fetchJWK = Ri; exports.fetchModuleAbi = Yu; exports.fetchMoveFunctionAbi = Zw; exports.fetchViewFunctionAbi = Xs; exports.findFirstNonSignerArg = js; exports.floorToWholeHour = _chunk347THBDEjs.ja; exports.generateRawTransaction = id; exports.generateSignedTransaction = eo; exports.generateSignedTransactionForSimulation = Zs; exports.generateSigningMessage = We; exports.generateSigningMessageForSerializable = Ah; exports.generateSigningMessageForTransaction = Be; exports.generateTransactionPayload = Qr; exports.generateTransactionPayloadWithABI = td; exports.generateUserTransactionHash = xS; exports.generateViewFunctionPayload = Ys; exports.generateViewFunctionPayloadWithABI = nd; exports.get = yr; exports.getAptosFullNode = H; exports.getAptosPepperService = lg; exports.getAuthenticatorForSimulation = hn; exports.getErrorMessage = _chunk347THBDEjs.ha; exports.getFunctionParts = _chunk347THBDEjs.qa; exports.getIssAudAndUidVal = tt; exports.getKeylessConfig = Xt; exports.getKeylessJWKs = Iu; exports.getPageWithObfuscatedCursor = fr; exports.hashStrToField = Le; exports.hashValues = ea; exports.hexToAsciiString = _chunk347THBDEjs.k; exports.isBcsAddress = qr; exports.isBcsBool = Vi; exports.isBcsFixedBytes = Ju; exports.isBcsString = Hi; exports.isBcsU128 = Qi; exports.isBcsU16 = qi; exports.isBcsU256 = ji; exports.isBcsU32 = $i; exports.isBcsU64 = Wi; exports.isBcsU8 = Li; exports.isBlockEpilogueTransactionResponse = _chunk347THBDEjs.P; exports.isBlockMetadataTransactionResponse = _chunk347THBDEjs.M; exports.isBool = qs; exports.isCanonicalEd25519Signature = Uu; exports.isEd25519Signature = _chunk347THBDEjs.Q; exports.isEmptyOption = $s; exports.isEncodedEntryFunctionArgument = Ws; exports.isEncodedStruct = _chunk347THBDEjs.pa; exports.isFeePayerSignature = _chunk347THBDEjs.T; exports.isGenesisTransactionResponse = _chunk347THBDEjs.L; exports.isKeylessSigner = Rr; exports.isLargeNumber = Lr; exports.isMultiAgentSignature = _chunk347THBDEjs.S; exports.isMultiEd25519Signature = _chunk347THBDEjs.U; exports.isNumber = ju; exports.isPendingTransactionResponse = _chunk347THBDEjs.J; exports.isScriptDataInput = Qs; exports.isSecp256k1Signature = _chunk347THBDEjs.R; exports.isSingleKeySigner = Ni; exports.isSingleSenderSignature = _chunk347THBDEjs.V; exports.isStateCheckpointTransactionResponse = _chunk347THBDEjs.N; exports.isString = yt; exports.isUserTransactionResponse = _chunk347THBDEjs.K; exports.isValidBIP44Path = zo; exports.isValidFunctionInfo = _chunk347THBDEjs.ra; exports.isValidHardenedPath = No; exports.isValidatorTransactionResponse = _chunk347THBDEjs.O; exports.mnemonicToSeed = ur; exports.normalizeBundle = Jo; exports.nowInSeconds = _chunk347THBDEjs.ia; exports.objectStructTag = be; exports.optionStructTag = iA; exports.outOfRangeErrorMessage = _chunk347THBDEjs.o; exports.padAndPackBytesWithLen = Cn; exports.paginateWithCursor = mr; exports.paginateWithObfuscatedCursor = Si; exports.pairedFaMetadataAddress = _chunk347THBDEjs.ta; exports.parseEncodedStruct = _chunk347THBDEjs.oa; exports.parseJwtHeader = vu; exports.parseTypeTag = Ve; exports.poseidonHash = Kt; exports.post = vn; exports.postAptosFaucet = Zo; exports.postAptosFullNode = wt; exports.postAptosIndexer = Yo; exports.postAptosPepperService = es; exports.postAptosProvingService = ts; exports.promiseFulfilledStatus = hc; exports.request = gu; exports.sleep = _chunk347THBDEjs.ga; exports.splitPath = Fo; exports.standardizeTypeTags = $r; exports.stringStructTag = I; exports.throwTypeMismatch = z; exports.truncateAddress = _chunk347THBDEjs.sa; exports.validateNumberInRange = _chunk347THBDEjs.p; exports.verifyKeylessSignature = Ki; exports.verifyKeylessSignatureWithJwkAndConfig = Ar;
|
|
481
|
+
`;async function Mr(n){let{aptosConfig:e}=n,{data:t}=await H({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function ra(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Ws,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Ss({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function ld(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Li},originMethod:"getProcessorStatuses"})).processor_status}async function Vr(n){let e=await ld({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Hr(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Li,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Lr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await H({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}`});return r}async function oa(n){return _optionalChain([n, 'access', _64 => _64.options, 'optionalAccess', _65 => _65.ledgerVersion])!==void 0?ia(n):$e(async()=>ia(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ia(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await H({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _66 => _66.ledgerVersion])}});return o}async function qr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await St({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _67 => _67.ledgerVersion])},body:r})).data}async function sa(n){let{aptosConfig:e,options:t}=n,r={query:Zs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _68 => _68.where]),offset:_optionalChain([t, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([t, 'optionalAccess', _70 => _70.limit]),order_by:_optionalChain([t, 'optionalAccess', _71 => _71.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function aa(n){let{aptosConfig:e,options:t}=n,r={query:ea,variables:{where_condition:_optionalChain([t, 'optionalAccess', _72 => _72.where]),offset:_optionalChain([t, 'optionalAccess', _73 => _73.offset]),limit:_optionalChain([t, 'optionalAccess', _74 => _74.limit]),order_by:_optionalChain([t, 'optionalAccess', _75 => _75.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function Wi(n){let{aptosConfig:e,options:t}=n;return wr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _76 => _76.offset]),limit:_optionalChain([t, 'optionalAccess', _77 => _77.limit])}})}async function Wr(n){let{aptosConfig:e}=n;return $e(async()=>{let{data:t}=await H({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function ca(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await H({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function Wn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await H({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function ua(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await Wn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _78 => _78.status])===404)return!0;throw r}}async function gd(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await H({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function Pn(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _79 => _79.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _80 => _80.checkSuccess]), () => (!0)),s=!0,a=0,c,d,m=200,A=1.5;function p(g){if(!(g instanceof Ee)||(d=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await Wn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){p(g)}if(s){let g=Date.now();try{c=await gd({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){p(b)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await Wn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){p(g)}await _chunkHO5ESTN4js.sa.call(void 0, m),a+=m/1e3,m*=A}if(c===void 0)throw d||new $r(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new $r(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new $i(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Qr(n){let{aptosConfig:e,processorType:t}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(t===void 0?s=await Vr({aptosConfig:e}):s=(await Hr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkHO5ESTN4js.sa.call(void 0, 200)}}var $r=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},$i=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function da(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await H({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _81 => _81.withTransactions])}});return la({block:i,...n})}async function pa(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await H({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _82 => _82.withTransactions])}});return la({block:i,...n})}async function la(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _83 => _83.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _84 => _84.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let d=[],m=100n;for(let p=c+1n;p<s;p+=BigInt(100))d.push(Wi({aptosConfig:e,options:{offset:p,limit:Math.min(Number(m),Number(s-p+1n))}}));let A=await Promise.all(d);for(let p of A)t.transactions.push(...p)}return t}function ga(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function ya(n){return!!n.match(/\s/)}function yd(n){return!!n.match(/^T[0-9]+$/)}function md(n){return!!n.match(/^&.+$/)}function fd(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":case"i8":case"i16":case"i32":case"i64":case"i128":case"i256":return!0;default:return!1}}function Ad(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!ya(r))break}return t}var hd=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(hd||{}),X= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function He(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _85 => _85.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let d=n[s];if(d==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(d===">"){if(a!==""){let b=Qn(a,i,t);o.push(b)}let m=r.pop();if(m===void 0)throw new X(n,"unexpected '>'");if(c!==o.length)throw new X(n,"type argument count doesn't match expected amount");let{savedStr:A,savedTypes:p,savedExpectedTypes:g}=m;i=o,o=p,a=A,c=g}else if(d===","){if(r.length===0)throw new X(n,"unexpected ','");if(a.length===0)throw new X(n,"no type argument before ','");let m=Qn(a,i,t);i=[],o.push(m),a="",c+=1}else if(ya(d)){let m=!1;if(a.length!==0){let p=Qn(a,i,t);i=[],o.push(p),a="",m=!0}s=Ad(n,s);let A=n[s];if(s<n.length&&m&&A!==","&&A!==">")throw new X(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new X(n,"no matching '>' for '<'");switch(o.length){case 0:return Qn(a,i,t);case 1:if(a==="")return o[0];throw new X(n,"unexpected ','");default:throw new X(n,"unexpected whitespace character")}}function Qn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(fd(i)&&e.length>0)throw new X(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Mt;case"bool":return new Q;case"address":return new G;case"u8":return new de;case"u16":return new st;case"u32":return new at;case"u64":return new te;case"u128":return new ct;case"u256":return new ut;case"i8":return new Nt;case"i16":return new Dt;case"i32":return new Ft;case"i64":return new Ot;case"i128":return new Bt;case"i256":return new Gt;case"vector":if(e.length!==1)throw new X(n,"vector type expected to have exactly one type argument");return new z(e[0]);default:if(md(r)){let a=r.substring(1);return new vr(Qn(a,e,t))}if(yd(r)){if(t)return new M(Number(r.split("T")[1]));throw new X(n,"unexpected generic type")}if(!r.match(/:/))throw new X(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new X(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunkHO5ESTN4js.na.fromString(o[0])}catch (e4){throw new X(n,"struct address must be valid")}if(!ga(o[1]))throw new X(n,"module name must only contain alphanumeric or '_' characters");if(!ga(o[2]))throw new X(n,"struct name must only contain alphanumeric or '_' characters");return new h(new Xe(s,new k(o[1]),new k(o[2]),e))}}function ma(n){return typeof n=="boolean"}function mt(n){return typeof n=="string"}function bd(n){return typeof n=="number"}function jr(n){if(bd(n))return n;if(mt(n)&&n!=="")return Number.parseInt(n,10)}function Jr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function fa(n){return n==null}function Aa(n){return Qi(n)||Ji(n)||Xi(n)||Yi(n)||Zi(n)||eo(n)||to(n)||Xr(n)||ji(n)||Td(n)||n instanceof S||n instanceof ne}function Qi(n){return n instanceof F}function Xr(n){return n instanceof _chunkHO5ESTN4js.na}function ji(n){return n instanceof v}function Td(n){return n instanceof Re}function Ji(n){return n instanceof Z}function Xi(n){return n instanceof Ue}function Yi(n){return n instanceof ze}function Zi(n){return n instanceof $}function eo(n){return n instanceof ke}function to(n){return n instanceof Se}function ha(n){return"bytecode"in n}function N(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function ba(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var wd=new TextEncoder;function Yr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _86 => _86.map, 'call', _87 => _87(e=>mt(e)?He(e):e)]), () => ([]))}async function Sd(n,e,t){return(await Zr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function ro(n,e,t,r){let i=await Sd(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 IS(n,e,t,r){let i=await ro(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(He(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function Ta(n,e,t,r){let i=await ro(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=ba(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(He(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function wa(n,e,t,r){let i=await ro(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(He(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(He(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function io(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.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=He(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 Jt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Jt(n,e,t,r,i,o){return Aa(n)?(no(e,n,t),n):Pd(n,e,t,r,i,o)}function Pd(n,e,t,r,i,o){if(e.isBool()){if(ma(n))return new F(n);if(mt(n)){if(n==="true")return new F(!0);if(n==="false")return new F(!1)}N("boolean",t)}if(e.isAddress()){if(mt(n))return _chunkHO5ESTN4js.na.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunkHO5ESTN4js.na)(n.data);N("string | AccountAddress",t)}if(e.isU8()){let s=jr(n);if(s!==void 0)return new Z(s);N("number | string",t)}if(e.isU16()){let s=jr(n);if(s!==void 0)return new Ue(s);N("number | string",t)}if(e.isU32()){let s=jr(n);if(s!==void 0)return new ze(s);N("number | string",t)}if(e.isU64()){if(Jr(n))return new $(BigInt(n));N("bigint | number | string",t)}if(e.isU128()){if(Jr(n))return new ke(BigInt(n));N("bigint | number | string",t)}if(e.isU256()){if(Jr(n))return new Se(BigInt(n));N("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 Jt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(mt(n))return S.U8(wd.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(mt(n)&&n.startsWith("["))return Jt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Jt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(mt(n))return new v(n);N("string",t)}if(e.isObject()){if(mt(n))return _chunkHO5ESTN4js.na.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new (0, _chunkHO5ESTN4js.na)(n.data);N("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Re(n);N("Uint8Array",t)}if(e.isOption()){if(fa(n)){let a=e.value.typeArgs[0];return a instanceof Q?new ne(null):a instanceof G?new ne(null):a instanceof de?new ne(null):a instanceof st?new ne(null):a instanceof at?new ne(null):a instanceof te?new ne(null):a instanceof ct?new ne(null):a instanceof ut?new ne(null):new ne(null)}return new ne(Jt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _88 => _88.structs, 'access', _89 => _89.find, 'call', _90 => _90(a=>a.name===e.value.name.identifier), 'optionalAccess', _91 => _91.fields, 'access', _92 => _92.length])===0&&n instanceof Uint8Array)return new Re(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _93 => _93.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Re(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 no(n,e,t){if(n.isBool()){if(Qi(e))return;N("Bool",t)}if(n.isAddress()){if(Xr(e))return;N("AccountAddress",t)}if(n.isU8()){if(Ji(e))return;N("U8",t)}if(n.isU16()){if(Xi(e))return;N("U16",t)}if(n.isU32()){if(Yi(e))return;N("U32",t)}if(n.isU64()){if(Zi(e))return;N("U64",t)}if(n.isU128()){if(eo(e))return;N("U128",t)}if(n.isU256()){if(to(e))return;N("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&no(n.value,e.values[0],t);return}N("MoveVector",t)}if(n instanceof h){if(n.isString()){if(ji(e))return;N("MoveString",t)}if(n.isObject()){if(Xr(e))return;N("AccountAddress",t)}if(n.isOption()){if(e instanceof ne){e.value!==void 0&&no(n.value.typeArgs[0],e.value,t);return}N("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function ei(n){if(ha(n))return xd(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunkHO5ESTN4js.Ca.call(void 0, n.function),i=await _a({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ta});return _d({...n,abi:i})}function _d(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkHO5ESTN4js.Ca.call(void 0, n.function),o=Yr(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,d)=>io(n.function,e,c,d,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=dt.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunkHO5ESTN4js.na.from(n.multisigAddress);return new mn(new Mn(c,new Vn(a)))}return new yn(a)}async function Sa(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunkHO5ESTN4js.Ca.call(void 0, n.function),i=await _a({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:wa});return Id({abi:i,...n})}function Id(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkHO5ESTN4js.Ca.call(void 0, n.function),o=Yr(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _94 => _94.functionArguments, 'optionalAccess', _95 => _95.map, 'call', _96 => _96((a,c)=>io(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return dt.build(`${t}::${r}`,i,o,s)}function xd(n){return new gn(new fn(_chunkHO5ESTN4js.v.fromHexInput(n.bytecode).toUint8Array(),Yr(n.typeArguments),n.functionArguments))}async function vd(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(_optionalChain([i, 'optionalAccess', _97 => _97.replayProtectionNonce])!==void 0&&_optionalChain([i, 'optionalAccess', _98 => _98.accountSequenceNumber])!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>_i[e.network]?{chainId:_i[e.network]}:{chainId:(await Mr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _99 => _99.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Wr({aptosConfig:e})).gas_estimate},c=async()=>{let se=async()=>_optionalChain([i, 'optionalAccess', _100 => _100.accountSequenceNumber])!==void 0?i.accountSequenceNumber:_optionalChain([i, 'optionalAccess', _101 => _101.replayProtectionNonce])!==void 0?0xdeadbeefn:(await Lr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunkHO5ESTN4js.na.from(o).equals(_chunkHO5ESTN4js.na.ZERO))try{return await se()}catch (e5){return 0}else return se()},[{chainId:d},{gasEstimate:m},A]=await Promise.all([s(),a(),c()]),{maxGasAmount:p,gasUnitPrice:g,expireTimestamp:b,replayProtectionNonce:D}={maxGasAmount:_optionalChain([i, 'optionalAccess', _102 => _102.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _103 => _103.gasUnitPrice]), () => (BigInt(m))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _104 => _104.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()))),replayProtectionNonce:_optionalChain([i, 'optionalAccess', _105 => _105.replayProtectionNonce])?BigInt(i.replayProtectionNonce):void 0},q=r;return D!==void 0&&(q=Cd(r,D)),new ve(_chunkHO5ESTN4js.na.from(t),BigInt(A),q,BigInt(p),BigInt(g),BigInt(b),new ln(d))}function Cd(n,e){if(n instanceof gn)return new Vt(new Hn(n.script),new Ht(void 0,e));if(n instanceof yn)return new Vt(new hn(n.entryFunction),new Ht(void 0,e));if(n instanceof mn){let t=n.multiSig.transaction_payload,r;if(t===void 0||_optionalChain([t, 'optionalAccess', _106 => _106.transaction_payload])===void 0)r=new Ln;else if(t.transaction_payload instanceof dt)r=new hn(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new Vt(r,new Ht(n.multiSig.multisig_address,e))}else throw new Error(`Unsupported payload type: ${n}`)}async function oo(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await vd({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _107 => _107.secondarySignerAddresses, 'optionalAccess', _108 => _108.map, 'call', _109 => _109(c=>_chunkHO5ESTN4js.na.from(c))]), () => ([]));return new kr(s,a,n.feePayerAddress?_chunkHO5ESTN4js.na.from(n.feePayerAddress):void 0)}return new zr(s,n.feePayerAddress?_chunkHO5ESTN4js.na.from(n.feePayerAddress):void 0)}function Pa(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=En(e);if(t.feePayerAddress){let a=new qt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(A=>En(A)):c=Array.from({length:t.secondarySignerAddresses.length},()=>En(void 0)));let d=En(i),m=new Qt(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:d});return new lt(a.raw_txn,m).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Lt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(m=>En(m)):c=Array.from({length:t.secondarySignerAddresses.length},()=>En(void 0));let d=new Wt(o,t.secondarySignerAddresses,c);return new lt(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Ge)s=new $t(o.public_key,o.signature);else if(o instanceof ue||o instanceof Je)s=new It(o);else if(o instanceof pn)s=new It(o);else throw new Error("Invalid public key");return new lt(t.rawTransaction,s).bcsToBytes()}function En(n){if(!n)return new pn;let t=K.isInstance(n)||L.isInstance(n)||Fe.isInstance(n)?new I(n):n,r=new R(new Uint8Array(64));if(E.isInstance(t))return new Ge(t,r);if(I.isInstance(t))return K.isInstance(t.publicKey)?new ue(t,new B(ce.getSimulationSignature())):new ue(t,new B(r));if(W.isInstance(t))return new Je(t,new Ie({signatures:t.publicKeys.map(i=>K.isInstance(i.publicKey)||L.isInstance(i.publicKey)?new B(ce.getSimulationSignature()):new B(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function so(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Ts(ee,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 Qt(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Wt(i,e.secondarySignerAddresses,r)}else i instanceof Ge?o=new $t(i.public_key,i.signature):i instanceof ot?o=new bn(i.public_key,i.signature):o=new It(i);return new lt(e.rawTransaction,o).bcsToBytes()}function Ea(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Kd=Ea(["APTOS::Transaction"]);function ZS(n){let e=so(n);return new (0, _chunkHO5ESTN4js.v)(Ea([Kd,new Uint8Array([0]),e])).toString()}async function _a({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:$e(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}async function T(n){let e=await Rd(n);return Ud(n,e)}async function Rd(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await ei(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ei(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await ei(r)),i}async function Ud(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(zd(n)&&(o=_chunkHO5ESTN4js.na.ZERO.toString()),kd(n)){let{secondarySignerAddresses:s}=n;return oo({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return oo({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function zd(n){return n.withFeePayer===!0}function kd(n){return"secondarySignerAddresses"in n}function Ia(n){let{transaction:e}=n;return Me(e)}function ti(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function ni(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,ti({signer:e,transaction:t})}async function ao(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Pa({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await St({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _110 => _110.options, 'optionalAccess', _111 => _111.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _112 => _112.options, 'optionalAccess', _113 => _113.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _114 => _114.options, 'optionalAccess', _115 => _115.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function jn(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=so({...n});try{let{data:o}=await St({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=lt.deserialize(new C(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof K||s.authenticator.sender.public_key.publicKey instanceof L)&&await we.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function ri(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;Fr(t)&&await t.checkKeylessAccountValidity(e),Fr(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&ni({signer:r,transaction:i}),a=ti({signer:t,transaction:i});return jn({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function xa(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;Fr(r)&&await r.checkKeylessAccountValidity(e);let s=ni({signer:r,transaction:i});return jn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var Nd={typeParameters:[],parameters:[z.u8(),new z(z.u8())]};async function va(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>S.U8(a));return T({aptosConfig:e,sender:_chunkHO5ESTN4js.na.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Nd},options:o})}async function _n(n){return Lr(n)}async function Ca(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return vi({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _116 => _116.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _117 => _117.limit]), () => (1e3))}})}async function Ka(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Sr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _118 => _118.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _119 => _119.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Zr(n){return oa(n)}async function uo(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return wr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _121 => _121.offset]),limit:_optionalChain([r, 'optionalAccess', _122 => _122.limit])}})}async function po(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return vi({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _123 => _123.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _124 => _124.limit]), () => (999))}})}async function Ra(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await Sr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _125 => _125.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _126 => _126.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _127 => _127.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function lo(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await H({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunkHO5ESTN4js.na.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _128 => _128.ledgerVersion])}});return o.data}async function Jn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await lo({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunkHO5ESTN4js.na.from(t);try{let a=await qr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunkHO5ESTN4js.na.from(a)}catch(a){if(a instanceof Ee&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ua(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Ls,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 za(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _129 => _129.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _130 => _130.tokenStandard])});let s={query:Vs,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _131 => _131.offset]),limit:_optionalChain([r, 'optionalAccess', _132 => _132.limit]),order_by:_optionalChain([r, 'optionalAccess', _133 => _133.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function ka(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunkHO5ESTN4js.na.from(t).toStringLong(),s=_chunkHO5ESTN4js.na.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _134 => _134.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _135 => _135.tokenStandard])});let c={query:Hs,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _136 => _136.offset]),limit:_optionalChain([i, 'optionalAccess', _137 => _137.limit]),order_by:_optionalChain([i, 'optionalAccess', _138 => _138.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Na(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _139 => _139.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _140 => _140.tokenStandard])}});let s={query:Ms,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([r, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([r, 'optionalAccess', _143 => _143.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function Da(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkHO5ESTN4js.na.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:qs,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Fa(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunkHO5ESTN4js.na.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _144 => _144.where]),owner_address:{_eq:i}},s={query:Gs,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _145 => _145.offset]),limit:_optionalChain([r, 'optionalAccess', _146 => _146.limit]),order_by:_optionalChain([r, 'optionalAccess', _147 => _147.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Oa(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunkHO5ESTN4js.na.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Bs,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 Ba(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await H({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?_chunkHO5ESTN4js.na.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function go(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}},s={query:Gr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _148 => _148.offset]),limit:_optionalChain([r, 'optionalAccess', _149 => _149.limit]),order_by:_optionalChain([r, 'optionalAccess', _150 => _150.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Ga(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _151 => _151.throwIfNoAccountFound]), () => (!1)),o=await ii({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return gt.fromPrivateKey({privateKey:t})}return o[0]}async function Dd(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([po({aptosConfig:e,accountAddress:t}),go({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!_optionalChain([r, 'optionalAccess', _152 => _152.withAuthKey]))return!0;let a;return s?a=s.data.authentication_key:a=t.toStringLong(),a===r.withAuthKey.toString()}catch(i){throw new Error(`Error while checking if account exists at ${t.toString()}: ${i}`)}}var Fd={typeParameters:[],parameters:[new de,z.u8(),new de,z.u8(),z.u8(),z.u8()]};async function Ma(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return co({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof oe?co({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):co({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function co(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await _n({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=gt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new Ur({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:_chunkHO5ESTN4js.na.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new Z(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new Z(o.signingScheme),S.U8(o.publicKey.toUint8Array()),S.U8(c.toUint8Array()),S.U8(d.toUint8Array())],abi:Fd},options:r})}var Od={typeParameters:[],parameters:[new de,z.u8()]};async function Va(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new Z(Rs(r)),S.U8(Bi(r).toUint8Array())],abi:Od},options:i})}async function oi(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _153 => _153.noMultiKey]), () => (!1));if(i&&t instanceof Oe)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof I&&t.publicKey instanceof E?o.push(t.publicKey):t instanceof E&&o.push(new I(t));let[s,a]=await Promise.all([Promise.all(o.map(async A=>{let p=await Hd({aptosConfig:e,publicKey:A});if(p)return{...p,publicKey:A}})),!(t instanceof Oe)&&!i?Gd({aptosConfig:e,publicKey:t,options:r}):Promise.resolve([])]),c=[];for(let A of s)A&&c.push(A);o.push(...a);let d=new Map(o.map(A=>[A.authKey().toString(),A])),m=await Md({aptosConfig:e,authKeys:o.map(A=>A.authKey()),options:r});for(let A of m){if(c.find(g=>g.accountAddress===A.accountAddress))continue;let p=d.get(A.authKey.toString());if(!p)throw new Error(`No publicKey found for authentication key ${A.authKey}. This should never happen.`);c.push({accountAddress:A.accountAddress,publicKey:p,lastTransactionVersion:A.lastTransactionVersion})}return c.sort((A,p)=>p.lastTransactionVersion-A.lastTransactionVersion)}async function yo(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof J||t instanceof rt)return ii({aptosConfig:e,privateKey:t,options:r});if(t instanceof oe||t instanceof pe)return ii({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof Ce||t instanceof Ve)return Bd({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof yt&&t.signers.length===1)return yo({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof qn&&t.signers.length===1)return ii({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function Bd(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await oi({aptosConfig:e,publicKey:t.getAnyPublicKey(),options:r}),o={proof:t.proofOrPromise,jwt:t.jwt,ephemeralKeyPair:t.ephemeralKeyPair,pepper:t.pepper,verificationKeyHash:t.verificationKeyHash},s=[];for(let{accountAddress:a,publicKey:c}of i)if(c instanceof Oe){if(c.getSignaturesRequired()>1)continue;if(c instanceof ie)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof W&&s.push(new yt({multiKey:c,signers:[t],address:a}))}else t instanceof Ve?s.push(Ve.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(Ce.create({...o,address:a}));return s}async function ii(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=gt.fromPrivateKey({privateKey:t,legacy:!1}),o=await oi({aptosConfig:e,publicKey:new I(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof Oe){if(c.getSignaturesRequired()>1)continue;c instanceof ie?s.push(new qn({publicKey:c,signers:[t],address:a})):c instanceof W&&s.push(new yt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof E;s.push(gt.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function Gd(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof Oe)throw new Error("Public key is a multi-key.");let i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _154 => _154.includeUnverified]), () => (!1)),o=t instanceof I?t:new I(t),s=o.publicKey,a=_chunkHO5ESTN4js.O.call(void 0, o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:$s,variables:{where_condition:c}},{public_key_auth_keys:m}=await w({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return m.map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return ie.deserializeWithoutLength(C.fromHex(p.account_public_key));case"multi_key_signature":return W.deserialize(C.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function Md(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _155 => _155.includeUnverified]), () => (!1));if(t.length===0)throw new Error("No authentication keys provided");let o={auth_key:{_in:t.map(c=>c.toString())},...i?{}:{is_auth_key_used:{_eq:!0}}},s={query:Os,variables:{where_condition:o,order_by:[{last_transaction_version:"desc"}]}},{auth_key_account_addresses:a}=await w({aptosConfig:e,query:s,originMethod:"getAccountAddressesForAuthKeys"});return a.map(c=>({authKey:new V({data:c.auth_key}),accountAddress:new (0, _chunkHO5ESTN4js.na)(_chunkHO5ESTN4js.v.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function Vd(n){let{aptosConfig:e,accountAddress:t}=n,r=await uo({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function Hd(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([Vd({aptosConfig:e,accountAddress:r}),Dd({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function P(n){n.minimumLedgerVersion!==void 0&&await Qr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function le(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Sa({...t,aptosConfig:e}),o=new _chunkHO5ESTN4js.y;i.serialize(o);let s=o.toUint8Array(),{data:a}=await St({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _156 => _156.ledgerVersion])},body:s});return a}async function Ha(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await St({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _157 => _157.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function La(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkHO5ESTN4js.Ca.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new G,new h(x()),new h(x())]}},options:i})}async function qa(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunkHO5ESTN4js.Ca.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new G,new h(x()),new h(x())]}},options:i})}async function $a(n){let{aptosConfig:e,sender:t,options:r}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Xt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunkHO5ESTN4js.Ca.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _158 => _158.some, 'call', _159 => _159(s=>_chunkHO5ESTN4js.na.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 La({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return qa({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return $a({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await le({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunkHO5ESTN4js.na.from(t)],abi:{typeParameters:[],parameters:[new G],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunkHO5ESTN4js.na.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var Xn=class{constructor(e){this.config=e;this.abstraction=new Xt(e)}async getAccountInfo(e){return _n({aptosConfig:this.config,...e})}async getAccountModules(e){return Ca({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Ka({aptosConfig:this.config,...e})}async getAccountModule(e){return Zr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return uo({aptosConfig:this.config,...e})}async getAccountResources(e){return po({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Ra({aptosConfig:this.config,...e})}async getAccountResource(e){return lo({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return Jn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ua({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),za({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ka({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Na({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Da({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Fa({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Oa({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Rt,faMetadataAddress:fs,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i}=e,o=r;r===void 0&&i!==void 0&&(o=await $e(async()=>{try{let c=(await le({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&_chunkHO5ESTN4js.Ba.call(void 0, c.vec[0]))return _chunkHO5ESTN4js.Aa.call(void 0, c.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=_chunkHO5ESTN4js.na.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Rt?s=_chunkHO5ESTN4js.na.A.toStringLong():s=_chunkHO5ESTN4js.oa.call(void 0, _chunkHO5ESTN4js.na.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=_chunkHO5ESTN4js.na.from(i);s=c.toStringLong(),c===_chunkHO5ESTN4js.na.A&&(o=Rt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await le({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await le({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,s]}});return parseInt(a,10)}async getBalance(e){return Ba({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),go({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ga({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),yo({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),oi({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var si=class{constructor(e){if(_optionalChain([e, 'optionalAccess', _160 => _160.fullnode])||_optionalChain([e, 'optionalAccess', _161 => _161.indexer])||_optionalChain([e, 'optionalAccess', _162 => _162.faucet])||_optionalChain([e, 'optionalAccess', _163 => _163.pepper])||_optionalChain([e, 'optionalAccess', _164 => _164.prover])){if(_optionalChain([e, 'optionalAccess', _165 => _165.network])==="custom")console.info("Note: using CUSTOM network will require queries to lookup ChainId");else if(!_optionalChain([e, 'optionalAccess', _166 => _166.network]))throw new Error("Custom endpoints require a network to be specified")}this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _167 => _167.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _168 => _168.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _169 => _169.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _170 => _170.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _171 => _171.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _172 => _172.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _173 => _173.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _174 => _174.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _175 => _175.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _176 => _176.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _177 => _177.faucetConfig]), () => ({})),this.transactionGenerationConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _178 => _178.transactionGenerationConfig]), () => ({})),this.pluginConfig=_optionalChain([e, 'optionalAccess', _179 => _179.pluginSettings])?{...e.pluginSettings,IGNORE_TRANSACTION_SUBMITTER:!1}:void 0}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 ls[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 gs[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 ps[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 Si[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 Pi[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return Si[this.network]===e}isProverServiceRequest(e){return Pi[this.network]===e}getDefaultMaxGasAmount(){return _nullishCoalesce(_optionalChain([this, 'access', _180 => _180.transactionGenerationConfig, 'optionalAccess', _181 => _181.defaultMaxGasAmount]), () => (2e5))}getDefaultTxnExpirySecFromNow(){return _nullishCoalesce(_optionalChain([this, 'access', _182 => _182.transactionGenerationConfig, 'optionalAccess', _183 => _183.defaultTxnExpirySecFromNow]), () => (20))}setIgnoreTransactionSubmitter(e){this.pluginConfig&&(this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER=e)}getTransactionSubmitter(){if(this.pluginConfig!==void 0&&this.pluginConfig.IGNORE_TRANSACTION_SUBMITTER!==!0)return this.pluginConfig.TRANSACTION_SUBMITTER}};var qd={typeParameters:[{constraints:[]}],parameters:[new G,new te]};async function Wa(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (Rt))],functionArguments:[r,i],abi:qd},options:s})}var Yn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Wa({aptosConfig:this.config,...e})}};var xt={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Ke="0x4::token::Token";async function Qa(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:na,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ja(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:qi,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Ja(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()},amount:{_gt:0}},o={query:qi,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _184 => _184.offset]),limit:_optionalChain([r, 'optionalAccess', _185 => _185.limit]),order_by:_optionalChain([r, 'optionalAccess', _186 => _186.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Xa(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}},o={query:ta,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _187 => _187.offset]),limit:_optionalChain([r, 'optionalAccess', _188 => _188.limit]),order_by:_optionalChain([r, 'optionalAccess', _189 => _189.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var $d={typeParameters:[],parameters:[new h(x()),new te,new h(x()),new h(x()),new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new Q,new te,new te]};async function Ya(n){let{aptosConfig:e,options:t,creator:r}=n;return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new v(n.description),new $(_nullishCoalesce(n.maxSupply, () => (_chunkHO5ESTN4js.e))),new v(n.name),new v(n.uri),new F(_nullishCoalesce(n.mutableDescription, () => (!0))),new F(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new F(_nullishCoalesce(n.mutableURI, () => (!0))),new F(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new F(_nullishCoalesce(n.mutableTokenName, () => (!0))),new F(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new F(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new F(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new F(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new $(_nullishCoalesce(n.royaltyNumerator, () => (0))),new $(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:$d},options:t})}async function In(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _190 => _190.where]);_optionalChain([t, 'optionalAccess', _191 => _191.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _192 => _192.tokenStandard]), () => ("v2"))});let i={query:Qs,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _193 => _193.offset]),limit:_optionalChain([t, 'optionalAccess', _194 => _194.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function Za(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunkHO5ESTN4js.na.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _195 => _195.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _196 => _196.tokenStandard]), () => ("v2"))}),In({aptosConfig:e,options:{...i,where:s}})}async function ec(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _197 => _197.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _198 => _198.tokenStandard]), () => ("v2"))}),In({aptosConfig:e,options:{...r,where:o}})}async function tc(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _199 => _199.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _200 => _200.tokenStandard]), () => ("v2"))}),In({aptosConfig:e,options:{...r,where:o}})}async function nc(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunkHO5ESTN4js.na.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _201 => _201.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _202 => _202.tokenStandard]), () => ("v2"))}),(await In({aptosConfig:i,options:{where:s}})).collection_id}var Wd={typeParameters:[],parameters:[new h(x()),new h(x()),new h(x()),new h(x()),new z(new h(x())),new z(new h(x())),new z(z.u8())]};async function rc(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:m}=n,A=_optionalChain([d, 'optionalAccess', _203 => _203.map, 'call', _204 => _204(p=>xt[p])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new v(i),new v(o),new v(s),new v(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(A, () => ([]))),Ac(_nullishCoalesce(m, () => ([])),_nullishCoalesce(A, () => ([])))],abi:Wd},options:t})}var Qd={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new G]};async function ic(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(r),_chunkHO5ESTN4js.na.from(i)],abi:Qd},options:s})}var jd={typeParameters:[],parameters:[new h(x()),new h(x()),new h(x()),new h(x()),new z(new h(x())),new z(new h(x())),new z(z.u8()),new G]};async function oc(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:m,options:A}=n;if(_optionalChain([c, 'optionalAccess', _205 => _205.length])!==_optionalChain([m, 'optionalAccess', _206 => _206.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([d, 'optionalAccess', _207 => _207.length])!==_optionalChain([m, 'optionalAccess', _208 => _208.length]))throw new Error("Property types and property values counts do not match");let p=_optionalChain([d, 'optionalAccess', _209 => _209.map, 'call', _210 => _210(g=>xt[g])]);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(p, () => ([]))),Ac(_nullishCoalesce(m, () => ([])),_nullishCoalesce(p, () => ([]))),a],abi:jd},options:A})}var Jd={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0)))]};async function sc(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(r)],abi:Jd},options:o})}var Xd={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0)))]};async function ac(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Ke))],functionArguments:[r],abi:Xd},options:o})}var Yd={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0)))]};async function cc(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Ke))],functionArguments:[r],abi:Yd},options:o})}var Zd={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new h(x())]};async function uc(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(i),new v(r)],abi:Zd},options:s})}var ep={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new h(x())]};async function dc(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(i),new v(r)],abi:ep},options:s})}var tp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new h(x())]};async function pc(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(i),new v(r)],abi:tp},options:s})}var np={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new h(x()),new h(x()),z.u8()]};async function lc(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(s),new v(r),new v(xt[i]),S.U8(mo(o,xt[i]))],abi:np},options:c})}var rp={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new h(x())]};async function gc(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(i),new v(r)],abi:rp},options:s})}var ip={typeParameters:[{constraints:["key"]}],parameters:[new h(Te(new M(0))),new h(x()),new h(x()),z.u8()]};async function yc(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Ke))],functionArguments:[_chunkHO5ESTN4js.na.from(s),new v(r),new v(xt[i]),mo(o,xt[i])],abi:ip},options:c})}var op={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(Te(new M(0))),new h(x()),new M(1)]};async function mc(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Ke)),xt[i]],functionArguments:[_chunkHO5ESTN4js.na.from(s),new v(r),o],abi:op},options:c})}var sp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new h(Te(new M(0))),new h(x()),new M(1)]};async function fc(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Ke)),xt[i]],functionArguments:[_chunkHO5ESTN4js.na.from(s),new v(r),o],abi:sp},options:c})}function Ac(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(mo(n[i],r))}),t}function mo(n,e){let t=He(e);return Jt(n,t,0,[]).bcsToBytes()}var Zn=class{constructor(e){this.config=e}async getCollectionData(e){await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunkHO5ESTN4js.na.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _211 => _211.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _212 => _212.tokenStandard]), () => ("v2"))}),In({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Za({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ec({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),tc({aptosConfig:this.config,...e})}async getCollectionId(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),nc({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Qa({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ja({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ja({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Xa({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return Ya({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return rc({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return ic({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return oc({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return sc({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ac({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return cc({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return uc({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return dc({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return pc({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return lc({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return gc({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return yc({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return mc({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return fc({aptosConfig:this.config,...e})}};async function hc(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _213 => _213.timeoutSecs])||20,{data:s}=await Ps({aptosConfig:e,path:"fund",body:{address:_chunkHO5ESTN4js.na.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Pn({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _214 => _214.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var er=class{constructor(e){this.config=e}async fundAccount(e){let t=await hc({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _215 => _215.options, 'optionalAccess', _216 => _216.waitForIndexer])===void 0||_optionalChain([e, 'access', _217 => _217.options, 'optionalAccess', _218 => _218.waitForIndexer]))&&await Qr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function ai(n){let{aptosConfig:e,options:t}=n,r={query:Ys,variables:{where_condition:_optionalChain([t, 'optionalAccess', _219 => _219.where]),limit:_optionalChain([t, 'optionalAccess', _220 => _220.limit]),offset:_optionalChain([t, 'optionalAccess', _221 => _221.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function bc(n){let{aptosConfig:e,options:t}=n,r={query:Xs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _222 => _222.where]),limit:_optionalChain([t, 'optionalAccess', _223 => _223.limit]),offset:_optionalChain([t, 'optionalAccess', _224 => _224.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Tc(n){let{aptosConfig:e,options:t}=n,r={query:js,variables:{where_condition:_optionalChain([t, 'optionalAccess', _225 => _225.where]),limit:_optionalChain([t, 'optionalAccess', _226 => _226.limit]),offset:_optionalChain([t, 'optionalAccess', _227 => _227.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var wc={typeParameters:[{constraints:[]}],parameters:[He("0x1::object::Object"),new G,new te]};async function Sc(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:wc},options:s})}async function Pc(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:wc},options:s})}var tr=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _228 => _228.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ai({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _229 => _229.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await ai({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _230 => _230.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await ai({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunkHO5ESTN4js.na.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _231 => _231.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),bc({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _232 => _232.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Tc({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Sc({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return Pc({aptosConfig:this.config,...e})}};var nr=class{constructor(e){this.config=e}async getLedgerInfo(){return Mr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return da({aptosConfig:this.config,...e})}async getBlockByHeight(e){return pa({aptosConfig:this.config,...e})}async view(e){return le({aptosConfig:this.config,...e})}async viewJson(e){return Ha({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return ra({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Vr({aptosConfig:this.config})}async getProcessorStatus(e){return Hr({aptosConfig:this.config,processorType:e})}};var Ec=["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 _c(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function vt(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(!_c(e))throw new Error(`${e} is not valid. ${Ec}`);if(t&&!_c(t))throw new Error(`${t} is not valid. ${Ec}`);return{domainName:t||e,subdomainName:t?e:void 0}}function Ic(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 ap="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",cp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:ap,custom:null,devnet:null,shelbynet:null,netna:null};function ft(n){let e=cp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var ci=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function xc(n){let{aptosConfig:e,name:t}=n,r=ft(e),{domainName:i,subdomainName:o}=vt(t),s=await le({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=ci(s[0]);return a?_chunkHO5ESTN4js.na.from(a):void 0}async function vc(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=ft(e),{domainName:m,subdomainName:A}=vt(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(A&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!A)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let q=_nullishCoalesce(t.years, () => (1));if(q!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ye=q*31536e3;return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_domain`,functionArguments:[m,Ye,o,s]},options:a})}if(!A)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await fo({aptosConfig:e,name:m});if(!g)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:g;if(b>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${d}::router::register_subdomain`,functionArguments:[m,A,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function fo(n){let{aptosConfig:e,name:t}=n,r=ft(e),{domainName:i,subdomainName:o}=vt(t);try{let s=await le({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Cc(n){let{aptosConfig:e,address:t}=n,r=ft(e),i=await le({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunkHO5ESTN4js.na.from(t).toString()]}}),o=ci(i[1]),s=ci(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Kc(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=ft(e);if(!r)return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=vt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Rc(n){let{aptosConfig:e,name:t}=n,r=ft(e),{domainName:i,subdomainName:o}=vt(t),s=await le({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=ci(s[0]);return a?_chunkHO5ESTN4js.na.from(a):void 0}async function Uc(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=ft(e),{domainName:a,subdomainName:c}=vt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function zc(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=vt(t),a=(await w({aptosConfig:e,query:{query:Sn,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=rr(a)),Ic(a)?a:void 0}async function kc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ao({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:Sn,variables:{limit:_optionalChain([t, 'optionalAccess', _233 => _233.limit]),offset:_optionalChain([t, 'optionalAccess', _234 => _234.offset]),order_by:_optionalChain([t, 'optionalAccess', _235 => _235.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _236 => _236.options, 'optionalAccess', _237 => _237.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(rr)}async function Nc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ao({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Sn,variables:{limit:_optionalChain([t, 'optionalAccess', _238 => _238.limit]),offset:_optionalChain([t, 'optionalAccess', _239 => _239.offset]),order_by:_optionalChain([t, 'optionalAccess', _240 => _240.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _241 => _241.options, 'optionalAccess', _242 => _242.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(rr)}async function Dc(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Ao({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Sn,variables:{limit:_optionalChain([t, 'optionalAccess', _243 => _243.limit]),offset:_optionalChain([t, 'optionalAccess', _244 => _244.offset]),order_by:_optionalChain([t, 'optionalAccess', _245 => _245.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _246 => _246.options, 'optionalAccess', _247 => _247.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(rr)}async function Fc(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Sn,variables:{limit:_optionalChain([t, 'optionalAccess', _248 => _248.limit]),offset:_optionalChain([t, 'optionalAccess', _249 => _249.offset]),order_by:_optionalChain([t, 'optionalAccess', _250 => _250.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _251 => _251.options, 'optionalAccess', _252 => _252.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(rr).filter(Ic)}async function Ao(n){let{aptosConfig:e}=n,t=ft(e),[r]=await le({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 Oc(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=ft(e),a=i*31536e3,{domainName:c,subdomainName:d}=vt(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 T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function rr(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var ir=class{constructor(e){this.config=e}async getOwnerAddress(e){return xc({aptosConfig:this.config,...e})}async getExpiration(e){return fo({aptosConfig:this.config,...e})}async getTargetAddress(e){return Rc({aptosConfig:this.config,...e})}async setTargetAddress(e){return Uc({aptosConfig:this.config,...e})}async getPrimaryName(e){return Cc({aptosConfig:this.config,...e})}async setPrimaryName(e){return Kc({aptosConfig:this.config,...e})}async registerName(e){return vc({aptosConfig:this.config,...e})}async renewDomain(e){return Oc({aptosConfig:this.config,...e})}async getName(e){return zc({aptosConfig:this.config,...e})}async getAccountNames(e){return kc({aptosConfig:this.config,...e})}async getAccountDomains(e){return Nc({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Dc({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Fc({aptosConfig:this.config,...e})}};async function Bc(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunkHO5ESTN4js.na.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Hi,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 Gc(n){let{aptosConfig:e,options:t}=n,r={query:Hi,variables:{order_by:_optionalChain([t, 'optionalAccess', _253 => _253.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Mc(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:Js,variables:{delegatorAddress:_chunkHO5ESTN4js.na.from(t).toStringLong(),poolAddress:_chunkHO5ESTN4js.na.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var or=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _254 => _254.minimumLedgerVersion]),processorType:"stake_processor"}),Bc({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _255 => _255.minimumLedgerVersion]),processorType:"stake_processor"}),Gc({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await P({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _256 => _256.minimumLedgerVersion]),processorType:"stake_processor"}),Mc({aptosConfig:this.config,...e})}};var ui=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function ho(n,e){if(!(n.getTransactionSubmitter()!==void 0||e.transactionSubmitter!==void 0)&&e.transaction.feePayerAddress&&!e.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator")}function bo(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var xn=class{constructor(e){this.config=e}async simple(e){return ao({aptosConfig:this.config,...e})}async multiAgent(e){return ao({aptosConfig:this.config,...e})}};_chunkHO5ESTN4js.a.call(void 0, [bo],xn.prototype,"simple",1),_chunkHO5ESTN4js.a.call(void 0, [bo],xn.prototype,"multiAgent",1);var di=class{constructor(e){this.config=e}async simple(e){return ho(this.config,e),jn({aptosConfig:this.config,...e})}async multiAgent(e){return ho(this.config,e),jn({aptosConfig:this.config,...e})}};var pi=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 _chunkHO5ESTN4js.sa.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunkHO5ESTN4js.ua.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkHO5ESTN4js.sa.call(void 0, this.sleepTime),_chunkHO5ESTN4js.ua.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await _n({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await _n({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 _chunkHO5ESTN4js.sa.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkHO5ESTN4js.ua.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkHO5ESTN4js.ua.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkHO5ESTN4js.sa.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var vn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _257 => _257.pendingDequeue, 'access', _258 => _258.shift, 'call', _259 => _259(), 'optionalAccess', _260 => _260.resolve, 'call', _261 => _261(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new Cn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Cn=class extends Error{};var Vc="fulfilled",Hc= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Hc||{}),li= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new vn;this.transactionsQueue=new vn;this.outstandingTransactions=new vn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new pi(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=ri({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Cn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Vc?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(t){if(t instanceof Cn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Pn({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===Vc?(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 T({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r,replayProtectionNonce:void 0}})}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 gi=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new li(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 sr=class{constructor(e){this.config=e,this.build=new ui(this.config),this.simulate=new xn(this.config),this.submit=new di(this.config),this.batch=new gi(this.config)}async getTransactions(e){return Wi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ca({aptosConfig:this.config,...e})}async getTransactionByHash(e){return Wn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ua({aptosConfig:this.config,...e})}async waitForTransaction(e){return Pn({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Wr({aptosConfig:this.config})}getSigningMessage(e){return Ia(e)}async publishPackageTransaction(e){return va({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Ma({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return Va({aptosConfig:this.config,...e})}sign(e){return ti({...e})}signAsFeePayer(e){return ni({...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 ri({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return xa({aptosConfig:this.config,...e})}};var ar=class{constructor(e){this.config=e}async getTableItem(e){return qr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),sa({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),aa({aptosConfig:this.config,...e})}};async function yi(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:_chunkHO5ESTN4js.v.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Es({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunkHO5ESTN4js.v.fromHexInput(a.pepper).toUint8Array()}async function To(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await yi(n),uidKey:o="sub",maxExpHorizonSecs:s=(await rn({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunkHO5ESTN4js.v.fromHexInput(i).toUint8Array().length!==Ce.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Ce.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunkHO5ESTN4js.v.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunkHO5ESTN4js.v.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await _s({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),m=d.proof,A=new Pt({a:m.a,b:m.b,c:m.c});return new fe({proof:new nn(A,0),trainingWheelsSignature:Le.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Lc(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await yi(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await rn({aptosConfig:e}),d=To({...n,pepper:s,maxExpHorizonSecs:c}),m=o?d:await d;if(r!==void 0){let g=L.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await Jn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Ve.create({...n,address:b,proof:m,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let A=K.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await Jn({aptosConfig:e,authenticationKey:A.authKey().derivedAddress()});return Ce.create({...n,address:p,proof:m,pepper:s,proofFetchCallback:o,verificationKey:a})}async function qc(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(bs.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let d;throw c instanceof Error?d=`${c.message}`:d=`error unknown - ${c}`,_.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var cr=class{constructor(e){this.config=e}async getPepper(e){return yi({aptosConfig:this.config,...e})}async getProof(e){return To({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Lc({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return qc({aptosConfig:this.config,...e})}};async function lp(n){let{aptosConfig:e,options:t}=n,r={query:Gr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _262 => _262.where]),offset:_optionalChain([t, 'optionalAccess', _263 => _263.offset]),limit:_optionalChain([t, 'optionalAccess', _264 => _264.limit]),order_by:_optionalChain([t, 'optionalAccess', _265 => _265.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function $c(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunkHO5ESTN4js.na.from(t).toStringLong()}};return(await lp({aptosConfig:e,options:{...r,where:o}}))[0]}var ur=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await P({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),$c({aptosConfig:this.config,...e})}};var re=class{constructor(e){this.config=_nullishCoalesce(e, () => (new si)),this.account=new Xn(this.config),this.abstraction=new Xt(this.config),this.ans=new ir(this.config),this.coin=new Yn(this.config),this.digitalAsset=new Zn(this.config),this.faucet=new er(this.config),this.fungibleAsset=new tr(this.config),this.general=new nr(this.config),this.staking=new or(this.config),this.transaction=new sr(this.config),this.table=new ar(this.config),this.keyless=new cr(this.config),this.object=new ur(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function ge(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value:function(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}ge(re,Xn,"account");ge(re,Xt,"abstraction");ge(re,ir,"ans");ge(re,Yn,"coin");ge(re,Zn,"digitalAsset");ge(re,Event,"event");ge(re,er,"faucet");ge(re,tr,"fungibleAsset");ge(re,nr,"general");ge(re,or,"staking");ge(re,sr,"transaction");ge(re,ar,"table");ge(re,cr,"keyless");ge(re,ur,"object");exports.ACCOUNT_ABSTRACTION_SIGNING_DATA_SALT = hs; exports.APTOS_BIP44_REGEX = cu; exports.APTOS_COIN = Rt; exports.APTOS_FA = fs; exports.APTOS_HARDENED_REGEX = au; exports.AbstractKeylessAccount = we; exports.AbstractMultiKey = Oe; exports.AbstractPublicKey = yr; exports.AbstractSignature = Un; exports.AbstractedAccount = Or; exports.Account = gt; exports.AccountAbstractionMessage = xr; exports.AccountAddress = _chunkHO5ESTN4js.na; exports.AccountAuthenticator = ee; exports.AccountAuthenticatorAbstraction = kt; exports.AccountAuthenticatorEd25519 = Ge; exports.AccountAuthenticatorMultiEd25519 = ot; exports.AccountAuthenticatorMultiKey = Je; exports.AccountAuthenticatorNoAccountAuthenticator = pn; exports.AccountAuthenticatorSingleKey = ue; exports.AccountAuthenticatorVariant = _chunkHO5ESTN4js.L; exports.AccountPublicKey = ae; exports.AccountSequenceNumber = pi; exports.AccountUtils = Ns; exports.AddressInvalidReason = _chunkHO5ESTN4js.ma; exports.AnyPublicKey = I; exports.AnyPublicKeyVariant = _chunkHO5ESTN4js.N; exports.AnySignature = B; exports.AnySignatureVariant = _chunkHO5ESTN4js.P; exports.Aptos = re; exports.AptosApiError = Ee; exports.AptosApiType = en; exports.AptosConfig = si; exports.AuthenticationKey = V; exports.Bool = F; exports.CKDPriv = ss; exports.ChainId = ln; exports.DEFAULT_MAX_GAS_AMOUNT = ys; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = ms; exports.DEFAULT_TXN_TIMEOUT_SEC = Ar; exports.DerivableAbstractedAccount = Fs; exports.DeriveScheme = _chunkHO5ESTN4js.la; exports.Deserializer = C; exports.EPK_HORIZON_SECS = Mu; exports.Ed25519Account = oe; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = E; exports.Ed25519Signature = R; exports.EntryFunction = dt; exports.EntryFunctionBytes = gr; exports.EphemeralCertificate = tn; exports.EphemeralCertificateVariant = _chunkHO5ESTN4js.S; exports.EphemeralKeyPair = jt; exports.EphemeralPublicKey = Tt; exports.EphemeralPublicKeyVariant = _chunkHO5ESTN4js.Q; exports.EphemeralSignature = Le; exports.EphemeralSignatureVariant = _chunkHO5ESTN4js.R; exports.FIREBASE_AUTH_ISS_PATTERN = bs; exports.FederatedKeylessAccount = Ve; exports.FederatedKeylessPublicKey = L; exports.FeePayerRawTransaction = qt; exports.FixedBytes = Re; exports.Groth16ProofAndStatement = Ui; exports.Groth16VerificationKey = ki; exports.Groth16Zkp = Pt; exports.HARDENED_OFFSET = rs; exports.Hex = _chunkHO5ESTN4js.v; exports.HexInvalidReason = _chunkHO5ESTN4js.u; exports.I128 = es; exports.I16 = Xo; exports.I256 = ts; exports.I32 = Yo; exports.I64 = Zo; exports.I8 = Jo; exports.Identifier = k; exports.KeyType = uu; exports.KeylessAccount = Ce; exports.KeylessConfiguration = zi; exports.KeylessError = _; exports.KeylessErrorCategory = zu; exports.KeylessErrorResolutionTip = ku; exports.KeylessErrorType = hr; exports.KeylessPublicKey = K; exports.KeylessSignature = ce; exports.MAX_AUD_VAL_BYTES = Ki; exports.MAX_COMMITED_EPK_BYTES = Wu; exports.MAX_EXTRA_FIELD_BYTES = qu; exports.MAX_ISS_VAL_BYTES = Lu; exports.MAX_JWT_HEADER_B64_BYTES = $u; exports.MAX_UID_KEY_BYTES = Vu; exports.MAX_UID_VAL_BYTES = Hu; exports.MimeType = _chunkHO5ESTN4js.C; exports.ModuleId = Gn; exports.MoveAbility = _chunkHO5ESTN4js.ha; exports.MoveFunctionVisibility = _chunkHO5ESTN4js.ga; exports.MoveJWK = Ni; exports.MoveOption = ne; exports.MoveString = v; exports.MoveVector = S; exports.MultiAgentRawTransaction = Lt; exports.MultiAgentTransaction = kr; exports.MultiEd25519Account = qn; exports.MultiEd25519PublicKey = ie; exports.MultiEd25519Signature = Be; exports.MultiKey = W; exports.MultiKeyAccount = yt; exports.MultiKeySignature = Ie; exports.MultiSig = Mn; exports.MultiSigTransactionPayload = Vn; exports.Network = Ei; exports.NetworkToChainId = _i; exports.NetworkToFaucetAPI = gs; exports.NetworkToIndexerAPI = ps; exports.NetworkToNetworkName = lg; exports.NetworkToNodeAPI = ls; exports.NetworkToPepperAPI = Si; exports.NetworkToProverAPI = Pi; exports.ParsingError = _chunkHO5ESTN4js.t; exports.PrivateKey = Pe; exports.PrivateKeyVariants = _chunkHO5ESTN4js.M; exports.ProcessorType = wt; exports.PublicKey = et; exports.RAW_TRANSACTION_SALT = As; exports.RAW_TRANSACTION_WITH_DATA_SALT = Ii; exports.RawTransaction = ve; exports.RawTransactionWithData = Rr; exports.RoleType = _chunkHO5ESTN4js.ia; exports.RotationProofChallenge = Ur; exports.Script = fn; exports.ScriptTransactionArgumentVariants = _chunkHO5ESTN4js.E; exports.Secp256k1PrivateKey = rt; exports.Secp256k1PublicKey = Fe; exports.Secp256k1Signature = it; exports.Secp256r1PrivateKey = Cs; exports.Secp256r1PublicKey = un; exports.Secp256r1Signature = Oi; exports.Serializable = _chunkHO5ESTN4js.x; exports.Serialized = Rn; exports.Serializer = _chunkHO5ESTN4js.y; exports.Signature = O; exports.SignedTransaction = lt; exports.SigningScheme = _chunkHO5ESTN4js.ja; exports.SigningSchemeInput = _chunkHO5ESTN4js.ka; exports.SimpleTransaction = zr; exports.SingleKeyAccount = pe; exports.StructTag = Xe; exports.TransactionAndProof = Dr; exports.TransactionAuthenticator = pt; exports.TransactionAuthenticatorEd25519 = $t; exports.TransactionAuthenticatorFeePayer = Qt; exports.TransactionAuthenticatorMultiAgent = Wt; exports.TransactionAuthenticatorMultiEd25519 = bn; exports.TransactionAuthenticatorSingleSender = It; exports.TransactionAuthenticatorVariant = _chunkHO5ESTN4js.K; exports.TransactionExecutable = An; exports.TransactionExecutableEmpty = Ln; exports.TransactionExecutableEntryFunction = hn; exports.TransactionExecutableScript = Hn; exports.TransactionExecutableVariants = _chunkHO5ESTN4js.H; exports.TransactionExtraConfig = Kr; exports.TransactionExtraConfigV1 = Ht; exports.TransactionExtraConfigVariants = _chunkHO5ESTN4js.I; exports.TransactionInnerPayload = Cr; exports.TransactionInnerPayloadV1 = Vt; exports.TransactionInnerPayloadVariants = _chunkHO5ESTN4js.G; exports.TransactionPayload = _t; exports.TransactionPayloadEntryFunction = yn; exports.TransactionPayloadMultiSig = mn; exports.TransactionPayloadScript = gn; exports.TransactionPayloadVariants = _chunkHO5ESTN4js.F; exports.TransactionResponseType = _chunkHO5ESTN4js.U; exports.TransactionVariants = _chunkHO5ESTN4js.J; exports.TransactionWorker = li; exports.TransactionWorkerEventsEnum = Hc; exports.TypeTag = U; exports.TypeTagAddress = G; exports.TypeTagBool = Q; exports.TypeTagGeneric = M; exports.TypeTagI128 = Bt; exports.TypeTagI16 = Dt; exports.TypeTagI256 = Gt; exports.TypeTagI32 = Ft; exports.TypeTagI64 = Ot; exports.TypeTagI8 = Nt; exports.TypeTagParserError = X; exports.TypeTagParserErrorType = hd; exports.TypeTagReference = vr; exports.TypeTagSigner = Mt; exports.TypeTagStruct = h; exports.TypeTagU128 = ct; exports.TypeTagU16 = st; exports.TypeTagU256 = ut; exports.TypeTagU32 = at; exports.TypeTagU64 = te; exports.TypeTagU8 = de; exports.TypeTagVariants = _chunkHO5ESTN4js.D; exports.TypeTagVector = z; exports.U128 = ke; exports.U16 = Ue; exports.U256 = Se; exports.U32 = ze; exports.U64 = $; exports.U8 = Z; exports.WebAuthnSignature = Bn; exports.ZeroKnowledgeSig = fe; exports.ZkProof = nn; exports.ZkpVariant = _chunkHO5ESTN4js.T; exports.anyPublicKeyVariantToString = _chunkHO5ESTN4js.O; exports.aptosCoinStructTag = KA; exports.aptosRequest = br; exports.base64UrlDecode = _chunkHO5ESTN4js.wa; exports.base64UrlToBytes = _chunkHO5ESTN4js.xa; exports.bigIntToBytesLE = wi; exports.buildTransaction = oo; exports.bytesToBigIntLE = Ct; exports.checkOrConvertArgument = Jt; exports.convertAmountFromHumanReadableToOnChain = _chunkHO5ESTN4js.ya; exports.convertAmountFromOnChainToHumanReadable = _chunkHO5ESTN4js.za; exports.convertArgument = io; exports.convertNumber = jr; exports.convertPayloadToInnerPayload = Cd; exports.createObjectAddress = _chunkHO5ESTN4js.oa; exports.createResourceAddress = _chunkHO5ESTN4js.pa; exports.createTokenAddress = _chunkHO5ESTN4js.ra; exports.createUserDerivedObjectAddress = _chunkHO5ESTN4js.qa; exports.deriveKey = bi; exports.deriveTransactionType = Nr; exports.deserializeFromScriptArgument = rd; exports.deserializePublicKey = Kf; exports.deserializeSignature = Rf; exports.ensureBoolean = _chunkHO5ESTN4js.z; exports.fetchEntryFunctionAbi = Ta; exports.fetchFunctionAbi = ro; exports.fetchJWK = Fi; exports.fetchModuleAbi = Sd; exports.fetchMoveFunctionAbi = IS; exports.fetchViewFunctionAbi = wa; exports.findFirstNonSignerArg = ba; exports.floorToWholeHour = _chunkHO5ESTN4js.va; exports.generateRawTransaction = vd; exports.generateSignedTransaction = so; exports.generateSignedTransactionForSimulation = Pa; exports.generateSigningMessage = Qe; exports.generateSigningMessageForSerializable = Lh; exports.generateSigningMessageForTransaction = Me; exports.generateTransactionPayload = ei; exports.generateTransactionPayloadWithABI = _d; exports.generateUserTransactionHash = ZS; exports.generateViewFunctionPayload = Sa; exports.generateViewFunctionPayloadWithABI = Id; exports.get = Tr; exports.getAptosFullNode = H; exports.getAptosPepperService = Bg; exports.getAuthenticatorForSimulation = En; exports.getErrorMessage = _chunkHO5ESTN4js.ta; exports.getFunctionParts = _chunkHO5ESTN4js.Ca; exports.getIssAudAndUidVal = nt; exports.getKeylessConfig = rn; exports.getKeylessJWKs = Xu; exports.getPageWithObfuscatedCursor = Sr; exports.hashStrToField = qe; exports.hashValues = Ea; exports.hexToAsciiString = _chunkHO5ESTN4js.w; exports.isBcsAddress = Xr; exports.isBcsBool = Qi; exports.isBcsFixedBytes = Td; exports.isBcsString = ji; exports.isBcsU128 = eo; exports.isBcsU16 = Xi; exports.isBcsU256 = to; exports.isBcsU32 = Yi; exports.isBcsU64 = Zi; exports.isBcsU8 = Ji; exports.isBlockEpilogueTransactionResponse = _chunkHO5ESTN4js.$; exports.isBlockMetadataTransactionResponse = _chunkHO5ESTN4js.Y; exports.isBool = ma; exports.isCanonicalEd25519Signature = nd; exports.isEd25519Signature = _chunkHO5ESTN4js.aa; exports.isEmptyOption = fa; exports.isEncodedEntryFunctionArgument = Aa; exports.isEncodedStruct = _chunkHO5ESTN4js.Ba; exports.isFeePayerSignature = _chunkHO5ESTN4js.da; exports.isGenesisTransactionResponse = _chunkHO5ESTN4js.X; exports.isKeylessSigner = Fr; exports.isLargeNumber = Jr; exports.isMultiAgentSignature = _chunkHO5ESTN4js.ca; exports.isMultiEd25519Signature = _chunkHO5ESTN4js.ea; exports.isNumber = bd; exports.isPendingTransactionResponse = _chunkHO5ESTN4js.V; exports.isScriptDataInput = ha; exports.isSecp256k1Signature = _chunkHO5ESTN4js.ba; exports.isSingleKeySigner = Mi; exports.isSingleSenderSignature = _chunkHO5ESTN4js.fa; exports.isStateCheckpointTransactionResponse = _chunkHO5ESTN4js.Z; exports.isString = mt; exports.isUserTransactionResponse = _chunkHO5ESTN4js.W; exports.isValidBIP44Path = is; exports.isValidFunctionInfo = _chunkHO5ESTN4js.Da; exports.isValidHardenedPath = os; exports.isValidatorTransactionResponse = _chunkHO5ESTN4js._; exports.mnemonicToSeed = mr; exports.normalizeBundle = Ts; exports.nowInSeconds = _chunkHO5ESTN4js.ua; exports.objectStructTag = Te; exports.optionStructTag = RA; exports.outOfRangeErrorMessage = _chunkHO5ESTN4js.A; exports.padAndPackBytesWithLen = kn; exports.paginateWithCursor = wr; exports.paginateWithObfuscatedCursor = vi; exports.pairedFaMetadataAddress = _chunkHO5ESTN4js.Fa; exports.parseEncodedStruct = _chunkHO5ESTN4js.Aa; exports.parseJwtHeader = Zu; exports.parseTypeTag = He; exports.poseidonHash = Kt; exports.post = Nn; exports.postAptosFaucet = Ps; exports.postAptosFullNode = St; exports.postAptosIndexer = Ss; exports.postAptosPepperService = Es; exports.postAptosProvingService = _s; exports.promiseFulfilledStatus = Vc; exports.request = Fu; exports.sleep = _chunkHO5ESTN4js.sa; exports.splitPath = as; exports.standardizeTypeTags = Yr; exports.stringStructTag = x; exports.throwTypeMismatch = N; exports.truncateAddress = _chunkHO5ESTN4js.Ea; exports.validateNumberInRange = _chunkHO5ESTN4js.B; exports.verifyKeylessSignature = Di; exports.verifyKeylessSignatureWithJwkAndConfig = Pr;
|
|
482
482
|
//# sourceMappingURL=index.js.map
|