@aptos-labs/ts-sdk 6.0.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/{account-Dpz_N9h-.d.ts → account-CSOaJ0SC.d.ts} +182 -19
- package/dist/common/chunk-3NBJLJ2Y.js +4 -0
- package/dist/common/chunk-3NBJLJ2Y.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 +69 -6
- package/dist/common/index.js +33 -44
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-BW_kXHC2.d.mts → Ed25519Account-BCt2cu_M.d.mts} +2 -2
- 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 +26 -2
- 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-CcxnCdYZ.d.mts → account-Dg0ejXHy.d.mts} +172 -8
- 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 +1 -1
- 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/aptosConfig.mjs +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/helpers.mjs +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/sign.mjs.map +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 +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-32J7VMLV.mjs +2 -0
- package/dist/esm/chunk-32J7VMLV.mjs.map +1 -0
- package/dist/esm/chunk-3FDSKP56.mjs +2 -0
- package/dist/esm/chunk-3FDSKP56.mjs.map +1 -0
- package/dist/esm/{chunk-X674XJNJ.mjs → chunk-3Q3J4DTI.mjs} +2 -2
- package/dist/esm/chunk-7FG7RJDS.mjs +2 -0
- package/dist/esm/chunk-7FG7RJDS.mjs.map +1 -0
- package/dist/esm/chunk-BHVMFSAD.mjs +2 -0
- package/dist/esm/chunk-BHVMFSAD.mjs.map +1 -0
- package/dist/esm/chunk-CWI5B5KE.mjs +2 -0
- package/dist/esm/{chunk-QDJDZ3ON.mjs → chunk-DE4YVX3L.mjs} +2 -2
- package/dist/esm/chunk-DECWO3X5.mjs +2 -0
- package/dist/esm/chunk-DECWO3X5.mjs.map +1 -0
- package/dist/esm/{chunk-76SVQZDX.mjs → chunk-DRGODFFX.mjs} +2 -2
- package/dist/esm/{chunk-GOXRBEIJ.mjs → chunk-F45HI7LU.mjs} +1 -1
- package/dist/esm/chunk-F45HI7LU.mjs.map +1 -0
- package/dist/esm/{chunk-LS2HRAVW.mjs → chunk-G5OONGWS.mjs} +1 -12
- package/dist/esm/chunk-G5OONGWS.mjs.map +1 -0
- package/dist/esm/chunk-GP3CDQFI.mjs +2 -0
- package/dist/esm/chunk-GP3CDQFI.mjs.map +1 -0
- package/dist/esm/chunk-GWM3VCT4.mjs +4 -0
- package/dist/esm/chunk-GWM3VCT4.mjs.map +1 -0
- package/dist/esm/{chunk-C5UZZHA4.mjs → chunk-HHAUJ5E4.mjs} +2 -2
- package/dist/esm/chunk-ITZN23GU.mjs +2 -0
- package/dist/esm/{chunk-G3HAIETV.mjs → chunk-KLDERTLN.mjs} +2 -2
- package/dist/esm/chunk-KLDERTLN.mjs.map +1 -0
- package/dist/esm/chunk-M65PXVDO.mjs +2 -0
- package/dist/esm/chunk-M65PXVDO.mjs.map +1 -0
- package/dist/esm/chunk-ODNZJSOC.mjs +2 -0
- package/dist/esm/chunk-ODNZJSOC.mjs.map +1 -0
- package/dist/esm/{chunk-NTLOKAPD.mjs → chunk-PDNDARQY.mjs} +2 -2
- package/dist/esm/{chunk-RYOICF37.mjs → chunk-POKQD2RK.mjs} +2 -2
- package/dist/esm/chunk-Q5ESW36C.mjs +2 -0
- package/dist/esm/chunk-Q5ESW36C.mjs.map +1 -0
- package/dist/esm/chunk-QRD5NGNC.mjs +2 -0
- package/dist/esm/{chunk-RQN6LA7E.mjs.map → chunk-QRD5NGNC.mjs.map} +1 -1
- package/dist/esm/{chunk-43LWUUXS.mjs → chunk-QV37KEZY.mjs} +2 -2
- package/dist/esm/{chunk-PXJEKGEG.mjs → chunk-QYC3HOQX.mjs} +2 -2
- package/dist/esm/{chunk-CUXCVNES.mjs → chunk-RGXAFBFA.mjs} +2 -2
- package/dist/esm/{chunk-3P474TWM.mjs → chunk-RSUFVB4P.mjs} +2 -2
- package/dist/esm/chunk-SZBXWUBS.mjs +2 -0
- package/dist/esm/chunk-SZBXWUBS.mjs.map +1 -0
- package/dist/esm/{chunk-F3NI6N7R.mjs → chunk-TIMTVXFU.mjs} +2 -2
- package/dist/esm/chunk-TIMTVXFU.mjs.map +1 -0
- package/dist/esm/{chunk-QREVMGQZ.mjs → chunk-U5HTF4OK.mjs} +1 -1
- package/dist/esm/{chunk-QREVMGQZ.mjs.map → chunk-U5HTF4OK.mjs.map} +1 -1
- package/dist/esm/{chunk-6IWGTO2J.mjs → chunk-UNA3V4UB.mjs} +2 -2
- package/dist/esm/chunk-US6KOOYS.mjs +2 -0
- package/dist/esm/chunk-US6KOOYS.mjs.map +1 -0
- package/dist/esm/chunk-UXDYADZV.mjs +2 -0
- package/dist/esm/chunk-UXDYADZV.mjs.map +1 -0
- package/dist/esm/{chunk-5FNZUL2Y.mjs → chunk-UZMJ4DAO.mjs} +2 -2
- package/dist/esm/chunk-V5K2RRFT.mjs +2 -0
- package/dist/esm/chunk-V5K2RRFT.mjs.map +1 -0
- package/dist/esm/{chunk-35DKMW7Q.mjs → chunk-VW3Y5EOJ.mjs} +1 -1
- package/dist/esm/{chunk-35DKMW7Q.mjs.map → chunk-VW3Y5EOJ.mjs.map} +1 -1
- package/dist/esm/{chunk-MEG27LEV.mjs → chunk-VWLK43JM.mjs} +3 -3
- package/dist/esm/chunk-VWLK43JM.mjs.map +1 -0
- package/dist/esm/{chunk-DIFSO4N6.mjs → chunk-VWXVSRRQ.mjs} +2 -2
- package/dist/esm/{chunk-WZ6FL7CH.mjs → chunk-WRV7BWXE.mjs} +2 -2
- package/dist/esm/{chunk-56IXVVXX.mjs → chunk-YMZF4KMT.mjs} +2 -2
- package/dist/esm/{chunk-FW6UHAQV.mjs → chunk-YNNDFGVQ.mjs} +2 -2
- package/dist/esm/{chunk-FW6UHAQV.mjs.map → chunk-YNNDFGVQ.mjs.map} +1 -1
- package/dist/esm/{chunk-52PWWLJJ.mjs → chunk-YOT47DDX.mjs} +2 -2
- package/dist/esm/chunk-YOT47DDX.mjs.map +1 -0
- 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/cli/move.mjs +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/poseidon.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-BzaYmP03.d.mts → federatedKeyless-BYLu31Sa.d.mts} +13 -2
- package/dist/esm/index.d.mts +5 -5
- 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 +3 -3
- 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 +3 -3
- 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 +4 -4
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.d.mts +4 -2
- 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 +2 -2
- 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 +12 -4
- 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 +2 -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 +1 -1
- 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/generated/operations.d.mts +0 -11
- package/dist/esm/types/generated/queries.d.mts +1 -1
- package/dist/esm/types/generated/queries.mjs +1 -1
- package/dist/esm/types/index.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/indexer.d.mts +1 -1
- package/dist/esm/types/types.d.mts +1 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/const.d.mts +11 -1
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +21 -2
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +3 -3
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/memoize.d.mts +23 -1
- package/dist/esm/utils/memoize.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 +38 -45
- package/src/account/AbstractKeylessAccount.ts +2 -3
- package/src/account/DerivableAbstractedAccount.ts +1 -3
- package/src/account/EphemeralKeyPair.ts +53 -1
- package/src/account/MultiEd25519Account.ts +0 -2
- package/src/account/MultiKeyAccount.ts +0 -2
- package/src/account/SingleKeyAccount.ts +0 -1
- package/src/api/account.ts +1 -2
- package/src/api/ans.ts +0 -1
- package/src/api/aptos.ts +3 -2
- package/src/api/aptosConfig.ts +13 -0
- package/src/api/transaction.ts +4 -4
- package/src/api/transactionSubmission/build.ts +1 -5
- package/src/api/transactionSubmission/helpers.ts +1 -1
- package/src/api/transactionSubmission/sign.ts +2 -2
- package/src/bcs/deserializer.ts +64 -17
- package/src/bcs/serializable/movePrimitives.ts +16 -28
- package/src/bcs/serializable/moveStructs.ts +4 -6
- package/src/bcs/serializer.ts +151 -12
- package/src/cli/localNode.ts +2 -3
- package/src/cli/move.ts +5 -5
- package/src/client/get.ts +8 -10
- package/src/core/accountAddress.ts +2 -3
- package/src/core/crypto/abstraction.ts +3 -3
- package/src/core/crypto/ed25519.ts +66 -1
- package/src/core/crypto/federatedKeyless.ts +1 -1
- package/src/core/crypto/keyless.ts +65 -13
- package/src/core/crypto/multiEd25519.ts +1 -3
- package/src/core/crypto/multiKey.ts +4 -7
- package/src/core/crypto/poseidon.ts +0 -1
- package/src/core/crypto/privateKey.ts +2 -4
- package/src/core/crypto/secp256k1.ts +68 -3
- package/src/core/crypto/secp256r1.ts +1 -1
- package/src/core/crypto/singleKey.ts +4 -0
- package/src/core/crypto/utils.ts +6 -3
- package/src/errors/index.ts +4 -5
- package/src/internal/account.ts +20 -29
- package/src/internal/ans.ts +5 -6
- package/src/internal/general.ts +24 -6
- package/src/internal/queries/getCollectionData.graphql +0 -11
- package/src/internal/transaction.ts +3 -5
- package/src/internal/transactionSubmission.ts +23 -0
- package/src/transactions/authenticator/account.ts +0 -3
- package/src/transactions/authenticator/transaction.ts +0 -2
- package/src/transactions/instances/multiAgentTransaction.ts +0 -2
- package/src/transactions/instances/rawTransaction.ts +0 -2
- package/src/transactions/instances/signedTransaction.ts +0 -2
- package/src/transactions/instances/simpleTransaction.ts +0 -2
- package/src/transactions/instances/transactionPayload.ts +7 -6
- package/src/transactions/management/accountSequenceNumber.ts +0 -2
- package/src/transactions/management/transactionWorker.ts +40 -10
- package/src/transactions/transactionBuilder/remoteAbi.ts +21 -6
- package/src/transactions/transactionBuilder/transactionBuilder.ts +13 -9
- package/src/transactions/typeTag/index.ts +1 -1
- package/src/transactions/typeTag/parser.ts +1 -2
- package/src/types/generated/operations.ts +0 -11
- package/src/types/generated/queries.ts +0 -11
- package/src/types/types.ts +26 -0
- package/src/utils/const.ts +11 -0
- package/src/utils/helpers.ts +45 -5
- package/src/utils/memoize.ts +177 -11
- package/src/version.ts +1 -1
- package/dist/common/chunk-4RHBBU7C.js +0 -4
- package/dist/common/chunk-4RHBBU7C.js.map +0 -1
- package/dist/esm/chunk-2DPQMXUG.mjs +0 -4
- package/dist/esm/chunk-2DPQMXUG.mjs.map +0 -1
- package/dist/esm/chunk-2LCPW76G.mjs +0 -2
- package/dist/esm/chunk-2LCPW76G.mjs.map +0 -1
- package/dist/esm/chunk-2PASUPUO.mjs +0 -2
- package/dist/esm/chunk-2PASUPUO.mjs.map +0 -1
- package/dist/esm/chunk-52PWWLJJ.mjs.map +0 -1
- package/dist/esm/chunk-54C2P534.mjs +0 -2
- package/dist/esm/chunk-54C2P534.mjs.map +0 -1
- package/dist/esm/chunk-BGZDJ5SM.mjs +0 -2
- package/dist/esm/chunk-BGZDJ5SM.mjs.map +0 -1
- package/dist/esm/chunk-F3NI6N7R.mjs.map +0 -1
- package/dist/esm/chunk-G3HAIETV.mjs.map +0 -1
- package/dist/esm/chunk-GOXRBEIJ.mjs.map +0 -1
- package/dist/esm/chunk-I42Z32Q2.mjs +0 -2
- package/dist/esm/chunk-I42Z32Q2.mjs.map +0 -1
- package/dist/esm/chunk-JN65XG2P.mjs +0 -2
- package/dist/esm/chunk-JN65XG2P.mjs.map +0 -1
- package/dist/esm/chunk-KUF4DKN5.mjs +0 -2
- package/dist/esm/chunk-LD3I4CYO.mjs +0 -2
- package/dist/esm/chunk-LS2HRAVW.mjs.map +0 -1
- package/dist/esm/chunk-MEG27LEV.mjs.map +0 -1
- package/dist/esm/chunk-NCKJ7X57.mjs +0 -2
- package/dist/esm/chunk-NCKJ7X57.mjs.map +0 -1
- package/dist/esm/chunk-NK3Y3PV3.mjs +0 -2
- package/dist/esm/chunk-NK3Y3PV3.mjs.map +0 -1
- package/dist/esm/chunk-OLILO7VD.mjs +0 -2
- package/dist/esm/chunk-OLILO7VD.mjs.map +0 -1
- package/dist/esm/chunk-PYVKCTUN.mjs +0 -2
- package/dist/esm/chunk-PYVKCTUN.mjs.map +0 -1
- package/dist/esm/chunk-QEHKRR3I.mjs +0 -2
- package/dist/esm/chunk-QEHKRR3I.mjs.map +0 -1
- package/dist/esm/chunk-RQN6LA7E.mjs +0 -2
- package/dist/esm/chunk-Y426VCPM.mjs +0 -2
- package/dist/esm/chunk-Y426VCPM.mjs.map +0 -1
- package/dist/esm/chunk-YOZBVVKL.mjs +0 -2
- package/dist/esm/chunk-YOZBVVKL.mjs.map +0 -1
- /package/dist/esm/{chunk-X674XJNJ.mjs.map → chunk-3Q3J4DTI.mjs.map} +0 -0
- /package/dist/esm/{chunk-KUF4DKN5.mjs.map → chunk-CWI5B5KE.mjs.map} +0 -0
- /package/dist/esm/{chunk-QDJDZ3ON.mjs.map → chunk-DE4YVX3L.mjs.map} +0 -0
- /package/dist/esm/{chunk-76SVQZDX.mjs.map → chunk-DRGODFFX.mjs.map} +0 -0
- /package/dist/esm/{chunk-C5UZZHA4.mjs.map → chunk-HHAUJ5E4.mjs.map} +0 -0
- /package/dist/esm/{chunk-LD3I4CYO.mjs.map → chunk-ITZN23GU.mjs.map} +0 -0
- /package/dist/esm/{chunk-NTLOKAPD.mjs.map → chunk-PDNDARQY.mjs.map} +0 -0
- /package/dist/esm/{chunk-RYOICF37.mjs.map → chunk-POKQD2RK.mjs.map} +0 -0
- /package/dist/esm/{chunk-43LWUUXS.mjs.map → chunk-QV37KEZY.mjs.map} +0 -0
- /package/dist/esm/{chunk-PXJEKGEG.mjs.map → chunk-QYC3HOQX.mjs.map} +0 -0
- /package/dist/esm/{chunk-CUXCVNES.mjs.map → chunk-RGXAFBFA.mjs.map} +0 -0
- /package/dist/esm/{chunk-3P474TWM.mjs.map → chunk-RSUFVB4P.mjs.map} +0 -0
- /package/dist/esm/{chunk-6IWGTO2J.mjs.map → chunk-UNA3V4UB.mjs.map} +0 -0
- /package/dist/esm/{chunk-5FNZUL2Y.mjs.map → chunk-UZMJ4DAO.mjs.map} +0 -0
- /package/dist/esm/{chunk-DIFSO4N6.mjs.map → chunk-VWXVSRRQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-WZ6FL7CH.mjs.map → chunk-WRV7BWXE.mjs.map} +0 -0
- /package/dist/esm/{chunk-56IXVVXX.mjs.map → chunk-YMZF4KMT.mjs.map} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as To}from"./chunk-YMZF4KMT.mjs";import{a as or,b as Xr}from"./chunk-A5L76YP7.mjs";import{a as er}from"./chunk-UNA3V4UB.mjs";import{a as z}from"./chunk-RSUFVB4P.mjs";import{a as Wr,c as jr}from"./chunk-SZBXWUBS.mjs";import{a as rr,b as Go}from"./chunk-PDNDARQY.mjs";import{a as De,b as Xn,c as Jt,d as Gr,e as Zt}from"./chunk-F45HI7LU.mjs";import{a as Qt}from"./chunk-US6KOOYS.mjs";import{a as co}from"./chunk-CWI5B5KE.mjs";import{a as Mr,b as Ji}from"./chunk-YOT47DDX.mjs";import{a as J}from"./chunk-DE4YVX3L.mjs";import{a as Qn,b as Fe}from"./chunk-UZMJ4DAO.mjs";import{d as Zi,e as Yi,f as Xi,g as eo,h as to,i as no,j as Jn}from"./chunk-C3Q23D22.mjs";import{a as Zr,b as Yr}from"./chunk-U5HTF4OK.mjs";import{a as ne}from"./chunk-POKQD2RK.mjs";import{a as ei}from"./chunk-QYC3HOQX.mjs";import{a as Vo}from"./chunk-RGXAFBFA.mjs";import{a as S}from"./chunk-3Q3J4DTI.mjs";import{a as Ho,b as ir,c as Lo,d as $o,e as qo,g as Xt,h as Wo,k as jo,l as Qo}from"./chunk-TIMTVXFU.mjs";import{a as nr,b as Oo,c as x,e as Bo,f as Mo}from"./chunk-3FDSKP56.mjs";import{A as No,B as Jr,C as Ro,d as So,e as Po,f as xo,g as Ko,h as Io,j as Eo,k as Co,l as vo,m as _o,o as Uo,p as ko,q as Fo,s as Do,t as zo,u as Yt,v as Qr,w as tr}from"./chunk-G5OONGWS.mjs";import{a as $e}from"./chunk-ODNZJSOC.mjs";import{b as yt,d as Ao,e as $r,f as qr}from"./chunk-DECWO3X5.mjs";import{b as Tt,d as ho,e as bo,f as wo}from"./chunk-WRV7BWXE.mjs";import{a as mo}from"./chunk-ITZN23GU.mjs";import{d as w,e as fo}from"./chunk-KLDERTLN.mjs";import{a as K,b as Qi,c as D,d as B}from"./chunk-UXDYADZV.mjs";import{a as H,b as Pe,c as Ot,d as Bt,e as Ae,f as Mt,g as Gt,h as Vt,i as Ht,j as Lt,k as $t,l as qt,m as Wt}from"./chunk-32J7VMLV.mjs";import{a as Wi}from"./chunk-QV37KEZY.mjs";import{a as Rt}from"./chunk-VWXVSRRQ.mjs";import{a as F}from"./chunk-M65PXVDO.mjs";import{a as Jo}from"./chunk-GP3CDQFI.mjs";import{g as Vr}from"./chunk-P5HCJN3A.mjs";import{c as Hr,e as uo,f as Le,g as po,h as lo,i as Lr,j as go,l as yo}from"./chunk-BHVMFSAD.mjs";import{b as Yn,c as Pn,e as He,f as ro,g as io,h as oo,k as so,l as ao,m as ce,n as jt}from"./chunk-7FG7RJDS.mjs";import{a as Zn}from"./chunk-HHAUJ5E4.mjs";import{b as u}from"./chunk-VWLK43JM.mjs";import{J as Q,m as ji}from"./chunk-Q5ESW36C.mjs";import{a as T,b as te}from"./chunk-V5K2RRFT.mjs";import{b as m,c as qi}from"./chunk-STY74NUA.mjs";import{d as $i}from"./chunk-X2TPNKLV.mjs";import{a as Br}from"./chunk-KDMSOCZY.mjs";import{ed25519 as Or}from"@noble/curves/ed25519";import{jwtDecode as La}from"jwt-decode";import{sha3_256 as su}from"@noble/hashes/sha3";import{bn254 as ke}from"@noble/curves/bn254";import{bytesToNumberBE as au}from"@noble/curves/abstract/utils";import{encode as cu}from"js-base64";import{sha3_256 as Zo}from"@noble/hashes/sha3";import{secp256k1 as xn}from"@noble/curves/secp256k1";import{HDKey as qa}from"@scure/bip32";var xe=class xe extends Qn{constructor(t){super();this.keyType="secp256k1";let r=m.fromHexInput(t),{length:i}=r.toUint8Array();if(i===xe.LENGTH)this.key=r;else if(i===xe.COMPRESSED_LENGTH){let o=xn.ProjectivePoint.fromHex(r.toUint8Array());this.key=m.fromHexInput(o.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${xe.LENGTH} or ${xe.COMPRESSED_LENGTH}, received ${i}`)}verifySignature(t){let{message:r,signature:i}=t,o=tn(r),s=m.fromHexInput(o).toUint8Array(),a=Zo(s),c=i.toUint8Array();return xn.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 We(r)}static deserialize(t){let r=t.deserializeBytes();return new xe(r)}static isPublicKey(t){return t instanceof xe}static isInstance(t){return"key"in t&&t.key?.data?.length===xe.LENGTH&&"keyType"in t&&t.keyType==="secp256k1"}};xe.LENGTH=65,xe.COMPRESSED_LENGTH=33;var Ke=xe,ze=class ze extends T{constructor(t,r){super();this.cleared=!1;let i=Qt.parseHexInput(t,"secp256k1",r);if(i.toUint8Array().length!==ze.LENGTH)throw new Error(`PrivateKey length should be ${ze.LENGTH}`);this.key=i}static generate(){let t=xn.utils.randomPrivateKey();return new ze(t,!1)}static fromDerivationPath(t,r){if(!Yi(t))throw new Error(`Invalid derivation path ${t}`);return ze.fromDerivationPathInner(t,Jn(r))}static fromDerivationPathInner(t,r){let{privateKey:i}=qa.fromMasterSeed(r).derive(t);if(i===null)throw new Error("Invalid key");return new ze(i,!1)}ensureNotCleared(){if(this.cleared)throw new Error("Private key has been cleared from memory and can no longer be used")}clear(){if(!this.cleared){let t=this.key.toUint8Array();crypto.getRandomValues(t),t.fill(255),crypto.getRandomValues(t),t.fill(0),this.cleared=!0}}isCleared(){return this.cleared}sign(t){this.ensureNotCleared();let r=tn(t),i=m.fromHexInput(r),o=Zo(i.toUint8Array()),s=xn.sign(o,this.key.toUint8Array(),{lowS:!0});return new We(s.toCompactRawBytes())}publicKey(){this.ensureNotCleared();let t=xn.getPublicKey(this.key.toUint8Array(),!1);return new Ke(t)}toUint8Array(){return this.ensureNotCleared(),this.key.toUint8Array()}toString(){return this.ensureNotCleared(),this.toAIP80String()}toHexString(){return this.ensureNotCleared(),this.key.toString()}toAIP80String(){return this.ensureNotCleared(),Qt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new ze(r,!1)}static isPrivateKey(t){return t instanceof ze}};ze.LENGTH=32;var qe=ze,en=class en extends J{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==en.LENGTH)throw new Error(`Signature length should be ${en.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 en(t)}};en.LENGTH=64;var We=en;var I=class n extends Fe{constructor(e){if(super(),this.publicKey=e,e instanceof b)this.variant=0;else if(e instanceof Ke)this.variant=1;else if(e instanceof Wr)this.variant=2;else if(e instanceof C)this.variant=3;else if(e instanceof M)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof C)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 N)){if(e.options?.throwErrorWithReason)throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return ne.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=b.deserialize(e);break;case 1:r=Ke.deserialize(e);break;case 2:r=Wr.deserialize(e);break;case 3:r=C.deserialize(e);break;case 4:r=M.deserialize(e);break;case 5:throw new Error("SlhDsaSha2_128s public key deserialization is not yet implemented");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 b}isSecp256k1PublicKey(){return this.publicKey instanceof Ke}static isInstance(e){return"publicKey"in e&&"variant"in e}},N=class n extends J{constructor(e){if(super(),this.signature=e,e instanceof v)this.variant=0;else if(e instanceof We)this.variant=1;else if(e instanceof jr)this.variant=2;else if(e instanceof re)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=v.deserialize(e);break;case 1:r=We.deserialize(e);break;case 2:r=jr.deserialize(e);break;case 3:r=re.deserialize(e);break;case 4:throw new Error("SlhDsaSha2_128s signature deserialization is not yet implemented");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 Wa(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var ar=3,Ie=class extends Fe{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}`)}},G=class n extends Ie{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>ar&&this.publicKeys.filter(o=>o.variant===3||o.variant===4).length>ar)throw new Error(`Construction of MultiKey with more than ${ar} keyless public keys is not allowed when signaturesRequired
|
|
2
|
+
is greater than ${ar}. This is because a maximum of 3 keyless signatures are supported for a
|
|
3
|
+
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 he))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(e.options?.throwErrorWithReason)throw r;return!1}}authKey(){return ne.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}},ue=class ue extends J{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>ue.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${ue.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof N?o:new N(o)),!(r instanceof Uint8Array))this.bitmap=ue.createBitmap({bits:r});else{if(r.length!==ue.BITMAP_LEN)throw new Error(`"bitmap" length should be ${ue.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+Wa(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>=ue.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${ue.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=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(N),r=e.deserializeBytes();return new ue({signatures:t,bitmap:r})}};ue.BITMAP_LEN=4,ue.MAX_SIGNATURES_SUPPORTED=ue.BITMAP_LEN*8;var he=ue;var de=class de extends Ie{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>de.MAX_KEYS||t.length<de.MIN_KEYS)throw new Error(`Must have between ${de.MIN_KEYS} and ${de.MAX_KEYS} public keys, inclusive`);if(r<de.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${de.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}getSignaturesRequired(){return this.threshold}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Ee))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 ne.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*b.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*b.LENGTH)}),e[this.publicKeys.length*b.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+=b.LENGTH){let s=o;i.push(new b(t.subarray(s,s+b.LENGTH)))}return new de({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+=b.LENGTH){let a=s;o.push(new b(r.subarray(a,a+b.LENGTH)))}return new de({publicKeys:o,threshold:i})}getIndex(e){return super.getIndex(e)}};de.MAX_KEYS=32,de.MIN_KEYS=2,de.MIN_THRESHOLD=1;var Z=de,pe=class pe extends J{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${pe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=pe.createBitmap({bits:r});else{if(r.length!==pe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${pe.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*v.LENGTH+pe.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*v.LENGTH)}),e.set(this.bitmap,this.signatures.length*v.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+=v.LENGTH){let s=o;i.push(new v(t.subarray(s,s+v.LENGTH)))}return new pe({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>=pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${pe.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}};pe.MAX_SIGNATURES_SUPPORTED=32,pe.BITMAP_LEN=4;var Ee=pe;var cr="Multiple possible deserializations found";function Id(n){let e=[b,I,Z,G,C,M,Ke],t;for(let r of e)try{let i=F.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${cr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(cr))throw i}if(!t)throw new Error(`Failed to deserialize public key: ${n}`);return t}function Ed(n){let e=[v,N,Ee,he,re,We],t;for(let r of e)try{let i=F.fromHex(n),o=r.deserialize(i);if(i.assertFinished(),t)throw new Error(`${cr}: ${n}`);t=o}catch(i){if(i instanceof Error&&i.message.includes(cr))throw i}if(!t)throw new Error(`Failed to deserialize signature: ${n}`);return t}var W=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ce.load(e);case 1:return je.load(e);case 2:return ie.load(e);case 3:return Ne.load(e);case 4:return nn.load(e);case 5:return St.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ce}isMultiEd25519(){return this instanceof je}isSingleKey(){return this instanceof ie}isMultiKey(){return this instanceof Ne}},Ce=class n extends W{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=b.deserialize(e),r=v.deserialize(e);return new n(t,r)}},je=class n extends W{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=Z.deserialize(e),r=Ee.deserialize(e);return new n(t,r)}},ie=class n extends W{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=N.deserialize(e);return new n(t,r)}},Ne=class n extends W{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=G.deserialize(e),r=he.deserialize(e);return new n(t,r)}},nn=class n extends W{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},St=class n extends W{constructor(e,t,r,i){if(super(),!jt(e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.abstractionSignature=r,this.signingMessageDigest=m.fromHexInput(m.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=ce(this.functionInfo);u.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=u.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}`)}},ur=class n extends T{constructor(e,t){super(),this.originalSigningMessage=m.fromHexInput(m.fromHexInput(e).toUint8Array()),this.functionInfo=t}serialize(e){e.serializeU32AsUleb128(0),e.serializeBytes(this.originalSigningMessage.toUint8Array());let{moduleAddress:t,moduleName:r,functionName:i}=ce(this.functionInfo);u.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=u.deserialize(e),o=e.deserializeStr(),s=e.deserializeStr(),a=`${i}::${o}::${s}`;return new n(r,a)}};import{sha3_256 as Qa}from"@noble/hashes/sha3";var Kn=class n extends T{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(u.fromString(t[0]),new z(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=z.deserialize(e);return new n(t,r)}};var _=class n extends T{deserialize(e){let t=u.deserialize(e),r=z.deserialize(e),i=z.deserialize(e),o=e.deserializeVector(n);return new Re(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return V.load(e);case 1:return oe.load(e);case 2:return j.load(e);case 3:return tt.load(e);case 4:return R.load(e);case 5:return Pt.load(e);case 6:return U.load(e);case 7:return f.load(e);case 8:return Je.load(e);case 9:return Ye.load(e);case 10:return rt.load(e);case 11:return Qe.load(e);case 12:return Ze.load(e);case 13:return Xe.load(e);case 14:return et.load(e);case 15:return nt.load(e);case 16:return it.load(e);case 255:return O.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof V}isAddress(){return this instanceof R}isGeneric(){return this instanceof O}isSigner(){return this instanceof Pt}isVector(){return this instanceof U}isStruct(){return this instanceof f}isU8(){return this instanceof oe}isU16(){return this instanceof Je}isU32(){return this instanceof Ye}isU64(){return this instanceof j}isU128(){return this instanceof tt}isU256(){return this instanceof rt}isI8(){return this instanceof Qe}isI16(){return this instanceof Ze}isI32(){return this instanceof Xe}isI64(){return this instanceof et}isI128(){return this instanceof nt}isI256(){return this instanceof it}isPrimitive(){return this instanceof Pt||this instanceof R||this instanceof V||this instanceof oe||this instanceof Je||this instanceof Ye||this instanceof j||this instanceof tt||this instanceof rt||this instanceof Qe||this instanceof Ze||this instanceof Xe||this instanceof et||this instanceof nt||this instanceof it}},V=class n extends _{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},oe=class n extends _{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Qe=class n extends _{toString(){return"i8"}serialize(e){e.serializeU32AsUleb128(11)}static load(e){return new n}},Je=class n extends _{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Ze=class n extends _{toString(){return"i16"}serialize(e){e.serializeU32AsUleb128(12)}static load(e){return new n}},Ye=class n extends _{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},Xe=class n extends _{toString(){return"i32"}serialize(e){e.serializeU32AsUleb128(13)}static load(e){return new n}},j=class n extends _{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},et=class n extends _{toString(){return"i64"}serialize(e){e.serializeU32AsUleb128(14)}static load(e){return new n}},tt=class n extends _{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},nt=class n extends _{toString(){return"i128"}serialize(e){e.serializeU32AsUleb128(15)}static load(e){return new n}},rt=class n extends _{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},it=class n extends _{toString(){return"i256"}serialize(e){e.serializeU32AsUleb128(16)}static load(e){return new n}},R=class n extends _{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Pt=class n extends _{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},dr=class n extends _{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=_.deserialize(t);return new n(r)}},O=class n extends _{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=class n extends _{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new oe)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=_.deserialize(t);return new n(r)}},f=class n extends _{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=Re.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(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(u.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(u.ONE,"rate_limiter","RateLimiter")}},Re=class n extends T{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=u.deserialize(e),r=z.deserialize(e),i=z.deserialize(e),o=e.deserializeVector(_);return new n(t,r,i,o)}};function Tp(){return new Re(u.ONE,new z("aptos_coin"),new z("AptosCoin"),[])}function E(){return new Re(u.ONE,new z("string"),new z("String"),[])}function Sp(n){return new Re(u.ONE,new z("option"),new z("Option"),[n])}function le(n){return new Re(u.ONE,new z("object"),new z("Object"),[n])}function ja(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Pe.deserialize(n);case 1:return Ae.deserialize(n);case 2:return Mt.deserialize(n);case 3:return u.deserialize(n);case 4:return K.deserialize(n,Pe);case 5:return H.deserialize(n);case 6:return Ot.deserialize(n);case 7:return Bt.deserialize(n);case 8:return Gt.deserialize(n);case 9:return Qi.deserialize(n);case 10:return Vt.deserialize(n);case 11:return Ht.deserialize(n);case 12:return Lt.deserialize(n);case 13:return $t.deserialize(n);case 14:return qt.deserialize(n);case 15:return Wt.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var mt=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return rn.load(e);case 2:return on.load(e);case 3:return sn.load(e);case 4:return pr.deserialize(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},rn=class n extends mt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=an.deserialize(e);return new n(t)}},on=class n extends mt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=ot.deserialize(e);return new n(t)}},sn=class n extends mt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=In.deserialize(e);return new n(t)}},ot=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(Kn.fromStr(e),new z(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=Kn.deserialize(e),r=z.deserialize(e),i=e.deserializeVector(_),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),d=Wi.deserialize(e,c);s.push(d)}return new n(t,r,i,s)}},an=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(_),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=ja(e);o.push(a)}return new n(t,r,o)}},In=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=u.deserialize(e),r=e.deserializeBool(),i;return r&&(i=En.deserialize(e)),new n(t,i)}},En=class n extends T{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(ot.deserialize(e))}},pr=class extends mt{static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return xt.load(e);throw new Error(`Unknown variant index for TransactionInnerPayload: ${t}`)}},xt=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=cn.deserialize(e),r=lr.deserialize(e);return new n(t,r)}},cn=class{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Cn.load(e);case 1:return un.load(e);case 2:return vn.load(e);default:throw new Error(`Unknown variant index for TransactionExecutable: ${t}`)}}},Cn=class n extends cn{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=an.deserialize(e);return new n(t)}},un=class n extends cn{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(1),this.entryFunction.serialize(e)}static load(e){let t=ot.deserialize(e);return new n(t)}},vn=class n extends cn{serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},lr=class{static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return Kt.load(e);throw new Error(`Unknown variant index for TransactionExtraConfig: ${t}`)}},Kt=class n extends lr{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 Ae(this.replayProtectionNonce):void 0)}static load(e){let t=e.deserializeOption(u),r=e.deserializeOption(Ae);return new n(t,r?.value)}};var be=class n extends T{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=u.deserialize(e),r=e.deserializeU64(),i=mt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=er.deserialize(e);return new n(t,r,i,o,s,a,c)}},gr=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return It.load(e);case 1:return Et.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},It=class n extends gr{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=be.deserialize(e),r=e.deserializeVector(u);return new n(t,r)}},Et=class n extends gr{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=be.deserialize(e),r=e.deserializeVector(u),i=u.deserialize(e);return new n(t,r,i)}};var st=class extends T{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ct.load(e);case 1:return dn.load(e);case 2:return vt.load(e);case 3:return _t.load(e);case 4:return ft.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Ct}isMultiEd25519(){return this instanceof dn}isMultiAgent(){return this instanceof vt}isFeePayer(){return this instanceof _t}isSingleSender(){return this instanceof ft}},Ct=class n extends st{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=b.deserialize(e),r=v.deserialize(e);return new n(t,r)}},dn=class n extends st{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=Z.deserialize(e),r=Ee.deserialize(e);return new n(t,r)}},vt=class n extends st{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=W.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(W);return new n(t,r,i)}},_t=class n extends st{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=W.deserialize(e),r=e.deserializeVector(u),i=e.deserializeVector(W),o=u.deserialize(e),s=W.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ft=class n extends st{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=W.deserialize(e);return new n(t)}};var at=class n extends T{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=be.deserialize(e),r=st.deserialize(e);return new n(t,r)}};var yr=class n extends T{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=be.deserialize(e),r=e.deserializeBool(),i;return r&&(i=u.deserialize(e)),new n(t,i)}};var mr=class n extends T{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=be.deserialize(e),r=e.deserializeVector(u),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(t,r,o)}};function fr(n){return n.feePayerAddress?new Et(n.rawTransaction,n.secondarySignerAddresses??[],n.feePayerAddress):n.secondarySignerAddresses?new It(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Oe(n,e){let t=Qa.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 zl(n){return Oe(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function ve(n){let e=fr(n);return n.feePayerAddress?Oe(e.bcsToBytes(),Lr):n.secondarySignerAddresses?Oe(e.bcsToBytes(),Lr):Oe(e.bcsToBytes(),lo)}var Y=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=L.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=L.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 Ce(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new Ce(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(ve(e))}};function ti(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var se=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?u.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=L.generate();break;case 2:r=qe.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=L.fromDerivationPath(r,i);break;case 2:o=qe.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 ie(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new ie(this.publicKey,this.signTransaction(e))}sign(e){return new N(this.privateKey.sign(e))}signTransaction(e){return this.sign(ve(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var ct=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?Y.generate():se.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof L&&i?new Y({privateKey:t,address:r}):new se({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?Y.fromDerivationPath({mnemonic:r,path:i}):se.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};import{randomBytes as Ya}from"@noble/hashes/utils";var Xa=1209600,pn=class pn extends T{constructor(t){super();this.cleared=!1;let{privateKey:r,expiryDateSecs:i,blinder:o}=t;this.privateKey=r,this.publicKey=new At(r.publicKey()),this.expiryDateSecs=i||ro(He()+Xa),this.blinder=o!==void 0?m.fromHexInput(o).toUint8Array():ec();let s=Xn(this.publicKey.bcsToBytes(),93);s.push(BigInt(this.expiryDateSecs)),s.push(Jt(this.blinder));let a=Zt(s);this.nonce=a.toString()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}clear(){if(!this.cleared){if("clear"in this.privateKey&&typeof this.privateKey.clear=="function")this.privateKey.clear();else{let t=this.privateKey.toUint8Array();crypto.getRandomValues(t),t.fill(255),crypto.getRandomValues(t),t.fill(0)}crypto.getRandomValues(this.blinder),this.blinder.fill(255),crypto.getRandomValues(this.blinder),this.blinder.fill(0),this.cleared=!0}}isCleared(){return this.cleared}serialize(t){t.serializeU32AsUleb128(this.publicKey.variant),t.serializeBytes(this.privateKey.toUint8Array()),t.serializeU64(this.expiryDateSecs),t.serializeFixedBytes(this.blinder)}static deserialize(t){let r=t.deserializeUleb128AsU32(),i;if(r===0)i=L.deserialize(t);else throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`);let o=t.deserializeU64(),s=t.deserializeFixedBytes(31);return new pn({privateKey:i,expiryDateSecs:Number(o),blinder:s})}static fromBytes(t){return pn.deserialize(new F(t))}static generate(t){let r;switch(t?.scheme){case 0:default:r=L.generate()}return new pn({privateKey:r,expiryDateSecs:t?.expiryDateSecs})}sign(t){if(this.cleared)throw new Error("EphemeralKeyPair has been cleared from memory and can no longer be used");if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Be(this.privateKey.sign(t))}};pn.BLINDER_LENGTH=31;var Ut=pn;function ec(){return Ya(Ut.BLINDER_LENGTH)}import nc from"eventemitter3";import{jwtDecode as rc}from"jwt-decode";function hr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var ln=class ln extends T{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:d,proof:l,proofFetchCallback:g,jwt:p,verificationKeyHash:y}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=p,this.emitter=new nc,this.proofOrPromise=l,l instanceof ge)this.proof=l;else{if(g===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async k=>{await g(k),this.emitter.removeAllListeners()}),this.init(l)}let h=m.fromHexInput(d).toUint8Array();if(h.length!==ln.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${ln.PEPPER_LENGTH}`);if(this.pepper=h,y!==void 0){if(m.hexInputToUint8Array(y).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=m.hexInputToUint8Array(y)}}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=u.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Ut.deserialize(t),c=ge.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 N(this.sign(t)),i=new I(this.publicKey);return new ie(i,r)}signTransactionWithAuthenticator(t){let r=new N(this.signTransaction(t)),i=new I(this.publicKey);return new ie(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw w.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw w.fromErrorType({type:2});let r=rc(this.jwt,{header:!0});if(r.kid===void 0)throw w.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 yn({aptosConfig:t});if(m.hexInputToString(i.hash())!==m.hexInputToString(this.verificationKeyHash))throw w.fromErrorType({type:4})}else Yn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await ln.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw w.fromErrorType({type:0});if(this.proof===void 0)throw w.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 re({jwtHeader:io(this.jwt.split(".")[0]),ephemeralCertificate:new gn(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw w.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=fr(t),o=new Ar(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw w.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=fr(t);return new Ar(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 ni(t)}};ln.PEPPER_LENGTH=31;var ye=ln,Ar=class extends T{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 Oe(this.bcsToBytes(),this.domainSeparator)}};var we=class n extends ye{constructor(e){let t=C.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}=ye.partialDeserialize(e),{iss:d,aud:l,uidVal:g}=ut({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:d,uidKey:s,uidVal:g,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new F(m.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:d,verificationKeyHash:l}=e;if(l&&d)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:g,aud:p,uidVal:y}=ut({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:g,uidKey:a,uidVal:y,aud:p,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:l??(d?d.hash():void 0)})}};var _e=class n extends ye{constructor(e){let t=M.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=e.audless??!1}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=ye.partialDeserialize(e),d=u.deserialize(e),{iss:l,aud:g,uidVal:p}=ut({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:p,aud:g,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:d})}static fromBytes(e){return n.deserialize(F.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:d,verificationKey:l,verificationKeyHash:g}=e;if(g&&l)throw new Error("Cannot provide both verificationKey and verificationKeyHash");let{iss:p,aud:y,uidVal:h}=ut({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:p,uidKey:c,uidVal:h,aud:y,pepper:s,jwkAddress:u.from(a),jwt:i,proofFetchCallback:d,verificationKeyHash:g??(l?l.hash():void 0)})}};var dt=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof Y?se.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?u.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 G({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Ne(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ne(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof ye).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof ye).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 he({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new he({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var _n=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?u.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 je(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new je(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Ee({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(ve(e))}};function Xo(n){let e=n.deserializeUleb128AsU32();if(!Object.values(Q).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:u.deserialize(n),signingScheme:e}}function es(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 ts(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Ut.deserialize(n),o=ge.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var ns;(g=>{function n(p){let y=new te;switch(y.serializeU32AsUleb128(p.signingScheme),p.accountAddress.serialize(y),p.signingScheme){case 0:return p.privateKey.serialize(y),y.toUint8Array();case 2:{if(!ti(p))throw new Error("Account is not a SingleKeySigner");let h=p.getAnyPublicKey();switch(y.serializeU32AsUleb128(h.variant),h.variant){case 3:return es(p,y),y.toUint8Array();case 4:{let k=p;return es(k,y),k.publicKey.jwkAddress.serialize(y),y.serializeBool(k.audless),y.toUint8Array()}case 1:case 0:return p.privateKey.serialize(y),y.toUint8Array();default:throw new Error(`Invalid public key variant: ${h.variant}`)}}case 3:{let h=p;return h.publicKey.serialize(y),y.serializeU32AsUleb128(h.signers.length),h.signers.forEach(k=>{y.serializeFixedBytes(n(k))}),y.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${p.signingScheme}`)}}g.toBytes=n;function e(p){return m.hexInputToStringWithoutPrefix(n(p))}g.toHexStringWithoutPrefix=e;function t(p){return m.hexInputToString(n(p))}g.toHexString=t;function r(p){let{address:y,signingScheme:h}=Xo(p);switch(h){case 0:{let k=L.deserialize(p);return new Y({privateKey:k,address:y})}case 2:{let k=p.deserializeUleb128AsU32();switch(k){case 0:{let q=L.deserialize(p);return new se({privateKey:q,address:y})}case 1:{let q=qe.deserialize(p);return new se({privateKey:q,address:y})}case 3:{let q=ts(p),ee=ut(q);return new we({...q,...ee})}case 4:{let q=ts(p),ee=u.deserialize(p),fe=p.deserializeBool(),Ve=ut(q);return new _e({...q,...Ve,jwkAddress:ee,audless:fe})}default:throw new Error(`Unsupported public key variant ${k}`)}}case 3:{let k=G.deserialize(p),q=p.deserializeUleb128AsU32(),ee=new Array;for(let fe=0;fe<q;fe+=1){let Ve=r(p);if(!ti(Ve)&&!(Ve instanceof Y))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");ee.push(Ve)}return new dt({multiKey:k,signers:ee,address:y})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${h}`)}}g.deserialize=r;function i(p){let y=d(p);if(!(y instanceof we))throw new Error("Deserialization of KeylessAccount failed");return y}g.keylessAccountFromHex=i;function o(p){let y=d(p);if(!(y instanceof _e))throw new Error("Deserialization of FederatedKeylessAccount failed");return y}g.federatedKeylessAccountFromHex=o;function s(p){let y=d(p);if(!(y instanceof dt))throw new Error("Deserialization of MultiKeyAccount failed");return y}g.multiKeyAccountFromHex=s;function a(p){let y=d(p);if(!(y instanceof se))throw new Error("Deserialization of SingleKeyAccount failed");return y}g.singleKeyAccountFromHex=a;function c(p){let y=d(p);if(!(y instanceof Y))throw new Error("Deserialization of Ed25519Account failed");return y}g.ed25519AccountFromHex=c;function d(p){return r(F.fromHex(p))}g.fromHex=d;function l(p){return d(p)}g.fromBytes=l})(ns||(ns={}));import{sha3_256 as rs}from"@noble/hashes/sha3";var br=class n extends ct{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!jt(i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new Ji(this.accountAddress),this.sign=o=>new Mr(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new te;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:r??t.accountAddress,authenticationFunction:"0x1::permissioned_delegation::authenticate"})}static generateAccountAbstractionMessage(t,r){let i=new ur(t,r);return Oe(i.bcsToBytes(),go)}signWithAuthenticator(t){return new St(this.authenticationFunction,rs(t),this.sign(rs(t)).toUint8Array())}signTransactionWithAuthenticator(t){let r=n.generateAccountAbstractionMessage(ve(t),this.authenticationFunction);return this.signWithAuthenticator(r)}signTransaction(t){return this.sign(ve(t))}setSigner(t){this.sign=r=>new Mr(t(r))}};import{sha3_256 as ri}from"@noble/hashes/sha3";var Un=class Un extends br{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new u(Un.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!jt(e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=ri.create(),a=new te;u.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new te;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([Un.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new St(this.authenticationFunction,ri(e),this.sign(ri(e)).value,this.abstractPublicKey)}};Un.ADDRESS_DOMAIN_SEPERATOR=5;var is=Un;import{sha3_256 as mc}from"@noble/hashes/sha3";function os(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function ss(n){return!!n.match(/\s/)}function ic(n){return!!n.match(/^T[0-9]+$/)}function oc(n){return!!n.match(/^&.+$/)}function sc(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 ac(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!ss(r))break}return t}var cc=(h=>(h.InvalidTypeTag="unknown type",h.UnexpectedGenericType="unexpected generic type",h.UnexpectedTypeArgumentClose="unexpected '>'",h.UnexpectedWhitespaceCharacter="unexpected whitespace character",h.UnexpectedComma="unexpected ','",h.TypeArgumentCountMismatch="type argument count doesn't match expected amount",h.MissingTypeArgumentClose="no matching '>' for '<'",h.MissingTypeArgument="no type argument before ','",h.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",h.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",h.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",h.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",h.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",h.InvalidAddress="struct address must be valid",h))(cc||{}),$=class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Ue(n,e){let t=e?.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 h=kn(a,i,t);o.push(h)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:g,savedTypes:p,savedExpectedTypes:y}=l;i=o,o=p,a=g,c=y}else if(d===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=kn(a,i,t);i=[],o.push(l),a="",c+=1}else if(ss(d)){let l=!1;if(a.length!==0){let p=kn(a,i,t);i=[],o.push(p),a="",l=!0}s=ac(n,s);let g=n[s];if(s<n.length&&l&&g!==","&&g!==">")throw new $(n,"unexpected whitespace character");continue}else a+=d;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return kn(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function kn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(sc(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Pt;case"bool":return new V;case"address":return new R;case"u8":return new oe;case"u16":return new Je;case"u32":return new Ye;case"u64":return new j;case"u128":return new tt;case"u256":return new rt;case"i8":return new Qe;case"i16":return new Ze;case"i32":return new Xe;case"i64":return new et;case"i128":return new nt;case"i256":return new it;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new U(e[0]);default:if(oc(r)){let a=r.substring(1);return new dr(kn(a,e,t))}if(ic(r)){if(t)return new O(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch{throw new $(n,"struct address must be valid")}if(!os(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!os(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new f(new Re(s,new z(o[1]),new z(o[2]),e))}}function as(n){return typeof n=="boolean"}function pt(n){return typeof n=="string"}function uc(n){return typeof n=="number"}function kt(n){if(uc(n))return n;if(pt(n)&&n!=="")return Number.parseInt(n,10)}function Ft(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function cs(n){return n==null}function us(n){return ii(n)||si(n)||ai(n)||ci(n)||ui(n)||di(n)||pi(n)||wr(n)||oi(n)||dc(n)||li(n)||gi(n)||yi(n)||mi(n)||fi(n)||Ai(n)||n instanceof K||n instanceof B}function ii(n){return n instanceof H}function wr(n){return n instanceof u}function oi(n){return n instanceof D}function dc(n){return n instanceof Rt}function si(n){return n instanceof Pe}function ai(n){return n instanceof Ot}function ci(n){return n instanceof Bt}function ui(n){return n instanceof Ae}function di(n){return n instanceof Mt}function pi(n){return n instanceof Gt}function li(n){return n instanceof Vt}function gi(n){return n instanceof Ht}function yi(n){return n instanceof Lt}function mi(n){return n instanceof $t}function fi(n){return n instanceof qt}function Ai(n){return n instanceof Wt}function ds(n){return"bytecode"in n}function P(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function ps(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var pc=new TextEncoder;function Tr(n){return n?.map(e=>pt(e)?Ue(e):e)??[]}var lc=300*1e3;async function gc(n,e,t){let r=`module-abi-${t.network}-${n}-${e}`;return $e(async()=>(await Sr({aptosConfig:t,accountAddress:n,moduleName:e})).abi,r,lc)()}async function bi(n,e,t,r){let i=await gc(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 Hm(n,e,t,r){let i=await bi(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(Ue(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function ls(n,e,t,r){let i=await bi(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=ps(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ue(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function gs(n,e,t,r){let i=await bi(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(Ue(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ue(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function wi(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=Ue(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 Dt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Dt(n,e,t,r,i,o){return us(n)?(hi(e,n,t),n):yc(n,e,t,r,i,o)}function yc(n,e,t,r,i,o){if(e.isBool()){if(as(n))return new H(n);if(pt(n)){if(n==="true")return new H(!0);if(n==="false")return new H(!1)}P("boolean",t)}if(e.isAddress()){if(pt(n))return u.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new u(n.data);P("string | AccountAddress",t)}if(e.isU8()){let s=kt(n);if(s!==void 0)return new Pe(s);P("number | string",t)}if(e.isU16()){let s=kt(n);if(s!==void 0)return new Ot(s);P("number | string",t)}if(e.isU32()){let s=kt(n);if(s!==void 0)return new Bt(s);P("number | string",t)}if(e.isU64()){if(Ft(n))return new Ae(BigInt(n));P("bigint | number | string",t)}if(e.isU128()){if(Ft(n))return new Mt(BigInt(n));P("bigint | number | string",t)}if(e.isU256()){if(Ft(n))return new Gt(BigInt(n));P("bigint | number | string",t)}if(e.isI8()){let s=kt(n);if(s!==void 0)return new Vt(s);P("number | string",t)}if(e.isI16()){let s=kt(n);if(s!==void 0)return new Ht(s);P("number | string",t)}if(e.isI32()){let s=kt(n);if(s!==void 0)return new Lt(s);P("number | string",t)}if(e.isI64()){if(Ft(n))return new $t(BigInt(n));P("bigint | number | string",t)}if(e.isI128()){if(Ft(n))return new qt(BigInt(n));P("bigint | number | string",t)}if(e.isI256()){if(Ft(n))return new Wt(BigInt(n));P("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 Dt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(pt(n))return K.U8(pc.encode(n));if(n instanceof Uint8Array)return K.U8(n);if(n instanceof ArrayBuffer)return K.U8(new Uint8Array(n))}if(pt(n)&&n.startsWith("["))return Dt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new K(n.map(s=>Dt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(pt(n))return new D(n);P("string",t)}if(e.isObject()){if(pt(n))return u.fromString(n);if(n&&typeof n=="object"&&"data"in n&&n.data instanceof Uint8Array)return new u(n.data);P("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Rt(n);P("Uint8Array",t)}if(e.isOption()){if(cs(n)){let a=e.value.typeArgs[0];return a instanceof V?new B(null):a instanceof R?new B(null):a instanceof oe?new B(null):a instanceof Je?new B(null):a instanceof Ye?new B(null):a instanceof j?new B(null):a instanceof tt?new B(null):a instanceof rt?new B(null):a instanceof Qe?new B(null):a instanceof Ze?new B(null):a instanceof Xe?new B(null):a instanceof et?new B(null):a instanceof nt?new B(null):a instanceof it?new B(null):new B(null)}return new B(Dt(n,e.value.typeArgs[0],t,r,i))}if(i?.structs.find(a=>a.name===e.value.name.identifier)?.fields.length===0&&n instanceof Uint8Array)return new Rt(n);if(n instanceof Uint8Array&&o?.allowUnknownStructs)return Yn(`[Aptos SDK] Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Rt(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 hi(n,e,t){if(n.isBool()){if(ii(e))return;P("Bool",t)}if(n.isAddress()){if(wr(e))return;P("AccountAddress",t)}if(n.isU8()){if(si(e))return;P("U8",t)}if(n.isU16()){if(ai(e))return;P("U16",t)}if(n.isU32()){if(ci(e))return;P("U32",t)}if(n.isU64()){if(ui(e))return;P("U64",t)}if(n.isU128()){if(di(e))return;P("U128",t)}if(n.isU256()){if(pi(e))return;P("U256",t)}if(n.isI8()){if(li(e))return;P("I8",t)}if(n.isI16()){if(gi(e))return;P("I16",t)}if(n.isI32()){if(yi(e))return;P("I32",t)}if(n.isI64()){if(mi(e))return;P("I64",t)}if(n.isI128()){if(fi(e))return;P("I128",t)}if(n.isI256()){if(Ai(e))return;P("I256",t)}if(n.isVector()){if(e instanceof K){e.values.length>0&&hi(n.value,e.values[0],t);return}P("MoveVector",t)}if(n instanceof f){if(n.isString()){if(oi(e))return;P("MoveString",t)}if(n.isObject()){if(wr(e))return;P("AccountAddress",t)}if(n.isOption()){if(e instanceof B){e.value!==void 0&&hi(n.value.typeArgs[0],e.value,t);return}P("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Pr(n){if(ds(n))return hc(n);let{moduleAddress:e,moduleName:t,functionName:r}=ce(n.function),i=await As({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:ls});return fc({...n,abi:i})}function fc(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=ce(n.function),o=Tr(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)=>wi(n.function,e,c,d,o));if((s?.length??0)!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s?.length??0}`);let a=ot.build(`${t}::${r}`,i,o,s??[]);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new sn(new In(c,new En(a)))}return new on(a)}async function ys(n){let{moduleAddress:e,moduleName:t,functionName:r}=ce(n.function),i=await As({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:gs});return Ac({abi:i,...n})}function Ac(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=ce(n.function),o=Tr(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n?.functionArguments?.map((a,c)=>wi(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 ot.build(`${t}::${r}`,i,o,s)}function hc(n){return new rn(new an(m.fromHexInput(n.bytecode).toUint8Array(),Tr(n.typeArguments),n.functionArguments))}async function bc(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n;if(i?.replayProtectionNonce!==void 0&&i?.accountSequenceNumber!==void 0)throw new Error("Cannot specify both replayProtectionNonce and accountSequenceNumber in options.");let s=async()=>Vr[e.network]?{chainId:Vr[e.network]}:{chainId:(await nr({aptosConfig:e})).chain_id},a=async()=>i?.gasUnitPrice?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await ir({aptosConfig:e})).gas_estimate},c=async()=>{let fe=async()=>i?.accountSequenceNumber!==void 0?i.accountSequenceNumber:i?.replayProtectionNonce!==void 0?0xdeadbeefn:(await rr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await fe()}catch{return 0}else return fe()},[{chainId:d},{gasEstimate:l},g]=await Promise.all([s(),a(),c()]),p=i?.maxGasAmount?BigInt(i.maxGasAmount):BigInt(e.getDefaultMaxGasAmount()),{maxGasAmount:y,gasUnitPrice:h,expireTimestamp:k,replayProtectionNonce:q}={maxGasAmount:p<BigInt(2e3)?BigInt(2e3):p,gasUnitPrice:i?.gasUnitPrice??BigInt(l),expireTimestamp:i?.expireTimestamp??BigInt(Math.floor(Date.now()/1e3)+e.getDefaultTxnExpirySecFromNow()),replayProtectionNonce:i?.replayProtectionNonce?BigInt(i.replayProtectionNonce):void 0},ee=r;return q!==void 0&&(ee=wc(r,q)),new be(u.from(t),BigInt(g),ee,BigInt(y),BigInt(h),BigInt(k),new er(d))}function wc(n,e){if(n instanceof rn)return new xt(new Cn(n.script),new Kt(void 0,e));if(n instanceof on)return new xt(new un(n.entryFunction),new Kt(void 0,e));if(n instanceof sn){let t=n.multiSig.transaction_payload,r;if(t===void 0||t?.transaction_payload===void 0)r=new vn;else if(t.transaction_payload instanceof ot)r=new un(t.transaction_payload);else throw new Error("Scripts are not supported in multi-sig transactions.");return new xt(r,new Kt(n.multiSig.multisig_address,e))}throw new Error(`Unsupported payload type: ${n}`)}async function Ti(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await bc({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=n.secondarySignerAddresses?.map(c=>u.from(c))??[];return new mr(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new yr(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function ms(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=mn(e);if(t.feePayerAddress){let a=new Et(t.rawTransaction,t.secondarySignerAddresses??[],t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(g=>mn(g)):c=Array.from({length:t.secondarySignerAddresses.length},()=>mn(void 0)));let d=mn(i),l=new _t(o,t.secondarySignerAddresses??[],c,{address:t.feePayerAddress,authenticator:d});return new at(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new It(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>mn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>mn(void 0));let d=new vt(o,t.secondarySignerAddresses,c);return new at(a.raw_txn,d).bcsToBytes()}let s;if(o instanceof Ce)s=new Ct(o.public_key,o.signature);else if(o instanceof ie||o instanceof Ne)s=new ft(o);else if(o instanceof nn)s=new ft(o);else throw new Error("Invalid public key");return new at(t.rawTransaction,s).bcsToBytes()}function mn(n){if(!n)return new nn;let t=C.isInstance(n)||M.isInstance(n)||Ke.isInstance(n)?new I(n):n,r=new v(new Uint8Array(64));if(b.isInstance(t))return new Ce(t,r);if(I.isInstance(t))return C.isInstance(t.publicKey)?new ie(t,new N(re.getSimulationSignature())):new ie(t,new N(r));if(G.isInstance(t))return new Ne(t,new he({signatures:t.publicKeys.map(i=>C.isInstance(i.publicKey)||M.isInstance(i.publicKey)?new N(re.getSimulationSignature()):new N(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Si(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=mo(W,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 _t(i,e.secondarySignerAddresses??[],r??[],{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new vt(i,e.secondarySignerAddresses,r)}else i instanceof Ce?o=new Ct(i.public_key,i.signature):i instanceof je?o=new dn(i.public_key,i.signature):o=new ft(i);return new at(e.rawTransaction,o).bcsToBytes()}function fs(n){let e=mc.create();for(let t of n)e.update(t);return e.digest()}var Tc=fs(["APTOS::Transaction"]);function hf(n){let e=Si(n);return new m(fs([Tc,new Uint8Array([0]),e])).toString()}async function As({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 A(n){let e=await Pc(n);return xc(n,e)}async function Pc(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Pr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Pr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Pr(r)),i}async function xc(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Kc(n)&&(o=u.ZERO.toString()),Ic(n)){let{secondarySignerAddresses:s}=n;return Ti({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Ti({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function Kc(n){return n.withFeePayer===!0}function Ic(n){return"secondarySignerAddresses"in n}function hs(n){let{transaction:e}=n;return ve(e)}function xr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Kr(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,xr({signer:e,transaction:t})}async function Pi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=ms({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Tt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:n.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:n.options?.estimateMaxGasAmount??!1,estimate_prioritized_gas_unit_price:n.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});if(n.options?.estimateMaxGasAmount&&c.length>0&&c[0].vm_status==="MAX_GAS_UNITS_BELOW_MIN_TRANSACTION_GAS_UNITS"){let{data:d}=await Tt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:n.options?.estimateGasUnitPrice??!1,estimate_max_gas_amount:!1,estimate_prioritized_gas_unit_price:n.options?.estimatePrioritizedGasUnitPrice??!1},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return d}return c}async function Fn(n){let{aptosConfig:e,transactionSubmitter:t}=n,r=t===void 0?e.getTransactionSubmitter():t;if(r)return r.submitTransaction(n);let i=Si({...n});try{let{data:o}=await Tt({aptosConfig:e,body:i,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return o}catch(o){let s=at.deserialize(new F(i));throw s.authenticator.isSingleSender()&&s.authenticator.sender.isSingleKey()&&(s.authenticator.sender.public_key.publicKey instanceof C||s.authenticator.sender.public_key.publicKey instanceof M)&&await ye.fetchJWK({aptosConfig:e,publicKey:s.authenticator.sender.public_key.publicKey,kid:s.authenticator.sender.signature.signature.getJwkKid()}),o}}async function Ir(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i,...o}=n;hr(t)&&await t.checkKeylessAccountValidity(e),hr(r)&&await r.checkKeylessAccountValidity(e);let s=n.feePayerAuthenticator||r&&Kr({signer:r,transaction:i}),a=xr({signer:t,transaction:i});return Fn({aptosConfig:e,transaction:i,senderAuthenticator:a,feePayerAuthenticator:s,...o})}async function bs(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i,...o}=n;hr(r)&&await r.checkKeylessAccountValidity(e);let s=Kr({signer:r,transaction:i});return Fn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:s,...o})}var Ec={typeParameters:[],parameters:[U.u8(),new U(U.u8())]};async function ws(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>K.U8(a));return A({aptosConfig:e,sender:u.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[K.U8(r),new K(s)],abi:Ec},options:o})}async function fn(n){return rr(n)}async function Ss(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return $r({aptosConfig:e,originMethod:"getModules",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??1e3}})}async function Ps(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await qr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${u.from(t).toString()}/modules`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{modules:i.data,cursor:o}}async function Sr(n){return Go(n)}async function Ii(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return Ao({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${u.from(t).toString()}/transactions`,params:{start:r?.offset,limit:r?.limit}})}async function Ei(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return $r({aptosConfig:e,originMethod:"getResources",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,limit:r?.limit??999}})}async function xs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await qr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${u.from(t).toString()}/resources`,params:{ledger_version:r?.ledgerVersion,cursor:r?.cursor,limit:r?.limit??100}});return{resources:i.data,cursor:o}}async function Ci(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await yt({aptosConfig:e,originMethod:"getResource",path:`accounts/${u.from(t).toString()}/resource/${r}`,params:{ledger_version:i?.ledgerVersion}});return o.data}async function An(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Ci({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(t);try{let a=await Vo({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof fo&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ks(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},s=await x({aptosConfig:e,query:{query:Co,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 Is(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard});let s={query:Io,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await x({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Es(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=u.from(t).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};i?.tokenStandard&&(a.token_standard={_eq:i?.tokenStandard});let c={query:Eo,variables:{where_condition:a,offset:i?.offset,limit:i?.limit,order_by:i?.orderBy}};return(await x({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Cs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}};r?.tokenStandard&&(o.current_collection={token_standard:{_eq:r?.tokenStandard}});let s={query:Ko,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await x({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function vs(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await x({aptosConfig:e,query:{query:vo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function zA(n){let{aptosConfig:e,accountAddress:t,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Le?s=u.A.toStringLong():s=Zn(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let l=u.from(i);s=l.toStringLong(),l===u.A&&(o=Le)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=u.from(t).toStringLong(),c={asset_type:{_eq:s}};o!==void 0&&(c={asset_type:{_in:[o,s]}});let d=await vi({aptosConfig:e,accountAddress:a,options:{where:c}});return d[0]?d[0].amount:0}async function vi(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=u.from(t).toStringLong(),o={...r?.where,owner_address:{_eq:i}},s={query:xo,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await x({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function _s(n){let{aptosConfig:e,accountAddress:t}=n,r=u.from(t).toStringLong(),o=await x({aptosConfig:e,query:{query:Po,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 Us(n){let{aptosConfig:e,accountAddress:t,asset:r}=n,i=await yt({aptosConfig:e,originMethod:"getBalance",path:`accounts/${t}/balance/${r}`,params:{accountAddress:t.toString(),asset:r instanceof Uint8Array?u.from(r).toString():r.toString()}});return parseInt(i.data.toString(),10)}async function _i(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:u.from(t).toStringLong()}},s={query:tr,variables:{where_condition:o,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await x({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function ks(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=r?.throwIfNoAccountFound??!1,o=await Er({aptosConfig:e,privateKey:t});if(o.length===0){if(i)throw new Error("No existing account found for private key.");return ct.fromPrivateKey({privateKey:t})}return o[0]}async function NA(n){let{aptosConfig:e,authKey:t}=n,r=await An({aptosConfig:e,authenticationKey:t.derivedAddress()});return Fs({aptosConfig:e,accountAddress:r})}async function Fs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;try{let[i,o]=await Promise.all([Ei({aptosConfig:e,accountAddress:t}),_i({aptosConfig:e,accountAddress:t,options:{limit:1}})]),s=i.find(c=>c.type==="0x1::account::Account");if(!s&&o.length===0)return!1;if(!r?.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 Cc={typeParameters:[],parameters:[new oe,U.u8(),new oe,U.u8(),U.u8(),U.u8()]};async function Ds(n){let{aptosConfig:e,fromAccount:t,options:r}=n;if("toNewPrivateKey"in n)return xi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey,options:r});if("toAccount"in n)return n.toAccount instanceof Y?xi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey,options:r}):xi({aptosConfig:e,fromAccount:t,toAccount:n.toAccount,options:r});throw new Error("Invalid arguments")}async function xi(n){let{aptosConfig:e,fromAccount:t,options:r}=n,i=await fn({aptosConfig:e,accountAddress:t.accountAddress}),o;"toNewPrivateKey"in n?o=ct.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):o=n.toAccount;let a=new To({sequenceNumber:BigInt(i.sequence_number),originator:t.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=t.sign(a),d=o.sign(a);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new Pe(t.signingScheme),K.U8(t.publicKey.toUint8Array()),new Pe(o.signingScheme),K.U8(o.publicKey.toUint8Array()),K.U8(c.toUint8Array()),K.U8(d.toUint8Array())],abi:Cc},options:r})}var vc={typeParameters:[],parameters:[new oe,U.u8()]};async function zs(n){let{aptosConfig:e,fromAccount:t,toNewPublicKey:r,options:i}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_from_public_key",functionArguments:[new Pe(Ts(r)),K.U8(Ki(r).toUint8Array())],abi:vc},options:i})}async function Cr(n){let{aptosConfig:e,publicKey:t,options:r}=n,i=r?.noMultiKey??!1;if(i&&t instanceof Ie)throw new Error("Multi-key accounts are not supported when noMultiKey is true.");let o=[t];t instanceof I&&t.publicKey instanceof b?o.push(t.publicKey):t instanceof b&&o.push(new I(t));let[s,a]=await Promise.all([Promise.all(o.map(async g=>{let p=await Dc({aptosConfig:e,publicKey:g});if(p)return{...p,publicKey:g}})),!(t instanceof Ie)&&!i?Uc({aptosConfig:e,publicKey:t,options:r}):Promise.resolve([])]),c=[];for(let g of s)g&&c.push(g);o.push(...a);let d=new Map(o.map(g=>[g.authKey().toString(),g])),l=await kc({aptosConfig:e,authKeys:o.map(g=>g.authKey()),options:r});for(let g of l){if(c.find(y=>y.accountAddress===g.accountAddress))continue;let p=d.get(g.authKey.toString());if(!p)throw new Error(`No publicKey found for authentication key ${g.authKey}. This should never happen.`);c.push({accountAddress:g.accountAddress,publicKey:p,lastTransactionVersion:g.lastTransactionVersion})}return c.sort((g,p)=>p.lastTransactionVersion-g.lastTransactionVersion)}async function Ui(n){let{aptosConfig:e,signer:t,options:r}=n;if(t instanceof L||t instanceof qe)return Er({aptosConfig:e,privateKey:t,options:r});if(t instanceof Y||t instanceof se)return Er({aptosConfig:e,privateKey:t.privateKey,options:r});if(t instanceof we||t instanceof _e)return _c({aptosConfig:e,keylessAccount:t,options:r});if(t instanceof dt&&t.signers.length===1)return Ui({aptosConfig:e,signer:t.signers[0],options:r});if(t instanceof _n&&t.signers.length===1)return Er({aptosConfig:e,privateKey:t.signers[0],options:r});throw new Error("Unknown signer type")}async function _c(n){let{aptosConfig:e,keylessAccount:t,options:r}=n,i=await Cr({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 Ie){if(c.getSignaturesRequired()>1)continue;if(c instanceof Z)throw new Error("Keyless authentication cannot be used for multi-ed25519 accounts. This should never happen.");c instanceof G&&s.push(new dt({multiKey:c,signers:[t],address:a}))}else t instanceof _e?s.push(_e.create({...o,address:a,jwkAddress:t.publicKey.jwkAddress})):s.push(we.create({...o,address:a}));return s}async function Er(n){let{aptosConfig:e,privateKey:t,options:r}=n,i=ct.fromPrivateKey({privateKey:t,legacy:!1}),o=await Cr({aptosConfig:e,publicKey:new I(t.publicKey()),options:r}),s=[];for(let{accountAddress:a,publicKey:c}of o)if(c instanceof Ie){if(c.getSignaturesRequired()>1)continue;c instanceof Z?s.push(new _n({publicKey:c,signers:[t],address:a})):c instanceof G&&s.push(new dt({multiKey:c,signers:[i],address:a}))}else{let d=c instanceof b;s.push(ct.fromPrivateKey({privateKey:t,address:a,legacy:d}))}return s}async function Uc(n){let{aptosConfig:e,publicKey:t,options:r}=n;if(t instanceof Ie)throw new Error("Public key is a multi-key.");let i=r?.includeUnverified??!1,o=t instanceof I?t:new I(t),s=o.publicKey,a=ji(o.variant),c={public_key:{_eq:s.toString()},public_key_type:{_eq:a},account_public_key:{_is_null:!1},...i?{}:{is_public_key_used:{_eq:!0}}},d={query:_o,variables:{where_condition:c}},{public_key_auth_keys:l}=await x({aptosConfig:e,query:d,originMethod:"getMultiKeysForPublicKey"});return l.filter(p=>p.account_public_key!==null).map(p=>{switch(p.signature_type){case"multi_ed25519_signature":return Z.deserializeWithoutLength(F.fromHex(p.account_public_key));case"multi_key_signature":return G.deserialize(F.fromHex(p.account_public_key));default:throw new Error(`Unknown multi-signature type: ${p.signature_type}`)}})}async function kc(n){let{aptosConfig:e,authKeys:t,options:r}=n,i=r?.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:So,variables:{where_condition:o,order_by:[{last_transaction_version:"desc"}]}},{auth_key_account_addresses:a}=await x({aptosConfig:e,query:s,originMethod:"getAccountAddressesForAuthKeys"});return a.map(c=>({authKey:new ne({data:c.auth_key}),accountAddress:new u(m.hexInputToUint8Array(c.account_address)),lastTransactionVersion:Number(c.last_transaction_version)}))}async function Fc(n){let{aptosConfig:e,accountAddress:t}=n,r=await Ii({aptosConfig:e,accountAddress:t,options:{limit:1}});return r.length===0?0:Number(r[0].version)}async function Dc(n){let{aptosConfig:e,publicKey:t}=n,r=t.authKey().derivedAddress(),[i,o]=await Promise.all([Fc({aptosConfig:e,accountAddress:r}),Fs({aptosConfig:e,accountAddress:r,options:{withAuthKey:t.authKey()}})]);if(o)return{accountAddress:r,lastTransactionVersion:i}}async function ae(n){let{aptosConfig:e,payload:t,options:r}=n,i=await ys({...t,aptosConfig:e}),o=new te;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Tt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:r?.ledgerVersion},body:s});return a}async function Ns(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await Tt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:r?.ledgerVersion},body:{function:t.function,type_arguments:t.typeArguments??[],arguments:t.functionArguments??[]}});return i}async function Rs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=ce(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new R,new f(E()),new f(E())]}},options:i})}async function Os(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=ce(r);return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new R,new f(E()),new f(E())]}},options:i})}async function Bs(n){let{aptosConfig:e,sender:t,options:r}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var zt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=ce(e.authenticationFunction);return t?.some(s=>u.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 Rs({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Os({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Bs({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ae({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[u.from(t)],abi:{typeParameters:[],parameters:[new R],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:u.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var Dn=class{constructor(e){this.config=e;this.abstraction=new zt(e)}async getAccountInfo(e){return fn({aptosConfig:this.config,...e})}async getAccountModules(e){return Ss({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Ps({aptosConfig:this.config,...e})}async getAccountModule(e){return Sr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Ii({aptosConfig:this.config,...e})}async getAccountResources(e){return Ei({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return xs({aptosConfig:this.config,...e})}async getAccountResource(e){return Ci({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return An({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ks({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Is({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Es({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Cs({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),vs({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),vi({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),_s({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:Le,faMetadataAddress:po,...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 ae({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}}))[0];if(c.vec.length>0&&ao(c.vec[0]))return so(c.vec[0])}catch{}},`coin-mapping-${i.toString()}`,1e3*60*5)());let s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===Le?s=u.A.toStringLong():s=Zn(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let c=u.from(i);s=c.toStringLong(),c===u.A&&(o=Le)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(o!==void 0){let[c]=await ae({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[o],functionArguments:[t]}});return parseInt(c,10)}let[a]=await ae({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 Us({aptosConfig:this.config,...e})}async getAccountOwnedObjects(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),_i({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ks({aptosConfig:this.config,...e})}async deriveOwnedAccountsFromSigner(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ui({aptosConfig:this.config,...e})}async getAccountsForPublicKey(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_restoration_processor"}),await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Cr({aptosConfig:this.config,...e})}};var zc={typeParameters:[{constraints:[]}],parameters:[new R,new j]};async function Ms(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return A({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[o??Le],functionArguments:[r,i],abi:zc},options:s})}var Nn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return Ms({aptosConfig:this.config,...e})}};var ht={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},Te="0x4::token::Token";async function Gs(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()}};return(await x({aptosConfig:e,query:{query:Ro,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Vs(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:u.from(t).toStringLong()},amount:{_gt:0}};return(await x({aptosConfig:e,query:{query:Jr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Hs(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:u.from(t).toStringLong()},amount:{_gt:0}},o={query:Jr,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await x({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ls(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:u.from(t).toStringLong()}},o={query:No,variables:{where_condition:i,offset:r?.offset,limit:r?.limit,order_by:r?.orderBy}};return(await x({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Nc={typeParameters:[],parameters:[new f(E()),new j,new f(E()),new f(E()),new V,new V,new V,new V,new V,new V,new V,new V,new V,new j,new j]};async function $s(n){let{aptosConfig:e,options:t,creator:r}=n;return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new D(n.description),new Ae(n.maxSupply??$i),new D(n.name),new D(n.uri),new H(n.mutableDescription??!0),new H(n.mutableRoyalty??!0),new H(n.mutableURI??!0),new H(n.mutableTokenDescription??!0),new H(n.mutableTokenName??!0),new H(n.mutableTokenProperties??!0),new H(n.mutableTokenURI??!0),new H(n.tokensBurnableByCreator??!0),new H(n.tokensFreezableByCreator??!0),new Ae(n.royaltyNumerator??0),new Ae(n.royaltyDenominator??1)],abi:Nc},options:t})}async function hn(n){let{aptosConfig:e,options:t}=n,r=t?.where;t?.tokenStandard&&(r.token_standard={_eq:t?.tokenStandard??"v2"});let i={query:Uo,variables:{where_condition:r,offset:t?.offset,limit:t?.limit}};return(await x({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function qs(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),hn({aptosConfig:e,options:{...i,where:s}})}async function Ws(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),hn({aptosConfig:e,options:{...r,where:o}})}async function js(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:u.from(t).toStringLong()}};return r?.tokenStandard&&(o.token_standard={_eq:r?.tokenStandard??"v2"}),hn({aptosConfig:e,options:{...r,where:o}})}async function Qs(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=u.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return r?.tokenStandard&&(s.token_standard={_eq:r?.tokenStandard??"v2"}),(await hn({aptosConfig:i,options:{where:s}})).collection_id}var Rc={typeParameters:[],parameters:[new f(E()),new f(E()),new f(E()),new f(E()),new U(new f(E())),new U(new f(E())),new U(U.u8())]};async function Js(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:d,propertyValues:l}=n,g=d?.map(p=>ht[p]);return A({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new D(i),new D(o),new D(s),new D(a),K.MoveString(c??[]),K.MoveString(g??[]),da(l??[],g??[])],abi:Rc},options:t})}var Oc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new R]};async function Zs(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[o??Te],functionArguments:[u.from(r),u.from(i)],abi:Oc},options:s})}var Bc={typeParameters:[],parameters:[new f(E()),new f(E()),new f(E()),new f(E()),new U(new f(E())),new U(new f(E())),new U(U.u8()),new R]};async function Ys(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:d,propertyValues:l,options:g}=n;if(c?.length!==l?.length)throw new Error("Property keys and property values counts do not match");if(d?.length!==l?.length)throw new Error("Property types and property values counts do not match");let p=d?.map(y=>ht[y]);return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,K.MoveString(c??[]),K.MoveString(p??[]),da(l??[],p??[]),a],abi:Bc},options:g})}var Mc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0)))]};async function Xs(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[i??Te],functionArguments:[u.from(r)],abi:Mc},options:o})}var Gc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0)))]};async function ea(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[i??Te],functionArguments:[r],abi:Gc},options:o})}var Vc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0)))]};async function ta(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[i??Te],functionArguments:[r],abi:Vc},options:o})}var Hc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new f(E())]};async function na(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[o??Te],functionArguments:[u.from(i),new D(r)],abi:Hc},options:s})}var Lc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new f(E())]};async function ra(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[o??Te],functionArguments:[u.from(i),new D(r)],abi:Lc},options:s})}var $c={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new f(E())]};async function ia(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[o??Te],functionArguments:[u.from(i),new D(r)],abi:$c},options:s})}var qc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new f(E()),new f(E()),U.u8()]};async function oa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[a??Te],functionArguments:[u.from(s),new D(r),new D(ht[i]),K.U8(ki(o,ht[i]))],abi:qc},options:c})}var Wc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new f(E())]};async function sa(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[o??Te],functionArguments:[u.from(i),new D(r)],abi:Wc},options:s})}var jc={typeParameters:[{constraints:["key"]}],parameters:[new f(le(new O(0))),new f(E()),new f(E()),U.u8()]};async function aa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[a??Te],functionArguments:[u.from(s),new D(r),new D(ht[i]),ki(o,ht[i])],abi:jc},options:c})}var Qc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(le(new O(0))),new f(E()),new O(1)]};async function ca(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[a??Te,ht[i]],functionArguments:[u.from(s),new D(r),o],abi:Qc},options:c})}var Jc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new f(le(new O(0))),new f(E()),new O(1)]};async function ua(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[a??Te,ht[i]],functionArguments:[u.from(s),new D(r),o],abi:Jc},options:c})}function da(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(ki(n[i],r))}),t}function ki(n,e){let t=Ue(e);return Dt(n,t,0,[]).bcsToBytes()}var Rn=class{constructor(e){this.config=e}async getCollectionData(e){await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=u.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return i?.tokenStandard&&(s.token_standard={_eq:i?.tokenStandard??"v2"}),hn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),qs({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ws({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),js({aptosConfig:this.config,...e})}async getCollectionId(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Qs({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Gs({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return $s({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return Js({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return Zs({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return Ys({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return Xs({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ea({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return ta({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return na({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ra({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ia({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return oa({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return sa({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return aa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return ca({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return ua({aptosConfig:this.config,...e})}};async function pa(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=i?.timeoutSecs||20,{data:s}=await ho({aptosConfig:e,path:"fund",body:{address:u.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Xt({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:i?.checkSuccess}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var On=class{constructor(e){this.config=e}async fundAccount(e){let t=await pa({aptosConfig:this.config,...e});return(e.options?.waitForIndexer===void 0||e.options?.waitForIndexer)&&await Wo({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function vr(n){let{aptosConfig:e,options:t}=n,r={query:zo,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await x({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function la(n){let{aptosConfig:e,options:t}=n,r={query:Do,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await x({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ga(n){let{aptosConfig:e,options:t}=n,r={query:ko,variables:{where_condition:t?.where,limit:t?.limit,offset:t?.offset}};return(await x({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ya={typeParameters:[{constraints:[]}],parameters:[Ue("0x1::object::Object"),new R,new j]};async function ma(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ya},options:s})}async function fa(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:ya},options:s})}var Bn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),vr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),(await vr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),await vr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),la({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"fungible_asset_processor"}),ga({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ma({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return fa({aptosConfig:this.config,...e})}};var Mn=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 jo({aptosConfig:this.config,...e})}async getBlockByHeight(e){return Qo({aptosConfig:this.config,...e})}async view(e){return ae({aptosConfig:this.config,...e})}async viewJson(e){return Ns({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return Oo({aptosConfig:this.config,...e})}async queryIndexer(e){return x({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Bo({aptosConfig:this.config})}async getProcessorStatus(e){return Mo({aptosConfig:this.config,processorType:e})}};var Fi,Zc=6,Aa=["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 ha(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function lt(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(!ha(e))throw new Error(`${e} is not valid. ${Aa}`);if(t&&!ha(t))throw new Error(`${t} is not valid. ${Aa}`);return{domainName:t||e,subdomainName:t?e:void 0}}function Yc({name:n,gracePeriod:e}){if(!n)return"expired";let t=e*1e3,r=Date.now(),i=new Date(n.domain_expiration_timestamp).getTime(),o=new Date(n.expiration_timestamp).getTime(),s=i<r,a=o<r,c=a&&r-o<t,d=s&&r-i<t;return n.subdomain&&s&&!d?"expired":n.subdomain&&n.subdomain_expiration_policy===1?d?"in_grace_period":"active":c?"in_grace_period":a?"expired":"active"}var Xb="0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",Xc="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",eu={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Xc,custom:null,devnet:null,shelbynet:null,netna:null};function Me(n){let e=eu[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var _r=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function ba(n){let{aptosConfig:e,name:t}=n,r=Me(e),{domainName:i,subdomainName:o}=lt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=_r(s[0]);return a?u.from(a):void 0}async function wa(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,d=Me(e),{domainName:l,subdomainName:g}=lt(r),p=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(g&&!p)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(p&&!g)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let ee=t.years??1;if(ee!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ve=ee*31536e3,Li={function:`${d}::router::register_domain`,functionArguments:[l,Ve,o,s]};return{transaction:await A({aptosConfig:e,sender:u.from(i).toString(),data:Li,options:a}),data:Li}}if(!g)throw new Error(`${t.policy} requires a subdomain to be provided.`);let y=await Di({aptosConfig:e,name:l});if(!y)throw new Error("The domain does not exist");let h=t.policy==="subdomain:independent"?t.expirationDate:y;if(h>y)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");let k={function:`${d}::router::register_subdomain`,functionArguments:[l,g,Math.round(h/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]};return{transaction:await A({aptosConfig:e,sender:u.from(i).toString(),data:k,options:a}),data:k}}async function Di(n){let{aptosConfig:e,name:t}=n,r=Me(e),{domainName:i,subdomainName:o}=lt(t);try{let s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch{return}}async function Ta(n){let{aptosConfig:e,address:t}=n,r=Me(e),i=await ae({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(t).toString()]}}),o=_r(i[1]),s=_r(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Sa(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=Me(e);if(!r){let l={function:`${o}::router::clear_primary_name`,functionArguments:[]};return{transaction:await A({aptosConfig:e,sender:u.from(t).toString(),data:l,options:i}),data:l}}let{domainName:s,subdomainName:a}=lt(r),c={function:`${o}::router::set_primary_name`,functionArguments:[s,a]};return{transaction:await A({aptosConfig:e,sender:u.from(t).toString(),data:c,options:i}),data:c}}async function Pa(n){let{aptosConfig:e,name:t}=n,r=Me(e),{domainName:i,subdomainName:o}=lt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=_r(s[0]);return a?u.from(a):void 0}async function xa(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=Me(e),{domainName:a,subdomainName:c}=lt(r),d={function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]};return{transaction:await A({aptosConfig:e,sender:u.from(t).toString(),data:d,options:o}),data:d}}async function Ka(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=Me(e),{domainName:s,subdomainName:a}=lt(r),c={function:`${o}::router::clear_target_addr`,functionArguments:[s,a??null]};return{transaction:await A({aptosConfig:e,sender:u.from(t).toString(),data:c,options:i}),data:c}}async function Ia(n){let{aptosConfig:e,name:t}=n,r=await bn({aptosConfig:e}),{domainName:i,subdomainName:o=""}=lt(t),c=(await x({aptosConfig:e,query:{query:Yt,variables:{where_condition:{domain:{_eq:i},subdomain:{_eq:o}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return c?Gn({aptosConfig:e,name:c,gracePeriod:r}):void 0}async function Ea(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await bn({aptosConfig:e}),o=await Ua({aptosConfig:e}),s=await x({aptosConfig:e,originMethod:"getAccountNames",query:{query:Yt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},...n.options?.where??{}}}}}),a=s.current_aptos_names.map(d=>Gn({aptosConfig:e,name:d,gracePeriod:i})),c=s.current_aptos_names_aggregate.aggregate?.count??0;return{names:a,total:c}}async function Ca(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await bn({aptosConfig:e}),o=await Ua({aptosConfig:e}),s=await x({aptosConfig:e,originMethod:"getAccountDomains",query:{query:Yt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""},...n.options?.where??{}}}}}),a=s.current_aptos_names.map(d=>Gn({aptosConfig:e,name:d,gracePeriod:i})),c=s.current_aptos_names_aggregate.aggregate?.count??0;return{names:a,total:c}}async function va(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await bn({aptosConfig:e}),o=await x({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:Yt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{owner_address:{_eq:r.toString()},subdomain:{_neq:""},...n.options?.where??{}}}}}),s=o.current_aptos_names.map(c=>Gn({aptosConfig:e,name:c,gracePeriod:i})),a=o.current_aptos_names_aggregate.aggregate?.count??0;return{names:s,total:a}}async function _a(n){let{aptosConfig:e,options:t,domain:r}=n,i=await bn({aptosConfig:e}),o=await x({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:Yt,variables:{limit:t?.limit,offset:t?.offset,order_by:t?.orderBy,where_condition:{domain:{_eq:r},subdomain:{_neq:""},...n.options?.where??{}}}}}),s=o.current_aptos_names.map(c=>Gn({aptosConfig:e,name:c,gracePeriod:i})),a=o.current_aptos_names_aggregate.aggregate?.count??0;return{names:s,total:a}}async function Ua(n){let{aptosConfig:e}=n,r=await bn({aptosConfig:e})/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-r)).toISOString()}async function bn(n){if(Fi)return Fi;let{aptosConfig:e}=n,t=Me(e),[r]=await ae({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}});return Fi=r,r}async function ka(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=Me(e),a=i*31536e3,{domainName:c,subdomainName:d}=lt(r);if(d)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");let l={function:`${s}::router::renew_domain`,functionArguments:[c,a]};return{transaction:await A({aptosConfig:e,sender:u.from(t).toString(),data:l,options:o}),data:l}}function Gn({name:n,aptosConfig:e,gracePeriod:t}){let r=`${n.expiration_timestamp}Z`,i=`${n.domain_expiration_timestamp}Z`,o=!!n.subdomain,s=n.subdomain_expiration_policy,a=o&&s===1?i:r,c=Yc({aptosConfig:e,name:n,gracePeriod:t}),d=!1;if(c==="in_grace_period")d=!0;else if(c==="active"){let l=new Date;l.setMonth(l.getMonth()+Zc),d=new Date(a)<l}return{domain:n.domain,subdomain:n.subdomain||void 0,expiration_timestamp:r,expiration_status:c,domain_expiration_timestamp:i,expiration:new Date(a),token_standard:n.token_standard,is_primary:n.is_primary,subdomain_expiration_policy:n.subdomain_expiration_policy??1,owner_address:n.owner_address??"",registered_address:n.registered_address,isInRenewablePeriod:d}}var Vn=class{constructor(e){this.config=e}async getOwnerAddress(e){return ba({aptosConfig:this.config,...e})}async getExpiration(e){return Di({aptosConfig:this.config,...e})}async getTargetAddress(e){return Pa({aptosConfig:this.config,...e})}async setTargetAddress(e){return xa({aptosConfig:this.config,...e})}async clearTargetAddress(e){return Ka({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ta({aptosConfig:this.config,...e})}async setPrimaryName(e){return Sa({aptosConfig:this.config,...e})}async registerName(e){return wa({aptosConfig:this.config,...e})}async renewDomain(e){return ka({aptosConfig:this.config,...e})}async getName(e){return Ia({aptosConfig:this.config,...e})}async getAccountNames(e){return Ea({aptosConfig:this.config,...e})}async getAccountDomains(e){return Ca({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return va({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return _a({aptosConfig:this.config,...e})}};async function Fa(n){let{aptosConfig:e,poolAddress:t}=n,r=u.from(t).toStringLong(),o=await x({aptosConfig:e,query:{query:Qr,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 Da(n){let{aptosConfig:e,options:t}=n,r={query:Qr,variables:{order_by:t?.orderBy}};return(await x({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function za(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:Fo,variables:{delegatorAddress:u.from(t).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await x({aptosConfig:e,query:i})).delegated_staking_activities}var Hn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Fa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),Da({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await S({config:this.config,minimumLedgerVersion:e?.minimumLedgerVersion,processorType:"stake_processor"}),za({aptosConfig:this.config,...e})}};var Ur=class{constructor(e){this.config=e}async simple(e){return A({aptosConfig:this.config,...e})}async multiAgent(e){return A({aptosConfig:this.config,...e})}};var wn=class{constructor(e){this.config=e}async simple(e){return Pi({aptosConfig:this.config,...e})}async multiAgent(e){return Pi({aptosConfig:this.config,...e})}};Br([Yr],wn.prototype,"simple",1),Br([Yr],wn.prototype,"multiAgent",1);var kr=class{constructor(e){this.config=e}async simple(e){return Zr(this.config,e),Fn({aptosConfig:this.config,...e})}async multiAgent(e){return Zr(this.config,e),Fn({aptosConfig:this.config,...e})}};import nu from"eventemitter3";var Fr=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 Pn(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=He();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await Pn(this.sleepTime),He()-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 fn({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await fn({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 Pn(this.sleepTime);this.lock=!0;try{await this.update();let e=He();for(;this.lastUncommintedNumber!==this.currentNumber;)He()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await Pn(this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};import tu from"eventemitter3";var Na=1e4,Ra="fulfilled",Oa=(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Oa||{}),Dr=class extends tu{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new or;this.transactionsQueue=new or;this.outstandingTransactions=new or;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Fr(t,r,i,o,s)}addToTransactionHistory(t,r){if(t.push(r),t.length>Na){let i=Math.ceil(Na*.1);t.splice(0,i)}}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=Ir({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof Xr)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===Ra?(this.addToTransactionHistory(this.sentTransactions,[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.addToTransactionHistory(this.sentTransactions,[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 Xr)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(Xt({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===Ra?(this.addToTransactionHistory(this.executedTransactions,[a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.value.hash})):(this.addToTransactionHistory(this.executedTransactions,[a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return A({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r,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 zr=class extends nu{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new Dr(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 Ln=class{constructor(e){this.config=e,this.build=new Ur(this.config),this.simulate=new wn(this.config),this.submit=new kr(this.config),this.batch=new zr(this.config)}async getTransactions(e){return Ho({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return Lo({aptosConfig:this.config,...e})}async getTransactionByHash(e){return $o({aptosConfig:this.config,...e})}async isPendingTransaction(e){return qo({aptosConfig:this.config,...e})}async waitForTransaction(e){return Xt({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return ir({aptosConfig:this.config})}getSigningMessage(e){return hs(e)}async publishPackageTransaction(e){return ws({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Ds({aptosConfig:this.config,...e})}async rotateAuthKeyUnverified(e){return zs({aptosConfig:this.config,...e})}sign(e){return xr({...e})}signAsFeePayer(e){return Kr({...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 Ir({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return bs({aptosConfig:this.config,...e})}};import{jwtDecode as iu}from"jwt-decode";async function Nr(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:m.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await bo({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return m.fromHexInput(a.pepper).toUint8Array()}async function zi(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Nr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await yn({aptosConfig:e})).maxExpHorizonSecs}=n;if(m.fromHexInput(i).toUint8Array().length!==we.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${we.PEPPER_LENGTH} bytes`);let a=iu(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:m.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:m.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:d}=await wo({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=d.proof,g=new bt({a:l.a,b:l.b,c:l.c});return new ge({proof:new Tn(g,0),trainingWheelsSignature:Be.fromHex(d.training_wheels_signature),expHorizonSecs:s})}async function Ba(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Nr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await yn({aptosConfig:e}),d=zi({...n,pepper:s,maxExpHorizonSecs:c}),l=o?d:await d;if(r!==void 0){let y=M.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),h=await An({aptosConfig:e,authenticationKey:y.authKey().derivedAddress()});return _e.create({...n,address:h,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let g=C.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),p=await An({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return we.create({...n,address:p,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function Ma(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(yo.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}`,w.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${d}`})}let a=await s.json();return A({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,K.MoveString(a.keys.map(c=>c.kid)),K.MoveString(a.keys.map(c=>c.alg)),K.MoveString(a.keys.map(c=>c.e)),K.MoveString(a.keys.map(c=>c.n))]},options:i})}var $n=class{constructor(e){this.config=e}async getPepper(e){return Nr({aptosConfig:this.config,...e})}async getProof(e){return zi({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Ba({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return Ma({aptosConfig:this.config,...e})}};async function ou(n){let{aptosConfig:e,options:t}=n,r={query:tr,variables:{where_condition:t?.where,offset:t?.offset,limit:t?.limit,order_by:t?.orderBy}};return(await x({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function Ga(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:u.from(t).toStringLong()}};return(await ou({aptosConfig:e,options:{...r,where:o}}))[0]}var qn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await S({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),Ga({aptosConfig:this.config,...e})}};var X=class{constructor(e){this.config=e??new Jo,this.account=new Dn(this.config),this.abstraction=new zt(this.config),this.ans=new Vn(this.config),this.coin=new Nn(this.config),this.digitalAsset=new Rn(this.config),this.faucet=new On(this.config),this.fungibleAsset=new Bn(this.config),this.general=new Mn(this.config),this.staking=new Hn(this.config),this.transaction=new Ln(this.config),this.table=new ei(this.config),this.keyless=new $n(this.config),this.object=new qn(this.config)}setIgnoreTransactionSubmitter(e){this.config.setIgnoreTransactionSubmitter(e)}};function me(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&Object.defineProperty(n.prototype,r,{value(...o){return this[t][r](...o)},writable:i.writable,configurable:i.configurable,enumerable:i.enumerable})})}me(X,Dn,"account");me(X,zt,"abstraction");me(X,Vn,"ans");me(X,Nn,"coin");me(X,Rn,"digitalAsset");me(X,On,"faucet");me(X,Bn,"fungibleAsset");me(X,Mn,"general");me(X,Hn,"staking");me(X,Ln,"transaction");me(X,ei,"table");me(X,$n,"keyless");me(X,qn,"object");var uu=1e7,Ni=120,du=30,pu=330,lu=120,gu=350,yu=300,mu=93,Ge=class Ge extends Fe{constructor(e,t){super();let r=m.fromHexInput(t).toUint8Array();if(r.length!==Ge.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ge.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new te;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),ne.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Rr({...e,publicKey:this}),!0}catch(t){if(t instanceof w)return!1;throw t}}async verifySignatureAsync(e){return Vi({...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 Ge(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ge(t,r)}static isPublicKey(e){return e instanceof Ge}static create(e){return Va(e),new Ge(e.iss,Va(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=La(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 Ge.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}};Ge.ID_COMMITMENT_LENGTH=32;var C=Ge;async function Vi(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await yn({aptosConfig:e}),options:a}=n;try{if(!(i instanceof re))throw w.fromErrorType({type:26,details:"Not a keyless signature"});return Rr({message:r,publicKey:t,signature:i,jwk:o||await ni({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(a?.throwErrorWithReason)throw c;return!1}}function Rr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof re))throw w.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ge))throw w.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let d=r.ephemeralCertificate.signature;if(!(d.proof.proof instanceof bt))throw w.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=d.proof.proof;if(r.expiryDateSecs<He())throw w.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(d.expHorizonSecs>a)throw w.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw w.fromErrorType({type:29});let g=fu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:g,groth16Proof:l}))throw w.fromErrorType({type:32});if(c){if(!d.trainingWheelsSignature)throw w.fromErrorType({type:30});let p=new Oi(l,g);if(!c.verifySignature({message:p.hash(),signature:d.trainingWheelsSignature}))throw w.fromErrorType({type:31})}}function fu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof C?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ge))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Xn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Jt(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(De(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(De(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(De(" ",i.maxExtraFieldBytes))),a.push(De(`${cu(t.jwtHeader,!0)}.`,i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(De(s.overrideAudVal,Ni)),a.push(1n)):(a.push(De("",Ni)),a.push(0n)),Zt(a)}async function ni(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof C?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof M?t.jwkAddress:void 0;try{s=await bu({aptosConfig:e,jwkAddr:a})}catch(l){throw w.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw w.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let d=c.find(l=>l.kid===r);if(d===void 0)throw w.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return d}function Va(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Jt(m.fromHexInput(i).toUint8Array()),De(r,Ni),De(t,pu),De(e,du)];return Gr(Zt(o),C.ID_COMMITMENT_LENGTH)}var re=class n extends J{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 Tu(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=gn.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=At.deserialize(e),s=Be.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new gn(new ge({proof:new Tn(new bt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new At(new b(new Uint8Array(32))),ephemeralSignature:new Be(new v(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},gn=class n extends J{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();if(t===0)return new n(ge.deserialize(e),t);throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}},Wn=class Wn extends T{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new Wn(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}=ke.fields,i=r.create(Ri(e)),o=r.sqrt(r.add(r.pow(i,3n),Wn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return ke.G1.ProjectivePoint.fromAffine({x:i,y:a})}};Wn.B=ke.fields.Fp.create(3n);var gt=Wn;function Ri(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]&=63,au(e)}var jn=class jn extends T{constructor(e){if(super(),this.data=m.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new jn(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}=ke.fields,s=o.fromBigTuple([Ri(t),Ri(r)]),a=o.sqrt(o.add(o.pow(s,3n),jn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return ke.G2.ProjectivePoint.fromAffine({x:s,y:l})}};jn.B=ke.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var Nt=jn,bt=class n extends co{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new gt(t),this.b=new Nt(r),this.c=new gt(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=gt.deserialize(e).bcsToBytes(),r=Nt.deserialize(e).bcsToBytes(),i=gt.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()}}},Oi=class n extends T{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?Gr(r,32):m.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(bt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return Oe(this.bcsToBytes(),this.domainSeparator)}},Tn=class n extends T{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();if(t===0)return new n(bt.deserialize(e),t);throw new Error(`Unknown variant index for ZkProof: ${t}`)}},ge=class n extends J{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 F(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=Tn.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Be);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},Bi=class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=uu,maxExtraFieldBytes:o=gu,maxJwtHeaderB64Bytes:s=yu,maxIssValBytes:a=lu,maxCommitedEpkBytes:c=mu}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new At(new b(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new Mi({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})}},Mi=class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new gt(t),this.betaG2=new Nt(r),this.deltaG2=new Nt(i),this.gammaAbcG1=[new gt(o[0]),new gt(o[1])],this.gammaG2=new Nt(s)}hash(){let e=new te;return this.serialize(e),su.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(),l=this.deltaG2.toProjectivePoint(),g=this.gammaAbcG1.map(Ve=>Ve.toProjectivePoint()),{Fp12:p}=ke.fields,y=g[0].add(g[1].multiply(t)),h=ke.pairing(y,d),k=ke.pairing(i,o),q=ke.pairing(a,c),ee=ke.pairing(s,l),fe=p.mul(q,p.mul(h,ee));return p.eql(k,fe)}catch(i){throw w.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 yn(n){let{aptosConfig:e}=n;try{return await $e(async()=>{let[t,r]=await Promise.all([Au(n),hu(n)]);return Bi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof w?t:w.fromErrorType({type:25,error:t})}}function ut(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=La(e)}catch{throw w.fromErrorType({type:12,details:"Invalid JWT format"})}if(typeof r.iss!="string")throw w.fromErrorType({type:12,details:"Invalid JWT: missing required claim"});if(typeof r.aud!="string")throw w.fromErrorType({type:12,details:"Invalid JWT: missing or malformed required claim"});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function Au(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await yt({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw w.fromErrorType({type:22,error:i})}}async function hu(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await yt({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${u.from("0x1").toString()}/resource/${r}`,params:{ledger_version:t?.ledgerVersion}});return i.data}catch(i){throw w.fromErrorType({type:23,error:i})}}async function bu(n){let{aptosConfig:e,jwkAddr:t,options:r,useCache:i=!0}=n,o=t?u.from(t).toString():"0x1",s=`keyless-jwks-${e.network}-${o}`;return i&&!r?.ledgerVersion?$e(async()=>Ha({aptosConfig:e,jwkAddr:t,options:r}),s,1e3*60*5)():Ha({aptosConfig:e,jwkAddr:t,options:r})}async function Ha(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await yt({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${u.from(t).toString()}/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await yt({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:r?.ledgerVersion}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:d}=c.variant,l=new F(m.fromHexInput(d).toUint8Array()),g=Gi.deserialize(l);a.push(g)}o.set(qi(s.issuer),a)}return o}var Gi=class n extends T{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 F(m.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw w.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=oo(this.n),r=wu(e.reverse()).map(i=>Jt(i));return r.push(256n),Zt(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 wu(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 Tu(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw w.fromErrorType({type:12,details:"Invalid JWT header: missing required field"});return e}catch(e){throw e instanceof w?e:w.fromErrorType({type:12,details:"Invalid JWT header format"})}}var M=class n extends Fe{constructor(e,t){super(),this.jwkAddress=u.from(e),this.keylessPublicKey=t}authKey(){let e=new te;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),ne.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return Rr({...e,publicKey:this}),!0}catch{return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=u.deserialize(e),r=C.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Vi({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,C.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,C.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof u&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof C}};var tn=n=>typeof n=="string"?m.isValid(n).valid?n:new TextEncoder().encode(n):n,Ki=n=>{if(n instanceof b||n instanceof I||n instanceof Z||n instanceof G)return n;if(n instanceof C||n instanceof M)return new I(n);throw new Error(`Unknown account public key: ${n}`)},Ts=n=>{let e=Ki(n);if(e instanceof b)return 0;if(e instanceof I)return 2;if(e instanceof Z)return 1;if(e instanceof G)return 3;throw new Error(`Unknown signing scheme: ${e}`)};var Hi=[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 Su(n){let e=n.toUint8Array().slice(32);for(let t=Hi.length-1;t>=0;t-=1){if(e[t]<Hi[t])return!0;if(e[t]>Hi[t])return!1}return!1}var wt=class wt extends Fe{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==wt.LENGTH)throw new Error(`PublicKey length should be ${wt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!Su(r))return!1;let i=tn(t),o=m.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return Or.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return ne.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 wt(t)}static isPublicKey(e){return e instanceof wt}static isInstance(e){return"key"in e&&e.key?.data?.length===wt.LENGTH}};wt.LENGTH=32;var b=wt,Se=class Se extends T{constructor(t,r){super();this.cleared=!1;let i=Qt.parseHexInput(t,"ed25519",r);if(i.toUint8Array().length!==Se.LENGTH)throw new Error(`PrivateKey length should be ${Se.LENGTH}`);this.signingKey=i}static generate(){let t=Or.utils.randomPrivateKey();return new Se(t,!1)}static fromDerivationPath(t,r){if(!Xi(t))throw new Error(`Invalid derivation path ${t}`);return Se.fromDerivationPathInner(t,Jn(r))}static fromDerivationPathInner(t,r,i=Zi){let{key:o,chainCode:s}=eo(Se.SLIP_0010_SEED,r),a=no(t).map(d=>parseInt(d,10)),{key:c}=a.reduce((d,l)=>to(d,l+i),{key:o,chainCode:s});return new Se(c,!1)}ensureNotCleared(){if(this.cleared)throw new Error("Private key has been cleared from memory and can no longer be used")}clear(){if(!this.cleared){let t=this.signingKey.toUint8Array();crypto.getRandomValues(t),t.fill(255),crypto.getRandomValues(t),t.fill(0),this.cleared=!0}}isCleared(){return this.cleared}publicKey(){this.ensureNotCleared();let t=Or.getPublicKey(this.signingKey.toUint8Array());return new b(t)}sign(t){this.ensureNotCleared();let r=tn(t),i=m.fromHexInput(r).toUint8Array(),o=Or.sign(i,this.signingKey.toUint8Array());return new v(o)}toUint8Array(){return this.ensureNotCleared(),this.signingKey.toUint8Array()}toString(){return this.ensureNotCleared(),this.toAIP80String()}toHexString(){return this.ensureNotCleared(),this.signingKey.toString()}toAIP80String(){return this.ensureNotCleared(),Qt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(t){t.serializeBytes(this.toUint8Array())}static deserialize(t){let r=t.deserializeBytes();return new Se(r,!1)}static isPrivateKey(t){return t instanceof Se}};Se.LENGTH=32,Se.SLIP_0010_SEED="ed25519 seed";var L=Se,Sn=class Sn extends J{constructor(e){super();let t=m.fromHexInput(e);if(t.toUint8Array().length!==Sn.LENGTH)throw new Error(`Signature length should be ${Sn.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 Sn(t)}};Sn.LENGTH=64;var v=Sn;var At=class n extends Qn{constructor(e){super();let t=e.constructor.name;if(t===b.name)this.publicKey=e,this.variant=0;else 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 b)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return new n(b.deserialize(e));throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}static isPublicKey(e){return e instanceof n}},Be=class n extends J{constructor(e){super();let t=e.constructor.name;if(t===v.name)this.signature=e;else throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}static fromHex(e){let t=m.fromHexInput(e),r=new F(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof v)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();if(t===0)return new n(v.deserialize(e));throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}};export{At as a,Be as b,uu as c,Ni as d,du as e,pu as f,lu as g,gu as h,yu as i,mu as j,C as k,Vi as l,Rr as m,ni as n,re as o,gn as p,bt as q,Oi as r,Tn as s,ge as t,Bi as u,Mi as v,yn as w,ut as x,bu as y,Gi as z,Tu as A,M as B,Ke as C,qe as D,We as E,I as F,N as G,Ie as H,G as I,he as J,Z as K,Ee as L,tn as M,Ki as N,Ts as O,Su as P,b as Q,L as R,v as S,Id as T,Ed as U,W as V,Ce as W,je as X,ie as Y,Ne as Z,nn as _,St as $,ur as aa,Kn as ba,_ as ca,V as da,oe as ea,Qe as fa,Je as ga,Ze as ha,Ye as ia,Xe as ja,j as ka,et as la,tt as ma,nt as na,rt as oa,it as pa,R as qa,Pt as ra,dr as sa,O as ta,U as ua,f as va,Re as wa,Tp as xa,E as ya,Sp as za,le as Aa,ja as Ba,mt as Ca,rn as Da,on as Ea,sn as Fa,ot as Ga,an as Ha,In as Ia,En as Ja,pr as Ka,xt as La,cn as Ma,Cn as Na,un as Oa,vn as Pa,lr as Qa,Kt as Ra,be as Sa,gr as Ta,It as Ua,Et as Va,st as Wa,Ct as Xa,dn as Ya,vt as Za,_t as _a,ft as $a,at as ab,yr as bb,mr as cb,fr as db,Oe as eb,zl as fb,ve as gb,Y as hb,ti as ib,se as jb,ct as kb,Ut as lb,hr as mb,ye as nb,Ar as ob,we as pb,_e as qb,dt as rb,_n as sb,Xo as tb,ns as ub,br as vb,is as wb,cc as xb,$ as yb,Ue as zb,as as Ab,pt as Bb,uc as Cb,kt as Db,Ft as Eb,cs as Fb,us as Gb,ii as Hb,wr as Ib,oi as Jb,dc as Kb,si as Lb,ai as Mb,ci as Nb,ui as Ob,di as Pb,pi as Qb,li as Rb,gi as Sb,yi as Tb,mi as Ub,fi as Vb,Ai as Wb,ds as Xb,P as Yb,ps as Zb,Tr as _b,gc as $b,bi as ac,Hm as bc,ls as cc,gs as dc,wi as ec,Dt as fc,Pr as gc,fc as hc,ys as ic,Ac as jc,bc as kc,wc as lc,Ti as mc,ms as nc,mn as oc,Si as pc,fs as qc,hf as rc,A as sc,Pc as tc,xc as uc,hs as vc,xr as wc,Kr as xc,Pi as yc,Fn as zc,Ir as Ac,bs as Bc,ws as Cc,fn as Dc,Ss as Ec,Ps as Fc,Sr as Gc,Ii as Hc,Ei as Ic,xs as Jc,Ci as Kc,An as Lc,Ks as Mc,Is as Nc,Es as Oc,Cs as Pc,vs as Qc,zA as Rc,vi as Sc,_s as Tc,Us as Uc,_i as Vc,ks as Wc,NA as Xc,Ds as Yc,zs as Zc,Cr as _c,Ui as $c,ae as ad,Ns as bd,Rs as cd,Os as dd,Bs as ed,zt as fd,Dn as gd,Ms as hd,Nn as id,Gs as jd,Vs as kd,Hs as ld,Ls as md,$s as nd,hn as od,qs as pd,Ws as qd,js as rd,Qs as sd,Js as td,Zs as ud,Ys as vd,Xs as wd,ea as xd,ta as yd,na as zd,ra as Ad,ia as Bd,oa as Cd,sa as Dd,aa as Ed,ca as Fd,ua as Gd,Rn as Hd,pa as Id,On as Jd,vr as Kd,la as Ld,ga as Md,ma as Nd,fa as Od,Bn as Pd,Mn as Qd,Aa as Rd,ha as Sd,lt as Td,Yc as Ud,Xb as Vd,Xc as Wd,ba as Xd,wa as Yd,Di as Zd,Ta as _d,Sa as $d,Pa as ae,xa as be,Ka as ce,Ia as de,Ea as ee,Ca as fe,va as ge,_a as he,bn as ie,ka as je,Vn as ke,Fa as le,Da as me,za as ne,Hn as oe,Ur as pe,wn as qe,kr as re,Fr as se,Ra as te,Oa as ue,Dr as ve,zr as we,Ln as xe,Nr as ye,zi as ze,Ba as Ae,Ma as Be,$n as Ce,ou as De,Ga as Ee,qn as Fe,X as Ge};
|
|
4
|
+
//# sourceMappingURL=chunk-GWM3VCT4.mjs.map
|