@aptos-labs/ts-sdk 1.13.1-zeta.5 → 1.13.2
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/index.d.ts +1399 -1821
- package/dist/common/index.js +26 -26
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-8gJF5t3F.d.mts → Ed25519Account--qjfup2u.d.mts} +12 -10
- package/dist/esm/api/account.d.mts +1 -13
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +2 -2
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +8 -14
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.d.mts +0 -20
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.d.mts +7 -7
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +5 -5
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +7 -7
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +8 -13
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.d.mts +2 -2
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +8 -8
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +1 -1
- 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 +6 -6
- package/dist/esm/api/transactionSubmission/simulate.mjs +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/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.d.mts +0 -2
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-MRTAMMS3.mjs → chunk-2PFN7LYP.mjs} +2 -2
- package/dist/esm/chunk-3426VLAZ.mjs +2 -0
- package/dist/esm/chunk-3426VLAZ.mjs.map +1 -0
- package/dist/esm/{chunk-PTIZKRON.mjs → chunk-3HV2C4SS.mjs} +2 -2
- package/dist/esm/chunk-3OCTOB2E.mjs +2 -0
- package/dist/esm/chunk-3OCTOB2E.mjs.map +1 -0
- package/dist/esm/{chunk-QJHFD2MT.mjs → chunk-3QBZU5ZD.mjs} +2 -2
- package/dist/esm/chunk-3QBZU5ZD.mjs.map +1 -0
- package/dist/esm/{chunk-GUWBE3CV.mjs → chunk-3RUY5FQK.mjs} +2 -2
- package/dist/esm/chunk-3RUY5FQK.mjs.map +1 -0
- package/dist/esm/{chunk-OJ4NIVFW.mjs → chunk-4DNVCOW7.mjs} +2 -2
- package/dist/esm/chunk-4DNVCOW7.mjs.map +1 -0
- package/dist/esm/{chunk-FFVWTX36.mjs → chunk-4LMAVPA4.mjs} +2 -2
- package/dist/esm/{chunk-TVRJ3M7B.mjs → chunk-52C73T26.mjs} +2 -2
- package/dist/esm/{chunk-TVRJ3M7B.mjs.map → chunk-52C73T26.mjs.map} +1 -1
- package/dist/esm/chunk-5HALZ6JC.mjs +2 -0
- package/dist/esm/chunk-5HALZ6JC.mjs.map +1 -0
- package/dist/esm/chunk-5OM4V4DR.mjs +2 -0
- package/dist/esm/chunk-5TMLAKSH.mjs +2 -0
- package/dist/esm/chunk-5TMLAKSH.mjs.map +1 -0
- package/dist/esm/{chunk-NCIRQZOJ.mjs → chunk-6IGEUEER.mjs} +2 -2
- package/dist/esm/{chunk-IGJCOZGO.mjs → chunk-6MG4JAYB.mjs} +2 -2
- package/dist/esm/{chunk-FYJMB23M.mjs → chunk-A556OVZY.mjs} +2 -2
- package/dist/esm/chunk-B252RJCU.mjs +2 -0
- package/dist/esm/{chunk-HTSXKHXX.mjs.map → chunk-B252RJCU.mjs.map} +1 -1
- package/dist/esm/{chunk-7PICPK26.mjs → chunk-BAV4XY7C.mjs} +2 -2
- package/dist/esm/{chunk-HGXO74Q3.mjs → chunk-BBU2EE6D.mjs} +2 -2
- package/dist/esm/{chunk-D4QQKQXJ.mjs → chunk-BRQYARQ3.mjs} +2 -2
- package/dist/esm/{chunk-MWUJCP27.mjs → chunk-BWFJHFBQ.mjs} +2 -2
- package/dist/esm/chunk-CYNQRMO5.mjs +2 -0
- package/dist/esm/chunk-CYNQRMO5.mjs.map +1 -0
- package/dist/esm/{chunk-3VGX3TXH.mjs → chunk-DMKUAQB7.mjs} +2 -2
- package/dist/esm/{chunk-MGOHPDX4.mjs → chunk-DSTKXJMA.mjs} +2 -2
- package/dist/esm/chunk-E7FWVXGX.mjs +1 -0
- package/dist/esm/{chunk-W3UCKFFU.mjs → chunk-EJCKCYYI.mjs} +2 -2
- package/dist/esm/chunk-FO6ZKE7A.mjs +2 -0
- package/dist/esm/chunk-FO6ZKE7A.mjs.map +1 -0
- package/dist/esm/{chunk-EB7AI4B4.mjs → chunk-FS3NSGBF.mjs} +2 -2
- package/dist/esm/{chunk-JTCWZB3Q.mjs → chunk-FXNFWLQC.mjs} +2 -2
- package/dist/esm/chunk-GED6IT3S.mjs +1 -0
- package/dist/esm/chunk-GMQQSSEO.mjs +2 -0
- package/dist/esm/chunk-GMQQSSEO.mjs.map +1 -0
- package/dist/esm/chunk-GNQXMS53.mjs +2 -0
- package/dist/esm/chunk-GNQXMS53.mjs.map +1 -0
- package/dist/esm/{chunk-AZABJ5QQ.mjs → chunk-GRT5PHL6.mjs} +2 -2
- package/dist/esm/{chunk-DORK55K3.mjs → chunk-GS5J57UA.mjs} +2 -2
- package/dist/esm/chunk-GS5J57UA.mjs.map +1 -0
- package/dist/esm/{chunk-3HL2ZWKG.mjs → chunk-GXYS45Y5.mjs} +2 -2
- package/dist/esm/chunk-HLVMEUWD.mjs +2 -0
- package/dist/esm/chunk-HLVMEUWD.mjs.map +1 -0
- package/dist/esm/chunk-HQSLBTW5.mjs +2 -0
- package/dist/esm/chunk-HQSLBTW5.mjs.map +1 -0
- package/dist/esm/{chunk-T23OVRNF.mjs → chunk-IOSQVDZI.mjs} +2 -2
- package/dist/esm/chunk-IZT6OX3R.mjs +2 -0
- package/dist/esm/{chunk-GHVMDDWO.mjs.map → chunk-IZT6OX3R.mjs.map} +1 -1
- package/dist/esm/{chunk-VLUJRHOL.mjs → chunk-KDCHX7BI.mjs} +2 -2
- package/dist/esm/chunk-KHOHRD2B.mjs +2 -0
- package/dist/esm/chunk-KHOHRD2B.mjs.map +1 -0
- package/dist/esm/chunk-L6PGWGFF.mjs +2 -0
- package/dist/esm/chunk-LR65XHSF.mjs +2 -0
- package/dist/esm/chunk-LR65XHSF.mjs.map +1 -0
- package/dist/esm/{chunk-H5YTHO4L.mjs → chunk-LV2V23Z6.mjs} +2 -2
- package/dist/esm/chunk-LV2V23Z6.mjs.map +1 -0
- package/dist/esm/chunk-MLWIHWNH.mjs +1 -0
- package/dist/esm/chunk-MNBYKY5P.mjs +2 -0
- package/dist/esm/{chunk-FJH4H4E5.mjs.map → chunk-MNBYKY5P.mjs.map} +1 -1
- package/dist/esm/{chunk-7STYQ5ZE.mjs → chunk-NPFNYP75.mjs} +2 -2
- package/dist/esm/{chunk-UT37XKQU.mjs → chunk-OGHE4AQA.mjs} +2 -2
- package/dist/esm/chunk-OVJQWQ2N.mjs +2 -0
- package/dist/esm/chunk-OVJQWQ2N.mjs.map +1 -0
- package/dist/esm/chunk-OWW6SIDP.mjs +2 -0
- package/dist/esm/chunk-OWW6SIDP.mjs.map +1 -0
- package/dist/esm/{chunk-FVU47J7S.mjs → chunk-PIOHC246.mjs} +2 -2
- package/dist/esm/chunk-PIOHC246.mjs.map +1 -0
- package/dist/esm/{chunk-QI2ILOP4.mjs → chunk-PJLCPRYJ.mjs} +2 -2
- package/dist/esm/{chunk-6RBUXB5I.mjs → chunk-QIAHBEEW.mjs} +2 -2
- package/dist/esm/{chunk-NC5HHEEM.mjs → chunk-QTRYMRYK.mjs} +2 -2
- package/dist/esm/{chunk-Q5T2WL2M.mjs → chunk-QWRH22H4.mjs} +2 -2
- package/dist/esm/{chunk-STYDBDYL.mjs → chunk-R5QUBEH6.mjs} +2 -2
- package/dist/esm/chunk-R7G3CLRI.mjs +1 -0
- package/dist/esm/{chunk-ZNEBMSNC.mjs → chunk-RHBCVCOS.mjs} +2 -2
- package/dist/esm/chunk-ROXFCLDT.mjs +2 -0
- package/dist/esm/chunk-ROXFCLDT.mjs.map +1 -0
- package/dist/esm/{chunk-LJ624HBI.mjs → chunk-RQEWIZ67.mjs} +2 -2
- package/dist/esm/{chunk-3FVRXELT.mjs → chunk-TBMAJ6AW.mjs} +2 -2
- package/dist/esm/{chunk-ZGTJMNZG.mjs → chunk-TC3VVMPY.mjs} +2 -2
- package/dist/esm/{chunk-YQOKWIVY.mjs → chunk-TGG7SWBO.mjs} +2 -2
- package/dist/esm/chunk-TGG7SWBO.mjs.map +1 -0
- package/dist/esm/{chunk-FEWIHUNW.mjs → chunk-TGXZVNR5.mjs} +2 -2
- package/dist/esm/{chunk-TTELTGMA.mjs → chunk-TORRTLWV.mjs} +2 -2
- package/dist/esm/chunk-TORRTLWV.mjs.map +1 -0
- package/dist/esm/chunk-TQR7M73S.mjs +2 -0
- package/dist/esm/chunk-TQR7M73S.mjs.map +1 -0
- package/dist/esm/{chunk-PFFAQZHT.mjs → chunk-U43IJHQN.mjs} +2 -2
- package/dist/esm/{chunk-GOT527V2.mjs → chunk-UMFJDDYI.mjs} +2 -2
- package/dist/esm/chunk-UMFJDDYI.mjs.map +1 -0
- package/dist/esm/{chunk-HGZGTBA4.mjs → chunk-UML2VQZT.mjs} +2 -2
- package/dist/esm/{chunk-47DNXBM6.mjs → chunk-UPIN5AIO.mjs} +2 -2
- package/dist/esm/chunk-UVSRX4SV.mjs +1 -0
- package/dist/esm/chunk-VNO4VHJN.mjs +2 -0
- package/dist/esm/chunk-VNO4VHJN.mjs.map +1 -0
- package/dist/esm/chunk-WBOLHLPX.mjs +2 -0
- package/dist/esm/chunk-WBOLHLPX.mjs.map +1 -0
- package/dist/esm/{chunk-COW5IGYC.mjs → chunk-WFZDFFBM.mjs} +2 -2
- package/dist/esm/chunk-XDGQTMDV.mjs +2 -0
- package/dist/esm/chunk-XDGQTMDV.mjs.map +1 -0
- package/dist/esm/{chunk-XHPLLMR5.mjs → chunk-XLPVG4XR.mjs} +2 -2
- package/dist/esm/{chunk-YQUZLZL4.mjs → chunk-YBEF3UR3.mjs} +2 -2
- package/dist/esm/{chunk-4MHEB5MN.mjs → chunk-YKVKSNH4.mjs} +2 -2
- package/dist/esm/chunk-YVSU6GOA.mjs +2 -0
- package/dist/esm/chunk-YVSU6GOA.mjs.map +1 -0
- package/dist/esm/{chunk-C3L4ETUF.mjs → chunk-ZYYK3UXP.mjs} +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.d.mts +1 -2
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +2 -2
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.d.mts +1 -3
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/Account.d.mts +20 -0
- package/dist/esm/core/account/Account.mjs +2 -0
- package/dist/esm/core/account/Ed25519Account.d.mts +20 -0
- package/dist/esm/core/account/Ed25519Account.mjs +2 -0
- package/dist/esm/core/account/SingleKeyAccount.d.mts +20 -0
- package/dist/esm/core/account/SingleKeyAccount.mjs +2 -0
- package/dist/esm/core/account/index.d.mts +14 -5
- package/dist/esm/core/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +10 -0
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/hdKey.d.mts +1 -15
- package/dist/esm/core/crypto/hdKey.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +5 -7
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +3 -4
- package/dist/esm/core/crypto/multiKey.mjs +1 -1
- package/dist/esm/core/crypto/publicKey.mjs +1 -1
- package/dist/esm/core/crypto/secp256k1.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.d.mts +7 -6
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/index.d.mts +10 -15
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +2 -14
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.d.mts +7 -7
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.d.mts +1 -1
- package/dist/esm/internal/event.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 +5 -5
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.d.mts +7 -7
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.d.mts +4 -3
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.d.mts +2 -2
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +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.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +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 +1 -13
- 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 +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.d.mts +9 -9
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.d.mts +6 -6
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +25 -13
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +6 -6
- package/dist/esm/types/index.d.mts +3 -17
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/utils/apiEndpoints.d.mts +1 -3
- package/dist/esm/utils/apiEndpoints.mjs +1 -1
- package/dist/esm/utils/const.d.mts +1 -3
- package/dist/esm/utils/const.mjs +1 -1
- package/dist/esm/utils/index.d.mts +10 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.d.mts +23 -0
- package/dist/esm/utils/normalizeBundle.mjs +2 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +3 -8
- package/src/api/account.ts +1 -2
- package/src/api/ans.ts +1 -2
- package/src/api/aptos.ts +0 -6
- package/src/api/aptosConfig.ts +1 -46
- package/src/api/digitalAsset.ts +1 -2
- package/src/api/fungibleAsset.ts +1 -2
- package/src/api/transaction.ts +1 -2
- package/src/api/transactionSubmission/management.ts +1 -1
- package/src/api/transactionSubmission/sign.ts +1 -1
- package/src/bcs/serializer.ts +0 -18
- package/src/client/core.ts +0 -8
- package/src/client/get.ts +0 -6
- package/src/client/post.ts +0 -12
- package/src/{account → core/account}/Account.ts +16 -12
- package/src/{account → core/account}/Ed25519Account.ts +7 -13
- package/src/{account → core/account}/SingleKeyAccount.ts +8 -13
- package/src/core/account/index.ts +3 -1
- package/src/core/crypto/ed25519.ts +24 -4
- package/src/core/crypto/hdKey.ts +0 -31
- package/src/core/crypto/index.ts +0 -2
- package/src/core/crypto/multiKey.ts +11 -21
- package/src/core/crypto/singleKey.ts +0 -11
- package/src/core/index.ts +1 -0
- package/src/index.ts +0 -1
- package/src/internal/account.ts +1 -1
- package/src/internal/ans.ts +1 -2
- package/src/internal/digitalAsset.ts +1 -2
- package/src/internal/fungibleAsset.ts +1 -2
- package/src/internal/transactionSubmission.ts +7 -8
- package/src/transactions/authenticator/account.ts +11 -6
- package/src/transactions/management/accountSequenceNumber.ts +1 -1
- package/src/transactions/management/transactionWorker.ts +2 -8
- package/src/transactions/transactionBuilder/index.ts +0 -1
- package/src/transactions/transactionBuilder/transactionBuilder.ts +103 -76
- package/src/types/index.ts +0 -19
- package/src/utils/apiEndpoints.ts +0 -14
- package/src/utils/const.ts +0 -2
- package/src/utils/index.ts +1 -0
- package/src/utils/normalizeBundle.ts +21 -0
- package/src/version.ts +1 -1
- package/dist/esm/account/Account.d.mts +0 -34
- package/dist/esm/account/Account.mjs +0 -2
- package/dist/esm/account/Ed25519Account.d.mts +0 -34
- package/dist/esm/account/Ed25519Account.mjs +0 -2
- package/dist/esm/account/EphemeralKeyPair.d.mts +0 -46
- package/dist/esm/account/EphemeralKeyPair.mjs +0 -2
- package/dist/esm/account/KeylessAccount.d.mts +0 -87
- package/dist/esm/account/KeylessAccount.mjs +0 -2
- package/dist/esm/account/MultiKeyAccount.d.mts +0 -99
- package/dist/esm/account/MultiKeyAccount.mjs +0 -2
- package/dist/esm/account/SingleKeyAccount.d.mts +0 -34
- package/dist/esm/account/SingleKeyAccount.mjs +0 -2
- package/dist/esm/account/index.d.mts +0 -39
- package/dist/esm/account/index.mjs +0 -2
- package/dist/esm/api/keyless.d.mts +0 -65
- package/dist/esm/api/keyless.mjs +0 -2
- package/dist/esm/chunk-4MS27RPK.mjs +0 -2
- package/dist/esm/chunk-4VAQCOR6.mjs +0 -2
- package/dist/esm/chunk-4VAQCOR6.mjs.map +0 -1
- package/dist/esm/chunk-5VSMDXZ6.mjs +0 -2
- package/dist/esm/chunk-5VSMDXZ6.mjs.map +0 -1
- package/dist/esm/chunk-6GQAHQGW.mjs +0 -2
- package/dist/esm/chunk-6GQAHQGW.mjs.map +0 -1
- package/dist/esm/chunk-6M6XXPQQ.mjs +0 -2
- package/dist/esm/chunk-6M6XXPQQ.mjs.map +0 -1
- package/dist/esm/chunk-7JNPSNL6.mjs +0 -2
- package/dist/esm/chunk-7JNPSNL6.mjs.map +0 -1
- package/dist/esm/chunk-7QFBF7FS.mjs +0 -2
- package/dist/esm/chunk-7QFBF7FS.mjs.map +0 -1
- package/dist/esm/chunk-7Z6DYLCA.mjs +0 -1
- package/dist/esm/chunk-AQ4I7VVB.mjs +0 -1
- package/dist/esm/chunk-AQ4I7VVB.mjs.map +0 -1
- package/dist/esm/chunk-C3AEWQ3A.mjs +0 -2
- package/dist/esm/chunk-C3AEWQ3A.mjs.map +0 -1
- package/dist/esm/chunk-CYDWEPFL.mjs +0 -1
- package/dist/esm/chunk-CYDWEPFL.mjs.map +0 -1
- package/dist/esm/chunk-D73X3S27.mjs +0 -2
- package/dist/esm/chunk-D73X3S27.mjs.map +0 -1
- package/dist/esm/chunk-DORK55K3.mjs.map +0 -1
- package/dist/esm/chunk-E7HMV2GZ.mjs +0 -2
- package/dist/esm/chunk-E7HMV2GZ.mjs.map +0 -1
- package/dist/esm/chunk-FJH4H4E5.mjs +0 -2
- package/dist/esm/chunk-FLYEALDB.mjs +0 -2
- package/dist/esm/chunk-FLYEALDB.mjs.map +0 -1
- package/dist/esm/chunk-FTWBJZYH.mjs +0 -2
- package/dist/esm/chunk-FTWBJZYH.mjs.map +0 -1
- package/dist/esm/chunk-FVU47J7S.mjs.map +0 -1
- package/dist/esm/chunk-GHVMDDWO.mjs +0 -2
- package/dist/esm/chunk-GOT527V2.mjs.map +0 -1
- package/dist/esm/chunk-GUWBE3CV.mjs.map +0 -1
- package/dist/esm/chunk-H5YTHO4L.mjs.map +0 -1
- package/dist/esm/chunk-HTSXKHXX.mjs +0 -2
- package/dist/esm/chunk-IPH435RF.mjs +0 -2
- package/dist/esm/chunk-IPH435RF.mjs.map +0 -1
- package/dist/esm/chunk-JXCZTOYC.mjs +0 -1
- package/dist/esm/chunk-JXCZTOYC.mjs.map +0 -1
- package/dist/esm/chunk-KGJITNRZ.mjs +0 -2
- package/dist/esm/chunk-KGJITNRZ.mjs.map +0 -1
- package/dist/esm/chunk-KY3SB7JG.mjs +0 -2
- package/dist/esm/chunk-KY3SB7JG.mjs.map +0 -1
- package/dist/esm/chunk-L3OMI2PE.mjs +0 -2
- package/dist/esm/chunk-L3OMI2PE.mjs.map +0 -1
- package/dist/esm/chunk-LX2KX36Q.mjs +0 -2
- package/dist/esm/chunk-LX2KX36Q.mjs.map +0 -1
- package/dist/esm/chunk-MIMIRNUQ.mjs +0 -2
- package/dist/esm/chunk-MIMIRNUQ.mjs.map +0 -1
- package/dist/esm/chunk-MO5LGCZV.mjs +0 -2
- package/dist/esm/chunk-MO5LGCZV.mjs.map +0 -1
- package/dist/esm/chunk-MQ32XR4V.mjs +0 -2
- package/dist/esm/chunk-MQ32XR4V.mjs.map +0 -1
- package/dist/esm/chunk-OJ4NIVFW.mjs.map +0 -1
- package/dist/esm/chunk-OKRUEVF3.mjs +0 -2
- package/dist/esm/chunk-OKRUEVF3.mjs.map +0 -1
- package/dist/esm/chunk-OPCSBCGS.mjs +0 -2
- package/dist/esm/chunk-OPCSBCGS.mjs.map +0 -1
- package/dist/esm/chunk-PKENQYTQ.mjs +0 -2
- package/dist/esm/chunk-QJHFD2MT.mjs.map +0 -1
- package/dist/esm/chunk-R7BAM2G6.mjs +0 -2
- package/dist/esm/chunk-R7BAM2G6.mjs.map +0 -1
- package/dist/esm/chunk-RFSO3JRG.mjs +0 -1
- package/dist/esm/chunk-RFSO3JRG.mjs.map +0 -1
- package/dist/esm/chunk-RQ6M2YQF.mjs +0 -2
- package/dist/esm/chunk-RQ6M2YQF.mjs.map +0 -1
- package/dist/esm/chunk-S5HG2QUD.mjs +0 -2
- package/dist/esm/chunk-S5HG2QUD.mjs.map +0 -1
- package/dist/esm/chunk-T7XMSCZV.mjs +0 -2
- package/dist/esm/chunk-T7XMSCZV.mjs.map +0 -1
- package/dist/esm/chunk-TTELTGMA.mjs.map +0 -1
- package/dist/esm/chunk-WPVBC4JS.mjs +0 -2
- package/dist/esm/chunk-WPVBC4JS.mjs.map +0 -1
- package/dist/esm/chunk-WTVN3XGK.mjs +0 -2
- package/dist/esm/chunk-WTVN3XGK.mjs.map +0 -1
- package/dist/esm/chunk-YE5B2S5L.mjs +0 -2
- package/dist/esm/chunk-YE5B2S5L.mjs.map +0 -1
- package/dist/esm/chunk-YQOKWIVY.mjs.map +0 -1
- package/dist/esm/core/crypto/ephemeral.d.mts +0 -77
- package/dist/esm/core/crypto/ephemeral.mjs +0 -2
- package/dist/esm/core/crypto/ephemeral.mjs.map +0 -1
- package/dist/esm/core/crypto/keyless.d.mts +0 -217
- package/dist/esm/core/crypto/keyless.mjs +0 -2
- package/dist/esm/core/crypto/keyless.mjs.map +0 -1
- package/dist/esm/core/crypto/poseidon.d.mts +0 -7
- package/dist/esm/core/crypto/poseidon.mjs +0 -2
- package/dist/esm/core/crypto/poseidon.mjs.map +0 -1
- package/dist/esm/internal/keyless.d.mts +0 -65
- package/dist/esm/internal/keyless.mjs +0 -2
- package/dist/esm/internal/keyless.mjs.map +0 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.d.mts +0 -47
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +0 -2
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs.map +0 -1
- package/dist/esm/types/keyless.d.mts +0 -14
- package/dist/esm/types/keyless.mjs +0 -1
- package/dist/esm/types/keyless.mjs.map +0 -1
- package/src/account/EphemeralKeyPair.ts +0 -115
- package/src/account/KeylessAccount.ts +0 -240
- package/src/account/MultiKeyAccount.ts +0 -119
- package/src/account/index.ts +0 -6
- package/src/api/keyless.ts +0 -34
- package/src/core/crypto/ephemeral.ts +0 -149
- package/src/core/crypto/keyless.ts +0 -508
- package/src/core/crypto/poseidon.ts +0 -134
- package/src/internal/keyless.ts +0 -185
- package/src/transactions/transactionBuilder/signingMessage.ts +0 -70
- package/src/types/keyless.ts +0 -6
- /package/dist/esm/{chunk-MRTAMMS3.mjs.map → chunk-2PFN7LYP.mjs.map} +0 -0
- /package/dist/esm/{chunk-PTIZKRON.mjs.map → chunk-3HV2C4SS.mjs.map} +0 -0
- /package/dist/esm/{chunk-FFVWTX36.mjs.map → chunk-4LMAVPA4.mjs.map} +0 -0
- /package/dist/esm/{chunk-PKENQYTQ.mjs.map → chunk-5OM4V4DR.mjs.map} +0 -0
- /package/dist/esm/{chunk-NCIRQZOJ.mjs.map → chunk-6IGEUEER.mjs.map} +0 -0
- /package/dist/esm/{chunk-IGJCOZGO.mjs.map → chunk-6MG4JAYB.mjs.map} +0 -0
- /package/dist/esm/{chunk-FYJMB23M.mjs.map → chunk-A556OVZY.mjs.map} +0 -0
- /package/dist/esm/{chunk-7PICPK26.mjs.map → chunk-BAV4XY7C.mjs.map} +0 -0
- /package/dist/esm/{chunk-HGXO74Q3.mjs.map → chunk-BBU2EE6D.mjs.map} +0 -0
- /package/dist/esm/{chunk-D4QQKQXJ.mjs.map → chunk-BRQYARQ3.mjs.map} +0 -0
- /package/dist/esm/{chunk-MWUJCP27.mjs.map → chunk-BWFJHFBQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-3VGX3TXH.mjs.map → chunk-DMKUAQB7.mjs.map} +0 -0
- /package/dist/esm/{chunk-MGOHPDX4.mjs.map → chunk-DSTKXJMA.mjs.map} +0 -0
- /package/dist/esm/{account/Account.mjs.map → chunk-E7FWVXGX.mjs.map} +0 -0
- /package/dist/esm/{chunk-W3UCKFFU.mjs.map → chunk-EJCKCYYI.mjs.map} +0 -0
- /package/dist/esm/{chunk-EB7AI4B4.mjs.map → chunk-FS3NSGBF.mjs.map} +0 -0
- /package/dist/esm/{chunk-JTCWZB3Q.mjs.map → chunk-FXNFWLQC.mjs.map} +0 -0
- /package/dist/esm/{account/Ed25519Account.mjs.map → chunk-GED6IT3S.mjs.map} +0 -0
- /package/dist/esm/{chunk-AZABJ5QQ.mjs.map → chunk-GRT5PHL6.mjs.map} +0 -0
- /package/dist/esm/{chunk-3HL2ZWKG.mjs.map → chunk-GXYS45Y5.mjs.map} +0 -0
- /package/dist/esm/{chunk-T23OVRNF.mjs.map → chunk-IOSQVDZI.mjs.map} +0 -0
- /package/dist/esm/{chunk-VLUJRHOL.mjs.map → chunk-KDCHX7BI.mjs.map} +0 -0
- /package/dist/esm/{chunk-4MS27RPK.mjs.map → chunk-L6PGWGFF.mjs.map} +0 -0
- /package/dist/esm/{account/EphemeralKeyPair.mjs.map → chunk-MLWIHWNH.mjs.map} +0 -0
- /package/dist/esm/{chunk-7STYQ5ZE.mjs.map → chunk-NPFNYP75.mjs.map} +0 -0
- /package/dist/esm/{chunk-UT37XKQU.mjs.map → chunk-OGHE4AQA.mjs.map} +0 -0
- /package/dist/esm/{chunk-QI2ILOP4.mjs.map → chunk-PJLCPRYJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-6RBUXB5I.mjs.map → chunk-QIAHBEEW.mjs.map} +0 -0
- /package/dist/esm/{chunk-NC5HHEEM.mjs.map → chunk-QTRYMRYK.mjs.map} +0 -0
- /package/dist/esm/{chunk-Q5T2WL2M.mjs.map → chunk-QWRH22H4.mjs.map} +0 -0
- /package/dist/esm/{chunk-STYDBDYL.mjs.map → chunk-R5QUBEH6.mjs.map} +0 -0
- /package/dist/esm/{account/KeylessAccount.mjs.map → chunk-R7G3CLRI.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZNEBMSNC.mjs.map → chunk-RHBCVCOS.mjs.map} +0 -0
- /package/dist/esm/{chunk-LJ624HBI.mjs.map → chunk-RQEWIZ67.mjs.map} +0 -0
- /package/dist/esm/{chunk-3FVRXELT.mjs.map → chunk-TBMAJ6AW.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZGTJMNZG.mjs.map → chunk-TC3VVMPY.mjs.map} +0 -0
- /package/dist/esm/{chunk-FEWIHUNW.mjs.map → chunk-TGXZVNR5.mjs.map} +0 -0
- /package/dist/esm/{chunk-PFFAQZHT.mjs.map → chunk-U43IJHQN.mjs.map} +0 -0
- /package/dist/esm/{chunk-HGZGTBA4.mjs.map → chunk-UML2VQZT.mjs.map} +0 -0
- /package/dist/esm/{chunk-47DNXBM6.mjs.map → chunk-UPIN5AIO.mjs.map} +0 -0
- /package/dist/esm/{account/MultiKeyAccount.mjs.map → chunk-UVSRX4SV.mjs.map} +0 -0
- /package/dist/esm/{chunk-COW5IGYC.mjs.map → chunk-WFZDFFBM.mjs.map} +0 -0
- /package/dist/esm/{chunk-XHPLLMR5.mjs.map → chunk-XLPVG4XR.mjs.map} +0 -0
- /package/dist/esm/{chunk-YQUZLZL4.mjs.map → chunk-YBEF3UR3.mjs.map} +0 -0
- /package/dist/esm/{chunk-4MHEB5MN.mjs.map → chunk-YKVKSNH4.mjs.map} +0 -0
- /package/dist/esm/{chunk-C3L4ETUF.mjs.map → chunk-ZYYK3UXP.mjs.map} +0 -0
- /package/dist/esm/{account/SingleKeyAccount.mjs.map → core/account/Account.mjs.map} +0 -0
- /package/dist/esm/{account/index.mjs.map → core/account/Ed25519Account.mjs.map} +0 -0
- /package/dist/esm/{api/keyless.mjs.map → core/account/SingleKeyAccount.mjs.map} +0 -0
- /package/dist/esm/{chunk-7Z6DYLCA.mjs.map → utils/normalizeBundle.mjs.map} +0 -0
package/dist/common/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkKSEUZTKYjs = require('./chunk-KSEUZTKY.js');var fn=255,An=65535,Se=4294967295,Ve=18446744073709551615n,Nt=340282366920938463463374607431768211455n,hn=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var Re=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<Se;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>Se)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<e;i+=1)r.push(this.deserialize(t));return r}};var _utils = require('@noble/hashes/utils');var H=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var Bs=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(Bs||{}),l= exports.Hex =class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new H("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new H("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, e))}catch(r){throw new H(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _4 => _4.message])}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,r)=>e===t.data[r])}};var d=class{bcsToBytes(){let t=new R;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return l.fromHexInput(t)}},R= exports.Serializer =class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,r){this.ensureBufferWillHandleSize(e);let i=new DataView(this.buffer,this.offset);t.apply(i,[0,r,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){pr(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(Se),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&Ve,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&Nt,r=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(r)}serializeU32AsUleb128(t){let e=t,r=[];for(;e>>>7;)r.push(e&127|128),e>>>=7;r.push(e),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}serializeOption(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),t.serialize(this))}serializeOptionStr(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(t))}};_chunkKSEUZTKYjs.a.call(void 0, [He(0,fn)],R.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [He(0,An)],R.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [He(0,Se)],R.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [He(BigInt(0),Ve)],R.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [He(BigInt(0),Nt)],R.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [He(BigInt(0),hn)],R.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [He(0,Se)],R.prototype,"serializeU32AsUleb128",1);function pr(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var Os=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function ze(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(Os(n,t,e))}function He(n,t){return(e,r,i)=>{let o=i.value;return i.value=function(a){return ze(a,n,t),o.apply(this,[a])},i}}var Le=class n extends d{constructor(e){super();this.value=l.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let i=e.deserializeFixedBytes(r);return new n(i)}};var Tn=class n extends d{constructor(e){super();this.value=new Le(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let i=Le.deserialize(e,r);return new n(i.value)}};var bn=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(bn||{}),ti= exports.TypeTagVariants =(g=>(g[g.Bool=0]="Bool",g[g.U8=1]="U8",g[g.U64=2]="U64",g[g.U128=3]="U128",g[g.Address=4]="Address",g[g.Signer=5]="Signer",g[g.Vector=6]="Vector",g[g.Struct=7]="Struct",g[g.U16=8]="U16",g[g.U32=9]="U32",g[g.U256=10]="U256",g[g.Reference=254]="Reference",g[g.Generic=255]="Generic",g))(ti||{}),Gt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Gt||{}),ni= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(ni||{}),ri= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(ri||{}),ii= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(ii||{}),oi= exports.AccountAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(oi||{}),dr= exports.AnyPublicKeyVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(dr||{}),si= exports.AnySignatureVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(si||{}),lr= exports.EphemeralPublicKeyVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(lr||{}),ai= exports.EphemeralSignatureVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(ai||{}),ci= exports.EphemeralCertificate =(e=>(e[e.ZkProof=0]="ZkProof",e[e.OpenIdSignature=1]="OpenIdSignature",e))(ci||{}),gr= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(gr||{});function eu(n){return n.type==="pending_transaction"}function tu(n){return n.type==="user_transaction"}function nu(n){return n.type==="genesis_transaction"}function ru(n){return n.type==="block_metadata_transaction"}function iu(n){return n.type==="state_checkpoint_transaction"}function ou(n){return n.type==="validator_transaction"}function su(n){return"signature"in n&&n.signature==="ed25519_signature"}function au(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function cu(n){return n.type==="multi_agent_signature"}function uu(n){return n.type==="fee_payer_signature"}function pu(n){return n.type==="multi_ed25519_signature"}var Ks=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(Ks||{}),ui= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(ui||{}),Ns= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(Ns||{}),ge= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(ge||{}),wn= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(wn||{}),Gs= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(Gs||{});var z=class n extends d{constructor(e){super();pr(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},N= exports.U8 =class n extends d{constructor(e){super();ze(e,0,fn),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},se= exports.U16 =class n extends d{constructor(e){super();ze(e,0,An),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},ae= exports.U32 =class n extends d{constructor(e){super();ze(e,0,Se),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},K= exports.U64 =class n extends d{constructor(e){super();ze(e,BigInt(0),Ve),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ce= exports.U128 =class n extends d{constructor(e){super();ze(e,BigInt(0),Nt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},ue= exports.U256 =class n extends d{constructor(e){super();ze(e,BigInt(0),hn),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super();this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(!(this.values[0]instanceof N)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let i=l.fromHexInput(e);r=Array.from(i.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(i=>new N(i)))}static U16(e){return new n(e.map(r=>new se(r)))}static U32(e){return new n(e.map(r=>new ae(r)))}static U64(e){return new n(e.map(r=>new K(r)))}static U128(e){return new n(e.map(r=>new ce(r)))}static U256(e){return new n(e.map(r=>new ue(r)))}static Bool(e){return new n(e.map(r=>new z(r)))}static MoveString(e){return new n(e.map(r=>new w(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1)o.push(r.deserialize(e));return new n(o)}},w= exports.MoveString =class n extends d{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=this.bcsToBytes().slice(1);T.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},ke= exports.MoveOption =class n extends d{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new T([e]):this.vec=new T([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new N(e):void 0)}static U16(e){return new n(e!=null?new se(e):void 0)}static U32(e){return new n(e!=null?new ae(e):void 0)}static U64(e){return new n(e!=null?new K(e):void 0)}static U128(e){return new n(e!=null?new ce(e):void 0)}static U256(e){return new n(e!=null?new ue(e):void 0)}static Bool(e){return new n(e!=null?new z(e):void 0)}static MoveString(e){return new n(e!=null?new w(e):void 0)}static deserialize(e,r){let i=T.deserialize(e,r);return new n(i.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ms=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(Ms||{}),S=class S extends d{constructor(e){super();if(e.length!==S.LENGTH)throw new H("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(S.LENGTH);return new S(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new H("Hex string must start with a leading 0x.","leading_zero_x_required");let r=S.fromString(e);if(e.length!==S.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new H(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new H(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e){let r=e;if(e.startsWith("0x")&&(r=e.slice(2)),r.length===0)throw new H("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new H("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let i;try{i=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(o){throw new H(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}return new S(i)}static from(e){return e instanceof S?e:e instanceof Uint8Array?new S(e):S.fromString(e)}static fromStrict(e){return e instanceof S?e:e instanceof Uint8Array?new S(e):S.fromStringStrict(e)}static isValid(e){try{return e.strict?S.fromStrict(e.input):S.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,i)=>r===e.data[i])}};S.LENGTH=32,S.LONG_STRING_LENGTH=64,S.ZERO=S.from("0x0"),S.ONE=S.from("0x1"),S.TWO=S.from("0x2"),S.THREE=S.from("0x3"),S.FOUR=S.from("0x4");var u=S;var De=class De extends d{constructor(e){super();let{data:r}=e,i=l.fromHexInput(r);if(i.toUint8Array().length!==De.LENGTH)throw new Error(`Authentication Key length should be ${De.LENGTH}`);this.data=i}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(De.LENGTH);return new De({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:r,input:i}=e,o=l.fromHexInput(i).toUint8Array(),s=new Uint8Array([...o,r]),a=_sha3.sha3_256.create();a.update(s);let c=a.digest();return new De({data:c})}static fromPublicKeyAndScheme(e){let{publicKey:r}=e;return r.authKey()}static fromPublicKey(e){let{publicKey:r}=e;return r.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};De.LENGTH=32;var G=De;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var di = _interopRequireWildcard(_bip39);var Hs=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ls= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,li= exports.APTOS_BIP44_DEFAULT_DERIVATION_PATH ="m/44'/637'/0'/0'/0'",Qs= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(Qs||{}),yr= exports.HARDENED_OFFSET =2147483648;function mr(n){return Ls.test(n)}function fr(n){return Hs.test(n)}var gi=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},Ws= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return gi(t,s)},js=n=>n.replace("'",""),Xs= exports.splitPath =n=>n.split("/").slice(1).map(js);function Sn(n,t,e,r=yr){if(r===yr&&!fr(n))throw new Error(`Invalid hardened derivation path ${n}`);if(r!==yr&&!mr(n))throw new Error(`Invalid derivation path ${n}`);let{key:i,chainCode:o}=gi(t,e),s=Xs(n).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Ws(c,p+r),{key:i,chainCode:o});return a}var xn=n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return di.mnemonicToSeedSync(t)};var Qe=class extends d{toString(){let t=this.toUint8Array();return l.fromHexInput(t).toString()}},ee= exports.AccountPublicKey =class extends Qe{};var B=class extends d{toString(){let t=this.toUint8Array();return l.fromHexInput(t).toString()}};var ct=n=>typeof n=="string"?l.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var yi=[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],We=class We extends ee{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==We.LENGTH)throw new Error(`PublicKey length should be ${We.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof P))return!1;let o=ct(r),s=l.fromHexInput(o).toUint8Array(),a=i.toUint8Array(),c=this.key.toUint8Array();return i.isCanonicalSignature()?_ed25519.ed25519.verify(a,s,c):!1}authKey(){return G.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new We(r)}static isPublicKey(e){return e instanceof We}};We.LENGTH=32;var v=We,pe=class pe extends d{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==pe.LENGTH)throw new Error(`PrivateKey length should be ${pe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new pe(e)}static fromDerivationPath(e,r){if(!fr(e))throw new Error(`Invalid derivation path ${e}`);return new pe(Sn(e,pe.SLIP_0010_SEED,xn(r)))}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new v(e)}sign(e){let r=ct(e),i=l.fromHexInput(r).toUint8Array(),o=_ed25519.ed25519.sign(i,this.signingKey.toUint8Array());return new P(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new pe(r)}static isPrivateKey(e){return e instanceof pe}};pe.LENGTH=32,pe.SLIP_0010_SEED="ed25519 seed";var q=pe,ut=class ut extends B{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==ut.LENGTH)throw new Error(`Signature length should be ${ut.LENGTH}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ut(r)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let r=e.length-1;r>=0;r-=1){if(e[r]<yi[r])return!0;if(e[r]>yi[r])return!1}return!1}};ut.LENGTH=64;var P=ut;var te=class te extends ee{constructor(e){super();let{publicKeys:r,threshold:i}=e;if(r.length>te.MAX_KEYS||r.length<te.MIN_KEYS)throw new Error(`Must have between ${te.MIN_KEYS} and ${te.MAX_KEYS} public keys, inclusive`);if(i<te.MIN_THRESHOLD||i>r.length)throw new Error(`Threshold must be between ${te.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=i}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof je))return!1;let o=[];for(let s=0;s<4;s+=1)for(let a=0;a<8;a+=1)if((i.bitmap[s]&1<<7-a)!==0){let p=s*8+a;o.push(p)}if(o.length!==i.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let s=0;s<o.length;s+=1)if(!this.publicKeys[o[s]].verifySignature({message:r,signature:i.signatures[s]}))return!1;return!0}authKey(){return G.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*v.LENGTH+1);return this.publicKeys.forEach((r,i)=>{e.set(r.toUint8Array(),i*v.LENGTH)}),e[this.publicKeys.length*v.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=v.LENGTH){let a=s;o.push(new v(r.subarray(a,a+v.LENGTH)))}return new te({publicKeys:o,threshold:i})}};te.MAX_KEYS=32,te.MIN_KEYS=2,te.MIN_THRESHOLD=1;var pt=te,Q=class Q extends B{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>Q.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${Q.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r,!(i instanceof Uint8Array))this.bitmap=Q.createBitmap({bits:i});else{if(i.length!==Q.BITMAP_LEN)throw new Error(`"bitmap" length should be ${Q.BITMAP_LEN}`);this.bitmap=i}}toUint8Array(){let e=new Uint8Array(this.signatures.length*P.LENGTH+Q.BITMAP_LEN);return this.signatures.forEach((r,i)=>{e.set(r.toUint8Array(),i*P.LENGTH)}),e.set(this.bitmap,this.signatures.length*P.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r.subarray(r.length-4),o=[];for(let s=0;s<r.length-i.length;s+=P.LENGTH){let a=s;o.push(new P(r.subarray(a,a+P.LENGTH)))}return new Q({signatures:o,bitmap:i})}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(a>=Q.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${Q.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");if(c>0&&a<=r[c-1])throw new Error("The bits need to be sorted in ascending order.");s.add(a);let p=Math.floor(a/8),y=o[p];y|=i>>a%8,o[p]=y}),o}};Q.MAX_SIGNATURES_SUPPORTED=32,Q.BITMAP_LEN=4;var je=Q;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Xe=class Xe extends Qe{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==Xe.LENGTH)throw new Error(`PublicKey length should be ${Xe.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof Je))return!1;let o=ct(r),s=l.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Xe(r)}static isPublicKey(e){return e instanceof Xe}};Xe.LENGTH=65;var Ye=Xe,ye=class ye extends d{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==ye.LENGTH)throw new Error(`PrivateKey length should be ${ye.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ye(e)}static fromDerivationPath(e,r){if(!mr(e))throw new Error(`Invalid derivation path ${e}`);return ye.fromDerivationPathInner(e,xn(r))}static fromDerivationPathInner(e,r){let{privateKey:i}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(i===null)throw new Error("Invalid key");return new ye(i)}sign(e){let r=ct(e),i=l.fromHexInput(r),o=_sha3.sha3_256.call(void 0, i.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new Je(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new Ye(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ye(r)}static isPrivateKey(e){return e instanceof ye}};ye.LENGTH=32;var Ze=ye,dt=class dt extends B{constructor(e){super();let r=l.fromHexInput(e);if(r.toUint8Array().length!==dt.LENGTH)throw new Error(`Signature length should be ${dt.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new dt(r)}};dt.LENGTH=64;var Je=dt;var et=class n extends Qe{constructor(e){super();let r=e.constructor.name;switch(r){case v.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${r}`)}}toUint8Array(){return this.bcsToBytes()}toString(){return this.bcsToHex().toString()}verifySignature(e){let{message:r,signature:i}=e;return this.publicKey.verifySignature({message:r,signature:i})}serialize(e){if(this.publicKey instanceof v)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(v.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof v}},de= exports.EphemeralSignature =class n extends B{constructor(e){super();let r=e.constructor.name;switch(r){case P.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${r}`)}}toUint8Array(){return this.signature.toUint8Array()}toString(){return this.signature.toString()}static fromHex(e){let r=l.fromHexInput(e),i=new Re(r.toUint8Array());return n.deserialize(i)}serialize(e){if(this.signature instanceof P)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${r}`)}}};var _poseidonlite = require('poseidon-lite');var ya=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],Ai=31,ma=16,fi=(ma-1)*Ai;function Pn(n,t){let r=new TextEncoder().encode(n);return fa(r,t)}function fa(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);let e=Ar(n,t);return Mt(e)}function Aa(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);let e=ba(n,t);return ha(e)}function Ar(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return Aa(n,t).concat([BigInt(n.length)])}function ha(n){if(n.length>fi)throw new Error(`Can't pack more than ${fi}. Was given ${n.length} bytes`);return Ta(n,Ai).map(t=>Ft(t))}function Ta(n,t){let e=[];for(let r=0;r<n.length;r+=t)e.push(n.subarray(r,r+t));return e}function Ft(n){let t=BigInt(0);for(let e=n.length-1;e>=0;e-=1)t=t<<BigInt(8)|BigInt(n[e]);return t}function hi(n,t){let e=new Uint8Array(t);for(let r=0;r<t;r+=1)e[r]=Number(n&BigInt(255)),n>>=BigInt(8);return e}function ba(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let e=new Uint8Array(t);e.set(n);for(let r=n.length;r<t;r+=1)e[r]=0;return e}function Mt(n){let t=ya[n.length-1];if(t)return t(n);throw new Error(`Unable to hash input of length ${n.length}`)}var qt=1e7,wa= exports.MAX_AUD_VAL_BYTES =120,Sa= exports.MAX_UID_KEY_BYTES =30,xa= exports.MAX_UID_VAL_BYTES =330,ud= exports.MAX_ISS_VAL_BYTES =120,pd= exports.MAX_EXTRA_FIELD_BYTES =350,dd= exports.MAX_JWT_HEADER_B64_BYTES =300,ld= exports.MAX_COMMITED_EPK_BYTES =93,xe=class xe extends ee{constructor(e,r){super();let i=l.fromHexInput(r).toUint8Array();if(i.length!==xe.ADDRESS_SEED_LENGTH)throw new Error(`Address seed length in bytes should be ${xe.ADDRESS_SEED_LENGTH}`);this.iss=e,this.addressSeed=i}authKey(){let e=new R;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),G.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return l.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){return!0}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.addressSeed)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new xe(r,i)}static load(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new xe(r,i)}static isPublicKey(e){return e instanceof xe}static create(e){return En(e),new xe(e.iss,En(e))}};xe.ADDRESS_SEED_LENGTH=32;var Be=xe;function En(n){let{uidKey:t,uidVal:e,aud:r,pepper:i}=n,o=[Ft(l.fromHexInput(i).toUint8Array()),Pn(r,wa),Pn(e,xa),Pn(t,Sa)];return hi(Mt(o),Be.ADDRESS_SEED_LENGTH)}var tt=class n extends B{constructor(e){super();this.signature=e}toUint8Array(){return this.signature.toUint8Array()}toString(){return this.signature.toString()}serialize(e){if(this.signature instanceof gt)e.serializeU32AsUleb128(1),this.signature.serialize(e);else if(this.signature instanceof Oe)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Not a valid OIDB signature")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(Oe.load(e));case 1:return new n(gt.load(e));default:throw new Error(`Unknown variant index for EphemeralCertificate: ${r}`)}}},lt= exports.Groth16Zkp =class n extends d{constructor(e){super();let{a:r,b:i,c:o}=e;this.a=l.fromHexInput(r).toUint8Array(),this.b=l.fromHexInput(i).toUint8Array(),this.c=l.fromHexInput(o).toUint8Array()}toUint8Array(){let e=new R;return this.serialize(e),e.toUint8Array()}serialize(e){e.serializeU32AsUleb128(0),e.serializeFixedBytes(this.a),e.serializeFixedBytes(this.b),e.serializeFixedBytes(this.c)}static deserialize(e){e.deserializeUleb128AsU32();let r=e.deserializeFixedBytes(32),i=e.deserializeFixedBytes(64),o=e.deserializeFixedBytes(32);return new n({a:r,b:i,c:o})}},Oe= exports.SignedGroth16Signature =class n extends B{constructor(e){super();let{proof:r,expHorizonSecs:i=BigInt(qt),trainingWheelsSignature:o,extraField:s,overrideAudVal:a}=e;this.proof=r,this.expHorizonSecs=i,this.trainingWheelsSignature=o,this.extraField=s,this.overrideAudVal=a}toUint8Array(){let e=new R;return this.serialize(e),e.toUint8Array()}toString(){return this.toString()}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let r=lt.deserialize(e),i=e.deserializeU64(),s=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,c=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,[p]=e.deserializeVector(de);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:p,extraField:s,overrideAudVal:c})}static load(e){let r=lt.deserialize(e),i=e.deserializeU64(),s=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,c=e.deserializeUleb128AsU32()?e.deserializeStr():void 0,[p]=e.deserializeVector(de);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:p,extraField:s,overrideAudVal:c})}},gt= exports.OpenIdSignature =class n extends B{constructor(e){super();let{jwtSignature:r,uidKey:i,jwtPayloadJson:o,epkBlinder:s,pepper:a,overrideAudValue:c}=e;this.jwtSignature=r,this.jwtPayloadJson=o,this.uidKey=_nullishCoalesce(i, () => ("sub")),this.epkBlinder=s,this.pepper=a,this.overrideAudValue=c}toUint8Array(){return this.epkBlinder}toString(){return this.toString()}serialize(e){e.serializeStr(this.jwtSignature),e.serializeStr(this.jwtPayloadJson),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.epkBlinder),e.serializeFixedBytes(this.pepper),e.serializeOptionStr(this.overrideAudValue)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeFixedBytes(31),a=e.deserializeFixedBytes(31),p=e.deserializeUleb128AsU32()?e.deserializeStr():void 0;return new n({jwtSignature:r,jwtPayloadJson:i,uidKey:o,epkBlinder:s,pepper:a,overrideAudValue:p})}static load(e){let r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeFixedBytes(31),a=e.deserializeFixedBytes(31),p=e.deserializeUleb128AsU32()?e.deserializeStr():void 0;return new n({jwtSignature:r,jwtPayloadJson:i,uidKey:o,epkBlinder:s,pepper:a,overrideAudValue:p})}static isSignature(e){return e instanceof n}},Ke= exports.KeylessSignature =class n extends B{constructor(e){super();let{jwtHeader:r,openIdSignatureOrZkProof:i,expiryDateSecs:o,ephemeralPublicKey:s,ephemeralSignature:a}=e;this.jwtHeader=r,this.openIdSignatureOrZkProof=i,this.expiryDateSecs=o,this.ephemeralPublicKey=s,this.ephemeralSignature=a}toUint8Array(){return this.ephemeralSignature.toUint8Array()}toString(){return this.toString()}serialize(e){this.openIdSignatureOrZkProof.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let r=tt.deserialize(e),i=e.deserializeStr(),o=e.deserializeU64(),s=et.deserialize(e),a=de.deserialize(e);return new n({jwtHeader:i,expiryDateSecs:o,openIdSignatureOrZkProof:r,ephemeralPublicKey:s,ephemeralSignature:a})}static load(e){let r=e.deserializeStr(),i=e.deserializeU64(),o=tt.deserialize(e),s=et.deserialize(e),a=de.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:i,openIdSignatureOrZkProof:o,ephemeralPublicKey:s,ephemeralSignature:a})}static isSignature(e){return e instanceof n}};var O=class n extends ee{constructor(e){super();if(this.publicKey=e,e instanceof v)this.variant=0;else if(e instanceof Ye)this.variant=1;else if(e instanceof Be)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:i}=e;return i instanceof $?this.publicKey.verifySignature({message:r,signature:i.signature}):!1}authKey(){return G.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=v.deserialize(e);break;case 1:i=Ye.deserialize(e);break;case 3:i=Be.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new n(i)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof v}isSecp256k1PublicKey(){return this.publicKey instanceof Ye}},$= exports.AnySignature =class n extends B{constructor(e){super();if(this.signature=e,e instanceof P)this.variant=0;else if(e instanceof Je)this.variant=1;else if(e instanceof Ke)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=P.deserialize(e);break;case 1:i=Je.deserialize(e);break;case 3:i=Ke.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(i)}};function Ti(n){let t=n;return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}var yt=class n extends ee{constructor(e){super();let{publicKeys:r,signaturesRequired:i}=e;if(i<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<i)throw new Error(`Provided ${r.length} public keys is smaller than the ${i} required signatures`);this.publicKeys=r.map(o=>o instanceof O?o:new O(o)),this.signaturesRequired=i}verifySignature(e){throw new Error("not implemented")}authKey(){return G.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(O),i=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:i})}createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(c+1>this.publicKeys.length)throw new Error(`Signature index ${c+1} is out of public keys range, ${this.publicKeys.length}.`);if(s.has(a))throw new Error(`Duplicate bit ${a} detected.`);s.add(a);let p=Math.floor(a/8),y=o[p];y|=i>>a%8,o[p]=y}),o}getIndex(e){let r=e instanceof O?e:new O(e),i=this.publicKeys.findIndex(o=>o.toString()===r.toString());if(i!==-1)return i;throw new Error("Public key not found in MultiKey")}},W=class W extends B{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>W.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${W.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(s=>s instanceof $?s:new $(s)),!(i instanceof Uint8Array))this.bitmap=W.createBitmap({bits:i});else{if(i.length!==W.BITMAP_LEN)throw new Error(`"bitmap" length should be ${W.BITMAP_LEN}`);this.bitmap=i}let o=this.bitmap.reduce((s,a)=>s+Ti(a),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach(a=>{if(a>=W.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${W.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");s.add(a);let c=Math.floor(a/8),p=o[c];p|=i>>a%8,o[c]=p}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeBytes(),i=r.reduce((s,a)=>s+Ti(a),0),o=[];for(let s=0;s<i;s+=1){let a=$.deserialize(e);o.push(a)}return new W({signatures:o,bitmap:r})}};W.BITMAP_LEN=4,W.MAX_SIGNATURES_SUPPORTED=W.BITMAP_LEN*8;var nt=W;var j=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return me.load(t);case 1:return Cn.load(t);case 2:return ne.load(t);case 3:return Ne.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof me}isMultiEd25519(){return this instanceof Cn}isSingleKey(){return this instanceof ne}isMultiKey(){return this instanceof Ne}},me= exports.AccountAuthenticatorEd25519 =class n extends j{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=v.deserialize(e),i=P.deserialize(e);return new n(r,i)}},Cn= exports.AccountAuthenticatorMultiEd25519 =class n extends j{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=pt.deserialize(e),i=je.deserialize(e);return new n(r,i)}},ne= exports.AccountAuthenticatorSingleKey =class n extends j{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=O.deserialize(e),i=$.deserialize(e);return new n(r,i)}},Ne= exports.AccountAuthenticatorMultiKey =class n extends j{constructor(e,r){super();this.public_keys=e,this.signatures=r}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let r=yt.deserialize(e),i=nt.deserialize(e);return new n(r,i)}};var $t=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))($t||{}),bi= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,wi= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,In= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Un= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Si= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",xi= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",mt= exports.ProcessorType =(a=>(a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a))(mt||{});var ft=class n extends d{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new n(r)}};var U=class n extends d{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new n(r)}};var Vt=class n extends d{constructor(e,r){super();this.address=e,this.name=r}static fromStr(e){let r=e.split("::");if(r.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(r[0]),new U(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),i=U.deserialize(e);return new n(r,i)}};var k=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return F.load(t);case 1:return fe.load(t);case 2:return L.load(t);case 3:return Tt.load(t);case 4:return X.load(t);case 5:return rt.load(t);case 6:return E.load(t);case 7:return m.load(t);case 8:return At.load(t);case 9:return ht.load(t);case 10:return bt.load(t);case 255:return D.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof F}isAddress(){return this instanceof X}isGeneric(){return this instanceof D}isSigner(){return this instanceof rt}isVector(){return this instanceof E}isStruct(){return this instanceof m}isU8(){return this instanceof fe}isU16(){return this instanceof At}isU32(){return this instanceof ht}isU64(){return this instanceof L}isU128(){return this instanceof Tt}isU256(){return this instanceof bt}},F= exports.TypeTagBool =class n extends k{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},fe= exports.TypeTagU8 =class n extends k{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},At= exports.TypeTagU16 =class n extends k{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},ht= exports.TypeTagU32 =class n extends k{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},L= exports.TypeTagU64 =class n extends k{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},Tt= exports.TypeTagU128 =class n extends k{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},bt= exports.TypeTagU256 =class n extends k{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},X= exports.TypeTagAddress =class n extends k{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},rt= exports.TypeTagSigner =class n extends k{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},Rn= exports.TypeTagReference =class n extends k{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=k.deserialize(e);return new n(r)}},D= exports.TypeTagGeneric =class n extends k{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let r=e.deserializeU32();return new n(r)}},E= exports.TypeTagVector =class n extends k{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new fe)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=k.deserialize(e);return new n(r)}},m= exports.TypeTagStruct =class n extends k{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let r=_e.deserialize(e);return new n(r)}isTypeTag(e,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(e)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},_e= exports.StructTag =class n extends d{constructor(e,r,i,o){super();this.address=e,this.moduleName=r,this.name=i,this.typeArgs=o}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let r=u.deserialize(e),i=U.deserialize(e),o=U.deserialize(e),s=e.deserializeVector(k);return new n(r,i,o,s)}};function Sl(){return new _e(u.ONE,new U("aptos_coin"),new U("AptosCoin"),[])}function _(){return new _e(u.ONE,new U("string"),new U("String"),[])}function xl(n){return new _e(u.ONE,new U("option"),new U("Option"),[n])}function Y(n){return new _e(u.ONE,new U("object"),new U("Object"),[n])}function _a(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return N.deserialize(n);case 1:return K.deserialize(n);case 2:return ce.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,N);case 5:return z.deserialize(n);case 6:return se.deserialize(n);case 7:return ae.deserialize(n);case 8:return ue.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var it=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ht.load(t);case 2:return Lt.load(t);case 3:return Qt.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Ht= exports.TransactionPayloadScript =class n extends it{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=Wt.deserialize(e);return new n(r)}},Lt= exports.TransactionPayloadEntryFunction =class n extends it{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=ot.deserialize(e);return new n(r)}},Qt= exports.TransactionPayloadMultiSig =class n extends it{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=jt.deserialize(e);return new n(r)}},ot= exports.EntryFunction =class n{constructor(t,e,r,i){this.module_name=t,this.function_name=e,this.type_args=r,this.args=i}static build(t,e,r,i){return new n(Vt.fromStr(t),new U(e),r,i)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=Vt.deserialize(t),r=U.deserialize(t),i=t.deserializeVector(k),o=t.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=t.deserializeUleb128AsU32(),p=Tn.deserialize(t,c);s.push(p)}return new n(e,r,i,s)}},Wt= exports.Script =class n{constructor(t,e,r){this.bytecode=t,this.type_args=e,this.args=r}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),r=t.deserializeVector(k),i=t.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=_a(t);o.push(a)}return new n(e,r,o)}},jt= exports.MultiSig =class n{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=u.deserialize(t),r=t.deserializeBool(),i;return r&&(i=Xt.deserialize(t)),new n(e,i)}},Xt= exports.MultiSigTransactionPayload =class n extends d{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))}};var M=class n extends d{constructor(e,r,i,o,s,a,c){super();this.sender=e,this.sequence_number=r,this.payload=i,this.max_gas_amount=o,this.gas_unit_price=s,this.expiration_timestamp_secs=a,this.chain_id=c}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 r=u.deserialize(e),i=e.deserializeU64(),o=it.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=ft.deserialize(e);return new n(r,i,o,s,a,c,p)}},zn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ae.load(t);case 1:return he.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},Ae= exports.MultiAgentRawTransaction =class n extends zn{constructor(e,r){super();this.raw_txn=e,this.secondary_signer_addresses=r}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let r=M.deserialize(e),i=e.deserializeVector(u);return new n(r,i)}},he= exports.FeePayerRawTransaction =class n extends zn{constructor(e,r,i){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=i}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 r=M.deserialize(e),i=e.deserializeVector(u),o=u.deserialize(e);return new n(r,i,o)}};var kn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new K(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=T.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var ve=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return wt.load(t);case 1:return hr.load(t);case 2:return St.load(t);case 3:return xt.load(t);case 4:return _t.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},wt= exports.TransactionAuthenticatorEd25519 =class n extends ve{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=v.deserialize(e),i=P.deserialize(e);return new n(r,i)}},hr= exports.TransactionAuthenticatorMultiEd25519 =class n extends ve{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=pt.deserialize(e),i=je.deserialize(e);return new n(r,i)}},St= exports.TransactionAuthenticatorMultiAgent =class n extends ve{constructor(e,r,i){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=j.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(j);return new n(r,i,o)}},xt= exports.TransactionAuthenticatorFeePayer =class n extends ve{constructor(e,r,i,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i,this.fee_payer=o}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 r=j.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(j),s=u.deserialize(e),a=j.deserialize(e),c={address:s,authenticator:a};return new n(r,i,o,c)}},_t= exports.TransactionAuthenticatorSingleSender =class n extends ve{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=j.deserialize(e);return new n(r)}};var Te=class n extends d{constructor(e,r){super();this.raw_txn=e,this.authenticator=r}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let r=M.deserialize(e),i=ve.deserialize(e);return new n(r,i)}};var Dn=class n extends d{constructor(e,r){super();this.rawTransaction=e,this.feePayerAddress=r}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=M.deserialize(e),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(r,o)}};function vt(n){return n.feePayerAddress?new he(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Ae(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function Yt(n,t){let e=_sha3.sha3_256.create();if(!t.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${t}`);e.update(t);let r=e.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function Cg(n){return Yt(n.bcsToBytes(),n.constructor.name)}function Ge(n){let t=vt(n);if(t instanceof M)return Yt(t.bcsToBytes(),Si);if(t instanceof Ae||t instanceof he)return Yt(t.bcsToBytes(),xi);throw new Error(`Unknown transaction type to sign on: ${t}`)}var Pt=class n{constructor(t){this.signingScheme=0;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=e.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let t=q.generate();return new n({privateKey:t})}static fromDerivationPath(t){let{path:e,mnemonic:r}=t,i=q.fromDerivationPath(e,r);return new n({privateKey:i})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.privateKey.sign(Ge(t));return new me(this.publicKey,e)}sign(t){return this.privateKey.sign(t)}signTransaction(t){return this.sign(Ge(t))}};var Et=class n{constructor(t){this.signingScheme=2;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=new O(e.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(t={}){let{scheme:e=0}=t,r;switch(e){case 0:r=q.generate();break;case 2:r=Ze.generate();break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:r})}static fromDerivationPath(t){let{scheme:e=0,path:r,mnemonic:i}=t,o;switch(e){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=Ze.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:o})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.sign(Ge(t));return new ne(this.publicKey,e)}sign(t){return new $(this.privateKey.sign(t))}signTransaction(t){return this.sign(Ge(t))}};var Fe=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?Pt.generate():Et.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:i=!0}=t;return e instanceof q&&i?new Pt({privateKey:e,address:r}):new Et({privateKey:e,address:r})}static fromPrivateKeyAndAddress(t){return this.fromPrivateKey(t)}static fromDerivationPath(t){let{scheme:e=0,mnemonic:r,path:i,legacy:o=!0}=t;return e===0&&o?Pt.fromDerivationPath({mnemonic:r,path:i}):Et.fromDerivationPath({scheme:e,mnemonic:r,path:i})}static authKey(t){let{publicKey:e}=t;return e.authKey()}verifySignature(t){return this.publicKey.verifySignature(t)}};var _jwtdecode = require('jwt-decode');var _base64 = require('base-64');var Bn=class n extends d{constructor(e){super();let{privateKey:r,expiryDateSecs:i,blinder:o}=e;this.privateKey=r,this.publicKey=new et(r.publicKey()),this.expiryDateSecs=i||BigInt(Ia(Ca()+qt)),this.blinder=o!==void 0?l.fromHexInput(o).toUint8Array():Ea(),this.nonce=this.generateNonce()}getPublicKey(){return this.publicKey}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}let o=e.deserializeU64(),s=e.deserializeFixedBytes(31);return new n({privateKey:i,expiryDateSecs:o,blinder:s})}static fromBytes(e){return n.deserialize(new Re(e))}static generate(e){let r;switch(_optionalChain([e, 'optionalAccess', _8 => _8.scheme])){case 0:default:r=q.generate()}return new n({privateKey:r})}generateNonce(){let e=Ar(this.publicKey.bcsToBytes(),93);return e.push(BigInt(this.expiryDateSecs)),e.push(Ft(this.blinder)),Mt(e).toString()}sign(e){return new de(this.privateKey.sign(e))}};function Ea(){return _utils.randomBytes.call(void 0, 31)}function Ca(){return Math.floor(new Date().getTime()/1e3)}function Ia(n){let t=new Date(n*1e3);return t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),Math.floor(t.getTime()/1e3)}function za(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),e=t+"==".substring(0,(3-t.length%3)%3);return _base64.decode.call(void 0, e)}var be=class be{constructor(t){let{address:e,ephemeralKeyPair:r,iss:i,uidKey:o,uidVal:s,aud:a,pepper:c,proof:p,jwt:y}=t;this.ephemeralKeyPair=r;let x=En(t);this.publicKey=new Be(i,x),this.accountAddress=e?u.from(e):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=s,this.aud=a,this.jwt=y,this.proof=p,this.signingScheme=2;let A=l.fromHexInput(c).toUint8Array();if(A.length!==be.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${be.PEPPER_LENGTH}`);this.pepper=A}serialize(t){t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof.serialize(t)}static deserialize(t){let e=t.deserializeStr(),r=t.deserializeStr(),i=t.deserializeFixedBytes(31),o=Bn.deserialize(t),s=Oe.deserialize(t);return be.fromJWTAndProof({proof:s,pepper:i,uidKey:r,jwt:e,ephemeralKeyPair:o})}bcsToBytes(){let t=new R;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return l.fromHexInput(t)}signWithAuthenticator(t){let e=vt(t),r=new $(this.sign(e.bcsToBytes())),i=new O(this.publicKey);return new ne(i,r)}async waitForProofFetch(){this.proof instanceof Promise&&await this.proof}sign(t){let{expiryDateSecs:e}=this.ephemeralKeyPair,r=Math.floor(new Date().getTime()/1e3);if(e<r)throw new Error("Ephemeral key pair is expired.");if(this.proof instanceof Promise)throw new Error("Failed to fetch proof.");let i=this.jwt.split(".")[0],o=this.ephemeralKeyPair.getPublicKey(),s=new R;s.serializeFixedBytes(l.fromHexInput(t).toUint8Array()),s.serializeOption(this.proof.proof);let a=Yt(s.toUint8Array(),"APTOS::TransactionAndProof"),c=this.ephemeralKeyPair.sign(a);return new Ke({jwtHeader:za(i),openIdSignatureOrZkProof:new tt(this.proof),expiryDateSecs:e,ephemeralPublicKey:o,ephemeralSignature:c})}signTransaction(t){let e=vt(t);return this.sign(e.bcsToBytes())}signWithOpenIdSignature(t){let[e,r,i]=this.jwt.split("."),o=new gt({jwtSignature:i,jwtPayloadJson:r,uidKey:this.uidKey,epkBlinder:this.ephemeralKeyPair.blinder,pepper:this.pepper}),{expiryDateSecs:s}=this.ephemeralKeyPair,a=this.ephemeralKeyPair.getPublicKey(),c=this.ephemeralKeyPair.sign(t);return new Ke({jwtHeader:e,openIdSignatureOrZkProof:new tt(o),expiryDateSecs:s,ephemeralPublicKey:a,ephemeralSignature:c})}verifySignature(t){return!0}static fromBytes(t){return be.deserialize(new Re(t))}static fromJWTAndProof(t){let{proof:e,jwt:r,ephemeralKeyPair:i,pepper:o}=t,s=_nullishCoalesce(t.uidKey, () => ("sub")),a=_jwtdecode.jwtDecode.call(void 0, r),c=a.iss;if(typeof a.aud!="string")throw new Error("aud was not found or an array of values");let p=a.aud,y=a[s];return new be({proof:e,ephemeralKeyPair:i,iss:c,uidKey:s,uidVal:y,aud:p,pepper:o,jwt:r})}static fromDerivationPath(t,e){return Sn(t,be.SLIP_0010_SEED,e)}};be.PEPPER_LENGTH=31,be.SLIP_0010_SEED="32 bytes";var Pe=be;var On=class n{constructor(t){let{multiKey:e,signers:r}=t;this.publicKey=e,this.signers=r,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let i=[];for(let o of r)i.push(this.publicKey.getIndex(o.publicKey));this.signaturesBitmap=this.publicKey.createBitmap({bits:i})}static fromPublicKeysAndSigners(t){let{publicKeys:e,signaturesRequired:r,signers:i}=t,o=new yt({publicKeys:e,signaturesRequired:r});return new n({multiKey:o,signers:i})}static isMultiKeySigner(t){return t instanceof n}signWithAuthenticator(t){return new Ne(this.publicKey,this.signTransaction(t))}async waitForProofFetch(){let t=this.signers.filter(e=>e instanceof Pe);await Promise.all(t.filter(e=>e.proof instanceof Promise).map(e=>e.proof))}sign(t){let e=[];for(let r of this.signers)e.push(r.sign(t));return new nt({signatures:e,bitmap:this.signaturesBitmap})}signTransaction(t){let e=[];for(let r of this.signers)e.push(r.signTransaction(t));return new nt({signatures:e,bitmap:this.signaturesBitmap})}verifySignature(t){return!0}};var re=class extends Error{constructor(e,r,i){super(i);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var _i="1.13.1-zeta.5";var vi={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",randomnet:"https://indexer-randomnet.hasura.app/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Pi= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",randomnet:"https://fullnode.random.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ei= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",randomnet:"https://faucet.random.aptoslabs.com",local:"http://127.0.0.1:8081"},Tr= exports.NetworkToPepperAPI ={mainnet:"mainnet not yet ready, requires sdk upgrade",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},br= exports.NetworkToProverAPI ={mainnet:"mainnet not yet ready, requires sdk upgrade",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},wr= exports.Network =(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.RANDOMNET="randomnet",s.LOCAL="local",s.CUSTOM="custom",s))(wr||{}),Sr= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70,local:4},Ly= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var Ci={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function ka(n,t){let{url:e,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _9 => _9.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${_i}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _10 => _10.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _11 => _11.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _12 => _12.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _13 => _13.API_KEY])}`),t.provider({url:e,method:r,body:i,params:s,headers:p,overrides:a})}async function Kn(n,t,e){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await ka({...n,url:o},t.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new re(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new re(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}if(a.status>=200&&a.status<300)return a;if(a.status>=500)throw new re(n,a,`${s.data}`);if(t.isPepperServiceRequest(r))throw new re(n,a,`${s.data}`);let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in Ci?c=Ci[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new re(n,a,`${e} error: ${c}`)}async function xr(n){let{aptosConfig:t,overrides:e,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return Kn({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...t.clientConfig,...e}},t,n.type)}async function Z(n){let{aptosConfig:t}=n;return xr({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _14 => _14.clientConfig, 'optionalAccess', _15 => _15.HEADERS]),..._optionalChain([t, 'access', _16 => _16.fullnodeConfig, 'optionalAccess', _17 => _17.HEADERS])}}})}async function Ii(n){return xr({...n,type:"Pepper"})}async function Ct(n){let t=[],e,r=n.params;do{let i=await xr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=i.headers["x-aptos-cursor"],delete i.headers,t.push(...i.data),r.start=e}while(e!=null);return t}async function Zt(n){let{type:t,originMethod:e,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,y=c.getRequestUrl(t);return Kn({url:y,method:"POST",originMethod:e,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function st(n){let{aptosConfig:t}=n;return Zt({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _18 => _18.clientConfig, 'optionalAccess', _19 => _19.HEADERS]),..._optionalChain([t, 'access', _20 => _20.fullnodeConfig, 'optionalAccess', _21 => _21.HEADERS])}}})}async function Ui(n){let{aptosConfig:t}=n;return Zt({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _22 => _22.clientConfig, 'optionalAccess', _23 => _23.HEADERS]),..._optionalChain([t, 'access', _24 => _24.indexerConfig, 'optionalAccess', _25 => _25.HEADERS])}}})}async function Ri(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _26 => _26.clientConfig, 'optionalAccess', _27 => delete _27.API_KEY]),Zt({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _28 => _28.clientConfig, 'optionalAccess', _29 => _29.HEADERS]),..._optionalChain([e, 'access', _30 => _30.faucetConfig, 'optionalAccess', _31 => _31.HEADERS])}}})}async function zi(n){return Zt({...n,type:"Pepper"})}async function ki(n){return Zt({...n,type:"Prover"})}var Da=`
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkKSEUZTKYjs = require('./chunk-KSEUZTKY.js');var ae=class extends Error{constructor(e,r,o){super(o);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var Sr="1.13.2";var Lt=(o=>(o.JSON="application/json",o.BCS="application/x-bcs",o.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",o.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",o))(Lt||{}),xr= exports.TypeTagVariants =(l=>(l[l.Bool=0]="Bool",l[l.U8=1]="U8",l[l.U64=2]="U64",l[l.U128=3]="U128",l[l.Address=4]="Address",l[l.Signer=5]="Signer",l[l.Vector=6]="Vector",l[l.Struct=7]="Struct",l[l.U16=8]="U16",l[l.U32=9]="U32",l[l.U256=10]="U256",l[l.Reference=254]="Reference",l[l.Generic=255]="Generic",l))(xr||{}),Tt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Tt||{}),vr= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(vr||{}),Cr= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(Cr||{}),Pr= exports.TransactionAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.MultiAgent=2]="MultiAgent",i[i.FeePayer=3]="FeePayer",i[i.SingleSender=4]="SingleSender",i))(Pr||{}),Er= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Er||{}),Ir= exports.AnyPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ir||{}),Ur= exports.AnySignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ur||{}),On= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(On||{});function ya(n){return n.type==="pending_transaction"}function Aa(n){return n.type==="user_transaction"}function fa(n){return n.type==="genesis_transaction"}function ha(n){return n.type==="block_metadata_transaction"}function Ta(n){return n.type==="state_checkpoint_transaction"}function ba(n){return n.type==="validator_transaction"}function wa(n){return"signature"in n&&n.signature==="ed25519_signature"}function _a(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function Sa(n){return n.type==="multi_agent_signature"}function xa(n){return n.type==="fee_payer_signature"}function va(n){return n.type==="multi_ed25519_signature"}var ts=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(ts||{}),Rr= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Rr||{}),ns= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(ns||{}),Re= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Re||{}),Bn= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(Bn||{}),zr= exports.DeriveScheme =(i=>(i[i.DeriveAuid=251]="DeriveAuid",i[i.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",i[i.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",i[i.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",i[i.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",i))(zr||{});var Nr={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",randomnet:"https://indexer-randomnet.hasura.app/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Dr= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",randomnet:"https://fullnode.random.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Gr= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",randomnet:"https://faucet.random.aptoslabs.com",local:"http://127.0.0.1:8081"},Fn= exports.Network =(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.RANDOMNET="randomnet",s.LOCAL="local",s.CUSTOM="custom",s))(Fn||{}),Mn= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70,local:4},Ea= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var bt=(r=>(r.FULLNODE="Fullnode",r.INDEXER="Indexer",r.FAUCET="Faucet",r))(bt||{}),kr= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Or= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Ht= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Qt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Br= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Kn= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Qe= exports.ProcessorType =(a=>(a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a))(Qe||{});var Wt=255,jt=65535,Ae=4294967295,ze=18446744073709551615n,wt=340282366920938463463374607431768211455n,Xt=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var Yt=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<Ae;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>Ae)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),r=new Array;for(let o=0;o<e;o+=1)r.push(this.deserialize(t));return r}};var _utils = require('@noble/hashes/utils');var M=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var is=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(is||{}),f= exports.Hex =class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new M("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new M("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, e))}catch(r){throw new M(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _4 => _4.message])}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,r)=>e===t.data[r])}};var d=class{bcsToBytes(){let t=new X;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return f.fromHexInput(t)}},X= exports.Serializer =class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,r){this.ensureBufferWillHandleSize(e);let o=new DataView(this.buffer,this.offset);t.apply(o,[0,r,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){qn(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(Ae),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&ze,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&wt,r=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(r)}serializeU32AsUleb128(t){let e=t,r=[];for(;e>>>7;)r.push(e&127|128),e>>>=7;r.push(e),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}};_chunkKSEUZTKYjs.a.call(void 0, [Ne(0,Wt)],X.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [Ne(0,jt)],X.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [Ne(0,Ae)],X.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [Ne(BigInt(0),ze)],X.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [Ne(BigInt(0),wt)],X.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [Ne(BigInt(0),Xt)],X.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [Ne(0,Ae)],X.prototype,"serializeU32AsUleb128",1);function qn(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var ss=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function xe(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(ss(n,t,e))}function Ne(n,t){return(e,r,o)=>{let i=o.value;return o.value=function(a){return xe(a,n,t),i.apply(this,[a])},o}}var De=class n extends d{constructor(e){super();this.value=f.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let o=e.deserializeFixedBytes(r);return new n(o)}};var Zt=class n extends d{constructor(e){super();this.value=new De(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let o=De.deserialize(e,r);return new n(o.value)}};var E=class n extends d{constructor(e){super();qn(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},G= exports.U8 =class n extends d{constructor(e){super();xe(e,0,Wt),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},re= exports.U16 =class n extends d{constructor(e){super();xe(e,0,jt),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},oe= exports.U32 =class n extends d{constructor(e){super();xe(e,0,Ae),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},D= exports.U64 =class n extends d{constructor(e){super();xe(e,BigInt(0),ze),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},ie= exports.U128 =class n extends d{constructor(e){super();xe(e,BigInt(0),wt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},se= exports.U256 =class n extends d{constructor(e){super();xe(e,BigInt(0),Xt),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var h=class n extends d{constructor(e){super();this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(!(this.values[0]instanceof G)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let o=f.fromHexInput(e);r=Array.from(o.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(o=>new G(o)))}static U16(e){return new n(e.map(r=>new re(r)))}static U32(e){return new n(e.map(r=>new oe(r)))}static U64(e){return new n(e.map(r=>new D(r)))}static U128(e){return new n(e.map(r=>new ie(r)))}static U256(e){return new n(e.map(r=>new se(r)))}static Bool(e){return new n(e.map(r=>new E(r)))}static MoveString(e){return new n(e.map(r=>new w(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let o=e.deserializeUleb128AsU32(),i=new Array;for(let s=0;s<o;s+=1)i.push(r.deserialize(e));return new n(i)}},w= exports.MoveString =class n extends d{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=this.bcsToBytes().slice(1);h.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},ve= exports.MoveOption =class n extends d{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new h([e]):this.vec=new h([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new G(e):void 0)}static U16(e){return new n(e!=null?new re(e):void 0)}static U32(e){return new n(e!=null?new oe(e):void 0)}static U64(e){return new n(e!=null?new D(e):void 0)}static U128(e){return new n(e!=null?new ie(e):void 0)}static U256(e){return new n(e!=null?new se(e):void 0)}static Bool(e){return new n(e!=null?new E(e):void 0)}static MoveString(e){return new n(e!=null?new w(e):void 0)}static deserialize(e,r){let o=h.deserialize(e,r);return new n(o.values[0])}};function Fr(n,t){let e=t.bcsToBytes(),r=new Yt(e);return n.deserialize(r)}var Mr={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function as(n,t){let{url:e,method:r,body:o,contentType:i,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _5 => _5.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Sr}`,"content-type":_nullishCoalesce(i, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _6 => _6.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _7 => _7.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _8 => _8.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _9 => _9.API_KEY])}`),t.provider({url:e,method:r,body:o,params:s,headers:p,overrides:a})}async function Jt(n,t,e){let{url:r,path:o}=n,i=o?`${r}/${o}`:r,s=await as({...n,url:i},t.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:i};if(a.status===401)throw new ae(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new ae(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}if(a.status>=200&&a.status<300)return a;let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in Mr?c=Mr[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new ae(n,a,`${e} error: ${c}`)}async function Kr(n){let{aptosConfig:t,overrides:e,params:r,contentType:o,acceptType:i,path:s,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return Jt({url:p,method:"GET",originMethod:a,path:s,contentType:o,acceptType:i,params:r,overrides:{...t.clientConfig,...e}},t,n.type)}async function V(n){let{aptosConfig:t}=n;return Kr({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _10 => _10.clientConfig, 'optionalAccess', _11 => _11.HEADERS]),..._optionalChain([t, 'access', _12 => _12.fullnodeConfig, 'optionalAccess', _13 => _13.HEADERS])}}})}async function We(n){let t=[],e,r=n.params;do{let o=await Kr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=o.headers["x-aptos-cursor"],delete o.headers,t.push(...o.data),r.start=e}while(e!=null);return t}async function $n(n){let{type:t,originMethod:e,path:r,body:o,acceptType:i,contentType:s,params:a,aptosConfig:c,overrides:p}=n,m=c.getRequestUrl(t);return Jt({url:m,method:"POST",originMethod:e,path:r,body:o,contentType:s,acceptType:i,params:a,overrides:p},c,n.type)}async function Ge(n){let{aptosConfig:t}=n;return $n({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _14 => _14.clientConfig, 'optionalAccess', _15 => _15.HEADERS]),..._optionalChain([t, 'access', _16 => _16.fullnodeConfig, 'optionalAccess', _17 => _17.HEADERS])}}})}async function qr(n){let{aptosConfig:t}=n;return $n({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _18 => _18.clientConfig, 'optionalAccess', _19 => _19.HEADERS]),..._optionalChain([t, 'access', _20 => _20.indexerConfig, 'optionalAccess', _21 => _21.HEADERS])}}})}async function $r(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _22 => _22.clientConfig, 'optionalAccess', _23 => delete _23.API_KEY]),$n({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _24 => _24.clientConfig, 'optionalAccess', _25 => _25.HEADERS]),..._optionalChain([e, 'access', _26 => _26.faucetConfig, 'optionalAccess', _27 => _27.HEADERS])}}})}var us=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(us||{}),_=class _ extends d{constructor(e){super();if(e.length!==_.LENGTH)throw new M("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(_.LENGTH);return new _(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new M("Hex string must start with a leading 0x.","leading_zero_x_required");let r=_.fromString(e);if(e.length!==_.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new M(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new M(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e){let r=e;if(e.startsWith("0x")&&(r=e.slice(2)),r.length===0)throw new M("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new M("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let o;try{o=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(i){throw new M(`Hex characters are invalid: ${_optionalChain([i, 'optionalAccess', _28 => _28.message])}`,"invalid_hex_chars")}return new _(o)}static from(e){return e instanceof _?e:e instanceof Uint8Array?new _(e):_.fromString(e)}static fromStrict(e){return e instanceof _?e:e instanceof Uint8Array?new _(e):_.fromStringStrict(e)}static isValid(e){try{return e.strict?_.fromStrict(e.input):_.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _29 => _29.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _30 => _30.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,o)=>r===e.data[o])}};_.LENGTH=32,_.LONG_STRING_LENGTH=64,_.ZERO=_.from("0x0"),_.ONE=_.from("0x1"),_.TWO=_.from("0x2"),_.THREE=_.from("0x3"),_.FOUR=_.from("0x4");var u=_;var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ce=class Ce extends d{constructor(e){super();let{data:r}=e,o=f.fromHexInput(r);if(o.toUint8Array().length!==Ce.LENGTH)throw new Error(`Authentication Key length should be ${Ce.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(Ce.LENGTH);return new Ce({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:r,input:o}=e,i=f.fromHexInput(o).toUint8Array(),s=new Uint8Array([...i,r]),a=_sha3.sha3_256.create();a.update(s);let c=a.digest();return new Ce({data:c})}static fromPublicKeyAndScheme(e){let{publicKey:r}=e;return r.authKey()}static fromPublicKey(e){let{publicKey:r}=e;return r.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};Ce.LENGTH=32;var K=Ce;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Lr = _interopRequireWildcard(_bip39);var gs=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,ms= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,ys= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(ys||{}),Hr= exports.HARDENED_OFFSET =2147483648;function Qr(n){return ms.test(n)}function Wr(n){return gs.test(n)}var Vn=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},jr= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let o=new Uint8Array(r),i=new Uint8Array([0]),s=new Uint8Array([...i,...n,...o]);return Vn(t,s)},As=n=>n.replace("'",""),Xr= exports.splitPath =n=>n.split("/").slice(1).map(As),en= exports.mnemonicToSeed =n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return Lr.mnemonicToSeedSync(t)};var _t=class extends d{toString(){let t=this.toUint8Array();return f.fromHexInput(t).toString()}},ce= exports.AccountPublicKey =class extends _t{};var Y=class extends d{toString(){let t=this.toUint8Array();return f.fromHexInput(t).toString()}};var je=n=>typeof n=="string"?f.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var Yr=[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],ke=class ke extends ce{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==ke.LENGTH)throw new Error(`PublicKey length should be ${ke.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof U))return!1;let i=je(r),s=f.fromHexInput(i).toUint8Array(),a=o.toUint8Array(),c=this.key.toUint8Array();return o.isCanonicalSignature()?_ed25519.ed25519.verify(a,s,c):!1}authKey(){return K.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ke(r)}static isPublicKey(e){return e instanceof ke}};ke.LENGTH=32;var I=ke,Z=class Z extends d{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==Z.LENGTH)throw new Error(`PrivateKey length should be ${Z.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new Z(e)}static fromDerivationPath(e,r){if(!Wr(e))throw new Error(`Invalid derivation path ${e}`);return Z.fromDerivationPathInner(e,en(r))}static fromDerivationPathInner(e,r,o=Hr){let{key:i,chainCode:s}=Vn(Z.SLIP_0010_SEED,r),a=Xr(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,m)=>jr(p,m+o),{key:i,chainCode:s});return new Z(c)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new I(e)}sign(e){let r=je(e),o=f.fromHexInput(r).toUint8Array(),i=_ed25519.ed25519.sign(o,this.signingKey.toUint8Array());return new U(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Z(r)}static isPrivateKey(e){return e instanceof Z}};Z.LENGTH=32,Z.SLIP_0010_SEED="ed25519 seed";var J=Z,Xe=class Xe extends Y{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==Xe.LENGTH)throw new Error(`Signature length should be ${Xe.LENGTH}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Xe(r)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let r=e.length-1;r>=0;r-=1){if(e[r]<Yr[r])return!0;if(e[r]>Yr[r])return!1}return!1}};Xe.LENGTH=64;var U=Xe;var ee=class ee extends ce{constructor(e){super();let{publicKeys:r,threshold:o}=e;if(r.length>ee.MAX_KEYS||r.length<ee.MIN_KEYS)throw new Error(`Must have between ${ee.MIN_KEYS} and ${ee.MAX_KEYS} public keys, inclusive`);if(o<ee.MIN_THRESHOLD||o>r.length)throw new Error(`Threshold must be between ${ee.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=o}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof Oe))return!1;let i=[];for(let s=0;s<4;s+=1)for(let a=0;a<8;a+=1)if((o.bitmap[s]&1<<7-a)!==0){let p=s*8+a;i.push(p)}if(i.length!==o.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let s=0;s<i.length;s+=1)if(!this.publicKeys[i[s]].verifySignature({message:r,signature:o.signatures[s]}))return!1;return!0}authKey(){return K.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*I.LENGTH+1);return this.publicKeys.forEach((r,o)=>{e.set(r.toUint8Array(),o*I.LENGTH)}),e[this.publicKeys.length*I.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),o=r[r.length-1],i=[];for(let s=0;s<r.length-1;s+=I.LENGTH){let a=s;i.push(new I(r.subarray(a,a+I.LENGTH)))}return new ee({publicKeys:i,threshold:o})}};ee.MAX_KEYS=32,ee.MIN_KEYS=2,ee.MIN_THRESHOLD=1;var Ye=ee,L=class L extends Y{constructor(e){super();let{signatures:r,bitmap:o}=e;if(r.length>L.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${L.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r,!(o instanceof Uint8Array))this.bitmap=L.createBitmap({bits:o});else{if(o.length!==L.BITMAP_LEN)throw new Error(`"bitmap" length should be ${L.BITMAP_LEN}`);this.bitmap=o}}toUint8Array(){let e=new Uint8Array(this.signatures.length*U.LENGTH+L.BITMAP_LEN);return this.signatures.forEach((r,o)=>{e.set(r.toUint8Array(),o*U.LENGTH)}),e.set(this.bitmap,this.signatures.length*U.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),o=r.subarray(r.length-4),i=[];for(let s=0;s<r.length-o.length;s+=U.LENGTH){let a=s;i.push(new U(r.subarray(a,a+U.LENGTH)))}return new L({signatures:i,bitmap:o})}static createBitmap(e){let{bits:r}=e,o=128,i=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(a>=L.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${L.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");if(c>0&&a<=r[c-1])throw new Error("The bits need to be sorted in ascending order.");s.add(a);let p=Math.floor(a/8),m=i[p];m|=o>>a%8,i[p]=m}),i}};L.MAX_SIGNATURES_SUPPORTED=32,L.BITMAP_LEN=4;var Oe=L;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Be=class Be extends _t{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==Be.LENGTH)throw new Error(`PublicKey length should be ${Be.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof he))return!1;let i=je(r),s=f.fromHexInput(i).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=o.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Be(r)}static isPublicKey(e){return e instanceof Be}};Be.LENGTH=65;var fe=Be,ue=class ue extends d{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==ue.LENGTH)throw new Error(`PrivateKey length should be ${ue.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ue(e)}static fromDerivationPath(e,r){if(!Qr(e))throw new Error(`Invalid derivation path ${e}`);return ue.fromDerivationPathInner(e,en(r))}static fromDerivationPathInner(e,r){let{privateKey:o}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(o===null)throw new Error("Invalid key");return new ue(o)}sign(e){let r=je(e),o=f.fromHexInput(r),i=_sha3.sha3_256.call(void 0, o.toUint8Array()),s=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new he(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new fe(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ue(r)}static isPrivateKey(e){return e instanceof ue}};ue.LENGTH=32;var Fe=ue,Ze=class Ze extends Y{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==Ze.LENGTH)throw new Error(`Signature length should be ${Ze.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ze(r)}};Ze.LENGTH=64;var he=Ze;var q=class n extends ce{constructor(e){super();if(this.publicKey=e,e instanceof I)this.variant=0;else if(e instanceof fe)this.variant=1;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:o}=e;return o instanceof O?this.publicKey.verifySignature({message:r,signature:o.signature}):!1}authKey(){return K.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),o;switch(r){case 0:o=I.deserialize(e);break;case 1:o=fe.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new n(o)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof I}isSecp256k1PublicKey(){return this.publicKey instanceof fe}},O= exports.AnySignature =class n extends Y{constructor(e){super();if(this.signature=e,e instanceof U)this.variant=0;else if(e instanceof he)this.variant=1;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),o;switch(r){case 0:o=U.deserialize(e);break;case 1:o=he.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(o)}};function Jr(n){let t=n;return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}var rn=class n extends ce{constructor(e){super();let{publicKeys:r,signaturesRequired:o}=e;if(o<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<o)throw new Error(`Provided ${r.length} public keys is smaller than the ${o} required signatures`);this.publicKeys=r.map(i=>i instanceof q?i:new q(i)),this.signaturesRequired=o}verifySignature(e){throw new Error("not implemented")}authKey(){return K.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(q),o=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:o})}createBitmap(e){let{bits:r}=e,o=128,i=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(c+1>this.publicKeys.length)throw new Error(`Signature index ${c+1} is out of public keys range, ${this.publicKeys.length}.`);if(s.has(a))throw new Error(`Duplicate bit ${a} detected.`);s.add(a);let p=Math.floor(a/8),m=i[p];m|=o>>a%8,i[p]=m}),i}},H=class H extends Y{constructor(e){super();let{signatures:r,bitmap:o}=e;if(r.length>H.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${H.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(s=>s instanceof O?s:new O(s)),!(o instanceof Uint8Array))this.bitmap=H.createBitmap({bits:o});else{if(o.length!==H.BITMAP_LEN)throw new Error(`"bitmap" length should be ${H.BITMAP_LEN}`);this.bitmap=o}let i=this.bitmap.reduce((s,a)=>s+Jr(a),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:r}=e,o=128,i=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach(a=>{if(a>=H.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${H.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");s.add(a);let c=Math.floor(a/8),p=i[c];p|=o>>a%8,i[c]=p}),i}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeBytes(),o=r.reduce((s,a)=>s+Jr(a),0),i=[];for(let s=0;s<o;s+=1){let a=O.deserialize(e);i.push(a)}return new H({signatures:i,bitmap:r})}};H.BITMAP_LEN=4,H.MAX_SIGNATURES_SUPPORTED=H.BITMAP_LEN*8;var eo=H;var B=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return pe.load(t);case 1:return on.load(t);case 2:return de.load(t);case 3:return sn.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof pe}isMultiEd25519(){return this instanceof on}isSingleKey(){return this instanceof de}isMultiKey(){return this instanceof sn}},pe= exports.AccountAuthenticatorEd25519 =class n extends B{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=I.deserialize(e),o=U.deserialize(e);return new n(r,o)}},on= exports.AccountAuthenticatorMultiEd25519 =class n extends B{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=Ye.deserialize(e),o=Oe.deserialize(e);return new n(r,o)}},de= exports.AccountAuthenticatorSingleKey =class n extends B{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=q.deserialize(e),o=O.deserialize(e);return new n(r,o)}},sn= exports.AccountAuthenticatorMultiKey =class n extends B{constructor(e,r,o){super();this.public_keys=e,this.signatures=r,this.signatures_bitmap=o}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),e.serializeVector(this.signatures),e.serializeBytes(this.signatures_bitmap)}static load(e){let r=rn.deserialize(e),o=e.deserializeVector(O),i=e.deserializeBytes();return new n(r,o,i)}};var Je=class n{constructor(t){this.signingScheme=0;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=e.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let t=J.generate();return new n({privateKey:t})}static fromDerivationPath(t){let{path:e,mnemonic:r}=t,o=J.fromDerivationPath(e,r);return new n({privateKey:o})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.privateKey.sign(t);return new pe(this.publicKey,e)}sign(t){return this.signWithAuthenticator(t).signature}};var et=class n{constructor(t){this.signingScheme=2;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=new q(e.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(t={}){let{scheme:e=0}=t,r;switch(e){case 0:r=J.generate();break;case 2:r=Fe.generate();break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:r})}static fromDerivationPath(t){let{scheme:e=0,path:r,mnemonic:o}=t,i;switch(e){case 0:i=J.fromDerivationPath(r,o);break;case 2:i=Fe.fromDerivationPath(r,o);break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:i})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){let e=this.privateKey.sign(t),r=new O(e);return new de(this.publicKey,r)}sign(t){return this.signWithAuthenticator(t).signature}};var Pe=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?Je.generate():et.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:o=!0}=t;return e instanceof J&&o?new Je({privateKey:e,address:r}):new et({privateKey:e,address:r})}static fromPrivateKeyAndAddress(t){return this.fromPrivateKey(t)}static fromDerivationPath(t){let{scheme:e=0,mnemonic:r,path:o,legacy:i=!0}=t;return e===0&&i?Je.fromDerivationPath({mnemonic:r,path:o}):et.fromDerivationPath({scheme:e,mnemonic:r,path:o})}static authKey(t){let{publicKey:e}=t;return e.authKey()}verifySignature(t){return this.publicKey.verifySignature(t)}};var hs=(n,t)=>{let e=n.bcsToBytes(),r=typeof t=="string"?Buffer.from(t,"utf8"):t,o=new Uint8Array([...e,...r,254]);return new u(_sha3.sha3_256.call(void 0, o))},ld= exports.createResourceAddress =(n,t)=>{let e=n.bcsToBytes(),r=typeof t=="string"?Buffer.from(t,"utf8"):t,o=new Uint8Array([...e,...r,255]);return new u(_sha3.sha3_256.call(void 0, o))},gd= exports.createTokenAddress =(n,t,e)=>{let r=`${t}::${e}`;return hs(n,r)};var Ts=`
|
|
2
2
|
fragment TokenActivitiesFields on token_activities_v2 {
|
|
3
3
|
after_value
|
|
4
4
|
before_value
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
transaction_version
|
|
17
17
|
type
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
19
|
+
`,bs=`
|
|
20
20
|
fragment AnsTokenFragment on current_aptos_names {
|
|
21
21
|
domain
|
|
22
22
|
expiration_timestamp
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
is_primary
|
|
27
27
|
owner_address
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,an=`
|
|
30
30
|
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
|
|
31
31
|
token_standard
|
|
32
32
|
token_properties_mutated_v1
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
`,
|
|
76
|
+
`,no=`
|
|
77
77
|
query getAccountCoinsCount($address: String) {
|
|
78
78
|
current_fungible_asset_balances_aggregate(
|
|
79
79
|
where: {owner_address: {_eq: $address}}
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
`,
|
|
86
|
+
`,ro=`
|
|
87
87
|
query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
|
|
88
88
|
current_fungible_asset_balances(
|
|
89
89
|
where: $where_condition
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
`,
|
|
119
|
+
`,oo=`
|
|
120
120
|
query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
|
|
121
121
|
current_collection_ownership_v2_view(
|
|
122
122
|
where: $where_condition
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
single_token_uri
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
`,
|
|
153
|
+
`,io=`
|
|
154
154
|
query getAccountOwnedObjects($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
|
|
155
155
|
current_objects(
|
|
156
156
|
where: $where_condition
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
is_deleted
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
`,
|
|
170
|
+
`,so=`
|
|
171
171
|
query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
172
172
|
current_token_ownerships_v2(
|
|
173
173
|
where: $where_condition
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
...CurrentTokenOwnershipFields
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
${
|
|
181
|
+
${an}`,_d=`
|
|
182
182
|
query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
183
183
|
current_token_ownerships_v2(
|
|
184
184
|
where: $where_condition
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
...CurrentTokenOwnershipFields
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
${
|
|
192
|
+
${an}`,ao=`
|
|
193
193
|
query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
194
194
|
current_token_ownerships_v2(
|
|
195
195
|
where: $where_condition
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
...CurrentTokenOwnershipFields
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
${
|
|
203
|
+
${an}`,co=`
|
|
204
204
|
query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
|
|
205
205
|
current_token_ownerships_v2_aggregate(
|
|
206
206
|
where: $where_condition
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
`,
|
|
215
|
+
`,uo=`
|
|
216
216
|
query getAccountTransactionsCount($address: String) {
|
|
217
217
|
account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
|
|
218
218
|
aggregate {
|
|
@@ -220,13 +220,13 @@
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
`,
|
|
223
|
+
`,po=`
|
|
224
224
|
query getChainTopUserTransactions($limit: Int) {
|
|
225
225
|
user_transactions(limit: $limit, order_by: {version: desc}) {
|
|
226
226
|
version
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
`,
|
|
229
|
+
`,Ln=`
|
|
230
230
|
query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
|
|
231
231
|
current_collections_v2(where: $where_condition) {
|
|
232
232
|
collection_id
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
uri
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
|
|
248
|
+
`,lo=`
|
|
249
249
|
query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
|
|
250
250
|
current_fungible_asset_balances(
|
|
251
251
|
where: $where_condition
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
token_standard
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
`,
|
|
266
|
+
`,go=`
|
|
267
267
|
query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
|
|
268
268
|
delegated_staking_activities(
|
|
269
269
|
where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
transaction_version
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
`,
|
|
279
|
+
`,mo=`
|
|
280
280
|
query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
|
|
281
281
|
events(
|
|
282
282
|
where: $where_condition
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
indexed_type
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
`,
|
|
298
|
+
`,yo=`
|
|
299
299
|
query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
|
|
300
300
|
fungible_asset_activities(
|
|
301
301
|
where: $where_condition
|
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
type
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
`,
|
|
323
|
+
`,Ao=`
|
|
324
324
|
query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
|
|
325
325
|
fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
|
|
326
326
|
icon_uri
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
token_standard
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
-
`,
|
|
340
|
+
`,tt=`
|
|
341
341
|
query getNames($offset: Int, $limit: Int, $where_condition: current_aptos_names_bool_exp, $order_by: [current_aptos_names_order_by!]) {
|
|
342
342
|
current_aptos_names(
|
|
343
343
|
limit: $limit
|
|
@@ -348,14 +348,14 @@
|
|
|
348
348
|
...AnsTokenFragment
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
${
|
|
351
|
+
${bs}`,Hn=`
|
|
352
352
|
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
353
353
|
num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
|
|
354
354
|
num_active_delegator
|
|
355
355
|
pool_address
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
`,
|
|
358
|
+
`,Qn=`
|
|
359
359
|
query getProcessorStatus($where_condition: processor_status_bool_exp) {
|
|
360
360
|
processor_status(where: $where_condition) {
|
|
361
361
|
last_success_version
|
|
@@ -363,7 +363,7 @@
|
|
|
363
363
|
last_updated
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
`,
|
|
366
|
+
`,fo=`
|
|
367
367
|
query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
|
|
368
368
|
token_activities_v2(
|
|
369
369
|
where: $where_condition
|
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
...TokenActivitiesFields
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
${
|
|
377
|
+
${Ts}`,Wn=`
|
|
378
378
|
query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
379
379
|
current_token_ownerships_v2(
|
|
380
380
|
where: $where_condition
|
|
@@ -385,7 +385,7 @@
|
|
|
385
385
|
...CurrentTokenOwnershipFields
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
${
|
|
388
|
+
${an}`,ho=`
|
|
389
389
|
query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
|
|
390
390
|
current_token_datas_v2(
|
|
391
391
|
where: $where_condition
|
|
@@ -425,5 +425,5 @@
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
`;async function Gn(n){let{aptosConfig:t}=n,{data:e}=await Z({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function Xi(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _32 => _32.withTransactions])}});return i}async function Yi(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _33 => _33.withTransactions])}});return i}async function Fn(n){let{aptosConfig:t,handle:e,data:r,options:i}=n;return(await st({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _34 => _34.ledgerVersion])},body:r})).data}async function Zi(n){let{aptosConfig:t,limit:e}=n;return(await f({aptosConfig:t,query:{query:qi,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:i}=await Ui({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return i}async function Oa(n){let{aptosConfig:t}=n;return(await f({aptosConfig:t,query:{query:Pr},originMethod:"getProcessorStatuses"})).processor_status}async function Mn(n){let t=await Oa({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function qn(n){let{aptosConfig:t,processorType:e}=n;return(await f({aptosConfig:t,query:{query:Pr,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var Cr=new Map;function Ut(n,t,e){return async(...r)=>{if(Cr.has(t)){let{value:o,timestamp:s}=Cr.get(t);if(e===void 0||Date.now()-s<=e)return o}let i=await n(...r);return Cr.set(t,{value:i,timestamp:Date.now()}),i}}async function we(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function to(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ct({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _35 => _35.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _36 => _36.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _37 => _37.limit]), () => (1e3))}})}async function $n(n){return _optionalChain([n, 'access', _38 => _38.options, 'optionalAccess', _39 => _39.ledgerVersion])!==void 0?Ji(n):Ut(async()=>Ji(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function Ji(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _40 => _40.ledgerVersion])}});return o}async function no(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ct({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _41 => _41.offset]),limit:_optionalChain([r, 'optionalAccess', _42 => _42.limit])}})}async function ro(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Ct({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _43 => _43.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _44 => _44.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _45 => _45.limit]), () => (999))}})}async function Ir(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _46 => _46.ledgerVersion])}});return o.data}async function Ur(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,i=await Ir({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(e);try{let a=await Fn({aptosConfig:t,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof re&&a.data.error_code==="table_item_not_found")return s;throw a}}async function io(n){let{aptosConfig:t,accountAddress:e}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s=await f({aptosConfig:t,query:{query:Fi,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 oo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _47 => _47.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _48 => _48.tokenStandard])});let s={query:Ni,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _49 => _49.offset]),limit:_optionalChain([r, 'optionalAccess', _50 => _50.limit]),order_by:_optionalChain([r, 'optionalAccess', _51 => _51.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function so(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:i}=n,o=u.from(e).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _52 => _52.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _53 => _53.tokenStandard])});let c={query:Gi,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _54 => _54.offset]),limit:_optionalChain([i, 'optionalAccess', _55 => _55.limit]),order_by:_optionalChain([i, 'optionalAccess', _56 => _56.orderBy])}};return(await f({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _57 => _57.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _58 => _58.tokenStandard])}});let s={query:Oi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _59 => _59.offset]),limit:_optionalChain([r, 'optionalAccess', _60 => _60.limit]),order_by:_optionalChain([r, 'optionalAccess', _61 => _61.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function co(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Mi,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function uo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,i=u.from(e).toStringLong(),o=await Rr({aptosConfig:t,accountAddress:i,options:{where:{asset_type:{_eq:r}}}});return o[0]?o[0].amount:0}async function Rr(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i=u.from(e).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _62 => _62.where]),owner_address:{_eq:i}},s={query:Bi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _63 => _63.offset]),limit:_optionalChain([r, 'optionalAccess', _64 => _64.limit]),order_by:_optionalChain([r, 'optionalAccess', _65 => _65.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function po(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Di,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 lo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}},s={query:Ki,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _66 => _66.offset]),limit:_optionalChain([r, 'optionalAccess', _67 => _67.limit]),order_by:_optionalChain([r, 'optionalAccess', _68 => _68.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function go(n){let{aptosConfig:t,privateKey:e}=n,r=new O(e.publicKey());if(e instanceof Ze){let o=G.fromPublicKey({publicKey:r}).derivedAddress();return Fe.fromPrivateKey({privateKey:e,address:o})}if(e instanceof q){let i=G.fromPublicKey({publicKey:r});if(await eo({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return Fe.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=G.fromPublicKey({publicKey:r.publicKey});if(await eo({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Fe.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function eo(n){let{aptosConfig:t,authKey:e}=n,r=await Ur({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await we({aptosConfig:t,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function yo(n){let{aptosConfig:t,options:e}=n;return Ct({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([e, 'optionalAccess', _70 => _70.limit])}})}async function Hn(n){let{aptosConfig:t}=n;return Ut(async()=>{let{data:e}=await Z({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function mo(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function Jt(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function fo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await Jt({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _71 => _71.status])===404)return!0;throw r}}async function Ka(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function Rt(n){let{aptosConfig:t,transactionHash:e,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _72 => _72.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _73 => _73.checkSuccess]), () => (!0)),s=!0,a=0,c,p,y=200,x=1.5;function A(g){if(!(g instanceof re)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await Jt({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(g){A(g)}if(s){let g=Date.now();try{c=await Ka({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(oe){A(oe)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await Jt({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(g){A(g)}await _chunkKSEUZTKYjs.b.call(void 0, y),a+=y/1e3,y*=x}if(c===void 0)throw p||new Vn(`Fetching transaction ${e} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Vn(`Transaction ${e} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new zr(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function Ln(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?s=await Mn({aptosConfig:t}):s=(await qn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var Vn=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},zr=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function b(n){n.minimumLedgerVersion!==void 0&&await Ln({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var en=class{constructor(t){this.config=t}async getAccountInfo(t){return we({aptosConfig:this.config,...t})}async getAccountModules(t){return to({aptosConfig:this.config,...t})}async getAccountModule(t){return $n({aptosConfig:this.config,...t})}async getAccountTransactions(t){return no({aptosConfig:this.config,...t})}async getAccountResources(t){return ro({aptosConfig:this.config,...t})}async getAccountResource(t){return Ir({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Ur({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),io({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),oo({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),so({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ao({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),co({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Rr({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),po({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Un,...t})}async getAccountCoinAmount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),uo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),lo({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return go({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Qn=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _74 => _74.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _75 => _75.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _76 => _76.faucet]),this.pepper=_optionalChain([t, 'optionalAccess', _77 => _77.pepper]),this.prover=_optionalChain([t, 'optionalAccess', _78 => _78.prover]),this.indexer=_optionalChain([t, 'optionalAccess', _79 => _79.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _80 => _80.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _81 => _81.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _82 => _82.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _83 => _83.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _84 => _84.faucetConfig]), () => ({}))}getRequestUrl(t){switch(t){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Pi[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Ei[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return vi[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return Tr[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return br[this.network];default:throw Error(`apiType ${t} is not supported`)}}isPepperServiceRequest(t){return Tr[this.network]===t}isProverServiceRequest(t){return br[this.network]===t}};function Ao(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function ho(n){return!!n.match(/\s/)}function Ga(n){return!!n.match(/^T[0-9]+$/)}function Fa(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!ho(r))break}return e}var Ma=(A=>(A.InvalidTypeTag="unknown type",A.UnexpectedGenericType="unexpected generic type",A.UnexpectedTypeArgumentClose="unexpected '>'",A.UnexpectedWhitespaceCharacter="unexpected whitespace character",A.UnexpectedComma="unexpected ','",A.TypeArgumentCountMismatch="type argument count doesn't match expected amount",A.MissingTypeArgumentClose="no matching '>' for '<'",A.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",A.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",A.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",A.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",A.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",A))(Ma||{}),C= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Ee(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _85 => _85.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let oe=Wn(a,i,e);o.push(oe)}let y=r.pop();if(y===void 0)throw new C(n,"unexpected '>'");if(c!==o.length)throw new C(n,"type argument count doesn't match expected amount");let{savedStr:x,savedTypes:A,savedExpectedTypes:g}=y;i=o,o=A,a=x,c=g}else if(p===","){if(a.length!==0){let y=Wn(a,i,e);i=[],o.push(y),a="",c+=1}}else if(ho(p)){let y=!1;if(a.length!==0){let A=Wn(a,i,e);i=[],o.push(A),a="",y=!0}s=Fa(n,s);let x=n[s];if(s<n.length&&y&&x!==","&&x!==">")throw new C(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new C(n,"no matching '>' for '<'");switch(o.length){case 0:return Wn(a,i,e);case 1:if(a==="")return o[0];throw new C(n,"unexpected ','");default:throw new C(n,"unexpected whitespace character")}}function Wn(n,t,e){switch(n){case"&signer":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new Rn(new rt);case"signer":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new rt;case"bool":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new F;case"address":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new X;case"u8":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new fe;case"u16":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new At;case"u32":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new ht;case"u64":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new L;case"u128":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new Tt;case"u256":if(t.length>0)throw new C(n,"primitive types not expected to have type arguments");return new bt;case"vector":if(t.length!==1)throw new C(n,"vector type expected to have exactly one type argument");return new E(t[0]);default:if(Ga(n)){if(e)return new D(Number(n.split("T")[1]));throw new C(n,"unexpected generic type")}if(!n.match(/:/))throw new C(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new C(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!Ao(r[1]))throw new C(n,"module name must only contain alphanumeric or '_' characters");if(!Ao(r[2]))throw new C(n,"struct name must only contain alphanumeric or '_' characters");return new m(new _e(u.fromString(r[0]),new U(r[1]),new U(r[2]),t))}}function To(n){return typeof n=="boolean"}function zt(n){return typeof n=="string"}function jn(n){return typeof n=="number"}function Xn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function bo(n){return n==null}function wo(n){return kr(n)||Br(n)||Or(n)||Kr(n)||Nr(n)||Gr(n)||Fr(n)||Yn(n)||Dr(n)||qa(n)||n instanceof T||n instanceof ke}function kr(n){return n instanceof z}function Yn(n){return n instanceof u}function Dr(n){return n instanceof w}function qa(n){return n instanceof Le}function Br(n){return n instanceof N}function Or(n){return n instanceof se}function Kr(n){return n instanceof ae}function Nr(n){return n instanceof K}function Gr(n){return n instanceof ce}function Fr(n){return n instanceof ue}function So(n){return"bytecode"in n}function I(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function xo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function tn(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],i=t[2];return{moduleAddress:e,moduleName:r,functionName:i}}var $a=new TextEncoder;function qr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _86 => _86.map, 'call', _87 => _87(t=>zt(t)?Ee(t):t)]), () => ([]))}async function _o(n,t,e,r){let i=await $n({aptosConfig:r,accountAddress:n,moduleName:t});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===e)}async function vo(n,t,e,r){let i=await _o(n,t,e,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!i.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let o=xo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ee(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Po(n,t,e,r){let i=await _o(n,t,e,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${t}::${e}'`);if(!i.is_view)throw new Error(`'${n}::${t}::${e}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Ee(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ee(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function $r(n,t,e,r,i){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let o=t.parameters[r];return kt(e,o,r,i)}function kt(n,t,e,r){return wo(n)?(Mr(t,n,e),n):Va(n,t,e,r)}function Va(n,t,e,r){if(t.isBool()){if(To(n))return new z(n);I("boolean",e)}if(t.isAddress()){if(zt(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isU8()){if(jn(n))return new N(n);I("number",e)}if(t.isU16()){if(jn(n))return new se(n);I("number",e)}if(t.isU32()){if(jn(n))return new ae(n);I("number",e)}if(t.isU64()){if(Xn(n))return new K(BigInt(n));I("bigint | number | string",e)}if(t.isU128()){if(Xn(n))return new ce(BigInt(n));I("bigint | number | string",e)}if(t.isU256()){if(Xn(n))return new ue(BigInt(n));I("bigint | number | string",e)}if(t.isGeneric()){let i=t.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return kt(n,r[i],e,r)}if(t.isVector()){if(t.value.isU8()){if(zt(n))return T.U8($a.encode(n));if(n instanceof Uint8Array)return T.U8(n);if(n instanceof ArrayBuffer)return T.U8(new Uint8Array(n))}if(Array.isArray(n))return new T(n.map(i=>kt(i,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(zt(n))return new w(n);I("string",e)}if(t.isObject()){if(zt(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isOption())return bo(n)?new ke(null):new ke(kt(n,t.value.typeArgs[0],e,r));throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function Mr(n,t,e){if(n.isBool()){if(kr(t))return;I("Bool",e)}if(n.isAddress()){if(Yn(t))return;I("AccountAddress",e)}if(n.isU8()){if(Br(t))return;I("U8",e)}if(n.isU16()){if(Or(t))return;I("U16",e)}if(n.isU32()){if(Kr(t))return;I("U32",e)}if(n.isU64()){if(Nr(t))return;I("U64",e)}if(n.isU128()){if(Gr(t))return;I("U128",e)}if(n.isU256()){if(Fr(t))return;I("U256",e)}if(n.isVector()){if(t instanceof T){t.values.length>0&&Mr(n.value,t.values[0],e);return}I("MoveVector",e)}if(n instanceof m){if(n.isString()){if(Dr(t))return;I("MoveString",e)}if(n.isObject()){if(Yn(t))return;I("AccountAddress",e)}if(n.isOption()){if(t instanceof ke){t.value!==void 0&&Mr(n.value.typeArgs[0],t.value,e);return}I("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}var Zn=class n extends d{constructor(e,r,i){super();this.rawTransaction=e,this.feePayerAddress=i,this.secondarySignerAddresses=r}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 r=M.deserialize(e),i=e.deserializeVector(u),o=e.deserializeBool(),s;return o&&(s=u.deserialize(e)),new n(r,i,s)}};async function er(n){if(So(n))return Wa(n);let{moduleAddress:t,moduleName:e,functionName:r}=tn(n.function),i=await Uo({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:vo});return La({...n,abi:i})}function La(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=tn(n.function),o=qr(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>$r(n.function,t,c,p,o));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);let a=ot.build(`${e}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Qt(new jt(c,new Xt(a)))}return new Lt(a)}async function Eo(n){let{moduleAddress:t,moduleName:e,functionName:r}=tn(n.function),i=await Uo({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Po});return Qa({abi:i,...n})}function Qa(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=tn(n.function),o=qr(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _88 => _88.functionArguments, 'optionalAccess', _89 => _89.map, 'call', _90 => _90((a,c)=>$r(n.function,t,a,c,o))]), () => ([]));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);return ot.build(`${e}::${r}`,i,o,s)}function Wa(n){return new Ht(new Wt(l.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function ja(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=async()=>Sr[t.network]?{chainId:Sr[t.network]}:{chainId:(await Gn({aptosConfig:t})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _91 => _91.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Hn({aptosConfig:t})).gas_estimate},c=async()=>{let at=async()=>_optionalChain([i, 'optionalAccess', _92 => _92.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await we({aptosConfig:t,accountAddress:e})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await at()}catch (e2){return 0}else return at()},[{chainId:p},{gasEstimate:y},x]=await Promise.all([s(),a(),c()]),{maxGasAmount:A,gasUnitPrice:g,expireTimestamp:oe}={maxGasAmount:_optionalChain([i, 'optionalAccess', _93 => _93.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(y),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...i};return new M(u.from(e),BigInt(x),r,BigInt(A),BigInt(g),BigInt(oe),new ft(p))}async function Vr(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=await ja({aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _94 => _94.secondarySignerAddresses, 'optionalAccess', _95 => _95.map, 'call', _96 => _96(c=>u.from(c))]), () => ([]));return new Zn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Dn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Co(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Jn(t);if(e.feePayerAddress){let a=new he(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(x=>Jn(x)));let p=Jn(i),y=new xt(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new Te(a.raw_txn,y).bcsToBytes()}if(e.secondarySignerAddresses){let a=new Ae(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(y=>Jn(y));let p=new St(o,e.secondarySignerAddresses,c);return new Te(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof me)s=new wt(o.public_key,o.signature);else if(o instanceof ne)s=new _t(o);else throw new Error("Invalid public key");return new Te(e.rawTransaction,s).bcsToBytes()}function Jn(n){return n instanceof O?new ne(n,new $(new P(new Uint8Array(64)))):new me(new v(n.toUint8Array()),new P(new Uint8Array(64)))}function Hr(n){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:r,additionalSignersAuthenticators:i}=n,o=vt(t);if((r||i)&&(o instanceof Ae||o instanceof he))return Ya(o,e,r,i);if(e instanceof me&&o instanceof M){let s=new wt(e.public_key,e.signature);return new Te(o,s).bcsToBytes()}if((e instanceof ne||e instanceof Ne)&&o instanceof M){let s=new _t(e);return new Te(o,s).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Io(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Xa=Io(["APTOS::Transaction"]);function Qf(n){let t=Hr(n);return new l(Io([Xa,new Uint8Array([0]),t])).toString()}function Ya(n,t,e,r){if(n instanceof he){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let i=new xt(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:e});return new Te(n.raw_txn,i).bcsToBytes()}if(n instanceof Ae){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let i=new St(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new Te(n.raw_txn,i).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}async function Uo({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Ut(async()=>s(t,e,r,i),`${n}-${i.network}-${t}-${e}-${r}`,1e3*60*5)()}async function h(n){let t=await Za(n);return Ja(n,t)}async function Za(n){let{aptosConfig:t,data:e}=n,r,i;return"bytecode"in e?i=await er(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await er(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await er(r)),i}async function Ja(n,t){let{aptosConfig:e,sender:r,options:i}=n,o;if(ec(n)&&(o=u.ZERO.toString()),tc(n)){let{secondarySignerAddresses:s}=n;return Vr({aptosConfig:e,sender:r,payload:t,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Vr({aptosConfig:e,sender:r,payload:t,options:i,feePayerAddress:o})}function ec(n){return n.withFeePayer===!0}function tc(n){return"secondarySignerAddresses"in n}function Ro(n){let{transaction:t}=n;return Ge(t)}function tr(n){let{signer:t,transaction:e}=n;return t.signWithAuthenticator(e)}async function Lr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Co({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await st({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _97 => _97.options, 'optionalAccess', _98 => _98.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _99 => _99.options, 'optionalAccess', _100 => _100.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _101 => _101.options, 'optionalAccess', _102 => _102.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function nr(n){let{aptosConfig:t}=n,e=Hr({...n}),{data:r}=await st({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function nn(n){let{aptosConfig:t,signer:e,transaction:r}=n;(e instanceof Pe||e instanceof On)&&await e.waitForProofFetch();let i=tr({signer:e,transaction:r});return nr({aptosConfig:t,transaction:r,senderAuthenticator:i})}var nc={typeParameters:[],parameters:[E.u8(),new E(E.u8())]};async function zo(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>T.U8(a));return h({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:nc},options:o})}var rc={typeParameters:[],parameters:[new fe,E.u8(),new fe,E.u8(),E.u8(),E.u8()]};async function ko(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,i=await we({aptosConfig:t,accountAddress:e.accountAddress}),o=Fe.fromPrivateKey({privateKey:r,legacy:!0}),a=new kn({sequenceNumber:BigInt(i.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=e.sign(a),p=o.sign(a),y=await h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new N(e.signingScheme),T.U8(e.publicKey.toUint8Array()),new N(o.signingScheme),T.U8(o.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:rc}});return nn({aptosConfig:t,signer:e,transaction:y})}var ic={typeParameters:[{constraints:[]}],parameters:[new X,new L]};async function Do(n){let{aptosConfig:t,sender:e,recipient:r,amount:i,coinType:o,options:s}=n;return h({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (Un))],functionArguments:[r,i],abi:ic},options:s})}var rn=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Do({aptosConfig:this.config,...t})}};var Me={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},ie="0x4::token::Token";async function Bo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:ji,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Oo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};return(await f({aptosConfig:t,query:{query:Er,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function Ko(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},o={query:Er,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _103 => _103.offset]),limit:_optionalChain([r, 'optionalAccess', _104 => _104.limit]),order_by:_optionalChain([r, 'optionalAccess', _105 => _105.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function No(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,i={token_data_id:{_eq:u.from(e).toStringLong()}},o={query:Wi,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _106 => _106.offset]),limit:_optionalChain([r, 'optionalAccess', _107 => _107.limit]),order_by:_optionalChain([r, 'optionalAccess', _108 => _108.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var oc={typeParameters:[],parameters:[new m(_()),new L,new m(_()),new m(_()),new F,new F,new F,new F,new F,new F,new F,new F,new F,new L,new L]};async function Go(n){let{aptosConfig:t,options:e,creator:r}=n;return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new K(_nullishCoalesce(n.maxSupply, () => (Ve))),new w(n.name),new w(n.uri),new z(_nullishCoalesce(n.mutableDescription, () => (!0))),new z(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new z(_nullishCoalesce(n.mutableURI, () => (!0))),new z(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new z(_nullishCoalesce(n.mutableTokenName, () => (!0))),new z(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new z(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new z(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new z(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new K(_nullishCoalesce(n.royaltyNumerator, () => (0))),new K(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:oc},options:e})}async function Qr(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:i}=n,o=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _109 => _109.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _110 => _110.tokenStandard]), () => ("v2"))}),(await f({aptosConfig:t,query:{query:_r,variables:{where_condition:s}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Fo(n){let{aptosConfig:t,collectionId:e}=n,i={collection_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:_r,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Mo(n){return(await Qr(n)).collection_id}var sc={typeParameters:[],parameters:[new m(_()),new m(_()),new m(_()),new m(_()),new E(new m(_())),new E(new m(_())),new E(E.u8())]};async function qo(n){let{aptosConfig:t,options:e,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:y}=n,x=_optionalChain([p, 'optionalAccess', _111 => _111.map, 'call', _112 => _112(A=>Me[A])]);return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(i),new w(o),new w(s),new w(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(x, () => ([]))),ns(_nullishCoalesce(y, () => ([])),_nullishCoalesce(x, () => ([])))],abi:sc},options:e})}var ac={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new X]};async function $o(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(r),u.from(i)],abi:ac},options:s})}var cc={typeParameters:[],parameters:[new m(_()),new m(_()),new m(_()),new m(_()),new E(new m(_())),new E(new m(_())),new E(E.u8()),new X]};async function Vo(n){let{aptosConfig:t,account:e,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:y,options:x}=n;if(_optionalChain([c, 'optionalAccess', _113 => _113.length])!==_optionalChain([y, 'optionalAccess', _114 => _114.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _115 => _115.length])!==_optionalChain([y, 'optionalAccess', _116 => _116.length]))throw new Error("Property types and property values counts do not match");let A=_optionalChain([p, 'optionalAccess', _117 => _117.map, 'call', _118 => _118(g=>Me[g])]);return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(A, () => ([]))),ns(_nullishCoalesce(y, () => ([])),_nullishCoalesce(A, () => ([]))),a],abi:cc},options:x})}var uc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0)))]};async function Ho(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (ie))],functionArguments:[u.from(r)],abi:uc},options:o})}var pc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0)))]};async function Lo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (ie))],functionArguments:[r],abi:pc},options:o})}var dc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0)))]};async function Qo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (ie))],functionArguments:[r],abi:dc},options:o})}var lc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(_())]};async function Wo(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new w(r)],abi:lc},options:s})}var gc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(_())]};async function jo(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new w(r)],abi:gc},options:s})}var yc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(_())]};async function Xo(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new w(r)],abi:yc},options:s})}var mc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(_()),new m(_()),E.u8()]};async function Yo(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (ie))],functionArguments:[u.from(s),new w(r),new w(Me[i]),T.U8(Wr(o,Me[i]))],abi:mc},options:c})}var fc={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(_())]};async function Zo(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (ie))],functionArguments:[u.from(i),new w(r)],abi:fc},options:s})}var Ac={typeParameters:[{constraints:["key"]}],parameters:[new m(Y(new D(0))),new m(_()),new m(_()),E.u8()]};async function Jo(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (ie))],functionArguments:[u.from(s),new w(r),new w(Me[i]),Wr(o,Me[i])],abi:Ac},options:c})}var hc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(Y(new D(0))),new m(_()),new D(1)]};async function es(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (ie)),Me[i]],functionArguments:[u.from(s),new w(r),o],abi:hc},options:c})}var Tc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new m(Y(new D(0))),new m(_()),new D(1)]};async function ts(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (ie)),Me[i]],functionArguments:[u.from(s),new w(r),o],abi:Tc},options:c})}function ns(n,t){let e=new Array;return t.forEach((r,i)=>{e.push(Wr(n[i],r))}),e}function Wr(n,t){let e=Ee(t);return kt(n,e,0,[]).bcsToBytes()}var on=class{constructor(t){this.config=t}async getCollectionData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Qr({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Fo({aptosConfig:this.config,...t})}async getCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Mo({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Bo({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Oo({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ko({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),No({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Go({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return qo({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return $o({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Vo({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return Ho({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Lo({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return Qo({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return Wo({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return jo({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return Xo({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return Yo({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return Zo({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return Jo({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return es({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return ts({aptosConfig:this.config,...t})}};var rs=300,bc=n=>{if(n&&n.length>rs)throw new Error(`Event type length exceeds the maximum length of ${rs}`)};async function is(n){let{aptosConfig:t,eventType:e,options:r}=n,o={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _119 => _119.orderBy])};return sn({aptosConfig:t,options:o})}async function os(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _120 => _120.orderBy])};return sn({aptosConfig:e,options:a})}async function ss(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _121 => _121.orderBy])};return sn({aptosConfig:e,options:a})}async function sn(n){let{aptosConfig:t,options:e}=n;bc(_optionalChain([e, 'optionalAccess', _122 => _122.where, 'optionalAccess', _123 => _123.indexed_type, 'optionalAccess', _124 => _124._eq]));let r={query:Hi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _125 => _125.where]),offset:_optionalChain([e, 'optionalAccess', _126 => _126.offset]),limit:_optionalChain([e, 'optionalAccess', _127 => _127.limit]),order_by:_optionalChain([e, 'optionalAccess', _128 => _128.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var an=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),is({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),os({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ss({aptosConfig:this.config,...t})}async getEvents(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _129 => _129.minimumLedgerVersion]),processorType:"events_processor"}),sn({aptosConfig:this.config,...t})}};async function as(n){let{aptosConfig:t,accountAddress:e,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _130 => _130.timeoutSecs])||20,{data:s}=await Ri({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await Rt({aptosConfig:t,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _131 => _131.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var cn=class{constructor(t){this.config=t}async fundAccount(t){let e=await as({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _132 => _132.options, 'optionalAccess', _133 => _133.waitForIndexer])!==!1&&await Ln({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function jr(n){let{aptosConfig:t,options:e}=n,r={query:Qi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _134 => _134.where]),limit:_optionalChain([e, 'optionalAccess', _135 => _135.limit]),offset:_optionalChain([e, 'optionalAccess', _136 => _136.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function cs(n){let{aptosConfig:t,options:e}=n,r={query:Li,variables:{where_condition:_optionalChain([e, 'optionalAccess', _137 => _137.where]),limit:_optionalChain([e, 'optionalAccess', _138 => _138.limit]),offset:_optionalChain([e, 'optionalAccess', _139 => _139.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function us(n){let{aptosConfig:t,options:e}=n,r={query:$i,variables:{where_condition:_optionalChain([e, 'optionalAccess', _140 => _140.where]),limit:_optionalChain([e, 'optionalAccess', _141 => _141.limit]),offset:_optionalChain([e, 'optionalAccess', _142 => _142.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var wc={typeParameters:[],parameters:[Ee("0x1::object::Object"),new X,new L]};async function ps(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:wc},options:s})}var un=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _143 => _143.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),jr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _144 => _144.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await jr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _145 => _145.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),cs({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _146 => _146.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),us({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return ps({aptosConfig:this.config,...t})}};async function qe(n){let{aptosConfig:t,payload:e,options:r}=n,i=await Eo({...e,aptosConfig:t}),o=new R;i.serialize(o);let s=o.toUint8Array(),{data:a}=await st({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _147 => _147.ledgerVersion])},body:s});return a}var pn=class{constructor(t){this.config=t}async getLedgerInfo(){return Gn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return Xi({aptosConfig:this.config,...t})}async getBlockByHeight(t){return Yi({aptosConfig:this.config,...t})}async getTableItem(t){return Fn({aptosConfig:this.config,...t})}async view(t){return qe({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return Zi({aptosConfig:this.config,...t})}async queryIndexer(t){return f({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return Mn({aptosConfig:this.config})}async getProcessorStatus(t){return qn({aptosConfig:this.config,processorType:t})}};var ds=["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 ls(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function $e(n){let[t,e,...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(!ls(t))throw new Error(`${t} is not valid. ${ds}`);if(e&&!ls(e))throw new Error(`${e} is not valid. ${ds}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Sc="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",xc={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Sc,custom:null,devnet:null,randomnet:null};function Ce(n){let t=xc[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var rr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function gs(n){let{aptosConfig:t,name:e}=n,r=Ce(t),{domainName:i,subdomainName:o}=$e(e),s=await qe({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=rr(s[0]);return a?u.from(a):void 0}async function ys(n){let{aptosConfig:t,expiration:e,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=Ce(t),{domainName:y,subdomainName:x}=$e(r),A=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(x&&!A)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(A&&!x)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let ur=_nullishCoalesce(e.years, () => (1));if(ur!==1)throw new Error("For now, names can only be registered for 1 year at a time");let zs=ur*31536e3;return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[y,zs,o,s]},options:a})}if(!x)throw new Error(`${e.policy} requires a subdomain to be provided.`);let g=await Xr({aptosConfig:t,name:y});if(!g)throw new Error("The domain does not exist");let oe=e.policy==="subdomain:independent"?e.expirationDate:g;if(oe>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[y,x,Math.round(oe/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function Xr(n){let{aptosConfig:t,name:e}=n,r=Ce(t),{domainName:i,subdomainName:o}=$e(e);try{let s=await qe({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e3){return}}async function ms(n){let{aptosConfig:t,address:e}=n,r=Ce(t),i=await qe({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),o=rr(i[1]),s=rr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function fs(n){let{aptosConfig:t,sender:e,name:r,options:i}=n,o=Ce(t);if(!r)return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=$e(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function As(n){let{aptosConfig:t,name:e}=n,r=Ce(t),{domainName:i,subdomainName:o}=$e(e),s=await qe({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=rr(s[0]);return a?u.from(a):void 0}async function hs(n){let{aptosConfig:t,sender:e,name:r,address:i,options:o}=n,s=Ce(t),{domainName:a,subdomainName:c}=$e(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ts(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:i=""}=$e(e),a=(await f({aptosConfig:t,query:{query:It,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=dn(a)),a}async function bs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Yr({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountNames",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _148 => _148.limit]),offset:_optionalChain([e, 'optionalAccess', _149 => _149.offset]),order_by:_optionalChain([e, 'optionalAccess', _150 => _150.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _151 => _151.options, 'optionalAccess', _152 => _152.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(dn)}async function ws(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Yr({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountDomains",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _153 => _153.limit]),offset:_optionalChain([e, 'optionalAccess', _154 => _154.offset]),order_by:_optionalChain([e, 'optionalAccess', _155 => _155.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _156 => _156.options, 'optionalAccess', _157 => _157.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(dn)}async function Ss(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Yr({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _158 => _158.limit]),offset:_optionalChain([e, 'optionalAccess', _159 => _159.offset]),order_by:_optionalChain([e, 'optionalAccess', _160 => _160.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _161 => _161.options, 'optionalAccess', _162 => _162.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(dn)}async function xs(n){let{aptosConfig:t,options:e,domain:r}=n;return(await f({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:It,variables:{limit:_optionalChain([e, 'optionalAccess', _163 => _163.limit]),offset:_optionalChain([e, 'optionalAccess', _164 => _164.offset]),order_by:_optionalChain([e, 'optionalAccess', _165 => _165.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _166 => _166.options, 'optionalAccess', _167 => _167.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(dn)}async function Yr(n){let{aptosConfig:t}=n,e=Ce(t),[r]=await qe({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function _s(n){let{aptosConfig:t,sender:e,name:r,years:i=1,options:o}=n,s=Ce(t),a=i*31536e3,{domainName:c,subdomainName:p}=$e(r);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function dn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var ln=class{constructor(t){this.config=t}async getOwnerAddress(t){return gs({aptosConfig:this.config,...t})}async getExpiration(t){return Xr({aptosConfig:this.config,...t})}async getTargetAddress(t){return As({aptosConfig:this.config,...t})}async setTargetAddress(t){return hs({aptosConfig:this.config,...t})}async getPrimaryName(t){return ms({aptosConfig:this.config,...t})}async setPrimaryName(t){return fs({aptosConfig:this.config,...t})}async registerName(t){return ys({aptosConfig:this.config,...t})}async renewDomain(t){return _s({aptosConfig:this.config,...t})}async getName(t){return Ts({aptosConfig:this.config,...t})}async getAccountNames(t){return bs({aptosConfig:this.config,...t})}async getAccountDomains(t){return ws({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Ss({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return xs({aptosConfig:this.config,...t})}};async function vs(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:vr,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 Ps(n){let{aptosConfig:t,options:e}=n,r={query:vr,variables:{order_by:_optionalChain([e, 'optionalAccess', _168 => _168.orderBy])}};return(await f({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function Es(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,i={query:Vi,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:t,query:i})).delegated_staking_activities}var gn=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _169 => _169.minimumLedgerVersion]),processorType:"stake_processor"}),vs({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _170 => _170.minimumLedgerVersion]),processorType:"stake_processor"}),Ps({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _171 => _171.minimumLedgerVersion]),processorType:"stake_processor"}),Es({aptosConfig:this.config,...t})}};var ir=class{constructor(t){this.config=t}async simple(t){return h({aptosConfig:this.config,...t})}async multiAgent(t){return h({aptosConfig:this.config,...t})}};function Zr(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},e}function Jr(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,i)},e}var Dt=class{constructor(t){this.config=t}async simple(t){return Lr({aptosConfig:this.config,...t})}async multiAgent(t){return Lr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [Jr],Dt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [Jr],Dt.prototype,"multiAgent",1);var Bt=class{constructor(t){this.config=t}async simple(t){return nr({aptosConfig:this.config,...t})}async multiAgent(t){return nr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [Zr],Bt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [Zr],Bt.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var or=()=>Math.floor(Date.now()/1e3),sr= exports.AccountSequenceNumber =class{constructor(t,e,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=or();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),or()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=or();for(;this.lastUncommintedNumber!==this.currentNumber;)or()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var Ot=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _172 => _172.pendingDequeue, 'access', _173 => _173.shift, 'call', _174 => _174(), 'optionalAccess', _175 => _175.resolve, 'call', _176 => _176(t)]);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new Kt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Kt=class extends Error{};var Cs="fulfilled",Is= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Is||{}),ar= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,i=30,o=100,s=10){super();this.taskQueue=new Ot;this.transactionsQueue=new Ot;this.outstandingTransactions=new Ot;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new sr(e,r,i,o,s)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let i=nn({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof Kt)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(e.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),e.push(i),r.push(o);let s=await Promise.allSettled(e);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Cs?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(e){if(e instanceof Kt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let i=[];i.push(Rt({aptosConfig:this.aptosConfig,transactionHash:e.value.hash,options:{timeoutSecs:3}}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===Cs?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return h({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}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 cr=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new ar(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:i}=e;for(let o of r)this.transactionWorker.push(o,i)}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:r,data:i,options:o}=e;this.start({sender:r}),this.push({data:i,options:o})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var yn=class{constructor(t){this.config=t,this.build=new ir(this.config),this.simulate=new Dt(this.config),this.submit=new Bt(this.config),this.batch=new cr(this.config)}async getTransactions(t){return yo({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return mo({aptosConfig:this.config,...t})}async getTransactionByHash(t){return Jt({aptosConfig:this.config,...t})}async isPendingTransaction(t){return fo({aptosConfig:this.config,...t})}async waitForTransaction(t){return Rt({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return Hn({aptosConfig:this.config})}getSigningMessage(t){return Ro(t)}async publishPackageTransaction(t){return zo({aptosConfig:this.config,...t})}async rotateAuthKey(t){return ko({aptosConfig:this.config,...t})}sign(t){return tr({...t})}signAsFeePayer(t){let{signer:e,transaction:r}=t;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=e.accountAddress,tr({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:i}=t;this.batch.forSingleAccount({sender:e,data:r,options:i})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return nn({aptosConfig:this.config,signer:e,transaction:r})}};var _bls12381 = require('@noble/curves/bls12-381');var Pc="APTOS_KEYLESS_PEPPER_PINKAS_VUF_DST";function Ec(n){return new TextEncoder().encode(n)}var Cc=_bls12381.bls12_381.G2.hashToCurve(Ec("APTOS_KEYLESS_PEPPER_PINKAS_VUF_SECRET_KEY_BASE"),{DST:Pc}).toAffine();function Ic(n){let{jwt:t,uidKey:e}=n,r=_jwtdecode.jwtDecode.call(void 0, t),i=new R;i.serializeStr(r.iss),i.serializeStr(r.aud),i.serializeStr(r[e||"sub"]),i.serializeStr(e||"sub");let o=i.toUint8Array(),s=_bls12381.bls12_381.G1.hashToCurve(o,{DST:"APTOS_PEPPER_SERVICE_BLS12381_VUF_DST"}).toAffine();return _bls12381.bls12_381.G1.ProjectivePoint.fromAffine(s)}async function Uc(n){let{aptosConfig:t,pepperInput:e,pepperBase:r}=n,{data:i}=await Ii({aptosConfig:t,path:"vrf-pub-key",originMethod:"getPepper"}),o=_bls12381.bls12_381.G2.ProjectivePoint.fromHex(i.vrf_public_key_hex_string);return _bls12381.bls12_381.verifyShortSignature(r,e,o)}async function ei(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,uidKey:i,verify:o}=n,{derivationPath:s}=n,a={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i},{data:c}=await zi({aptosConfig:t,path:"fetch",body:a,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}}),p=l.fromHexInput(c.signature).toUint8Array();if(o&&!Uc({aptosConfig:t,pepperBase:p,pepperInput:Ic(n)}))throw new Error("Unable to verify");let y=_bls12381.bls12_381.pairing(_bls12381.bls12_381.G1.ProjectivePoint.fromHex(p),_bls12381.bls12_381.G2.ProjectivePoint.fromAffine(Cc));return s===void 0&&(s=li),Pe.fromDerivationPath(s,_bls12381.bls12_381.fields.Fp12.toBytes(y)).slice(0,31)}async function Rc(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,pepper:i,uidKey:o,extraFieldKey:s}=n,a=_jwtdecode.jwtDecode.call(void 0, e),c;if(s){let oe=a[s];c=`"${s}":"${oe}",`}let p={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:l.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),exp_horizon_secs:qt,pepper:l.fromHexInput(i).toStringWithoutPrefix(),extra_field:s,uid_key:o||"sub"},{data:y}=await ki({aptosConfig:t,path:"prove",body:p,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),x=y.proof,A=new lt({a:x.a,b:x.b,c:x.c});return new Oe({proof:A,extraField:c,trainingWheelsSignature:de.fromHex(y.training_wheels_signature)})}async function Rs(n){let{pepper:t}=n;if(t===void 0)t=await ei(n);else if(l.fromHexInput(t).toUint8Array().length!==31)throw new Error("Pepper needs to be 31 bytes");let e=await Rc({...n,pepper:t});return Pe.fromJWTAndProof({...n,proof:e,pepper:t})}var mn=class{constructor(t){this.config=t}async getPepper(t){return ei({aptosConfig:this.config,...t})}async deriveKeylessAccount(t){return Rs({aptosConfig:this.config,...t})}};var J=class{constructor(t){this.config=new Qn(t),this.account=new en(this.config),this.ans=new ln(this.config),this.coin=new rn(this.config),this.digitalAsset=new on(this.config),this.event=new an(this.config),this.faucet=new cn(this.config),this.fungibleAsset=new un(this.config),this.general=new pn(this.config),this.staking=new gn(this.config),this.transaction=new yn(this.config),this.keyless=new mn(this.config)}};function le(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(t.prototype,r);i&&(i.value=function(...o){return this[e][r](...o)},Object.defineProperty(n.prototype,r,i))})}le(J,en,"account");le(J,ln,"ans");le(J,rn,"coin");le(J,on,"digitalAsset");le(J,an,"event");le(J,cn,"faucet");le(J,un,"fungibleAsset");le(J,pn,"general");le(J,gn,"staking");le(J,yn,"transaction");le(J,mn,"keyless");exports.APTOS_BIP44_DEFAULT_DERIVATION_PATH = li; exports.APTOS_BIP44_REGEX = Ls; exports.APTOS_COIN = Un; exports.APTOS_HARDENED_REGEX = Hs; exports.Account = Fe; exports.AccountAddress = u; exports.AccountAuthenticator = j; exports.AccountAuthenticatorEd25519 = me; exports.AccountAuthenticatorMultiEd25519 = Cn; exports.AccountAuthenticatorMultiKey = Ne; exports.AccountAuthenticatorSingleKey = ne; exports.AccountAuthenticatorVariant = oi; exports.AccountPublicKey = ee; exports.AccountSequenceNumber = sr; exports.AddressInvalidReason = Ms; exports.AnyPublicKey = O; exports.AnyPublicKeyVariant = dr; exports.AnySignature = $; exports.AnySignatureVariant = si; exports.Aptos = J; exports.AptosApiError = re; exports.AptosApiType = $t; exports.AptosConfig = Qn; exports.AuthenticationKey = G; exports.Bool = z; exports.CKDPriv = Ws; exports.ChainId = ft; exports.DEFAULT_MAX_GAS_AMOUNT = bi; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = wi; exports.DEFAULT_TXN_TIMEOUT_SEC = In; exports.DeriveScheme = Gs; exports.Deserializer = Re; exports.EPK_HORIZON_SECS = qt; exports.Ed25519Account = Pt; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = v; exports.Ed25519Signature = P; exports.EntryFunction = ot; exports.EntryFunctionBytes = Tn; exports.EphemeralCertificate = ci; exports.EphemeralKeyPair = Bn; exports.EphemeralPublicKey = et; exports.EphemeralPublicKeyVariant = lr; exports.EphemeralSignature = de; exports.EphemeralSignatureVariant = ai; exports.FeePayerRawTransaction = he; exports.FixedBytes = Le; exports.Groth16Zkp = lt; exports.HARDENED_OFFSET = yr; exports.Hex = l; exports.HexInvalidReason = Bs; exports.Identifier = U; exports.KeyType = Qs; exports.KeylessAccount = Pe; exports.KeylessPublicKey = Be; exports.KeylessSignature = Ke; exports.MAX_AUD_VAL_BYTES = wa; exports.MAX_COMMITED_EPK_BYTES = ld; exports.MAX_EXTRA_FIELD_BYTES = pd; exports.MAX_ISS_VAL_BYTES = ud; exports.MAX_JWT_HEADER_B64_BYTES = dd; exports.MAX_UID_KEY_BYTES = Sa; exports.MAX_UID_VAL_BYTES = xa; exports.MimeType = bn; exports.ModuleId = Vt; exports.MoveAbility = ui; exports.MoveFunctionVisibility = Ks; exports.MoveOption = ke; exports.MoveString = w; exports.MoveVector = T; exports.MultiAgentRawTransaction = Ae; exports.MultiEd25519PublicKey = pt; exports.MultiEd25519Signature = je; exports.MultiKey = yt; exports.MultiKeyAccount = On; exports.MultiSig = jt; exports.MultiSigTransactionPayload = Xt; exports.MultiSignature = nt; exports.Network = wr; exports.NetworkToChainId = Sr; exports.NetworkToFaucetAPI = Ei; exports.NetworkToIndexerAPI = vi; exports.NetworkToNetworkName = Ly; exports.NetworkToNodeAPI = Pi; exports.NetworkToPepperAPI = Tr; exports.NetworkToProverAPI = br; exports.OpenIdSignature = gt; exports.OpenIdSignatureOrZkProof = tt; exports.ParsingError = H; exports.ProcessorType = mt; exports.PublicKey = Qe; exports.RAW_TRANSACTION_SALT = Si; exports.RAW_TRANSACTION_WITH_DATA_SALT = xi; exports.RawTransaction = M; exports.RawTransactionWithData = zn; exports.RoleType = Ns; exports.RotationProofChallenge = kn; exports.Script = Wt; exports.ScriptTransactionArgumentVariants = Gt; exports.Secp256k1PrivateKey = Ze; exports.Secp256k1PublicKey = Ye; exports.Secp256k1Signature = Je; exports.Serializable = d; exports.Serializer = R; exports.Signature = B; exports.SignedGroth16Signature = Oe; exports.SignedTransaction = Te; exports.SigningScheme = ge; exports.SigningSchemeInput = wn; exports.SimpleTransaction = Dn; exports.SingleKeyAccount = Et; exports.StructTag = _e; exports.TransactionAuthenticator = ve; exports.TransactionAuthenticatorEd25519 = wt; exports.TransactionAuthenticatorFeePayer = xt; exports.TransactionAuthenticatorMultiAgent = St; exports.TransactionAuthenticatorMultiEd25519 = hr; exports.TransactionAuthenticatorSingleSender = _t; exports.TransactionAuthenticatorVariant = ii; exports.TransactionPayload = it; exports.TransactionPayloadEntryFunction = Lt; exports.TransactionPayloadMultiSig = Qt; exports.TransactionPayloadScript = Ht; exports.TransactionPayloadVariants = ni; exports.TransactionResponseType = gr; exports.TransactionVariants = ri; exports.TransactionWorker = ar; exports.TransactionWorkerEventsEnum = Is; exports.TypeTag = k; exports.TypeTagAddress = X; exports.TypeTagBool = F; exports.TypeTagGeneric = D; exports.TypeTagParserError = C; exports.TypeTagParserErrorType = Ma; exports.TypeTagReference = Rn; exports.TypeTagSigner = rt; exports.TypeTagStruct = m; exports.TypeTagU128 = Tt; exports.TypeTagU16 = At; exports.TypeTagU256 = bt; exports.TypeTagU32 = ht; exports.TypeTagU64 = L; exports.TypeTagU8 = fe; exports.TypeTagVariants = ti; exports.TypeTagVector = E; exports.U128 = ce; exports.U16 = se; exports.U256 = ue; exports.U32 = ae; exports.U64 = K; exports.U8 = N; exports.aptosCoinStructTag = Sl; exports.aptosRequest = Kn; exports.buildTransaction = Vr; exports.checkOrConvertArgument = kt; exports.computeAddressSeed = En; exports.convertArgument = $r; exports.deriveKey = gi; exports.deriveTransactionType = vt; exports.deserializeFromScriptArgument = _a; exports.ensureBoolean = pr; exports.fetchEntryFunctionAbi = vo; exports.fetchFunctionAbi = _o; exports.fetchViewFunctionAbi = Po; exports.findFirstNonSignerArg = xo; exports.fromDerivationPath = Sn; exports.generateMultiSignersSignedTransaction = Ya; exports.generateRawTransaction = ja; exports.generateSignedTransaction = Hr; exports.generateSignedTransactionForSimulation = Co; exports.generateSigningMessage = Yt; exports.generateSigningMessageForSerializable = Cg; exports.generateSigningMessageForTransaction = Ge; exports.generateTransactionPayload = er; exports.generateTransactionPayloadWithABI = La; exports.generateUserTransactionHash = Qf; exports.generateViewFunctionPayload = Eo; exports.generateViewFunctionPayloadWithABI = Qa; exports.get = xr; exports.getAptosFullNode = Z; exports.getAptosPepperService = Ii; exports.getAuthenticatorForSimulation = Jn; exports.getFunctionParts = tn; exports.hashValues = Io; exports.isBcsAddress = Yn; exports.isBcsBool = kr; exports.isBcsFixedBytes = qa; exports.isBcsString = Dr; exports.isBcsU128 = Gr; exports.isBcsU16 = Or; exports.isBcsU256 = Fr; exports.isBcsU32 = Kr; exports.isBcsU64 = Nr; exports.isBcsU8 = Br; exports.isBlockMetadataTransactionResponse = ru; exports.isBool = To; exports.isEd25519Signature = su; exports.isEncodedEntryFunctionArgument = wo; exports.isFeePayerSignature = uu; exports.isGenesisTransactionResponse = nu; exports.isLargeNumber = Xn; exports.isMultiAgentSignature = cu; exports.isMultiEd25519Signature = pu; exports.isNull = bo; exports.isNumber = jn; exports.isPendingTransactionResponse = eu; exports.isScriptDataInput = So; exports.isSecp256k1Signature = au; exports.isStateCheckpointTransactionResponse = iu; exports.isString = zt; exports.isUserTransactionResponse = tu; exports.isValidBIP44Path = mr; exports.isValidHardenedPath = fr; exports.isValidatorTransactionResponse = ou; exports.mnemonicToSeed = xn; exports.objectStructTag = Y; exports.optionStructTag = xl; exports.outOfRangeErrorMessage = Os; exports.paginateWithCursor = Ct; exports.parseTypeTag = Ee; exports.post = Zt; exports.postAptosFaucet = Ri; exports.postAptosFullNode = st; exports.postAptosIndexer = Ui; exports.postAptosPepperService = zi; exports.postAptosProvingService = ki; exports.promiseFulfilledStatus = Cs; exports.request = ka; exports.splitPath = Xs; exports.standardizeTypeTags = qr; exports.stringStructTag = _; exports.throwTypeMismatch = I; exports.validateNumberInRange = ze;
|
|
428
|
+
`;async function cn(n){let{aptosConfig:t}=n,{data:e}=await V({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function To(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:o}=await V({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _31 => _31.withTransactions])}});return o}async function bo(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:o}=await V({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _32 => _32.withTransactions])}});return o}async function un(n){let{aptosConfig:t,handle:e,data:r,options:o}=n;return(await Ge({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _33 => _33.ledgerVersion])},body:r})).data}async function wo(n){let{aptosConfig:t,limit:e}=n;return(await y({aptosConfig:t,query:{query:po,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function y(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:o}=await qr({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return o}async function ws(n){let{aptosConfig:t}=n;return(await y({aptosConfig:t,query:{query:Qn},originMethod:"getProcessorStatuses"})).processor_status}async function pn(n){let t=await ws({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function dn(n){let{aptosConfig:t,processorType:e}=n;return(await y({aptosConfig:t,query:{query:Qn,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var jn=new Map;function nt(n,t,e){return async(...r)=>{if(jn.has(t)){let{value:i,timestamp:s}=jn.get(t);if(e===void 0||Date.now()-s<=e)return i}let o=await n(...r);return jn.set(t,{value:o,timestamp:Date.now()}),o}}async function le(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await V({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function xo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return We({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _34 => _34.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _35 => _35.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _36 => _36.limit]), () => (1e3))}})}async function ln(n){return _optionalChain([n, 'access', _37 => _37.options, 'optionalAccess', _38 => _38.ledgerVersion])!==void 0?_o(n):nt(async()=>_o(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function _o(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:o}=n,{data:i}=await V({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _39 => _39.ledgerVersion])}});return i}async function vo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return We({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _40 => _40.offset]),limit:_optionalChain([r, 'optionalAccess', _41 => _41.limit])}})}async function Co(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return We({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _42 => _42.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _43 => _43.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _44 => _44.limit]), () => (999))}})}async function Xn(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:o}=n,{data:i}=await V({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([o, 'optionalAccess', _45 => _45.ledgerVersion])}});return i.data}async function Yn(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,o=await Xn({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:i}}=o,s=u.from(e);try{let a=await un({aptosConfig:t,handle:i,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Po(n){let{aptosConfig:t,accountAddress:e}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s=await y({aptosConfig:t,query:{query:co,variables:{where_condition:o}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Eo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _46 => _46.tokenStandard])&&(i.token_standard={_eq:_optionalChain([r, 'optionalAccess', _47 => _47.tokenStandard])});let s={query:so,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _48 => _48.offset]),limit:_optionalChain([r, 'optionalAccess', _49 => _49.limit]),order_by:_optionalChain([r, 'optionalAccess', _50 => _50.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Io(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:o}=n,i=u.from(e).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:i},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([o, 'optionalAccess', _51 => _51.tokenStandard])&&(a.token_standard={_eq:_optionalChain([o, 'optionalAccess', _52 => _52.tokenStandard])});let c={query:ao,variables:{where_condition:a,offset:_optionalChain([o, 'optionalAccess', _53 => _53.offset]),limit:_optionalChain([o, 'optionalAccess', _54 => _54.limit]),order_by:_optionalChain([o, 'optionalAccess', _55 => _55.orderBy])}};return(await y({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Uo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _56 => _56.tokenStandard])&&(i.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _57 => _57.tokenStandard])}});let s={query:oo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _58 => _58.offset]),limit:_optionalChain([r, 'optionalAccess', _59 => _59.limit]),order_by:_optionalChain([r, 'optionalAccess', _60 => _60.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function Ro(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:uo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return i.account_transactions_aggregate.aggregate?i.account_transactions_aggregate.aggregate.count:0}async function zo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,o=u.from(e).toStringLong(),i=await Zn({aptosConfig:t,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return i[0]?i[0].amount:0}async function Zn(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o=u.from(e).toStringLong(),i={..._optionalChain([r, 'optionalAccess', _61 => _61.where]),owner_address:{_eq:o}},s={query:ro,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _62 => _62.offset]),limit:_optionalChain([r, 'optionalAccess', _63 => _63.limit]),order_by:_optionalChain([r, 'optionalAccess', _64 => _64.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function No(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:no,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!i.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return i.current_fungible_asset_balances_aggregate.aggregate.count}async function Do(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()}},s={query:io,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([r, 'optionalAccess', _66 => _66.limit]),order_by:_optionalChain([r, 'optionalAccess', _67 => _67.orderBy])}};return(await y({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Go(n){let{aptosConfig:t,privateKey:e}=n,r=new q(e.publicKey());if(e instanceof Fe){let i=K.fromPublicKey({publicKey:r}).derivedAddress();return Pe.fromPrivateKey({privateKey:e,address:i})}if(e instanceof J){let o=K.fromPublicKey({publicKey:r});if(await So({authKey:o,aptosConfig:t})){let c=o.derivedAddress();return Pe.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=K.fromPublicKey({publicKey:r.publicKey});if(await So({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Pe.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function So(n){let{aptosConfig:t,authKey:e}=n,r=await Yn({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await le({aptosConfig:t,accountAddress:r}),!0}catch(o){if(o.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function ko(n){let{aptosConfig:t,options:e}=n;return We({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _68 => _68.offset]),limit:_optionalChain([e, 'optionalAccess', _69 => _69.limit])}})}async function mn(n){let{aptosConfig:t}=n;return nt(async()=>{let{data:e}=await V({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function Oo(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await V({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function St(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await V({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Bo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await St({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _70 => _70.status])===404)return!0;throw r}}async function _s(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await V({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function rt(n){let{aptosConfig:t,transactionHash:e,options:r}=n,o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _71 => _71.timeoutSecs]), () => (20)),i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _72 => _72.checkSuccess]), () => (!0)),s=!0,a=0,c,p,m=200,N=1.5;function b(l){if(!(l instanceof ae)||(p=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await St({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(l){b(l)}if(s){let l=Date.now();try{c=await _s({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(ye){b(ye)}a=(Date.now()-l)/1e3}for(;s&&!(a>=o);){try{if(c=await St({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(l){b(l)}await _chunkKSEUZTKYjs.b.call(void 0, m),a+=m/1e3,m*=N}if(c===void 0)throw p||new gn(`Fetching transaction ${e} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new gn(`Transaction ${e} timed out in pending state after ${o} seconds`,c);if(!i)return c;if(!c.success)throw new Jn(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function yn(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),o=3e3,i=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-i>o)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?s=await pn({aptosConfig:t}):s=(await dn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var gn=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Jn=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function T(n){n.minimumLedgerVersion!==void 0&&await yn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var xt=class{constructor(t){this.config=t}async getAccountInfo(t){return le({aptosConfig:this.config,...t})}async getAccountModules(t){return xo({aptosConfig:this.config,...t})}async getAccountModule(t){return ln({aptosConfig:this.config,...t})}async getAccountTransactions(t){return vo({aptosConfig:this.config,...t})}async getAccountResources(t){return Co({aptosConfig:this.config,...t})}async getAccountResource(t){return Xn({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Yn({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Po({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Eo({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Io({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Uo({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ro({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Zn({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),No({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Qt,...t})}async getAccountCoinAmount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),zo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),Do({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return Go({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var An=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _73 => _73.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _74 => _74.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _75 => _75.faucet]),this.indexer=_optionalChain([t, 'optionalAccess', _76 => _76.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _77 => _77.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _78 => _78.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _79 => _79.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _80 => _80.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _81 => _81.faucetConfig]), () => ({}))}getRequestUrl(t){switch(t){case"Fullnode":if(this.fullnode!==void 0)return this.fullnode;if(this.network==="custom")throw new Error("Please provide a custom full node url");return Dr[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Gr[this.network];case"Indexer":if(this.indexer!==void 0)return this.indexer;if(this.network==="custom")throw new Error("Please provide a custom indexer url");return Nr[this.network];default:throw Error(`apiType ${t} is not supported`)}}};var fn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new D(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=h.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var Te=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return ot.load(t);case 1:return er.load(t);case 2:return it.load(t);case 3:return st.load(t);case 4:return at.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},ot= exports.TransactionAuthenticatorEd25519 =class n extends Te{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=I.deserialize(e),o=U.deserialize(e);return new n(r,o)}},er= exports.TransactionAuthenticatorMultiEd25519 =class n extends Te{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=Ye.deserialize(e),o=Oe.deserialize(e);return new n(r,o)}},it= exports.TransactionAuthenticatorMultiAgent =class n extends Te{constructor(e,r,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=o}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=B.deserialize(e),o=e.deserializeVector(u),i=e.deserializeVector(B);return new n(r,o,i)}},st= exports.TransactionAuthenticatorFeePayer =class n extends Te{constructor(e,r,o,i){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=o,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 r=B.deserialize(e),o=e.deserializeVector(u),i=e.deserializeVector(B),s=u.deserialize(e),a=B.deserialize(e),c={address:s,authenticator:a};return new n(r,o,i,c)}},at= exports.TransactionAuthenticatorSingleSender =class n extends Te{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=B.deserialize(e);return new n(r)}};var ct=class n extends d{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new n(r)}};var P=class n extends d{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new n(r)}};var vt=class n extends d{constructor(e,r){super();this.address=e,this.name=r}static fromStr(e){let r=e.split("::");if(r.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(r[0]),new P(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),o=P.deserialize(e);return new n(r,o)}};var R=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return k.load(t);case 1:return ge.load(t);case 2:return $.load(t);case 3:return dt.load(t);case 4:return Q.load(t);case 5:return Me.load(t);case 6:return x.load(t);case 7:return g.load(t);case 8:return ut.load(t);case 9:return pt.load(t);case 10:return lt.load(t);case 255:return z.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof k}isAddress(){return this instanceof Q}isGeneric(){return this instanceof z}isSigner(){return this instanceof Me}isVector(){return this instanceof x}isStruct(){return this instanceof g}isU8(){return this instanceof ge}isU16(){return this instanceof ut}isU32(){return this instanceof pt}isU64(){return this instanceof $}isU128(){return this instanceof dt}isU256(){return this instanceof lt}},k= exports.TypeTagBool =class n extends R{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},ge= exports.TypeTagU8 =class n extends R{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},ut= exports.TypeTagU16 =class n extends R{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},pt= exports.TypeTagU32 =class n extends R{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},$= exports.TypeTagU64 =class n extends R{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},dt= exports.TypeTagU128 =class n extends R{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},lt= exports.TypeTagU256 =class n extends R{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},Q= exports.TypeTagAddress =class n extends R{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},Me= exports.TypeTagSigner =class n extends R{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},hn= exports.TypeTagReference =class n extends R{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=R.deserialize(e);return new n(r)}},z= exports.TypeTagGeneric =class n extends R{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let r=e.deserializeU32();return new n(r)}},x= exports.TypeTagVector =class n extends R{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ge)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=R.deserialize(e);return new n(r)}},g= exports.TypeTagStruct =class n extends R{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let r=be.deserialize(e);return new n(r)}isTypeTag(e,r,o){return this.value.moduleName.identifier===r&&this.value.name.identifier===o&&this.value.address.equals(e)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},be= exports.StructTag =class n extends d{constructor(e,r,o,i){super();this.address=e,this.moduleName=r,this.name=o,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 r=u.deserialize(e),o=P.deserialize(e),i=P.deserialize(e),s=e.deserializeVector(R);return new n(r,o,i,s)}};function Vl(){return new be(u.ONE,new P("aptos_coin"),new P("AptosCoin"),[])}function S(){return new be(u.ONE,new P("string"),new P("String"),[])}function Ll(n){return new be(u.ONE,new P("option"),new P("Option"),[n])}function W(n){return new be(u.ONE,new P("object"),new P("Object"),[n])}function xs(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return G.deserialize(n);case 1:return D.deserialize(n);case 2:return ie.deserialize(n);case 3:return u.deserialize(n);case 4:return h.deserialize(n,G);case 5:return E.deserialize(n);case 6:return re.deserialize(n);case 7:return oe.deserialize(n);case 8:return se.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var Ke=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ct.load(t);case 2:return Pt.load(t);case 3:return Et.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Ct= exports.TransactionPayloadScript =class n extends Ke{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=It.deserialize(e);return new n(r)}},Pt= exports.TransactionPayloadEntryFunction =class n extends Ke{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=qe.deserialize(e);return new n(r)}},Et= exports.TransactionPayloadMultiSig =class n extends Ke{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Ut.deserialize(e);return new n(r)}},qe= exports.EntryFunction =class n{constructor(t,e,r,o){this.module_name=t,this.function_name=e,this.type_args=r,this.args=o}static build(t,e,r,o){return new n(vt.fromStr(t),new P(e),r,o)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=vt.deserialize(t),r=P.deserialize(t),o=t.deserializeVector(R),i=t.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<i;a+=1){let c=t.deserializeUleb128AsU32(),p=Zt.deserialize(t,c);s.push(p)}return new n(e,r,o,s)}},It= exports.Script =class n{constructor(t,e,r){this.bytecode=t,this.type_args=e,this.args=r}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),r=t.deserializeVector(R),o=t.deserializeUleb128AsU32(),i=new Array;for(let s=0;s<o;s+=1){let a=xs(t);i.push(a)}return new n(e,r,i)}},Ut= exports.MultiSig =class n{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=u.deserialize(t),r=t.deserializeBool(),o;return r&&(o=Rt.deserialize(t)),new n(e,o)}},Rt= exports.MultiSigTransactionPayload =class n extends d{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(qe.deserialize(e))}};var j=class n extends d{constructor(e,r,o,i,s,a,c){super();this.sender=e,this.sequence_number=r,this.payload=o,this.max_gas_amount=i,this.gas_unit_price=s,this.expiration_timestamp_secs=a,this.chain_id=c}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 r=u.deserialize(e),o=e.deserializeU64(),i=Ke.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=ct.deserialize(e);return new n(r,o,i,s,a,c,p)}},Tn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return $e.load(t);case 1:return Ve.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},$e= exports.MultiAgentRawTransaction =class n extends Tn{constructor(e,r){super();this.raw_txn=e,this.secondary_signer_addresses=r}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let r=j.deserialize(e),o=e.deserializeVector(u);return new n(r,o)}},Ve= exports.FeePayerRawTransaction =class n extends Tn{constructor(e,r,o){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=o}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 r=j.deserialize(e),o=e.deserializeVector(u),i=u.deserialize(e);return new n(r,o,i)}};var Le=class n extends d{constructor(e,r){super();this.raw_txn=e,this.authenticator=r}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let r=j.deserialize(e),o=Te.deserialize(e);return new n(r,o)}};var bn=class n extends d{constructor(e,r){super();this.rawTransaction=e,this.feePayerAddress=r}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=j.deserialize(e),o=e.deserializeBool(),i;return o&&(i=u.deserialize(e)),new n(r,i)}};function Fo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Mo(n){return!!n.match(/\s/)}function vs(n){return!!n.match(/^T[0-9]+$/)}function Cs(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!Mo(r))break}return e}var Ps=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b))(Ps||{}),v= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function we(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _82 => _82.allowGenerics]), () => (!1)),r=[],o=[],i=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:i}),a="",i=[],c=1;else if(p===">"){if(a!==""){let ye=wn(a,o,e);i.push(ye)}let m=r.pop();if(m===void 0)throw new v(n,"unexpected '>'");if(c!==i.length)throw new v(n,"type argument count doesn't match expected amount");let{savedStr:N,savedTypes:b,savedExpectedTypes:l}=m;o=i,i=b,a=N,c=l}else if(p===","){if(a.length!==0){let m=wn(a,o,e);o=[],i.push(m),a="",c+=1}}else if(Mo(p)){let m=!1;if(a.length!==0){let b=wn(a,o,e);o=[],i.push(b),a="",m=!0}s=Cs(n,s);let N=n[s];if(s<n.length&&m&&N!==","&&N!==">")throw new v(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new v(n,"no matching '>' for '<'");switch(i.length){case 0:return wn(a,o,e);case 1:if(a==="")return i[0];throw new v(n,"unexpected ','");default:throw new v(n,"unexpected whitespace character")}}function wn(n,t,e){switch(n){case"&signer":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new hn(new Me);case"signer":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new Me;case"bool":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new k;case"address":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new Q;case"u8":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new ge;case"u16":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new ut;case"u32":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new pt;case"u64":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new $;case"u128":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new dt;case"u256":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new lt;case"vector":if(t.length!==1)throw new v(n,"vector type expected to have exactly one type argument");return new x(t[0]);default:if(vs(n)){if(e)return new z(Number(n.split("T")[1]));throw new v(n,"unexpected generic type")}if(!n.match(/:/))throw new v(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new v(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!Fo(r[1]))throw new v(n,"module name must only contain alphanumeric or '_' characters");if(!Fo(r[2]))throw new v(n,"struct name must only contain alphanumeric or '_' characters");return new g(new be(u.fromString(r[0]),new P(r[1]),new P(r[2]),t))}}function Ko(n){return typeof n=="boolean"}function gt(n){return typeof n=="string"}function _n(n){return typeof n=="number"}function Sn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function qo(n){return n==null}function $o(n){return tr(n)||rr(n)||or(n)||ir(n)||sr(n)||ar(n)||cr(n)||xn(n)||nr(n)||Es(n)||n instanceof h||n instanceof ve}function tr(n){return n instanceof E}function xn(n){return n instanceof u}function nr(n){return n instanceof w}function Es(n){return n instanceof De}function rr(n){return n instanceof G}function or(n){return n instanceof re}function ir(n){return n instanceof oe}function sr(n){return n instanceof D}function ar(n){return n instanceof ie}function cr(n){return n instanceof se}function Vo(n){return"bytecode"in n}function C(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Lo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function zt(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],o=t[2];return{moduleAddress:e,moduleName:r,functionName:o}}var Is=new TextEncoder;function pr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _83 => _83.map, 'call', _84 => _84(t=>gt(t)?we(t):t)]), () => ([]))}async function Ho(n,t,e,r){let o=await ln({aptosConfig:r,accountAddress:n,moduleName:t});if(o.abi)return o.abi.exposed_functions.find(i=>i.name===e)}async function Qo(n,t,e,r){let o=await Ho(n,t,e,r);if(!o)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!o.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let i=Lo(o),s=[];for(let a=i;a<o.params.length;a+=1)s.push(we(o.params[a],{allowGenerics:!0}));return{signers:i,typeParameters:o.generic_type_params,parameters:s}}async function Wo(n,t,e,r){let o=await Ho(n,t,e,r);if(!o)throw new Error(`Could not find view function ABI for '${n}::${t}::${e}'`);if(!o.is_view)throw new Error(`'${n}::${t}::${e}' is not an view function`);let i=[];for(let a=0;a<o.params.length;a+=1)i.push(we(o.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<o.return.length;a+=1)s.push(we(o.return[a],{allowGenerics:!0}));return{typeParameters:o.generic_type_params,parameters:i,returnTypes:s}}function dr(n,t,e,r,o){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let i=t.parameters[r];return mt(e,i,r,o)}function mt(n,t,e,r){return $o(n)?(ur(t,n,e),n):Us(n,t,e,r)}function Us(n,t,e,r){if(t.isBool()){if(Ko(n))return new E(n);C("boolean",e)}if(t.isAddress()){if(gt(n))return u.fromString(n);C("string | AccountAddress",e)}if(t.isU8()){if(_n(n))return new G(n);C("number",e)}if(t.isU16()){if(_n(n))return new re(n);C("number",e)}if(t.isU32()){if(_n(n))return new oe(n);C("number",e)}if(t.isU64()){if(Sn(n))return new D(BigInt(n));C("bigint | number | string",e)}if(t.isU128()){if(Sn(n))return new ie(BigInt(n));C("bigint | number | string",e)}if(t.isU256()){if(Sn(n))return new se(BigInt(n));C("bigint | number | string",e)}if(t.isGeneric()){let o=t.value;if(o<0||o>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return mt(n,r[o],e,r)}if(t.isVector()){if(t.value.isU8()){if(gt(n))return h.U8(Is.encode(n));if(n instanceof Uint8Array)return h.U8(n);if(n instanceof ArrayBuffer)return h.U8(new Uint8Array(n))}if(Array.isArray(n))return new h(n.map(o=>mt(o,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(gt(n))return new w(n);C("string",e)}if(t.isObject()){if(gt(n))return u.fromString(n);C("string | AccountAddress",e)}if(t.isOption())return qo(n)?new ve(null):new ve(mt(n,t.value.typeArgs[0],e,r));throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function ur(n,t,e){if(n.isBool()){if(tr(t))return;C("Bool",e)}if(n.isAddress()){if(xn(t))return;C("AccountAddress",e)}if(n.isU8()){if(rr(t))return;C("U8",e)}if(n.isU16()){if(or(t))return;C("U16",e)}if(n.isU32()){if(ir(t))return;C("U32",e)}if(n.isU64()){if(sr(t))return;C("U64",e)}if(n.isU128()){if(ar(t))return;C("U128",e)}if(n.isU256()){if(cr(t))return;C("U256",e)}if(n.isVector()){if(t instanceof h){t.values.length>0&&ur(n.value,t.values[0],e);return}C("MoveVector",e)}if(n instanceof g){if(n.isString()){if(nr(t))return;C("MoveString",e)}if(n.isObject()){if(xn(t))return;C("AccountAddress",e)}if(n.isOption()){if(t instanceof ve){t.value!==void 0&&ur(n.value.typeArgs[0],t.value,e);return}C("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}var vn=class n extends d{constructor(e,r,o){super();this.rawTransaction=e,this.feePayerAddress=o,this.secondarySignerAddresses=r}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 r=j.deserialize(e),o=e.deserializeVector(u),i=e.deserializeBool(),s;return i&&(s=u.deserialize(e)),new n(r,o,s)}};async function Pn(n){if(Vo(n))return Ns(n);let{moduleAddress:t,moduleName:e,functionName:r}=zt(n.function),o=await ei({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Qo});return Rs({...n,abi:o})}function Rs(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=zt(n.function),i=pr(n.typeArguments);if(i.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${i.length}`);let s=n.functionArguments.map((c,p)=>dr(n.function,t,c,p,i));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${o}', expected ${t.parameters.length} but got ${s.length}`);let a=qe.build(`${e}::${r}`,o,i,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Et(new Ut(c,new Rt(a)))}return new Pt(a)}async function Xo(n){let{moduleAddress:t,moduleName:e,functionName:r}=zt(n.function),o=await ei({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Wo});return zs({abi:o,...n})}function zs(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=zt(n.function),i=pr(n.typeArguments);if(i.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${i.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _85 => _85.functionArguments, 'optionalAccess', _86 => _86.map, 'call', _87 => _87((a,c)=>dr(n.function,t,a,c,i))]), () => ([]));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${o}', expected ${t.parameters.length} but got ${s.length}`);return qe.build(`${e}::${r}`,o,i,s)}function Ns(n){return new Ct(new It(f.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function Ds(n){let{aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:i}=n,s=async()=>Mn[t.network]?{chainId:Mn[t.network]}:{chainId:(await cn({aptosConfig:t})).chain_id},a=async()=>_optionalChain([o, 'optionalAccess', _88 => _88.gasUnitPrice])?{gasEstimate:o.gasUnitPrice}:{gasEstimate:(await mn({aptosConfig:t})).gas_estimate},c=async()=>{let He=async()=>_optionalChain([o, 'optionalAccess', _89 => _89.accountSequenceNumber])!==void 0?o.accountSequenceNumber:(await le({aptosConfig:t,accountAddress:e})).sequence_number;if(i&&u.from(i).equals(u.ZERO))try{return await He()}catch (e2){return 0}else return He()},[{chainId:p},{gasEstimate:m},N]=await Promise.all([s(),a(),c()]),{maxGasAmount:b,gasUnitPrice:l,expireTimestamp:ye}={maxGasAmount:_optionalChain([o, 'optionalAccess', _90 => _90.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _91 => _91.gasUnitPrice]), () => (BigInt(m))),expireTimestamp:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _92 => _92.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new j(u.from(e),BigInt(N),r,BigInt(b),BigInt(l),BigInt(ye),new ct(p))}async function lr(n){let{aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:i}=n,s=await Ds({aptosConfig:t,sender:e,payload:r,options:o,feePayerAddress:i});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _93 => _93.secondarySignerAddresses, 'optionalAccess', _94 => _94.map, 'call', _95 => _95(c=>u.from(c))]), () => ([]));return new vn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new bn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Yo(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,i=Cn(t);if(e.feePayerAddress){let a=new Ve(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(N=>Cn(N)));let p=Cn(o),m=new st(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new Le(a.raw_txn,m).bcsToBytes()}if(e.secondarySignerAddresses){let a=new $e(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(m=>Cn(m));let p=new it(i,e.secondarySignerAddresses,c);return new Le(a.raw_txn,p).bcsToBytes()}let s;if(i instanceof pe)s=new ot(i.public_key,i.signature);else if(i instanceof de)s=new at(i);else throw new Error("Invalid public key");return new Le(e.rawTransaction,s).bcsToBytes()}function Cn(n){if(n instanceof q){if(n.publicKey instanceof I)return new de(n,new O(new U(new Uint8Array(64))));if(n.publicKey instanceof fe)return new de(n,new O(new he(new Uint8Array(64))))}return new pe(new I(n.toUint8Array()),new U(new Uint8Array(64)))}function Zo(n){let{signer:t,transaction:e}=n,r=mr(e);return t.signWithAuthenticator(r)}function gr(n){let{transaction:t,feePayerAuthenticator:e,additionalSignersAuthenticators:r}=n,o=Fr(B,n.senderAuthenticator),i;if(t.feePayerAddress){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");i=new st(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:t.feePayerAddress,authenticator:e})}else if(t.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");i=new it(o,t.secondarySignerAddresses,r)}else o instanceof pe?i=new ot(o.public_key,o.signature):i=new at(o);return new Le(t.rawTransaction,i).bcsToBytes()}function Jo(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Gs=Jo(["APTOS::Transaction"]);function _m(n){let t=gr(n);return new f(Jo([Gs,new Uint8Array([0]),t])).toString()}function ks(n){return n.feePayerAddress?new Ve(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new $e(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function mr(n){let t=ks(n),e=_sha3.sha3_256.create();if(t instanceof j)e.update(Br);else if(t instanceof $e)e.update(Kn);else if(t instanceof Ve)e.update(Kn);else throw new Error(`Unknown transaction type to sign on: ${t}`);let r=e.digest(),o=t.bcsToBytes(),i=new Uint8Array(r.length+o.length);return i.set(r),i.set(o,r.length),i}async function ei({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:o,abi:i,fetch:s}){return i!==void 0?i:nt(async()=>s(t,e,r,o),`${n}-${o.network}-${t}-${e}-${r}`,1e3*60*5)()}async function A(n){let t=await Os(n);return Bs(n,t)}async function Os(n){let{aptosConfig:t,data:e}=n,r,o;return"bytecode"in e?o=await Pn(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},o=await Pn(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},o=await Pn(r)),o}async function Bs(n,t){let{aptosConfig:e,sender:r,options:o}=n,i;if(Fs(n)&&(i=u.ZERO.toString()),Ms(n)){let{secondarySignerAddresses:s}=n;return lr({aptosConfig:e,sender:r,payload:t,options:o,secondarySignerAddresses:s,feePayerAddress:i})}return lr({aptosConfig:e,sender:r,payload:t,options:o,feePayerAddress:i})}function Fs(n){return n.withFeePayer===!0}function Ms(n){return"secondarySignerAddresses"in n}function ti(n){let{transaction:t}=n;return mr(t)}function En(n){return Zo({...n})}async function yr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}=n,a=Yo({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}),{data:c}=await Ge({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _96 => _96.options, 'optionalAccess', _97 => _97.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.options, 'optionalAccess', _99 => _99.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _100 => _100.options, 'optionalAccess', _101 => _101.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function In(n){let{aptosConfig:t}=n,e=gr({...n}),{data:r}=await Ge({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function Nt(n){let{aptosConfig:t,signer:e,transaction:r}=n,o=En({signer:e,transaction:r});return In({aptosConfig:t,transaction:r,senderAuthenticator:o})}var Ks={typeParameters:[],parameters:[x.u8(),new x(x.u8())]};async function ni(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:o,options:i}=n,s=o.map(a=>h.U8(a));return A({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[h.U8(r),new h(s)],abi:Ks},options:i})}var qs={typeParameters:[],parameters:[new ge,x.u8(),new ge,x.u8(),x.u8(),x.u8()]};async function ri(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,o=await le({aptosConfig:t,accountAddress:e.accountAddress}),i=Pe.fromPrivateKey({privateKey:r,legacy:!0}),a=new fn({sequenceNumber:BigInt(o.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(o.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),c=e.sign(a),p=i.sign(a),m=await A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new G(e.signingScheme),h.U8(e.publicKey.toUint8Array()),new G(i.signingScheme),h.U8(i.publicKey.toUint8Array()),h.U8(c.toUint8Array()),h.U8(p.toUint8Array())],abi:qs}});return Nt({aptosConfig:t,signer:e,transaction:m})}var $s={typeParameters:[{constraints:[]}],parameters:[new Q,new $]};async function oi(n){let{aptosConfig:t,sender:e,recipient:r,amount:o,coinType:i,options:s}=n;return A({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(i, () => (Qt))],functionArguments:[r,o],abi:$s},options:s})}var Dt=class{constructor(t){this.config=t}async transferCoinTransaction(t){return oi({aptosConfig:this.config,...t})}};var Ee={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 ii(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:ho,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function si(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};return(await y({aptosConfig:t,query:{query:Wn,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ai(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},i={query:Wn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _102 => _102.offset]),limit:_optionalChain([r, 'optionalAccess', _103 => _103.limit]),order_by:_optionalChain([r, 'optionalAccess', _104 => _104.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function ci(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,o={token_data_id:{_eq:u.from(e).toStringLong()}},i={query:fo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _105 => _105.offset]),limit:_optionalChain([r, 'optionalAccess', _106 => _106.limit]),order_by:_optionalChain([r, 'optionalAccess', _107 => _107.orderBy])}};return(await y({aptosConfig:t,query:i,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Vs={typeParameters:[],parameters:[new g(S()),new $,new g(S()),new g(S()),new k,new k,new k,new k,new k,new k,new k,new k,new k,new $,new $]};async function ui(n){let{aptosConfig:t,options:e,creator:r}=n;return A({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new D(_nullishCoalesce(n.maxSupply, () => (ze))),new w(n.name),new w(n.uri),new E(_nullishCoalesce(n.mutableDescription, () => (!0))),new E(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new E(_nullishCoalesce(n.mutableURI, () => (!0))),new E(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new E(_nullishCoalesce(n.mutableTokenName, () => (!0))),new E(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new E(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new E(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new E(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new D(_nullishCoalesce(n.royaltyNumerator, () => (0))),new D(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Vs},options:e})}async function Ar(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:o}=n,i=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:i.toStringLong()}};return _optionalChain([o, 'optionalAccess', _108 => _108.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _109 => _109.tokenStandard]), () => ("v2"))}),(await y({aptosConfig:t,query:{query:Ln,variables:{where_condition:s}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function pi(n){let{aptosConfig:t,collectionId:e}=n,o={collection_id:{_eq:u.from(e).toStringLong()}};return(await y({aptosConfig:t,query:{query:Ln,variables:{where_condition:o}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function di(n){return(await Ar(n)).collection_id}var Ls={typeParameters:[],parameters:[new g(S()),new g(S()),new g(S()),new g(S()),new x(new g(S())),new x(new g(S())),new x(x.u8())]};async function li(n){let{aptosConfig:t,options:e,creator:r,collection:o,description:i,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:m}=n,N=_optionalChain([p, 'optionalAccess', _110 => _110.map, 'call', _111 => _111(b=>Ee[b])]);return A({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(o),new w(i),new w(s),new w(a),h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(N, () => ([]))),Ci(_nullishCoalesce(m, () => ([])),_nullishCoalesce(N, () => ([])))],abi:Ls},options:e})}var Hs={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new Q]};async function gi(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(r),u.from(o)],abi:Hs},options:s})}var Qs={typeParameters:[],parameters:[new g(S()),new g(S()),new g(S()),new g(S()),new x(new g(S())),new x(new g(S())),new x(x.u8()),new Q]};async function mi(n){let{aptosConfig:t,account:e,collection:r,description:o,name:i,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:m,options:N}=n;if(_optionalChain([c, 'optionalAccess', _112 => _112.length])!==_optionalChain([m, 'optionalAccess', _113 => _113.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _114 => _114.length])!==_optionalChain([m, 'optionalAccess', _115 => _115.length]))throw new Error("Property types and property values counts do not match");let b=_optionalChain([p, 'optionalAccess', _116 => _116.map, 'call', _117 => _117(l=>Ee[l])]);return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,o,i,s,h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(b, () => ([]))),Ci(_nullishCoalesce(m, () => ([])),_nullishCoalesce(b, () => ([]))),a],abi:Qs},options:N})}var Ws={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0)))]};async function yi(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(o, () => (te))],functionArguments:[u.from(r)],abi:Ws},options:i})}var js={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0)))]};async function Ai(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(o, () => (te))],functionArguments:[r],abi:js},options:i})}var Xs={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0)))]};async function fi(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:o,options:i}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(o, () => (te))],functionArguments:[r],abi:Xs},options:i})}var Ys={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new g(S())]};async function hi(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:Ys},options:s})}var Zs={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new g(S())]};async function Ti(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:Zs},options:s})}var Js={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new g(S())]};async function bi(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:Js},options:s})}var ea={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new g(S()),new g(S()),x.u8()]};async function wi(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (te))],functionArguments:[u.from(s),new w(r),new w(Ee[o]),h.U8(fr(i,Ee[o]))],abi:ea},options:c})}var ta={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new g(S())]};async function _i(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:o,digitalAssetType:i,options:s}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(i, () => (te))],functionArguments:[u.from(o),new w(r)],abi:ta},options:s})}var na={typeParameters:[{constraints:["key"]}],parameters:[new g(W(new z(0))),new g(S()),new g(S()),x.u8()]};async function Si(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (te))],functionArguments:[u.from(s),new w(r),new w(Ee[o]),fr(i,Ee[o])],abi:na},options:c})}var ra={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new g(W(new z(0))),new g(S()),new z(1)]};async function xi(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (te)),Ee[o]],functionArguments:[u.from(s),new w(r),i],abi:ra},options:c})}var oa={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new g(W(new z(0))),new g(S()),new z(1)]};async function vi(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:o,propertyValue:i,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (te)),Ee[o]],functionArguments:[u.from(s),new w(r),i],abi:oa},options:c})}function Ci(n,t){let e=new Array;return t.forEach((r,o)=>{e.push(fr(n[o],r))}),e}function fr(n,t){let e=we(t);return mt(n,e,0,[]).bcsToBytes()}var Gt=class{constructor(t){this.config=t}async getCollectionData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ar({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),pi({aptosConfig:this.config,...t})}async getCollectionId(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),di({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ii({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),si({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ai({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ci({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return ui({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return li({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return gi({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return mi({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return yi({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Ai({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return fi({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return hi({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return Ti({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return bi({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return wi({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return _i({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return Si({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return xi({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return vi({aptosConfig:this.config,...t})}};var Pi=300,ia=n=>{if(n&&n.length>Pi)throw new Error(`Event type length exceeds the maximum length of ${Pi}`)};async function Ei(n){let{aptosConfig:t,eventType:e,options:r}=n,i={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _118 => _118.orderBy])};return kt({aptosConfig:t,options:i})}async function Ii(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:o}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _119 => _119.orderBy])};return kt({aptosConfig:e,options:a})}async function Ui(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:o}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:o,orderBy:_optionalChain([o, 'optionalAccess', _120 => _120.orderBy])};return kt({aptosConfig:e,options:a})}async function kt(n){let{aptosConfig:t,options:e}=n;ia(_optionalChain([e, 'optionalAccess', _121 => _121.where, 'optionalAccess', _122 => _122.indexed_type, 'optionalAccess', _123 => _123._eq]));let r={query:mo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _124 => _124.where]),offset:_optionalChain([e, 'optionalAccess', _125 => _125.offset]),limit:_optionalChain([e, 'optionalAccess', _126 => _126.limit]),order_by:_optionalChain([e, 'optionalAccess', _127 => _127.orderBy])}};return(await y({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var Ot=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Ei({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Ii({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Ui({aptosConfig:this.config,...t})}async getEvents(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _128 => _128.minimumLedgerVersion]),processorType:"events_processor"}),kt({aptosConfig:this.config,...t})}};async function Ri(n){let{aptosConfig:t,accountAddress:e,amount:r,options:o}=n,i=_optionalChain([o, 'optionalAccess', _129 => _129.timeoutSecs])||20,{data:s}=await $r({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await rt({aptosConfig:t,transactionHash:a,options:{timeoutSecs:i,checkSuccess:_optionalChain([o, 'optionalAccess', _130 => _130.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Bt=class{constructor(t){this.config=t}async fundAccount(t){let e=await Ri({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _131 => _131.options, 'optionalAccess', _132 => _132.waitForIndexer])!==!1&&await yn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function hr(n){let{aptosConfig:t,options:e}=n,r={query:Ao,variables:{where_condition:_optionalChain([e, 'optionalAccess', _133 => _133.where]),limit:_optionalChain([e, 'optionalAccess', _134 => _134.limit]),offset:_optionalChain([e, 'optionalAccess', _135 => _135.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function zi(n){let{aptosConfig:t,options:e}=n,r={query:yo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _136 => _136.where]),limit:_optionalChain([e, 'optionalAccess', _137 => _137.limit]),offset:_optionalChain([e, 'optionalAccess', _138 => _138.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ni(n){let{aptosConfig:t,options:e}=n,r={query:lo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _139 => _139.where]),limit:_optionalChain([e, 'optionalAccess', _140 => _140.limit]),offset:_optionalChain([e, 'optionalAccess', _141 => _141.offset])}};return(await y({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var sa={typeParameters:[],parameters:[we("0x1::object::Object"),new Q,new $]};async function Di(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:o,amount:i,options:s}=n;return A({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,o,i],abi:sa},options:s})}var Ft=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _142 => _142.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),hr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _143 => _143.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await hr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _144 => _144.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),zi({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _145 => _145.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ni({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return Di({aptosConfig:this.config,...t})}};async function Ie(n){let{aptosConfig:t,payload:e,options:r}=n,o=await Xo({...e,aptosConfig:t}),i=new X;o.serialize(i);let s=i.toUint8Array(),{data:a}=await Ge({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _146 => _146.ledgerVersion])},body:s});return a}var Mt=class{constructor(t){this.config=t}async getLedgerInfo(){return cn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return To({aptosConfig:this.config,...t})}async getBlockByHeight(t){return bo({aptosConfig:this.config,...t})}async getTableItem(t){return un({aptosConfig:this.config,...t})}async view(t){return Ie({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return wo({aptosConfig:this.config,...t})}async queryIndexer(t){return y({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return pn({aptosConfig:this.config})}async getProcessorStatus(t){return dn({aptosConfig:this.config,processorType:t})}};var Gi=["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 ki(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Ue(n){let[t,e,...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(!ki(t))throw new Error(`${t} is not valid. ${Gi}`);if(e&&!ki(e))throw new Error(`${e} is not valid. ${Gi}`);return{domainName:e||t,subdomainName:e?t:void 0}}var aa="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",ca={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:aa,custom:null,devnet:null,randomnet:null};function _e(n){let t=ca[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var Un=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Oi(n){let{aptosConfig:t,name:e}=n,r=_e(t),{domainName:o,subdomainName:i}=Ue(e),s=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,i]}}),a=Un(s[0]);return a?u.from(a):void 0}async function Bi(n){let{aptosConfig:t,expiration:e,name:r,sender:o,targetAddress:i,toAddress:s,options:a,transferable:c}=n,p=_e(t),{domainName:m,subdomainName:N}=Ue(r),b=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(N&&!b)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(b&&!N)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let kn=_nullishCoalesce(e.years, () => (1));if(kn!==1)throw new Error("For now, names can only be registered for 1 year at a time");let es=kn*31536e3;return await A({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[m,es,i,s]},options:a})}if(!N)throw new Error(`${e.policy} requires a subdomain to be provided.`);let l=await Tr({aptosConfig:t,name:m});if(!l)throw new Error("The domain does not exist");let ye=e.policy==="subdomain:independent"?e.expirationDate:l;if(ye>l)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await A({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[m,N,Math.round(ye/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,i,s]},options:a})}async function Tr(n){let{aptosConfig:t,name:e}=n,r=_e(t),{domainName:o,subdomainName:i}=Ue(e);try{let s=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[o,i]}});return Number(s[0])*1e3}catch (e3){return}}async function Fi(n){let{aptosConfig:t,address:e}=n,r=_e(t),o=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),i=Un(o[1]),s=Un(o[0]);if(i)return[s,i].filter(Boolean).join(".")}async function Mi(n){let{aptosConfig:t,sender:e,name:r,options:o}=n,i=_e(t);if(!r)return await A({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::clear_primary_name`,functionArguments:[]},options:o});let{domainName:s,subdomainName:a}=Ue(r);return await A({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${i}::router::set_primary_name`,functionArguments:[s,a]},options:o})}async function Ki(n){let{aptosConfig:t,name:e}=n,r=_e(t),{domainName:o,subdomainName:i}=Ue(e),s=await Ie({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,i]}}),a=Un(s[0]);return a?u.from(a):void 0}async function qi(n){let{aptosConfig:t,sender:e,name:r,address:o,options:i}=n,s=_e(t),{domainName:a,subdomainName:c}=Ue(r);return await A({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,o]},options:i})}async function $i(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:o=""}=Ue(e),a=(await y({aptosConfig:t,query:{query:tt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Kt(a)),a}async function Vi(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await br({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountNames",query:{query:tt,variables:{limit:_optionalChain([e, 'optionalAccess', _147 => _147.limit]),offset:_optionalChain([e, 'optionalAccess', _148 => _148.offset]),order_by:_optionalChain([e, 'optionalAccess', _149 => _149.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _150 => _150.options, 'optionalAccess', _151 => _151.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(Kt)}async function Li(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await br({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountDomains",query:{query:tt,variables:{limit:_optionalChain([e, 'optionalAccess', _152 => _152.limit]),offset:_optionalChain([e, 'optionalAccess', _153 => _153.offset]),order_by:_optionalChain([e, 'optionalAccess', _154 => _154.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _155 => _155.options, 'optionalAccess', _156 => _156.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(Kt)}async function Hi(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await br({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:tt,variables:{limit:_optionalChain([e, 'optionalAccess', _157 => _157.limit]),offset:_optionalChain([e, 'optionalAccess', _158 => _158.offset]),order_by:_optionalChain([e, 'optionalAccess', _159 => _159.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _160 => _160.options, 'optionalAccess', _161 => _161.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(Kt)}async function Qi(n){let{aptosConfig:t,options:e,domain:r}=n;return(await y({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:tt,variables:{limit:_optionalChain([e, 'optionalAccess', _162 => _162.limit]),offset:_optionalChain([e, 'optionalAccess', _163 => _163.offset]),order_by:_optionalChain([e, 'optionalAccess', _164 => _164.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _165 => _165.options, 'optionalAccess', _166 => _166.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(Kt)}async function br(n){let{aptosConfig:t}=n,e=_e(t),[r]=await Ie({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),o=r/60/60/24,i=()=>new Date;return new Date(i().setDate(i().getDate()-o)).toISOString()}async function Wi(n){let{aptosConfig:t,sender:e,name:r,years:o=1,options:i}=n,s=_e(t),a=o*31536e3,{domainName:c,subdomainName:p}=Ue(r);if(p)throw new Error("Subdomains cannot be renewed");if(o!==1)throw new Error("Currently, only 1 year renewals are supported");return await A({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:i})}function Kt(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var qt=class{constructor(t){this.config=t}async getOwnerAddress(t){return Oi({aptosConfig:this.config,...t})}async getExpiration(t){return Tr({aptosConfig:this.config,...t})}async getTargetAddress(t){return Ki({aptosConfig:this.config,...t})}async setTargetAddress(t){return qi({aptosConfig:this.config,...t})}async getPrimaryName(t){return Fi({aptosConfig:this.config,...t})}async setPrimaryName(t){return Mi({aptosConfig:this.config,...t})}async registerName(t){return Bi({aptosConfig:this.config,...t})}async renewDomain(t){return Wi({aptosConfig:this.config,...t})}async getName(t){return $i({aptosConfig:this.config,...t})}async getAccountNames(t){return Vi({aptosConfig:this.config,...t})}async getAccountDomains(t){return Li({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Hi({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return Qi({aptosConfig:this.config,...t})}};async function ji(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:Hn,variables:{where_condition:{pool_address:{_eq:r}}}}});return i.num_active_delegator_per_pool[0]?i.num_active_delegator_per_pool[0].num_active_delegator:0}async function Xi(n){let{aptosConfig:t,options:e}=n,r={query:Hn,variables:{order_by:_optionalChain([e, 'optionalAccess', _167 => _167.orderBy])}};return(await y({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function Yi(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,o={query:go,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await y({aptosConfig:t,query:o})).delegated_staking_activities}var $t=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _168 => _168.minimumLedgerVersion]),processorType:"stake_processor"}),ji({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _169 => _169.minimumLedgerVersion]),processorType:"stake_processor"}),Xi({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _170 => _170.minimumLedgerVersion]),processorType:"stake_processor"}),Yi({aptosConfig:this.config,...t})}};var Rn=class{constructor(t){this.config=t}async simple(t){return A({aptosConfig:this.config,...t})}async multiAgent(t){return A({aptosConfig:this.config,...t})}};function wr(n,t,e){let r=e.value;return e.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,o)},e}function _r(n,t,e){let r=e.value;return e.value=async function(...o){let[i]=o;if(i.transaction.feePayerAddress&&!i.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,o)},e}var yt=class{constructor(t){this.config=t}async simple(t){return yr({aptosConfig:this.config,...t})}async multiAgent(t){return yr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [_r],yt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [_r],yt.prototype,"multiAgent",1);var At=class{constructor(t){this.config=t}async simple(t){return In({aptosConfig:this.config,...t})}async multiAgent(t){return In({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [wr],At.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [wr],At.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var zn=()=>Math.floor(Date.now()/1e3),Nn= exports.AccountSequenceNumber =class{constructor(t,e,r,o,i){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=o,this.sleepTime=i}async nextSequenceNumber(){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=zn();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),zn()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await le({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await le({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=zn();for(;this.lastUncommintedNumber!==this.currentNumber;)zn()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var ft=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _171 => _171.pendingDequeue, 'access', _172 => _172.shift, 'call', _173 => _173(), 'optionalAccess', _174 => _174.resolve, 'call', _175 => _175(t)]);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new ht("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},ht=class extends Error{};var Zi="fulfilled",Ji= exports.TransactionWorkerEventsEnum =(i=>(i.TransactionSent="transactionSent",i.TransactionSendFailed="transactionSendFailed",i.TransactionExecuted="transactionExecuted",i.TransactionExecutionFailed="transactionExecutionFailed",i.ExecutionFinish="executionFinish",i))(Ji||{}),Dn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,o=30,i=100,s=10){super();this.taskQueue=new ft;this.transactionsQueue=new ft;this.outstandingTransactions=new ft;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new Nn(e,r,o,i,s)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let o=Nt({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,e])}}catch(e){if(e instanceof ht)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[o,i]=await this.outstandingTransactions.dequeue();for(e.push(o),r.push(i);!this.outstandingTransactions.isEmpty();)[o,i]=await this.outstandingTransactions.dequeue(),e.push(o),r.push(i);let s=await Promise.allSettled(e);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];i=r[a],c.status===Zi?(this.sentTransactions.push([c.value.hash,i,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,i)):(this.sentTransactions.push([c.status,i,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(e){if(e instanceof ht)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let o=[];o.push(rt({aptosConfig:this.aptosConfig,transactionHash:e.value.hash}));let i=await Promise.allSettled(o);for(let s=0;s<i.length;s+=1){let a=i[s];a.status===Zi?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(o){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${o}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[o,i]=await this.transactionsQueue.dequeue();return A({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:o,options:{...i,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}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 Gn=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new Dn(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:o}=e;for(let i of r)this.transactionWorker.push(i,o)}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:r,data:o,options:i}=e;this.start({sender:r}),this.push({data:o,options:i})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var Vt=class{constructor(t){this.config=t,this.build=new Rn(this.config),this.simulate=new yt(this.config),this.submit=new At(this.config),this.batch=new Gn(this.config)}async getTransactions(t){return ko({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return Oo({aptosConfig:this.config,...t})}async getTransactionByHash(t){return St({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Bo({aptosConfig:this.config,...t})}async waitForTransaction(t){return rt({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return mn({aptosConfig:this.config})}getSigningMessage(t){return ti(t)}async publishPackageTransaction(t){return ni({aptosConfig:this.config,...t})}async rotateAuthKey(t){return ri({aptosConfig:this.config,...t})}sign(t){return En({...t})}signAsFeePayer(t){let{signer:e,transaction:r}=t;if(!r.feePayerAddress)throw new Error(`Transaction ${r} is not a Fee Payer transaction`);return r.feePayerAddress=e.accountAddress,En({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:o}=t;this.batch.forSingleAccount({sender:e,data:r,options:o})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return Nt({aptosConfig:this.config,signer:e,transaction:r})}};var ne=class{constructor(t){this.config=new An(t),this.account=new xt(this.config),this.ans=new qt(this.config),this.coin=new Dt(this.config),this.digitalAsset=new Gt(this.config),this.event=new Ot(this.config),this.faucet=new Bt(this.config),this.fungibleAsset=new Ft(this.config),this.general=new Mt(this.config),this.staking=new $t(this.config),this.transaction=new Vt(this.config)}};function me(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let o=Object.getOwnPropertyDescriptor(t.prototype,r);o&&(o.value=function(...i){return this[e][r](...i)},Object.defineProperty(n.prototype,r,o))})}me(ne,xt,"account");me(ne,qt,"ans");me(ne,Dt,"coin");me(ne,Gt,"digitalAsset");me(ne,Ot,"event");me(ne,Bt,"faucet");me(ne,Ft,"fungibleAsset");me(ne,Mt,"general");me(ne,$t,"staking");me(ne,Vt,"transaction");exports.APTOS_BIP44_REGEX = ms; exports.APTOS_COIN = Qt; exports.APTOS_HARDENED_REGEX = gs; exports.Account = Pe; exports.AccountAddress = u; exports.AccountAuthenticator = B; exports.AccountAuthenticatorEd25519 = pe; exports.AccountAuthenticatorMultiEd25519 = on; exports.AccountAuthenticatorMultiKey = sn; exports.AccountAuthenticatorSingleKey = de; exports.AccountAuthenticatorVariant = Er; exports.AccountPublicKey = ce; exports.AccountSequenceNumber = Nn; exports.AddressInvalidReason = us; exports.AnyPublicKey = q; exports.AnyPublicKeyVariant = Ir; exports.AnySignature = O; exports.AnySignatureVariant = Ur; exports.Aptos = ne; exports.AptosApiError = ae; exports.AptosApiType = bt; exports.AptosConfig = An; exports.AuthenticationKey = K; exports.Bool = E; exports.CKDPriv = jr; exports.ChainId = ct; exports.DEFAULT_MAX_GAS_AMOUNT = kr; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Or; exports.DEFAULT_TXN_TIMEOUT_SEC = Ht; exports.DeriveScheme = zr; exports.Deserializer = Yt; exports.Ed25519Account = Je; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = I; exports.Ed25519Signature = U; exports.EntryFunction = qe; exports.EntryFunctionBytes = Zt; exports.FeePayerRawTransaction = Ve; exports.FixedBytes = De; exports.HARDENED_OFFSET = Hr; exports.Hex = f; exports.HexInvalidReason = is; exports.Identifier = P; exports.KeyType = ys; exports.MimeType = Lt; exports.ModuleId = vt; exports.MoveAbility = Rr; exports.MoveFunctionVisibility = ts; exports.MoveOption = ve; exports.MoveString = w; exports.MoveVector = h; exports.MultiAgentRawTransaction = $e; exports.MultiEd25519PublicKey = Ye; exports.MultiEd25519Signature = Oe; exports.MultiKey = rn; exports.MultiKeySignature = eo; exports.MultiSig = Ut; exports.MultiSigTransactionPayload = Rt; exports.Network = Fn; exports.NetworkToChainId = Mn; exports.NetworkToFaucetAPI = Gr; exports.NetworkToIndexerAPI = Nr; exports.NetworkToNetworkName = Ea; exports.NetworkToNodeAPI = Dr; exports.ParsingError = M; exports.ProcessorType = Qe; exports.PublicKey = _t; exports.RAW_TRANSACTION_SALT = Br; exports.RAW_TRANSACTION_WITH_DATA_SALT = Kn; exports.RawTransaction = j; exports.RawTransactionWithData = Tn; exports.RoleType = ns; exports.RotationProofChallenge = fn; exports.Script = It; exports.ScriptTransactionArgumentVariants = Tt; exports.Secp256k1PrivateKey = Fe; exports.Secp256k1PublicKey = fe; exports.Secp256k1Signature = he; exports.Serializable = d; exports.Serializer = X; exports.Signature = Y; exports.SignedTransaction = Le; exports.SigningScheme = Re; exports.SigningSchemeInput = Bn; exports.SimpleTransaction = bn; exports.SingleKeyAccount = et; exports.StructTag = be; exports.TransactionAuthenticator = Te; exports.TransactionAuthenticatorEd25519 = ot; exports.TransactionAuthenticatorFeePayer = st; exports.TransactionAuthenticatorMultiAgent = it; exports.TransactionAuthenticatorMultiEd25519 = er; exports.TransactionAuthenticatorSingleSender = at; exports.TransactionAuthenticatorVariant = Pr; exports.TransactionPayload = Ke; exports.TransactionPayloadEntryFunction = Pt; exports.TransactionPayloadMultiSig = Et; exports.TransactionPayloadScript = Ct; exports.TransactionPayloadVariants = vr; exports.TransactionResponseType = On; exports.TransactionVariants = Cr; exports.TransactionWorker = Dn; exports.TransactionWorkerEventsEnum = Ji; exports.TypeTag = R; exports.TypeTagAddress = Q; exports.TypeTagBool = k; exports.TypeTagGeneric = z; exports.TypeTagParserError = v; exports.TypeTagParserErrorType = Ps; exports.TypeTagReference = hn; exports.TypeTagSigner = Me; exports.TypeTagStruct = g; exports.TypeTagU128 = dt; exports.TypeTagU16 = ut; exports.TypeTagU256 = lt; exports.TypeTagU32 = pt; exports.TypeTagU64 = $; exports.TypeTagU8 = ge; exports.TypeTagVariants = xr; exports.TypeTagVector = x; exports.U128 = ie; exports.U16 = re; exports.U256 = se; exports.U32 = oe; exports.U64 = D; exports.U8 = G; exports.aptosCoinStructTag = Vl; exports.aptosRequest = Jt; exports.buildTransaction = lr; exports.checkOrConvertArgument = mt; exports.convertArgument = dr; exports.createObjectAddress = hs; exports.createResourceAddress = ld; exports.createTokenAddress = gd; exports.deriveKey = Vn; exports.deriveTransactionType = ks; exports.deserializeFromScriptArgument = xs; exports.ensureBoolean = qn; exports.fetchEntryFunctionAbi = Qo; exports.fetchFunctionAbi = Ho; exports.fetchViewFunctionAbi = Wo; exports.findFirstNonSignerArg = Lo; exports.generateRawTransaction = Ds; exports.generateSignedTransaction = gr; exports.generateSignedTransactionForSimulation = Yo; exports.generateSigningMessage = mr; exports.generateTransactionPayload = Pn; exports.generateTransactionPayloadWithABI = Rs; exports.generateUserTransactionHash = _m; exports.generateViewFunctionPayload = Xo; exports.generateViewFunctionPayloadWithABI = zs; exports.get = Kr; exports.getAptosFullNode = V; exports.getAuthenticatorForSimulation = Cn; exports.getFunctionParts = zt; exports.hashValues = Jo; exports.isBcsAddress = xn; exports.isBcsBool = tr; exports.isBcsFixedBytes = Es; exports.isBcsString = nr; exports.isBcsU128 = ar; exports.isBcsU16 = or; exports.isBcsU256 = cr; exports.isBcsU32 = ir; exports.isBcsU64 = sr; exports.isBcsU8 = rr; exports.isBlockMetadataTransactionResponse = ha; exports.isBool = Ko; exports.isEd25519Signature = wa; exports.isEncodedEntryFunctionArgument = $o; exports.isFeePayerSignature = xa; exports.isGenesisTransactionResponse = fa; exports.isLargeNumber = Sn; exports.isMultiAgentSignature = Sa; exports.isMultiEd25519Signature = va; exports.isNull = qo; exports.isNumber = _n; exports.isPendingTransactionResponse = ya; exports.isScriptDataInput = Vo; exports.isSecp256k1Signature = _a; exports.isStateCheckpointTransactionResponse = Ta; exports.isString = gt; exports.isUserTransactionResponse = Aa; exports.isValidBIP44Path = Qr; exports.isValidHardenedPath = Wr; exports.isValidatorTransactionResponse = ba; exports.mnemonicToSeed = en; exports.normalizeBundle = Fr; exports.objectStructTag = W; exports.optionStructTag = Ll; exports.outOfRangeErrorMessage = ss; exports.paginateWithCursor = We; exports.parseTypeTag = we; exports.post = $n; exports.postAptosFaucet = $r; exports.postAptosFullNode = Ge; exports.postAptosIndexer = qr; exports.promiseFulfilledStatus = Zi; exports.request = as; exports.sign = Zo; exports.splitPath = Xr; exports.standardizeTypeTags = pr; exports.stringStructTag = S; exports.throwTypeMismatch = C; exports.validateNumberInRange = xe;
|
|
429
429
|
//# sourceMappingURL=index.js.map
|