@aptos-labs/ts-sdk 1.13.0 → 1.13.1
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.js +6 -6
- package/dist/common/index.js.map +1 -1
- package/dist/esm/api/account.d.mts +1 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +2 -2
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.d.mts +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 +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.d.mts +2 -2
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/staking.d.mts +2 -2
- 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.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/simulate.mjs +1 -1
- package/dist/esm/api/transactionSubmission/submit.mjs +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.mjs +1 -1
- package/dist/esm/{chunk-TGLSJGFO.mjs → chunk-2SPJ7XZB.mjs} +2 -2
- package/dist/esm/{chunk-GMVVQD72.mjs → chunk-32PB5F74.mjs} +2 -2
- package/dist/esm/{chunk-GXVUN32G.mjs → chunk-3YCG7Y63.mjs} +2 -2
- package/dist/esm/{chunk-TR2YS7DT.mjs → chunk-4UJ5Y6QQ.mjs} +2 -2
- package/dist/esm/{chunk-BSEQPVD6.mjs → chunk-5M7D6SXS.mjs} +2 -2
- package/dist/esm/{chunk-YWQLLV2R.mjs → chunk-5RE43AX2.mjs} +2 -2
- package/dist/esm/{chunk-KVIVMWN5.mjs → chunk-6GZ5SUUK.mjs} +2 -2
- package/dist/esm/{chunk-H4UVHJ3M.mjs → chunk-6T4IFH73.mjs} +2 -2
- package/dist/esm/{chunk-KUOIRTNL.mjs → chunk-BGW77OLE.mjs} +2 -2
- package/dist/esm/{chunk-QTSECE7R.mjs → chunk-CYTNMIOT.mjs} +2 -2
- package/dist/esm/{chunk-2M6OT6DU.mjs → chunk-CZF6JTC2.mjs} +2 -2
- package/dist/esm/chunk-DJ5TUMIY.mjs +2 -0
- package/dist/esm/chunk-DJ5TUMIY.mjs.map +1 -0
- package/dist/esm/{chunk-IS3OLRMB.mjs → chunk-DW4FAHFT.mjs} +2 -2
- package/dist/esm/{chunk-A7MSW6OL.mjs → chunk-DW5XFUDM.mjs} +2 -2
- package/dist/esm/{chunk-Y5M5DD64.mjs → chunk-E7OPTWPP.mjs} +2 -2
- package/dist/esm/{chunk-ZKNM27TR.mjs → chunk-F2LL2BWZ.mjs} +2 -2
- package/dist/esm/{chunk-ONDQ4MK7.mjs → chunk-F5O5BBEK.mjs} +2 -2
- package/dist/esm/{chunk-AP7UZTPZ.mjs → chunk-H3NRKYG4.mjs} +2 -2
- package/dist/esm/{chunk-VX6LTXGB.mjs → chunk-HDDI532F.mjs} +2 -2
- package/dist/esm/{chunk-TLKV4NHK.mjs → chunk-HHETZQ6D.mjs} +2 -2
- package/dist/esm/{chunk-IA6XM7QE.mjs → chunk-HLBUOMKA.mjs} +2 -2
- package/dist/esm/{chunk-647IOEXV.mjs → chunk-I24X55BI.mjs} +2 -2
- package/dist/esm/{chunk-TBFLWWV4.mjs → chunk-I2RHCBHM.mjs} +2 -2
- package/dist/esm/{chunk-QW3VNZJ7.mjs → chunk-ILTVKYMT.mjs} +2 -2
- package/dist/esm/{chunk-7PYFGGHM.mjs → chunk-J5WUVXKC.mjs} +2 -2
- package/dist/esm/{chunk-6CBPMYW5.mjs → chunk-JAIQBRLH.mjs} +2 -2
- package/dist/esm/{chunk-SDUIZ3FY.mjs → chunk-JK23P2GY.mjs} +2 -2
- package/dist/esm/{chunk-KOAUBVO6.mjs → chunk-KBRRTSF6.mjs} +2 -2
- package/dist/esm/{chunk-7CAEMK4R.mjs → chunk-KECXKWWV.mjs} +2 -2
- package/dist/esm/{chunk-MIEV7J74.mjs → chunk-LGVHYLN2.mjs} +2 -2
- package/dist/esm/{chunk-63AIRYJX.mjs → chunk-LJ6MB5U7.mjs} +2 -2
- package/dist/esm/{chunk-VM3EJYJU.mjs → chunk-LYCGUGYR.mjs} +2 -2
- package/dist/esm/{chunk-ZEXZ4CX5.mjs → chunk-M3NK6GOI.mjs} +2 -2
- package/dist/esm/{chunk-OKCU4GHN.mjs → chunk-MFFSJJSY.mjs} +2 -2
- package/dist/esm/chunk-MQXSU6GN.mjs +2 -0
- package/dist/esm/{chunk-WEZXFWPR.mjs.map → chunk-MQXSU6GN.mjs.map} +1 -1
- package/dist/esm/{chunk-3F6EYD5O.mjs → chunk-O5ZLNJ6Z.mjs} +2 -2
- package/dist/esm/{chunk-I7YI22IW.mjs → chunk-O7P52OOA.mjs} +2 -2
- package/dist/esm/{chunk-XYLYHSEI.mjs → chunk-O7PPRJJC.mjs} +2 -2
- package/dist/esm/{chunk-Y2VA7F5D.mjs → chunk-OATDMLDK.mjs} +2 -2
- package/dist/esm/chunk-OMC3ZGKN.mjs +2 -0
- package/dist/esm/chunk-OMC3ZGKN.mjs.map +1 -0
- package/dist/esm/{chunk-5AQEETAC.mjs → chunk-OVJQWQ2N.mjs} +2 -2
- package/dist/esm/{chunk-QVKMFPAV.mjs → chunk-OZNBOCEF.mjs} +2 -2
- package/dist/esm/{chunk-QK4P26SH.mjs → chunk-PNGS6IWC.mjs} +2 -2
- package/dist/esm/{chunk-L4Q2XTHT.mjs → chunk-QM4UQVGB.mjs} +2 -2
- package/dist/esm/{chunk-BMKDEIRL.mjs → chunk-VVMR7UKB.mjs} +2 -2
- package/dist/esm/{chunk-VBTJVPAM.mjs → chunk-WFL6YWJS.mjs} +2 -2
- package/dist/esm/{chunk-3CLYWZYZ.mjs → chunk-WZNX3RBA.mjs} +2 -2
- package/dist/esm/{chunk-C67BKZND.mjs → chunk-XDGQTMDV.mjs} +2 -2
- package/dist/esm/{chunk-C67BKZND.mjs.map → chunk-XDGQTMDV.mjs.map} +1 -1
- package/dist/esm/{chunk-RAYJRFIG.mjs → chunk-XRAL7KVT.mjs} +2 -2
- package/dist/esm/{chunk-G2QII3AT.mjs → chunk-Y5GRH4YJ.mjs} +2 -2
- package/dist/esm/{chunk-V4YBGBCN.mjs → chunk-YUN2JVAN.mjs} +2 -2
- package/dist/esm/{chunk-HXN2WRUX.mjs → chunk-YVIP7DMT.mjs} +2 -2
- package/dist/esm/{chunk-HB6T27S2.mjs → chunk-YWN2T4IU.mjs} +2 -2
- package/dist/esm/{chunk-ZPNCA4C7.mjs → chunk-YZKDNVA5.mjs} +2 -2
- package/dist/esm/client/core.mjs +1 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/post.mjs +1 -1
- package/dist/esm/core/account/Account.mjs +1 -1
- package/dist/esm/core/account/Ed25519Account.mjs +1 -1
- package/dist/esm/core/account/SingleKeyAccount.mjs +1 -1
- 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.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- 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.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/account.d.mts +1 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- 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.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/staking.d.mts +2 -2
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +4 -4
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- 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.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.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.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- 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/utils/apiEndpoints.mjs +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
- package/src/internal/transactionSubmission.ts +3 -1
- package/src/transactions/transactionBuilder/transactionBuilder.ts +48 -37
- package/src/utils/apiEndpoints.ts +1 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-54BANKLA.mjs +0 -2
- package/dist/esm/chunk-54BANKLA.mjs.map +0 -1
- package/dist/esm/chunk-KL6VJ3UK.mjs +0 -2
- package/dist/esm/chunk-KL6VJ3UK.mjs.map +0 -1
- package/dist/esm/chunk-WEZXFWPR.mjs +0 -2
- /package/dist/esm/{chunk-TGLSJGFO.mjs.map → chunk-2SPJ7XZB.mjs.map} +0 -0
- /package/dist/esm/{chunk-GMVVQD72.mjs.map → chunk-32PB5F74.mjs.map} +0 -0
- /package/dist/esm/{chunk-GXVUN32G.mjs.map → chunk-3YCG7Y63.mjs.map} +0 -0
- /package/dist/esm/{chunk-TR2YS7DT.mjs.map → chunk-4UJ5Y6QQ.mjs.map} +0 -0
- /package/dist/esm/{chunk-BSEQPVD6.mjs.map → chunk-5M7D6SXS.mjs.map} +0 -0
- /package/dist/esm/{chunk-YWQLLV2R.mjs.map → chunk-5RE43AX2.mjs.map} +0 -0
- /package/dist/esm/{chunk-KVIVMWN5.mjs.map → chunk-6GZ5SUUK.mjs.map} +0 -0
- /package/dist/esm/{chunk-H4UVHJ3M.mjs.map → chunk-6T4IFH73.mjs.map} +0 -0
- /package/dist/esm/{chunk-KUOIRTNL.mjs.map → chunk-BGW77OLE.mjs.map} +0 -0
- /package/dist/esm/{chunk-QTSECE7R.mjs.map → chunk-CYTNMIOT.mjs.map} +0 -0
- /package/dist/esm/{chunk-2M6OT6DU.mjs.map → chunk-CZF6JTC2.mjs.map} +0 -0
- /package/dist/esm/{chunk-IS3OLRMB.mjs.map → chunk-DW4FAHFT.mjs.map} +0 -0
- /package/dist/esm/{chunk-A7MSW6OL.mjs.map → chunk-DW5XFUDM.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y5M5DD64.mjs.map → chunk-E7OPTWPP.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZKNM27TR.mjs.map → chunk-F2LL2BWZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-ONDQ4MK7.mjs.map → chunk-F5O5BBEK.mjs.map} +0 -0
- /package/dist/esm/{chunk-AP7UZTPZ.mjs.map → chunk-H3NRKYG4.mjs.map} +0 -0
- /package/dist/esm/{chunk-VX6LTXGB.mjs.map → chunk-HDDI532F.mjs.map} +0 -0
- /package/dist/esm/{chunk-TLKV4NHK.mjs.map → chunk-HHETZQ6D.mjs.map} +0 -0
- /package/dist/esm/{chunk-IA6XM7QE.mjs.map → chunk-HLBUOMKA.mjs.map} +0 -0
- /package/dist/esm/{chunk-647IOEXV.mjs.map → chunk-I24X55BI.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBFLWWV4.mjs.map → chunk-I2RHCBHM.mjs.map} +0 -0
- /package/dist/esm/{chunk-QW3VNZJ7.mjs.map → chunk-ILTVKYMT.mjs.map} +0 -0
- /package/dist/esm/{chunk-7PYFGGHM.mjs.map → chunk-J5WUVXKC.mjs.map} +0 -0
- /package/dist/esm/{chunk-6CBPMYW5.mjs.map → chunk-JAIQBRLH.mjs.map} +0 -0
- /package/dist/esm/{chunk-SDUIZ3FY.mjs.map → chunk-JK23P2GY.mjs.map} +0 -0
- /package/dist/esm/{chunk-KOAUBVO6.mjs.map → chunk-KBRRTSF6.mjs.map} +0 -0
- /package/dist/esm/{chunk-7CAEMK4R.mjs.map → chunk-KECXKWWV.mjs.map} +0 -0
- /package/dist/esm/{chunk-MIEV7J74.mjs.map → chunk-LGVHYLN2.mjs.map} +0 -0
- /package/dist/esm/{chunk-63AIRYJX.mjs.map → chunk-LJ6MB5U7.mjs.map} +0 -0
- /package/dist/esm/{chunk-VM3EJYJU.mjs.map → chunk-LYCGUGYR.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZEXZ4CX5.mjs.map → chunk-M3NK6GOI.mjs.map} +0 -0
- /package/dist/esm/{chunk-OKCU4GHN.mjs.map → chunk-MFFSJJSY.mjs.map} +0 -0
- /package/dist/esm/{chunk-3F6EYD5O.mjs.map → chunk-O5ZLNJ6Z.mjs.map} +0 -0
- /package/dist/esm/{chunk-I7YI22IW.mjs.map → chunk-O7P52OOA.mjs.map} +0 -0
- /package/dist/esm/{chunk-XYLYHSEI.mjs.map → chunk-O7PPRJJC.mjs.map} +0 -0
- /package/dist/esm/{chunk-Y2VA7F5D.mjs.map → chunk-OATDMLDK.mjs.map} +0 -0
- /package/dist/esm/{chunk-5AQEETAC.mjs.map → chunk-OVJQWQ2N.mjs.map} +0 -0
- /package/dist/esm/{chunk-QVKMFPAV.mjs.map → chunk-OZNBOCEF.mjs.map} +0 -0
- /package/dist/esm/{chunk-QK4P26SH.mjs.map → chunk-PNGS6IWC.mjs.map} +0 -0
- /package/dist/esm/{chunk-L4Q2XTHT.mjs.map → chunk-QM4UQVGB.mjs.map} +0 -0
- /package/dist/esm/{chunk-BMKDEIRL.mjs.map → chunk-VVMR7UKB.mjs.map} +0 -0
- /package/dist/esm/{chunk-VBTJVPAM.mjs.map → chunk-WFL6YWJS.mjs.map} +0 -0
- /package/dist/esm/{chunk-3CLYWZYZ.mjs.map → chunk-WZNX3RBA.mjs.map} +0 -0
- /package/dist/esm/{chunk-RAYJRFIG.mjs.map → chunk-XRAL7KVT.mjs.map} +0 -0
- /package/dist/esm/{chunk-G2QII3AT.mjs.map → chunk-Y5GRH4YJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-V4YBGBCN.mjs.map → chunk-YUN2JVAN.mjs.map} +0 -0
- /package/dist/esm/{chunk-HXN2WRUX.mjs.map → chunk-YVIP7DMT.mjs.map} +0 -0
- /package/dist/esm/{chunk-HB6T27S2.mjs.map → chunk-YWN2T4IU.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZPNCA4C7.mjs.map → chunk-YZKDNVA5.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 ce=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 _r="1.13.0";var Ht=(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))(Ht||{}),Sr= 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))(Sr||{}),bt= 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))(bt||{}),xr= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(xr||{}),vr= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(vr||{}),Cr= 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))(Cr||{}),Pr= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Pr||{}),Er= exports.AnyPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Er||{}),Ir= exports.AnySignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ir||{}),Gn= 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))(Gn||{});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||{}),Ur= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Ur||{}),ns= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(ns||{}),De= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(De||{}),kn= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(kn||{}),Rr= 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))(Rr||{});var zr={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"},Nr= 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"},Dr= 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"},On= exports.Network =(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.RANDOMNET="randomnet",s.LOCAL="local",s.CUSTOM="custom",s))(On||{}),Bn= exports.NetworkToChainId ={mainnet:1,testnet:2,randomnet:70},Ea= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",randomnet:"randomnet",local:"local",custom:"custom"};var wt=(r=>(r.FULLNODE="Fullnode",r.INDEXER="Indexer",r.FAUCET="Faucet",r))(wt||{}),Gr= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,kr= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Qt= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Wt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Or= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Fn= 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 Br={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 rs(n,t){let{url:e,method:r,body:o,contentType:i,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _2 => _2.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${_r}`,"content-type":_nullishCoalesce(i, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _3 => _3.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _4 => _4.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _5 => _5.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _6 => _6.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 rs({...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 ce(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new ce(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 Br?c=Br[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new ce(n,a,`${e} error: ${c}`)}async function Fr(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 Fr({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _7 => _7.clientConfig, 'optionalAccess', _8 => _8.HEADERS]),..._optionalChain([t, 'access', _9 => _9.fullnodeConfig, 'optionalAccess', _10 => _10.HEADERS])}}})}async function We(n){let t=[],e,r=n.params;do{let o=await Fr({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 Mn(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 Mn({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _11 => _11.clientConfig, 'optionalAccess', _12 => _12.HEADERS]),..._optionalChain([t, 'access', _13 => _13.fullnodeConfig, 'optionalAccess', _14 => _14.HEADERS])}}})}async function Mr(n){let{aptosConfig:t}=n;return Mn({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _15 => _15.clientConfig, 'optionalAccess', _16 => _16.HEADERS]),..._optionalChain([t, 'access', _17 => _17.indexerConfig, 'optionalAccess', _18 => _18.HEADERS])}}})}async function Kr(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _19 => _19.clientConfig, 'optionalAccess', _20 => delete _20.API_KEY]),Mn({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([e, 'access', _23 => _23.faucetConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}var _utils = require('@noble/hashes/utils');var Xt=255,Yt=65535,fe=4294967295,ke=18446744073709551615n,_t=340282366920938463463374607431768211455n,Zt=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var M=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var ss=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(ss||{}),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', _25 => _25.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', _26 => _26.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _27 => _27.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){Kn(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(fe),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&ke,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&_t,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, [Oe(0,Xt)],X.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(0,Yt)],X.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(0,fe)],X.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(BigInt(0),ke)],X.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(BigInt(0),_t)],X.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(BigInt(0),Zt)],X.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(0,fe)],X.prototype,"serializeU32AsUleb128",1);function Kn(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var as=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function Pe(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(as(n,t,e))}function Oe(n,t){return(e,r,o)=>{let i=o.value;return o.value=function(a){return Pe(a,n,t),i.apply(this,[a])},o}}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 $r=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<fe;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>fe)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 Be=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 Jt=class n extends d{constructor(e){super();this.value=new Be(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let o=Be.deserialize(e,r);return new n(o.value)}};var I=class n extends d{constructor(e){super();Kn(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();Pe(e,0,Xt),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();Pe(e,0,Yt),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();Pe(e,0,fe),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();Pe(e,BigInt(0),ke),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();Pe(e,BigInt(0),_t),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();Pe(e,BigInt(0),Zt),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 I(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())}},Ee= 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 I(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])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ie=class Ie extends d{constructor(e){super();let{data:r}=e,o=f.fromHexInput(r);if(o.toUint8Array().length!==Ie.LENGTH)throw new Error(`Authentication Key length should be ${Ie.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(Ie.LENGTH);return new Ie({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 Ie({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())}};Ie.LENGTH=32;var K=Ie;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Vr = _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||{}),Lr= exports.HARDENED_OFFSET =2147483648;function Hr(n){return ms.test(n)}function Qr(n){return gs.test(n)}var qn=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},Wr= 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 qn(t,s)},As=n=>n.replace("'",""),jr= 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 Vr.mnemonicToSeedSync(t)};var St=class extends d{toString(){let t=this.toUint8Array();return f.fromHexInput(t).toString()}},ue= exports.AccountPublicKey =class extends St{};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 Xr=[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],Fe=class Fe extends ue{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==Fe.LENGTH)throw new Error(`PublicKey length should be ${Fe.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:o}=e;if(!(o instanceof R))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 Fe(r)}static isPublicKey(e){return e instanceof Fe}};Fe.LENGTH=32;var U=Fe,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(!Qr(e))throw new Error(`Invalid derivation path ${e}`);return Z.fromDerivationPathInner(e,en(r))}static fromDerivationPathInner(e,r,o=Lr){let{key:i,chainCode:s}=qn(Z.SLIP_0010_SEED,r),a=jr(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,m)=>Wr(p,m+o),{key:i,chainCode:s});return new Z(c)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new U(e)}sign(e){let r=je(e),o=f.fromHexInput(r).toUint8Array(),i=_ed25519.ed25519.sign(o,this.signingKey.toUint8Array());return new R(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]<Xr[r])return!0;if(e[r]>Xr[r])return!1}return!1}};Xe.LENGTH=64;var R=Xe;var ee=class ee extends ue{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 Me))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*U.LENGTH+1);return this.publicKeys.forEach((r,o)=>{e.set(r.toUint8Array(),o*U.LENGTH)}),e[this.publicKeys.length*U.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+=U.LENGTH){let a=s;i.push(new U(r.subarray(a,a+U.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*R.LENGTH+L.BITMAP_LEN);return this.signatures.forEach((r,o)=>{e.set(r.toUint8Array(),o*R.LENGTH)}),e.set(this.bitmap,this.signatures.length*R.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+=R.LENGTH){let a=s;i.push(new R(r.subarray(a,a+R.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 Me=L;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ke=class Ke extends St{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 Te))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 Ke(r)}static isPublicKey(e){return e instanceof Ke}};Ke.LENGTH=65;var he=Ke,pe=class pe extends d{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==pe.LENGTH)throw new Error(`PrivateKey length should be ${pe.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new pe(e)}static fromDerivationPath(e,r){if(!Hr(e))throw new Error(`Invalid derivation path ${e}`);return pe.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 pe(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 Te(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new he(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 pe(r)}static isPrivateKey(e){return e instanceof pe}};pe.LENGTH=32;var qe=pe,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 Te=Ze;var q=class n extends ue{constructor(e){super();if(this.publicKey=e,e instanceof U)this.variant=0;else if(e instanceof he)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=U.deserialize(e);break;case 1:o=he.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 U}isSecp256k1PublicKey(){return this.publicKey instanceof he}},O= exports.AnySignature =class n extends Y{constructor(e){super();if(this.signature=e,e instanceof R)this.variant=0;else if(e instanceof Te)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=R.deserialize(e);break;case 1:o=Te.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(o)}};function Zr(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 ue{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+Zr(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+Zr(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 Jr=H;var Q=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return de.load(t);case 1:return on.load(t);case 2:return ae.load(t);case 3:return Je.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof de}isMultiEd25519(){return this instanceof on}isSingleKey(){return this instanceof ae}isMultiKey(){return this instanceof Je}},de= exports.AccountAuthenticatorEd25519 =class n extends Q{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=U.deserialize(e),o=R.deserialize(e);return new n(r,o)}},on= exports.AccountAuthenticatorMultiEd25519 =class n extends Q{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=Me.deserialize(e);return new n(r,o)}},ae= exports.AccountAuthenticatorSingleKey =class n extends Q{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)}},Je= exports.AccountAuthenticatorMultiKey =class n extends Q{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 et=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 de(this.publicKey,e)}sign(t){return this.signWithAuthenticator(t).signature}};var tt=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=qe.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=qe.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 ae(this.publicKey,r)}sign(t){return this.signWithAuthenticator(t).signature}};var Ue=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?et.generate():tt.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:o=!0}=t;return e instanceof J&&o?new et({privateKey:e,address:r}):new tt({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?et.fromDerivationPath({mnemonic:r,path:o}):tt.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))},cd= 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))},ud= exports.createTokenAddress =(n,t,e)=>{let r=`${t}::${e}`;return hs(n,r)};var Ts=`
|
|
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 ce=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 _r="1.13.1";var Ht=(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))(Ht||{}),Sr= 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))(Sr||{}),bt= 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))(bt||{}),xr= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(xr||{}),vr= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(vr||{}),Cr= 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))(Cr||{}),Pr= exports.AccountAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(Pr||{}),Er= exports.AnyPublicKeyVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Er||{}),Ir= exports.AnySignatureVariant =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1=1]="Secp256k1",e))(Ir||{}),kn= 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))(kn||{});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||{}),Ur= exports.MoveAbility =(o=>(o.STORE="store",o.DROP="drop",o.KEY="key",o.COPY="copy",o))(Ur||{}),ns= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(ns||{}),De= exports.SigningScheme =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.SingleKey=2]="SingleKey",o[o.MultiKey=3]="MultiKey",o))(De||{}),On= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(On||{}),Rr= 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))(Rr||{});var zr={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"},Nr= 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"},Dr= 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"},Bn= exports.Network =(s=>(s.MAINNET="mainnet",s.TESTNET="testnet",s.DEVNET="devnet",s.RANDOMNET="randomnet",s.LOCAL="local",s.CUSTOM="custom",s))(Bn||{}),Fn= 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 wt=(r=>(r.FULLNODE="Fullnode",r.INDEXER="Indexer",r.FAUCET="Faucet",r))(wt||{}),Gr= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,kr= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Qt= exports.DEFAULT_TXN_TIMEOUT_SEC =20,Wt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Or= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Mn= 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 Br={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 rs(n,t){let{url:e,method:r,body:o,contentType:i,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _2 => _2.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${_r}`,"content-type":_nullishCoalesce(i, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _3 => _3.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _4 => _4.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _5 => _5.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _6 => _6.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 rs({...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 ce(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new ce(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 Br?c=Br[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new ce(n,a,`${e} error: ${c}`)}async function Fr(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 Fr({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _7 => _7.clientConfig, 'optionalAccess', _8 => _8.HEADERS]),..._optionalChain([t, 'access', _9 => _9.fullnodeConfig, 'optionalAccess', _10 => _10.HEADERS])}}})}async function We(n){let t=[],e,r=n.params;do{let o=await Fr({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 Kn(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 Kn({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _11 => _11.clientConfig, 'optionalAccess', _12 => _12.HEADERS]),..._optionalChain([t, 'access', _13 => _13.fullnodeConfig, 'optionalAccess', _14 => _14.HEADERS])}}})}async function Mr(n){let{aptosConfig:t}=n;return Kn({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _15 => _15.clientConfig, 'optionalAccess', _16 => _16.HEADERS]),..._optionalChain([t, 'access', _17 => _17.indexerConfig, 'optionalAccess', _18 => _18.HEADERS])}}})}async function Kr(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _19 => _19.clientConfig, 'optionalAccess', _20 => delete _20.API_KEY]),Kn({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _21 => _21.clientConfig, 'optionalAccess', _22 => _22.HEADERS]),..._optionalChain([e, 'access', _23 => _23.faucetConfig, 'optionalAccess', _24 => _24.HEADERS])}}})}var _utils = require('@noble/hashes/utils');var Xt=255,Yt=65535,fe=4294967295,ke=18446744073709551615n,_t=340282366920938463463374607431768211455n,Zt=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var M=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var ss=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(ss||{}),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', _25 => _25.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', _26 => _26.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _27 => _27.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(fe),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&ke,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&_t,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, [Oe(0,Xt)],X.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(0,Yt)],X.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(0,fe)],X.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(BigInt(0),ke)],X.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(BigInt(0),_t)],X.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(BigInt(0),Zt)],X.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [Oe(0,fe)],X.prototype,"serializeU32AsUleb128",1);function qn(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var as=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function Pe(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(as(n,t,e))}function Oe(n,t){return(e,r,o)=>{let i=o.value;return o.value=function(a){return Pe(a,n,t),i.apply(this,[a])},o}}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 $r=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<fe;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>fe)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 Be=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 Jt=class n extends d{constructor(e){super();this.value=new Be(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let o=Be.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();Pe(e,0,Xt),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();Pe(e,0,Yt),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();Pe(e,0,fe),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();Pe(e,BigInt(0),ke),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();Pe(e,BigInt(0),_t),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();Pe(e,BigInt(0),Zt),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())}},Ee= 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])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ie=class Ie extends d{constructor(e){super();let{data:r}=e,o=f.fromHexInput(r);if(o.toUint8Array().length!==Ie.LENGTH)throw new Error(`Authentication Key length should be ${Ie.LENGTH}`);this.data=o}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(Ie.LENGTH);return new Ie({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 Ie({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())}};Ie.LENGTH=32;var K=Ie;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var Vr = _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||{}),Lr= exports.HARDENED_OFFSET =2147483648;function Hr(n){return ms.test(n)}function Qr(n){return gs.test(n)}var $n=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},Wr= 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 $n(t,s)},As=n=>n.replace("'",""),jr= 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 Vr.mnemonicToSeedSync(t)};var St=class extends d{toString(){let t=this.toUint8Array();return f.fromHexInput(t).toString()}},ue= exports.AccountPublicKey =class extends St{};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 Xr=[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],Fe=class Fe extends ue{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==Fe.LENGTH)throw new Error(`PublicKey length should be ${Fe.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 Fe(r)}static isPublicKey(e){return e instanceof Fe}};Fe.LENGTH=32;var I=Fe,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(!Qr(e))throw new Error(`Invalid derivation path ${e}`);return Z.fromDerivationPathInner(e,en(r))}static fromDerivationPathInner(e,r,o=Lr){let{key:i,chainCode:s}=$n(Z.SLIP_0010_SEED,r),a=jr(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,m)=>Wr(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]<Xr[r])return!0;if(e[r]>Xr[r])return!1}return!1}};Xe.LENGTH=64;var U=Xe;var ee=class ee extends ue{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 Me))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 Me=L;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ke=class Ke extends St{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 Te))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 Ke(r)}static isPublicKey(e){return e instanceof Ke}};Ke.LENGTH=65;var he=Ke,pe=class pe extends d{constructor(e){super();let r=f.fromHexInput(e);if(r.toUint8Array().length!==pe.LENGTH)throw new Error(`PrivateKey length should be ${pe.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new pe(e)}static fromDerivationPath(e,r){if(!Hr(e))throw new Error(`Invalid derivation path ${e}`);return pe.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 pe(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 Te(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new he(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 pe(r)}static isPrivateKey(e){return e instanceof pe}};pe.LENGTH=32;var qe=pe,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 Te=Ze;var q=class n extends ue{constructor(e){super();if(this.publicKey=e,e instanceof I)this.variant=0;else if(e instanceof he)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=he.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 he}},O= exports.AnySignature =class n extends Y{constructor(e){super();if(this.signature=e,e instanceof U)this.variant=0;else if(e instanceof Te)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=Te.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(o)}};function Zr(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 ue{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+Zr(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+Zr(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 Jr=H;var Q=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return de.load(t);case 1:return on.load(t);case 2:return ae.load(t);case 3:return Je.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof de}isMultiEd25519(){return this instanceof on}isSingleKey(){return this instanceof ae}isMultiKey(){return this instanceof Je}},de= exports.AccountAuthenticatorEd25519 =class n extends Q{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 Q{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=Me.deserialize(e);return new n(r,o)}},ae= exports.AccountAuthenticatorSingleKey =class n extends Q{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)}},Je= exports.AccountAuthenticatorMultiKey =class n extends Q{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 et=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 de(this.publicKey,e)}sign(t){return this.signWithAuthenticator(t).signature}};var tt=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=qe.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=qe.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 ae(this.publicKey,r)}sign(t){return this.signWithAuthenticator(t).signature}};var Ue=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?et.generate():tt.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:o=!0}=t;return e instanceof J&&o?new et({privateKey:e,address:r}):new tt({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?et.fromDerivationPath({mnemonic:r,path:o}):tt.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))},cd= 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))},ud= 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
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
version
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
|
|
229
|
+
`,Vn=`
|
|
230
230
|
query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
|
|
231
231
|
current_collections_v2(where: $where_condition) {
|
|
232
232
|
collection_id
|
|
@@ -348,14 +348,14 @@
|
|
|
348
348
|
...AnsTokenFragment
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
${bs}`,
|
|
351
|
+
${bs}`,Ln=`
|
|
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
|
+
`,Hn=`
|
|
359
359
|
query getProcessorStatus($where_condition: processor_status_bool_exp) {
|
|
360
360
|
processor_status(where: $where_condition) {
|
|
361
361
|
last_success_version
|
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
...TokenActivitiesFields
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
${Ts}`,
|
|
377
|
+
${Ts}`,Qn=`
|
|
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
|
|
@@ -425,5 +425,5 @@
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
`;async function an(n){let{aptosConfig:t}=n,{data:e}=await V({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function ho(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 To(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 cn(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 bo(n){let{aptosConfig:t,limit:e}=n;return(await y({aptosConfig:t,query:{query:uo,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function y(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:o}=await Mr({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:Ln},originMethod:"getProcessorStatuses"})).processor_status}async function un(n){let t=await ws({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function pn(n){let{aptosConfig:t,processorType:e}=n;return(await y({aptosConfig:t,query:{query:Ln,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var Qn=new Map;function rt(n,t,e){return async(...r)=>{if(Qn.has(t)){let{value:i,timestamp:s}=Qn.get(t);if(e===void 0||Date.now()-s<=e)return i}let o=await n(...r);return Qn.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 So(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 dn(n){return _optionalChain([n, 'access', _37 => _37.options, 'optionalAccess', _38 => _38.ledgerVersion])!==void 0?wo(n):rt(async()=>wo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function wo(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 xo(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 vo(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 Wn(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 jn(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,o=await Wn({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:i}}=o,s=u.from(e);try{let a=await cn({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 ce&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Co(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:ao,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 Po(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:io,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 Eo(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:so,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 Io(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:ro,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 Uo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:co,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return i.account_transactions_aggregate.aggregate?i.account_transactions_aggregate.aggregate.count:0}async function Ro(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,o=u.from(e).toStringLong(),i=await Xn({aptosConfig:t,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return i[0]?i[0].amount:0}async function Xn(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:no,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 zo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:to,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 No(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()}},s={query:oo,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 Do(n){let{aptosConfig:t,privateKey:e}=n,r=new q(e.publicKey());if(e instanceof qe){let i=K.fromPublicKey({publicKey:r}).derivedAddress();return Ue.fromPrivateKey({privateKey:e,address:i})}if(e instanceof J){let o=K.fromPublicKey({publicKey:r});if(await _o({authKey:o,aptosConfig:t})){let c=o.derivedAddress();return Ue.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=K.fromPublicKey({publicKey:r.publicKey});if(await _o({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Ue.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function _o(n){let{aptosConfig:t,authKey:e}=n,r=await jn({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 Go(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 gn(n){let{aptosConfig:t}=n;return rt(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 ko(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await V({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function xt(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await V({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Oo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await xt({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 ot(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,C=1.5;function b(l){if(!(l instanceof ce)||(p=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await xt({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(Ae){b(Ae)}a=(Date.now()-l)/1e3}for(;s&&!(a>=o);){try{if(c=await xt({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*=C}if(c===void 0)throw p||new ln(`Fetching transaction ${e} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new ln(`Transaction ${e} timed out in pending state after ${o} seconds`,c);if(!i)return c;if(!c.success)throw new Yn(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function mn(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 un({aptosConfig:t}):s=(await pn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var ln=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Yn=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function T(n){n.minimumLedgerVersion!==void 0&&await mn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var vt=class{constructor(t){this.config=t}async getAccountInfo(t){return le({aptosConfig:this.config,...t})}async getAccountModules(t){return So({aptosConfig:this.config,...t})}async getAccountModule(t){return dn({aptosConfig:this.config,...t})}async getAccountTransactions(t){return xo({aptosConfig:this.config,...t})}async getAccountResources(t){return vo({aptosConfig:this.config,...t})}async getAccountResource(t){return Wn({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return jn({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Co({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Po({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Eo({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Io({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Uo({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Xn({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),zo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Wt,...t})}async getAccountCoinAmount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ro({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),No({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return Do({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var yn=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 Nr[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 Dr[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 zr[this.network];default:throw Error(`apiType ${t} is not supported`)}}};var An=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 be=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return it.load(t);case 1:return Zn.load(t);case 2:return st.load(t);case 3:return at.load(t);case 4:return ct.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},it= exports.TransactionAuthenticatorEd25519 =class n extends be{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=U.deserialize(e),o=R.deserialize(e);return new n(r,o)}},Zn= exports.TransactionAuthenticatorMultiEd25519 =class n extends be{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=Me.deserialize(e);return new n(r,o)}},st= exports.TransactionAuthenticatorMultiAgent =class n extends be{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=Q.deserialize(e),o=e.deserializeVector(u),i=e.deserializeVector(Q);return new n(r,o,i)}},at= exports.TransactionAuthenticatorFeePayer =class n extends be{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=Q.deserialize(e),o=e.deserializeVector(u),i=e.deserializeVector(Q),s=u.deserialize(e),a=Q.deserialize(e),c={address:s,authenticator:a};return new n(r,o,i,c)}},ct= exports.TransactionAuthenticatorSingleSender =class n extends be{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=Q.deserialize(e);return new n(r)}};var ut=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 E=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 Ct=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 E(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),o=E.deserialize(e);return new n(r,o)}};var z=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 lt.load(t);case 4:return W.load(t);case 5:return $e.load(t);case 6:return x.load(t);case 7:return g.load(t);case 8:return pt.load(t);case 9:return dt.load(t);case 10:return gt.load(t);case 255:return N.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof k}isAddress(){return this instanceof W}isGeneric(){return this instanceof N}isSigner(){return this instanceof $e}isVector(){return this instanceof x}isStruct(){return this instanceof g}isU8(){return this instanceof ge}isU16(){return this instanceof pt}isU32(){return this instanceof dt}isU64(){return this instanceof $}isU128(){return this instanceof lt}isU256(){return this instanceof gt}},k= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},ge= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},pt= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},dt= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},$= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},lt= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},gt= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},W= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},$e= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},fn= exports.TypeTagReference =class n extends z{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=z.deserialize(e);return new n(r)}},N= exports.TypeTagGeneric =class n extends z{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 z{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=z.deserialize(e);return new n(r)}},g= exports.TypeTagStruct =class n extends z{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=we.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")}},we= 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=E.deserialize(e),i=E.deserialize(e),s=e.deserializeVector(z);return new n(r,o,i,s)}};function Ml(){return new we(u.ONE,new E("aptos_coin"),new E("AptosCoin"),[])}function S(){return new we(u.ONE,new E("string"),new E("String"),[])}function Kl(n){return new we(u.ONE,new E("option"),new E("Option"),[n])}function j(n){return new we(u.ONE,new E("object"),new E("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 I.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 Ve=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Pt.load(t);case 2:return Et.load(t);case 3:return It.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Pt= exports.TransactionPayloadScript =class n extends Ve{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=Ut.deserialize(e);return new n(r)}},Et= exports.TransactionPayloadEntryFunction =class n extends Ve{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=Le.deserialize(e);return new n(r)}},It= exports.TransactionPayloadMultiSig =class n extends Ve{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Rt.deserialize(e);return new n(r)}},Le= 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(Ct.fromStr(t),new E(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=Ct.deserialize(t),r=E.deserialize(t),o=t.deserializeVector(z),i=t.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<i;a+=1){let c=t.deserializeUleb128AsU32(),p=Jt.deserialize(t,c);s.push(p)}return new n(e,r,o,s)}},Ut= 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(z),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)}},Rt= 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=zt.deserialize(t)),new n(e,o)}},zt= 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(Le.deserialize(e))}};var B=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=Ve.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=ut.deserialize(e);return new n(r,o,i,s,a,c,p)}},hn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return _e.load(t);case 1:return Se.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},_e= exports.MultiAgentRawTransaction =class n extends hn{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=B.deserialize(e),o=e.deserializeVector(u);return new n(r,o)}},Se= exports.FeePayerRawTransaction =class n extends hn{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=B.deserialize(e),o=e.deserializeVector(u),i=u.deserialize(e);return new n(r,o,i)}};var me=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=B.deserialize(e),o=be.deserialize(e);return new n(r,o)}};var Tn=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=B.deserialize(e),o=e.deserializeBool(),i;return o&&(i=u.deserialize(e)),new n(r,i)}};function Bo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Fo(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(!Fo(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 xe(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 Ae=bn(a,o,e);i.push(Ae)}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:C,savedTypes:b,savedExpectedTypes:l}=m;o=i,i=b,a=C,c=l}else if(p===","){if(a.length!==0){let m=bn(a,o,e);o=[],i.push(m),a="",c+=1}}else if(Fo(p)){let m=!1;if(a.length!==0){let b=bn(a,o,e);o=[],i.push(b),a="",m=!0}s=Cs(n,s);let C=n[s];if(s<n.length&&m&&C!==","&&C!==">")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 bn(a,o,e);case 1:if(a==="")return i[0];throw new v(n,"unexpected ','");default:throw new v(n,"unexpected whitespace character")}}function bn(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 fn(new $e);case"signer":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new $e;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 W;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 pt;case"u32":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new dt;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 lt;case"u256":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new gt;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 N(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(!Bo(r[1]))throw new v(n,"module name must only contain alphanumeric or '_' characters");if(!Bo(r[2]))throw new v(n,"struct name must only contain alphanumeric or '_' characters");return new g(new we(u.fromString(r[0]),new E(r[1]),new E(r[2]),t))}}function Mo(n){return typeof n=="boolean"}function mt(n){return typeof n=="string"}function wn(n){return typeof n=="number"}function _n(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ko(n){return n==null}function qo(n){return Jn(n)||tr(n)||nr(n)||rr(n)||or(n)||ir(n)||sr(n)||Sn(n)||er(n)||Es(n)||n instanceof h||n instanceof Ee}function Jn(n){return n instanceof I}function Sn(n){return n instanceof u}function er(n){return n instanceof w}function Es(n){return n instanceof Be}function tr(n){return n instanceof G}function nr(n){return n instanceof re}function rr(n){return n instanceof oe}function or(n){return n instanceof D}function ir(n){return n instanceof ie}function sr(n){return n instanceof se}function $o(n){return"bytecode"in n}function P(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Vo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function Nt(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 cr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _83 => _83.map, 'call', _84 => _84(t=>mt(t)?xe(t):t)]), () => ([]))}async function Lo(n,t,e,r){let o=await dn({aptosConfig:r,accountAddress:n,moduleName:t});if(o.abi)return o.abi.exposed_functions.find(i=>i.name===e)}async function Ho(n,t,e,r){let o=await Lo(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=Vo(o),s=[];for(let a=i;a<o.params.length;a+=1)s.push(xe(o.params[a],{allowGenerics:!0}));return{signers:i,typeParameters:o.generic_type_params,parameters:s}}async function Qo(n,t,e,r){let o=await Lo(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(xe(o.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<o.return.length;a+=1)s.push(xe(o.return[a],{allowGenerics:!0}));return{typeParameters:o.generic_type_params,parameters:i,returnTypes:s}}function ur(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 yt(e,i,r,o)}function yt(n,t,e,r){return qo(n)?(ar(t,n,e),n):Us(n,t,e,r)}function Us(n,t,e,r){if(t.isBool()){if(Mo(n))return new I(n);P("boolean",e)}if(t.isAddress()){if(mt(n))return u.fromString(n);P("string | AccountAddress",e)}if(t.isU8()){if(wn(n))return new G(n);P("number",e)}if(t.isU16()){if(wn(n))return new re(n);P("number",e)}if(t.isU32()){if(wn(n))return new oe(n);P("number",e)}if(t.isU64()){if(_n(n))return new D(BigInt(n));P("bigint | number | string",e)}if(t.isU128()){if(_n(n))return new ie(BigInt(n));P("bigint | number | string",e)}if(t.isU256()){if(_n(n))return new se(BigInt(n));P("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 yt(n,r[o],e,r)}if(t.isVector()){if(t.value.isU8()){if(mt(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=>yt(o,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(mt(n))return new w(n);P("string",e)}if(t.isObject()){if(mt(n))return u.fromString(n);P("string | AccountAddress",e)}if(t.isOption())return Ko(n)?new Ee(null):new Ee(yt(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 ar(n,t,e){if(n.isBool()){if(Jn(t))return;P("Bool",e)}if(n.isAddress()){if(Sn(t))return;P("AccountAddress",e)}if(n.isU8()){if(tr(t))return;P("U8",e)}if(n.isU16()){if(nr(t))return;P("U16",e)}if(n.isU32()){if(rr(t))return;P("U32",e)}if(n.isU64()){if(or(t))return;P("U64",e)}if(n.isU128()){if(ir(t))return;P("U128",e)}if(n.isU256()){if(sr(t))return;P("U256",e)}if(n.isVector()){if(t instanceof h){t.values.length>0&&ar(n.value,t.values[0],e);return}P("MoveVector",e)}if(n instanceof g){if(n.isString()){if(er(t))return;P("MoveString",e)}if(n.isObject()){if(Sn(t))return;P("AccountAddress",e)}if(n.isOption()){if(t instanceof Ee){t.value!==void 0&&ar(n.value.typeArgs[0],t.value,e);return}P("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}var xn=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=B.deserialize(e),o=e.deserializeVector(u),i=e.deserializeBool(),s;return i&&(s=u.deserialize(e)),new n(r,o,s)}};async function Cn(n){if($o(n))return Ns(n);let{moduleAddress:t,moduleName:e,functionName:r}=Nt(n.function),o=await ei({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ho});return Rs({abi:o,...n})}function Rs(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=Nt(n.function),i=cr(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)=>ur(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=Le.build(`${e}::${r}`,o,i,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new It(new Rt(c,new zt(a)))}return new Et(a)}async function jo(n){let{moduleAddress:t,moduleName:e,functionName:r}=Nt(n.function),o=await ei({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Qo});return zs({abi:o,...n})}function zs(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=Nt(n.function),i=cr(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)=>ur(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 Le.build(`${e}::${r}`,o,i,s)}function Ns(n){return new Pt(new Ut(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=Bn[t.network]?Promise.resolve({chain_id:Bn[t.network]}):an({aptosConfig:t}),a=_optionalChain([o, 'optionalAccess', _88 => _88.gasUnitPrice])?Promise.resolve({gas_estimate:o.gasUnitPrice}):gn({aptosConfig:t}),[{chain_id:c},{gas_estimate:p}]=await Promise.all([s,a]),m=_optionalChain([o, 'optionalAccess', _89 => _89.accountSequenceNumber])!==void 0?Promise.resolve({sequence_number:o.accountSequenceNumber}):le({aptosConfig:t,accountAddress:e}),C;if(i&&u.from(i).equals(u.ZERO))try{let{sequence_number:He}=await m;C=He}catch (e2){C="0"}else{let{sequence_number:He}=await m;C=He}let{maxGasAmount:b,gasUnitPrice:l,expireTimestamp:Ae}={maxGasAmount:_optionalChain([o, 'optionalAccess', _90 => _90.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(p),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...o};return new B(u.from(e),BigInt(C),r,BigInt(b),BigInt(l),BigInt(Ae),new ut(c))}async function pr(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', _91 => _91.secondarySignerAddresses, 'optionalAccess', _92 => _92.map, 'call', _93 => _93(c=>u.from(c))]), () => ([]));return new xn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Tn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Xo(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,i=vn(t);if(e.feePayerAddress){let a=new Se(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(C=>vn(C)));let p=vn(o),m=new at(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new me(a.raw_txn,m).bcsToBytes()}if(e.secondarySignerAddresses){let a=new _e(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(m=>vn(m));let p=new st(i,e.secondarySignerAddresses,c);return new me(a.raw_txn,p).bcsToBytes()}let s;if(i instanceof de)s=new it(i.public_key,i.signature);else if(i instanceof ae)s=new ct(i);else throw new Error("Invalid public key");return new me(e.rawTransaction,s).bcsToBytes()}function vn(n){if(n instanceof q){if(n.publicKey instanceof U)return new ae(n,new O(new R(new Uint8Array(64))));if(n.publicKey instanceof he)return new ae(n,new O(new Te(new Uint8Array(64))))}return new de(new U(n.toUint8Array()),new R(new Uint8Array(64)))}function Yo(n){let{signer:t,transaction:e}=n,r=lr(e);return t.signWithAuthenticator(r)}function dr(n){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:r,additionalSignersAuthenticators:o}=n,i=Jo(t);if((r||o)&&(i instanceof _e||i instanceof Se))return ks(i,e,r,o);if(e instanceof de&&i instanceof B){let s=new it(e.public_key,e.signature);return new me(i,s).bcsToBytes()}if((e instanceof ae||e instanceof Je)&&i instanceof B){let s=new ct(e);return new me(i,s).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Zo(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Gs=Zo(["APTOS::Transaction"]);function fm(n){let t=dr(n);return new f(Zo([Gs,new Uint8Array([0]),t])).toString()}function Jo(n){return n.feePayerAddress?new Se(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new _e(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function ks(n,t,e,r){if(n instanceof Se){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new at(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:e});return new me(n.raw_txn,o).bcsToBytes()}if(n instanceof _e){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new st(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new me(n.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}function lr(n){let t=Jo(n),e=_sha3.sha3_256.create();if(t instanceof B)e.update(Or);else if(t instanceof _e)e.update(Fn);else if(t instanceof Se)e.update(Fn);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||rt(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 Cn(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await Cn(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments},o=await Cn(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 pr({aptosConfig:e,sender:r,payload:t,options:o,secondarySignerAddresses:s,feePayerAddress:i})}return pr({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 lr(t)}function Pn(n){return Yo({...n})}async function gr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}=n,a=Xo({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', _94 => _94.options, 'optionalAccess', _95 => _95.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _96 => _96.options, 'optionalAccess', _97 => _97.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.options, 'optionalAccess', _99 => _99.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function En(n){let{aptosConfig:t}=n,e=dr({...n}),{data:r}=await Ge({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function Dt(n){let{aptosConfig:t,signer:e,transaction:r}=n,o=Pn({signer:e,transaction:r});return En({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=Ue.fromPrivateKey({privateKey:r,legacy:!0}),a=new An({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 Dt({aptosConfig:t,signer:e,transaction:m})}var $s={typeParameters:[{constraints:[]}],parameters:[new W,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, () => (Wt))],functionArguments:[r,o],abi:$s},options:s})}var Gt=class{constructor(t){this.config=t}async transferCoinTransaction(t){return oi({aptosConfig:this.config,...t})}};var Re={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:fo,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:Hn,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:Hn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _100 => _100.offset]),limit:_optionalChain([r, 'optionalAccess', _101 => _101.limit]),order_by:_optionalChain([r, 'optionalAccess', _102 => _102.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:Ao,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _103 => _103.offset]),limit:_optionalChain([r, 'optionalAccess', _104 => _104.limit]),order_by:_optionalChain([r, 'optionalAccess', _105 => _105.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, () => (ke))),new w(n.name),new w(n.uri),new I(_nullishCoalesce(n.mutableDescription, () => (!0))),new I(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new I(_nullishCoalesce(n.mutableURI, () => (!0))),new I(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new I(_nullishCoalesce(n.mutableTokenName, () => (!0))),new I(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new I(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new I(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new I(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new D(_nullishCoalesce(n.royaltyNumerator, () => (0))),new D(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Vs},options:e})}async function mr(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', _106 => _106.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _107 => _107.tokenStandard]), () => ("v2"))}),(await y({aptosConfig:t,query:{query:$n,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:$n,variables:{where_condition:o}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function di(n){return(await mr(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,C=_optionalChain([p, 'optionalAccess', _108 => _108.map, 'call', _109 => _109(b=>Re[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(C, () => ([]))),Ci(_nullishCoalesce(m, () => ([])),_nullishCoalesce(C, () => ([])))],abi:Ls},options:e})}var Hs={typeParameters:[{constraints:["key"]}],parameters:[new g(j(new N(0))),new W]};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 W]};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:C}=n;if(_optionalChain([c, 'optionalAccess', _110 => _110.length])!==_optionalChain([m, 'optionalAccess', _111 => _111.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _112 => _112.length])!==_optionalChain([m, 'optionalAccess', _113 => _113.length]))throw new Error("Property types and property values counts do not match");let b=_optionalChain([p, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(l=>Re[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:C})}var Ws={typeParameters:[{constraints:["key"]}],parameters:[new g(j(new N(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(j(new N(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(j(new N(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(j(new N(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(j(new N(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(j(new N(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(j(new N(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(Re[o]),h.U8(yr(i,Re[o]))],abi:ea},options:c})}var ta={typeParameters:[{constraints:["key"]}],parameters:[new g(j(new N(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(j(new N(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(Re[o]),yr(i,Re[o])],abi:na},options:c})}var ra={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new g(j(new N(0))),new g(S()),new N(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)),Re[o]],functionArguments:[u.from(s),new w(r),i],abi:ra},options:c})}var oa={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new g(j(new N(0))),new g(S()),new N(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)),Re[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(yr(n[o],r))}),e}function yr(n,t){let e=xe(t);return yt(n,e,0,[]).bcsToBytes()}var kt=class{constructor(t){this.config=t}async getCollectionData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),mr({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', _116 => _116.orderBy])};return Ot({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', _117 => _117.orderBy])};return Ot({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', _118 => _118.orderBy])};return Ot({aptosConfig:e,options:a})}async function Ot(n){let{aptosConfig:t,options:e}=n;ia(_optionalChain([e, 'optionalAccess', _119 => _119.where, 'optionalAccess', _120 => _120.indexed_type, 'optionalAccess', _121 => _121._eq]));let r={query:go,variables:{where_condition:_optionalChain([e, 'optionalAccess', _122 => _122.where]),offset:_optionalChain([e, 'optionalAccess', _123 => _123.offset]),limit:_optionalChain([e, 'optionalAccess', _124 => _124.limit]),order_by:_optionalChain([e, 'optionalAccess', _125 => _125.orderBy])}};return(await y({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var Bt=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', _126 => _126.minimumLedgerVersion]),processorType:"events_processor"}),Ot({aptosConfig:this.config,...t})}};async function Ri(n){let{aptosConfig:t,accountAddress:e,amount:r,options:o}=n,i=_optionalChain([o, 'optionalAccess', _127 => _127.timeoutSecs])||20,{data:s}=await Kr({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await ot({aptosConfig:t,transactionHash:a,options:{timeoutSecs:i,checkSuccess:_optionalChain([o, 'optionalAccess', _128 => _128.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Ft=class{constructor(t){this.config=t}async fundAccount(t){let e=await Ri({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _129 => _129.options, 'optionalAccess', _130 => _130.waitForIndexer])!==!1&&await mn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function Ar(n){let{aptosConfig:t,options:e}=n,r={query:yo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _131 => _131.where]),limit:_optionalChain([e, 'optionalAccess', _132 => _132.limit]),offset:_optionalChain([e, 'optionalAccess', _133 => _133.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:mo,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 y({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ni(n){let{aptosConfig:t,options:e}=n,r={query:po,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 y({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var sa={typeParameters:[],parameters:[xe("0x1::object::Object"),new W,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 Mt=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _140 => _140.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ar({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _141 => _141.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Ar({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _142 => _142.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),zi({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _143 => _143.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ni({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return Di({aptosConfig:this.config,...t})}};async function ze(n){let{aptosConfig:t,payload:e,options:r}=n,o=await jo({...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', _144 => _144.ledgerVersion])},body:s});return a}var Kt=class{constructor(t){this.config=t}async getLedgerInfo(){return an({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return ho({aptosConfig:this.config,...t})}async getBlockByHeight(t){return To({aptosConfig:this.config,...t})}async getTableItem(t){return cn({aptosConfig:this.config,...t})}async view(t){return ze({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return bo({aptosConfig:this.config,...t})}async queryIndexer(t){return y({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return un({aptosConfig:this.config})}async getProcessorStatus(t){return pn({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 Ne(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 ve(n){let t=ca[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var In=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=ve(t),{domainName:o,subdomainName:i}=Ne(e),s=await ze({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,i]}}),a=In(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=ve(t),{domainName:m,subdomainName:C}=Ne(r),b=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(C&&!b)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(b&&!C)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let wr=_nullishCoalesce(e.years, () => (1));if(wr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let es=wr*31536e3;return await A({aptosConfig:t,sender:o.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[m,es,i,s]},options:a})}if(!C)throw new Error(`${e.policy} requires a subdomain to be provided.`);let l=await fr({aptosConfig:t,name:m});if(!l)throw new Error("The domain does not exist");let Ae=e.policy==="subdomain:independent"?e.expirationDate:l;if(Ae>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,C,Math.round(Ae/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,i,s]},options:a})}async function fr(n){let{aptosConfig:t,name:e}=n,r=ve(t),{domainName:o,subdomainName:i}=Ne(e);try{let s=await ze({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=ve(t),o=await ze({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),i=In(o[1]),s=In(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=ve(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}=Ne(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=ve(t),{domainName:o,subdomainName:i}=Ne(e),s=await ze({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,i]}}),a=In(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=ve(t),{domainName:a,subdomainName:c}=Ne(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=""}=Ne(e),a=(await y({aptosConfig:t,query:{query:nt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=qt(a)),a}async function Vi(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await hr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountNames",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _145 => _145.limit]),offset:_optionalChain([e, 'optionalAccess', _146 => _146.offset]),order_by:_optionalChain([e, 'optionalAccess', _147 => _147.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _148 => _148.options, 'optionalAccess', _149 => _149.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(qt)}async function Li(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await hr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountDomains",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _150 => _150.limit]),offset:_optionalChain([e, 'optionalAccess', _151 => _151.offset]),order_by:_optionalChain([e, 'optionalAccess', _152 => _152.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _153 => _153.options, 'optionalAccess', _154 => _154.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(qt)}async function Hi(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await hr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _155 => _155.limit]),offset:_optionalChain([e, 'optionalAccess', _156 => _156.offset]),order_by:_optionalChain([e, 'optionalAccess', _157 => _157.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _158 => _158.options, 'optionalAccess', _159 => _159.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(qt)}async function Qi(n){let{aptosConfig:t,options:e,domain:r}=n;return(await y({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _160 => _160.limit]),offset:_optionalChain([e, 'optionalAccess', _161 => _161.offset]),order_by:_optionalChain([e, 'optionalAccess', _162 => _162.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _163 => _163.options, 'optionalAccess', _164 => _164.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(qt)}async function hr(n){let{aptosConfig:t}=n,e=ve(t),[r]=await ze({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=ve(t),a=o*31536e3,{domainName:c,subdomainName:p}=Ne(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 qt(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var $t=class{constructor(t){this.config=t}async getOwnerAddress(t){return Oi({aptosConfig:this.config,...t})}async getExpiration(t){return fr({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:Vn,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:Vn,variables:{order_by:_optionalChain([e, 'optionalAccess', _165 => _165.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:lo,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await y({aptosConfig:t,query:o})).delegated_staking_activities}var Vt=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _166 => _166.minimumLedgerVersion]),processorType:"stake_processor"}),ji({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _167 => _167.minimumLedgerVersion]),processorType:"stake_processor"}),Xi({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _168 => _168.minimumLedgerVersion]),processorType:"stake_processor"}),Yi({aptosConfig:this.config,...t})}};var Un=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 Tr(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 br(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 At=class{constructor(t){this.config=t}async simple(t){return gr({aptosConfig:this.config,...t})}async multiAgent(t){return gr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [br],At.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [br],At.prototype,"multiAgent",1);var ft=class{constructor(t){this.config=t}async simple(t){return En({aptosConfig:this.config,...t})}async multiAgent(t){return En({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [Tr],ft.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [Tr],ft.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Rn=()=>Math.floor(Date.now()/1e3),zn= 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=Rn();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),Rn()-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=Rn();for(;this.lastUncommintedNumber!==this.currentNumber;)Rn()-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 ht=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _169 => _169.pendingDequeue, 'access', _170 => _170.shift, 'call', _171 => _171(), 'optionalAccess', _172 => _172.resolve, 'call', _173 => _173(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 Tt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Tt=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||{}),Nn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,o=30,i=100,s=10){super();this.taskQueue=new ht;this.transactionsQueue=new ht;this.outstandingTransactions=new ht;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new zn(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=Dt({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,e])}}catch(e){if(e instanceof Tt)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 Tt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let o=[];o.push(ot({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 Dn=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new Nn(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 Lt=class{constructor(t){this.config=t,this.build=new Un(this.config),this.simulate=new At(this.config),this.submit=new ft(this.config),this.batch=new Dn(this.config)}async getTransactions(t){return Go({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return ko({aptosConfig:this.config,...t})}async getTransactionByHash(t){return xt({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Oo({aptosConfig:this.config,...t})}async waitForTransaction(t){return ot({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return gn({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 Pn({...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,Pn({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 Dt({aptosConfig:this.config,signer:e,transaction:r})}};var ne=class{constructor(t){this.config=new yn(t),this.account=new vt(this.config),this.ans=new $t(this.config),this.coin=new Gt(this.config),this.digitalAsset=new kt(this.config),this.event=new Bt(this.config),this.faucet=new Ft(this.config),this.fungibleAsset=new Mt(this.config),this.general=new Kt(this.config),this.staking=new Vt(this.config),this.transaction=new Lt(this.config)}};function ye(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))})}ye(ne,vt,"account");ye(ne,$t,"ans");ye(ne,Gt,"coin");ye(ne,kt,"digitalAsset");ye(ne,Bt,"event");ye(ne,Ft,"faucet");ye(ne,Mt,"fungibleAsset");ye(ne,Kt,"general");ye(ne,Vt,"staking");ye(ne,Lt,"transaction");exports.APTOS_BIP44_REGEX = ms; exports.APTOS_COIN = Wt; exports.APTOS_HARDENED_REGEX = gs; exports.Account = Ue; exports.AccountAddress = u; exports.AccountAuthenticator = Q; exports.AccountAuthenticatorEd25519 = de; exports.AccountAuthenticatorMultiEd25519 = on; exports.AccountAuthenticatorMultiKey = Je; exports.AccountAuthenticatorSingleKey = ae; exports.AccountAuthenticatorVariant = Pr; exports.AccountPublicKey = ue; exports.AccountSequenceNumber = zn; exports.AddressInvalidReason = us; exports.AnyPublicKey = q; exports.AnyPublicKeyVariant = Er; exports.AnySignature = O; exports.AnySignatureVariant = Ir; exports.Aptos = ne; exports.AptosApiError = ce; exports.AptosApiType = wt; exports.AptosConfig = yn; exports.AuthenticationKey = K; exports.Bool = I; exports.CKDPriv = Wr; exports.ChainId = ut; exports.DEFAULT_MAX_GAS_AMOUNT = Gr; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = kr; exports.DEFAULT_TXN_TIMEOUT_SEC = Qt; exports.DeriveScheme = Rr; exports.Deserializer = $r; exports.Ed25519Account = et; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = U; exports.Ed25519Signature = R; exports.EntryFunction = Le; exports.EntryFunctionBytes = Jt; exports.FeePayerRawTransaction = Se; exports.FixedBytes = Be; exports.HARDENED_OFFSET = Lr; exports.Hex = f; exports.HexInvalidReason = ss; exports.Identifier = E; exports.KeyType = ys; exports.MimeType = Ht; exports.ModuleId = Ct; exports.MoveAbility = Ur; exports.MoveFunctionVisibility = ts; exports.MoveOption = Ee; exports.MoveString = w; exports.MoveVector = h; exports.MultiAgentRawTransaction = _e; exports.MultiEd25519PublicKey = Ye; exports.MultiEd25519Signature = Me; exports.MultiKey = rn; exports.MultiKeySignature = Jr; exports.MultiSig = Rt; exports.MultiSigTransactionPayload = zt; exports.Network = On; exports.NetworkToChainId = Bn; exports.NetworkToFaucetAPI = Dr; exports.NetworkToIndexerAPI = zr; exports.NetworkToNetworkName = Ea; exports.NetworkToNodeAPI = Nr; exports.ParsingError = M; exports.ProcessorType = Qe; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Or; exports.RAW_TRANSACTION_WITH_DATA_SALT = Fn; exports.RawTransaction = B; exports.RawTransactionWithData = hn; exports.RoleType = ns; exports.RotationProofChallenge = An; exports.Script = Ut; exports.ScriptTransactionArgumentVariants = bt; exports.Secp256k1PrivateKey = qe; exports.Secp256k1PublicKey = he; exports.Secp256k1Signature = Te; exports.Serializable = d; exports.Serializer = X; exports.Signature = Y; exports.SignedTransaction = me; exports.SigningScheme = De; exports.SigningSchemeInput = kn; exports.SimpleTransaction = Tn; exports.SingleKeyAccount = tt; exports.StructTag = we; exports.TransactionAuthenticator = be; exports.TransactionAuthenticatorEd25519 = it; exports.TransactionAuthenticatorFeePayer = at; exports.TransactionAuthenticatorMultiAgent = st; exports.TransactionAuthenticatorMultiEd25519 = Zn; exports.TransactionAuthenticatorSingleSender = ct; exports.TransactionAuthenticatorVariant = Cr; exports.TransactionPayload = Ve; exports.TransactionPayloadEntryFunction = Et; exports.TransactionPayloadMultiSig = It; exports.TransactionPayloadScript = Pt; exports.TransactionPayloadVariants = xr; exports.TransactionResponseType = Gn; exports.TransactionVariants = vr; exports.TransactionWorker = Nn; exports.TransactionWorkerEventsEnum = Ji; exports.TypeTag = z; exports.TypeTagAddress = W; exports.TypeTagBool = k; exports.TypeTagGeneric = N; exports.TypeTagParserError = v; exports.TypeTagParserErrorType = Ps; exports.TypeTagReference = fn; exports.TypeTagSigner = $e; exports.TypeTagStruct = g; exports.TypeTagU128 = lt; exports.TypeTagU16 = pt; exports.TypeTagU256 = gt; exports.TypeTagU32 = dt; exports.TypeTagU64 = $; exports.TypeTagU8 = ge; exports.TypeTagVariants = Sr; exports.TypeTagVector = x; exports.U128 = ie; exports.U16 = re; exports.U256 = se; exports.U32 = oe; exports.U64 = D; exports.U8 = G; exports.aptosCoinStructTag = Ml; exports.aptosRequest = jt; exports.buildTransaction = pr; exports.checkOrConvertArgument = yt; exports.convertArgument = ur; exports.createObjectAddress = hs; exports.createResourceAddress = cd; exports.createTokenAddress = ud; exports.deriveKey = qn; exports.deriveTransactionType = Jo; exports.deserializeFromScriptArgument = xs; exports.ensureBoolean = Kn; exports.fetchEntryFunctionAbi = Ho; exports.fetchFunctionAbi = Lo; exports.fetchViewFunctionAbi = Qo; exports.findFirstNonSignerArg = Vo; exports.generateMultiSignersSignedTransaction = ks; exports.generateRawTransaction = Ds; exports.generateSignedTransaction = dr; exports.generateSignedTransactionForSimulation = Xo; exports.generateSigningMessage = lr; exports.generateTransactionPayload = Cn; exports.generateTransactionPayloadWithABI = Rs; exports.generateUserTransactionHash = fm; exports.generateViewFunctionPayload = jo; exports.generateViewFunctionPayloadWithABI = zs; exports.get = Fr; exports.getAptosFullNode = V; exports.getAuthenticatorForSimulation = vn; exports.getFunctionParts = Nt; exports.hashValues = Zo; exports.isBcsAddress = Sn; exports.isBcsBool = Jn; exports.isBcsFixedBytes = Es; exports.isBcsString = er; exports.isBcsU128 = ir; exports.isBcsU16 = nr; exports.isBcsU256 = sr; exports.isBcsU32 = rr; exports.isBcsU64 = or; exports.isBcsU8 = tr; exports.isBlockMetadataTransactionResponse = ha; exports.isBool = Mo; exports.isEd25519Signature = wa; exports.isEncodedEntryFunctionArgument = qo; exports.isFeePayerSignature = xa; exports.isGenesisTransactionResponse = fa; exports.isLargeNumber = _n; exports.isMultiAgentSignature = Sa; exports.isMultiEd25519Signature = va; exports.isNull = Ko; exports.isNumber = wn; exports.isPendingTransactionResponse = ya; exports.isScriptDataInput = $o; exports.isSecp256k1Signature = _a; exports.isStateCheckpointTransactionResponse = Ta; exports.isString = mt; exports.isUserTransactionResponse = Aa; exports.isValidBIP44Path = Hr; exports.isValidHardenedPath = Qr; exports.isValidatorTransactionResponse = ba; exports.mnemonicToSeed = en; exports.objectStructTag = j; exports.optionStructTag = Kl; exports.outOfRangeErrorMessage = as; exports.paginateWithCursor = We; exports.parseTypeTag = xe; exports.post = Mn; exports.postAptosFaucet = Kr; exports.postAptosFullNode = Ge; exports.postAptosIndexer = Mr; exports.promiseFulfilledStatus = Zi; exports.request = rs; exports.sign = Yo; exports.splitPath = jr; exports.standardizeTypeTags = cr; exports.stringStructTag = S; exports.throwTypeMismatch = P; exports.validateNumberInRange = Pe;
|
|
428
|
+
`;async function an(n){let{aptosConfig:t}=n,{data:e}=await V({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function ho(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 To(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 cn(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 bo(n){let{aptosConfig:t,limit:e}=n;return(await y({aptosConfig:t,query:{query:uo,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function y(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:o}=await Mr({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:Hn},originMethod:"getProcessorStatuses"})).processor_status}async function un(n){let t=await ws({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function pn(n){let{aptosConfig:t,processorType:e}=n;return(await y({aptosConfig:t,query:{query:Hn,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var Wn=new Map;function rt(n,t,e){return async(...r)=>{if(Wn.has(t)){let{value:i,timestamp:s}=Wn.get(t);if(e===void 0||Date.now()-s<=e)return i}let o=await n(...r);return Wn.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 So(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 dn(n){return _optionalChain([n, 'access', _37 => _37.options, 'optionalAccess', _38 => _38.ledgerVersion])!==void 0?wo(n):rt(async()=>wo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function wo(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 xo(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 vo(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 jn(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 Xn(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,o=await jn({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:i}}=o,s=u.from(e);try{let a=await cn({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 ce&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Co(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:ao,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 Po(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:io,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 Eo(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:so,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 Io(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:ro,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 Uo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:co,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return i.account_transactions_aggregate.aggregate?i.account_transactions_aggregate.aggregate.count:0}async function Ro(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,o=u.from(e).toStringLong(),i=await Yn({aptosConfig:t,accountAddress:o,options:{where:{asset_type:{_eq:r}}}});return i[0]?i[0].amount:0}async function Yn(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:no,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 zo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),i=await y({aptosConfig:t,query:{query:to,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 No(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()}},s={query:oo,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 Do(n){let{aptosConfig:t,privateKey:e}=n,r=new q(e.publicKey());if(e instanceof qe){let i=K.fromPublicKey({publicKey:r}).derivedAddress();return Ue.fromPrivateKey({privateKey:e,address:i})}if(e instanceof J){let o=K.fromPublicKey({publicKey:r});if(await _o({authKey:o,aptosConfig:t})){let c=o.derivedAddress();return Ue.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=K.fromPublicKey({publicKey:r.publicKey});if(await _o({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Ue.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function _o(n){let{aptosConfig:t,authKey:e}=n,r=await Xn({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 Go(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 gn(n){let{aptosConfig:t}=n;return rt(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 ko(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await V({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function xt(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await V({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Oo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await xt({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 ot(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 ce)||(p=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await xt({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(Ae){b(Ae)}a=(Date.now()-l)/1e3}for(;s&&!(a>=o);){try{if(c=await xt({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 ln(`Fetching transaction ${e} failed and timed out after ${o} seconds`,c);if(c.type==="pending_transaction")throw new ln(`Transaction ${e} timed out in pending state after ${o} seconds`,c);if(!i)return c;if(!c.success)throw new Zn(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function mn(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 un({aptosConfig:t}):s=(await pn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var ln=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Zn=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function T(n){n.minimumLedgerVersion!==void 0&&await mn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var vt=class{constructor(t){this.config=t}async getAccountInfo(t){return le({aptosConfig:this.config,...t})}async getAccountModules(t){return So({aptosConfig:this.config,...t})}async getAccountModule(t){return dn({aptosConfig:this.config,...t})}async getAccountTransactions(t){return xo({aptosConfig:this.config,...t})}async getAccountResources(t){return vo({aptosConfig:this.config,...t})}async getAccountResource(t){return jn({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Xn({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Co({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Po({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Eo({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Io({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Uo({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Yn({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),zo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:Wt,...t})}async getAccountCoinAmount(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ro({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),No({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return Do({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var yn=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 Nr[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 Dr[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 zr[this.network];default:throw Error(`apiType ${t} is not supported`)}}};var An=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 be=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return it.load(t);case 1:return Jn.load(t);case 2:return st.load(t);case 3:return at.load(t);case 4:return ct.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},it= exports.TransactionAuthenticatorEd25519 =class n extends be{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)}},Jn= exports.TransactionAuthenticatorMultiEd25519 =class n extends be{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=Me.deserialize(e);return new n(r,o)}},st= exports.TransactionAuthenticatorMultiAgent =class n extends be{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=Q.deserialize(e),o=e.deserializeVector(u),i=e.deserializeVector(Q);return new n(r,o,i)}},at= exports.TransactionAuthenticatorFeePayer =class n extends be{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=Q.deserialize(e),o=e.deserializeVector(u),i=e.deserializeVector(Q),s=u.deserialize(e),a=Q.deserialize(e),c={address:s,authenticator:a};return new n(r,o,i,c)}},ct= exports.TransactionAuthenticatorSingleSender =class n extends be{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=Q.deserialize(e);return new n(r)}};var ut=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 Ct=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 lt.load(t);case 4:return W.load(t);case 5:return $e.load(t);case 6:return x.load(t);case 7:return g.load(t);case 8:return pt.load(t);case 9:return dt.load(t);case 10:return gt.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 W}isGeneric(){return this instanceof z}isSigner(){return this instanceof $e}isVector(){return this instanceof x}isStruct(){return this instanceof g}isU8(){return this instanceof ge}isU16(){return this instanceof pt}isU32(){return this instanceof dt}isU64(){return this instanceof $}isU128(){return this instanceof lt}isU256(){return this instanceof gt}},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}},pt= exports.TypeTagU16 =class n extends R{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},dt= 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}},lt= exports.TypeTagU128 =class n extends R{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},gt= exports.TypeTagU256 =class n extends R{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},W= exports.TypeTagAddress =class n extends R{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},$e= exports.TypeTagSigner =class n extends R{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},fn= 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=we.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")}},we= 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 Ml(){return new we(u.ONE,new P("aptos_coin"),new P("AptosCoin"),[])}function S(){return new we(u.ONE,new P("string"),new P("String"),[])}function Kl(n){return new we(u.ONE,new P("option"),new P("Option"),[n])}function j(n){return new we(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 Ve=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Pt.load(t);case 2:return Et.load(t);case 3:return It.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Pt= exports.TransactionPayloadScript =class n extends Ve{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=Ut.deserialize(e);return new n(r)}},Et= exports.TransactionPayloadEntryFunction =class n extends Ve{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=Le.deserialize(e);return new n(r)}},It= exports.TransactionPayloadMultiSig =class n extends Ve{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Rt.deserialize(e);return new n(r)}},Le= 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(Ct.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=Ct.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=Jt.deserialize(t,c);s.push(p)}return new n(e,r,o,s)}},Ut= 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)}},Rt= 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=zt.deserialize(t)),new n(e,o)}},zt= 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(Le.deserialize(e))}};var B=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=Ve.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=ut.deserialize(e);return new n(r,o,i,s,a,c,p)}},hn= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return _e.load(t);case 1:return Se.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},_e= exports.MultiAgentRawTransaction =class n extends hn{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=B.deserialize(e),o=e.deserializeVector(u);return new n(r,o)}},Se= exports.FeePayerRawTransaction =class n extends hn{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=B.deserialize(e),o=e.deserializeVector(u),i=u.deserialize(e);return new n(r,o,i)}};var me=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=B.deserialize(e),o=be.deserialize(e);return new n(r,o)}};var Tn=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=B.deserialize(e),o=e.deserializeBool(),i;return o&&(i=u.deserialize(e)),new n(r,i)}};function Bo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Fo(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(!Fo(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 xe(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 Ae=bn(a,o,e);i.push(Ae)}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=bn(a,o,e);o=[],i.push(m),a="",c+=1}}else if(Fo(p)){let m=!1;if(a.length!==0){let b=bn(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 bn(a,o,e);case 1:if(a==="")return i[0];throw new v(n,"unexpected ','");default:throw new v(n,"unexpected whitespace character")}}function bn(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 fn(new $e);case"signer":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new $e;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 W;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 pt;case"u32":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new dt;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 lt;case"u256":if(t.length>0)throw new v(n,"primitive types not expected to have type arguments");return new gt;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(!Bo(r[1]))throw new v(n,"module name must only contain alphanumeric or '_' characters");if(!Bo(r[2]))throw new v(n,"struct name must only contain alphanumeric or '_' characters");return new g(new we(u.fromString(r[0]),new P(r[1]),new P(r[2]),t))}}function Mo(n){return typeof n=="boolean"}function mt(n){return typeof n=="string"}function wn(n){return typeof n=="number"}function _n(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ko(n){return n==null}function qo(n){return er(n)||nr(n)||rr(n)||or(n)||ir(n)||sr(n)||ar(n)||Sn(n)||tr(n)||Es(n)||n instanceof h||n instanceof Ee}function er(n){return n instanceof E}function Sn(n){return n instanceof u}function tr(n){return n instanceof w}function Es(n){return n instanceof Be}function nr(n){return n instanceof G}function rr(n){return n instanceof re}function or(n){return n instanceof oe}function ir(n){return n instanceof D}function sr(n){return n instanceof ie}function ar(n){return n instanceof se}function $o(n){return"bytecode"in n}function C(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Vo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function Nt(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 ur(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _83 => _83.map, 'call', _84 => _84(t=>mt(t)?xe(t):t)]), () => ([]))}async function Lo(n,t,e,r){let o=await dn({aptosConfig:r,accountAddress:n,moduleName:t});if(o.abi)return o.abi.exposed_functions.find(i=>i.name===e)}async function Ho(n,t,e,r){let o=await Lo(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=Vo(o),s=[];for(let a=i;a<o.params.length;a+=1)s.push(xe(o.params[a],{allowGenerics:!0}));return{signers:i,typeParameters:o.generic_type_params,parameters:s}}async function Qo(n,t,e,r){let o=await Lo(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(xe(o.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<o.return.length;a+=1)s.push(xe(o.return[a],{allowGenerics:!0}));return{typeParameters:o.generic_type_params,parameters:i,returnTypes:s}}function pr(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 yt(e,i,r,o)}function yt(n,t,e,r){return qo(n)?(cr(t,n,e),n):Us(n,t,e,r)}function Us(n,t,e,r){if(t.isBool()){if(Mo(n))return new E(n);C("boolean",e)}if(t.isAddress()){if(mt(n))return u.fromString(n);C("string | AccountAddress",e)}if(t.isU8()){if(wn(n))return new G(n);C("number",e)}if(t.isU16()){if(wn(n))return new re(n);C("number",e)}if(t.isU32()){if(wn(n))return new oe(n);C("number",e)}if(t.isU64()){if(_n(n))return new D(BigInt(n));C("bigint | number | string",e)}if(t.isU128()){if(_n(n))return new ie(BigInt(n));C("bigint | number | string",e)}if(t.isU256()){if(_n(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 yt(n,r[o],e,r)}if(t.isVector()){if(t.value.isU8()){if(mt(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=>yt(o,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(mt(n))return new w(n);C("string",e)}if(t.isObject()){if(mt(n))return u.fromString(n);C("string | AccountAddress",e)}if(t.isOption())return Ko(n)?new Ee(null):new Ee(yt(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 cr(n,t,e){if(n.isBool()){if(er(t))return;C("Bool",e)}if(n.isAddress()){if(Sn(t))return;C("AccountAddress",e)}if(n.isU8()){if(nr(t))return;C("U8",e)}if(n.isU16()){if(rr(t))return;C("U16",e)}if(n.isU32()){if(or(t))return;C("U32",e)}if(n.isU64()){if(ir(t))return;C("U64",e)}if(n.isU128()){if(sr(t))return;C("U128",e)}if(n.isU256()){if(ar(t))return;C("U256",e)}if(n.isVector()){if(t instanceof h){t.values.length>0&&cr(n.value,t.values[0],e);return}C("MoveVector",e)}if(n instanceof g){if(n.isString()){if(tr(t))return;C("MoveString",e)}if(n.isObject()){if(Sn(t))return;C("AccountAddress",e)}if(n.isOption()){if(t instanceof Ee){t.value!==void 0&&cr(n.value.typeArgs[0],t.value,e);return}C("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}var xn=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=B.deserialize(e),o=e.deserializeVector(u),i=e.deserializeBool(),s;return i&&(s=u.deserialize(e)),new n(r,o,s)}};async function Cn(n){if($o(n))return Ns(n);let{moduleAddress:t,moduleName:e,functionName:r}=Nt(n.function),o=await ei({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ho});return Rs({...n,abi:o})}function Rs(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=Nt(n.function),i=ur(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)=>pr(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=Le.build(`${e}::${r}`,o,i,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new It(new Rt(c,new zt(a)))}return new Et(a)}async function jo(n){let{moduleAddress:t,moduleName:e,functionName:r}=Nt(n.function),o=await ei({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Qo});return zs({abi:o,...n})}function zs(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:o}=Nt(n.function),i=ur(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)=>pr(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 Le.build(`${e}::${r}`,o,i,s)}function Ns(n){return new Pt(new Ut(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()=>Fn[t.network]?{chainId:Fn[t.network]}:{chainId:(await an({aptosConfig:t})).chain_id},a=async()=>_optionalChain([o, 'optionalAccess', _88 => _88.gasUnitPrice])?{gasEstimate:o.gasUnitPrice}:{gasEstimate:(await gn({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:Ae}={maxGasAmount:_optionalChain([o, 'optionalAccess', _90 => _90.maxGasAmount])?BigInt(o.maxGasAmount):BigInt(2e5),gasUnitPrice:BigInt(m),expireTimestamp:BigInt(Math.floor(Date.now()/1e3)+20),...o};return new B(u.from(e),BigInt(N),r,BigInt(b),BigInt(l),BigInt(Ae),new ut(p))}async function dr(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', _91 => _91.secondarySignerAddresses, 'optionalAccess', _92 => _92.map, 'call', _93 => _93(c=>u.from(c))]), () => ([]));return new xn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new Tn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Xo(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:o}=n,i=vn(t);if(e.feePayerAddress){let a=new Se(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(N=>vn(N)));let p=vn(o),m=new at(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new me(a.raw_txn,m).bcsToBytes()}if(e.secondarySignerAddresses){let a=new _e(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(m=>vn(m));let p=new st(i,e.secondarySignerAddresses,c);return new me(a.raw_txn,p).bcsToBytes()}let s;if(i instanceof de)s=new it(i.public_key,i.signature);else if(i instanceof ae)s=new ct(i);else throw new Error("Invalid public key");return new me(e.rawTransaction,s).bcsToBytes()}function vn(n){if(n instanceof q){if(n.publicKey instanceof I)return new ae(n,new O(new U(new Uint8Array(64))));if(n.publicKey instanceof he)return new ae(n,new O(new Te(new Uint8Array(64))))}return new de(new I(n.toUint8Array()),new U(new Uint8Array(64)))}function Yo(n){let{signer:t,transaction:e}=n,r=gr(e);return t.signWithAuthenticator(r)}function lr(n){let{transaction:t,senderAuthenticator:e,feePayerAuthenticator:r,additionalSignersAuthenticators:o}=n,i=Jo(t);if((r||o)&&(i instanceof _e||i instanceof Se))return ks(i,e,r,o);if(e instanceof de&&i instanceof B){let s=new it(e.public_key,e.signature);return new me(i,s).bcsToBytes()}if((e instanceof ae||e instanceof Je)&&i instanceof B){let s=new ct(e);return new me(i,s).bcsToBytes()}throw new Error(`Cannot generate a signed transaction, ${e} is not a supported account authentication scheme`)}function Zo(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Gs=Zo(["APTOS::Transaction"]);function fm(n){let t=lr(n);return new f(Zo([Gs,new Uint8Array([0]),t])).toString()}function Jo(n){return n.feePayerAddress?new Se(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new _e(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function ks(n,t,e,r){if(n instanceof Se){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");let o=new at(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])),{address:n.fee_payer_address,authenticator:e});return new me(n.raw_txn,o).bcsToBytes()}if(n instanceof _e){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");let o=new st(t,n.secondary_signer_addresses,_nullishCoalesce(r, () => ([])));return new me(n.raw_txn,o).bcsToBytes()}throw new Error(`Cannot prepare multi signers transaction to submission, ${typeof n} transaction is not supported`)}function gr(n){let t=Jo(n),e=_sha3.sha3_256.create();if(t instanceof B)e.update(Or);else if(t instanceof _e)e.update(Mn);else if(t instanceof Se)e.update(Mn);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:rt(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 Cn(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},o=await Cn(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},o=await Cn(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 dr({aptosConfig:e,sender:r,payload:t,options:o,secondarySignerAddresses:s,feePayerAddress:i})}return dr({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 gr(t)}function Pn(n){return Yo({...n})}async function mr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:o,feePayerPublicKey:i,options:s}=n,a=Xo({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', _94 => _94.options, 'optionalAccess', _95 => _95.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _96 => _96.options, 'optionalAccess', _97 => _97.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.options, 'optionalAccess', _99 => _99.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function En(n){let{aptosConfig:t}=n,e=lr({...n}),{data:r}=await Ge({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function Dt(n){let{aptosConfig:t,signer:e,transaction:r}=n,o=Pn({signer:e,transaction:r});return En({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=Ue.fromPrivateKey({privateKey:r,legacy:!0}),a=new An({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 Dt({aptosConfig:t,signer:e,transaction:m})}var $s={typeParameters:[{constraints:[]}],parameters:[new W,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, () => (Wt))],functionArguments:[r,o],abi:$s},options:s})}var Gt=class{constructor(t){this.config=t}async transferCoinTransaction(t){return oi({aptosConfig:this.config,...t})}};var Re={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:fo,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:Qn,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:Qn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _100 => _100.offset]),limit:_optionalChain([r, 'optionalAccess', _101 => _101.limit]),order_by:_optionalChain([r, 'optionalAccess', _102 => _102.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:Ao,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _103 => _103.offset]),limit:_optionalChain([r, 'optionalAccess', _104 => _104.limit]),order_by:_optionalChain([r, 'optionalAccess', _105 => _105.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, () => (ke))),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 yr(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', _106 => _106.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([o, 'optionalAccess', _107 => _107.tokenStandard]), () => ("v2"))}),(await y({aptosConfig:t,query:{query:Vn,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:Vn,variables:{where_condition:o}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function di(n){return(await yr(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', _108 => _108.map, 'call', _109 => _109(b=>Re[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(j(new z(0))),new W]};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 W]};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', _110 => _110.length])!==_optionalChain([m, 'optionalAccess', _111 => _111.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _112 => _112.length])!==_optionalChain([m, 'optionalAccess', _113 => _113.length]))throw new Error("Property types and property values counts do not match");let b=_optionalChain([p, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(l=>Re[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(j(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(j(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(j(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(j(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(j(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(j(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(j(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(Re[o]),h.U8(Ar(i,Re[o]))],abi:ea},options:c})}var ta={typeParameters:[{constraints:["key"]}],parameters:[new g(j(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(j(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(Re[o]),Ar(i,Re[o])],abi:na},options:c})}var ra={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new g(j(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)),Re[o]],functionArguments:[u.from(s),new w(r),i],abi:ra},options:c})}var oa={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new g(j(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)),Re[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(Ar(n[o],r))}),e}function Ar(n,t){let e=xe(t);return yt(n,e,0,[]).bcsToBytes()}var kt=class{constructor(t){this.config=t}async getCollectionData(t){return await T({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),yr({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', _116 => _116.orderBy])};return Ot({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', _117 => _117.orderBy])};return Ot({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', _118 => _118.orderBy])};return Ot({aptosConfig:e,options:a})}async function Ot(n){let{aptosConfig:t,options:e}=n;ia(_optionalChain([e, 'optionalAccess', _119 => _119.where, 'optionalAccess', _120 => _120.indexed_type, 'optionalAccess', _121 => _121._eq]));let r={query:go,variables:{where_condition:_optionalChain([e, 'optionalAccess', _122 => _122.where]),offset:_optionalChain([e, 'optionalAccess', _123 => _123.offset]),limit:_optionalChain([e, 'optionalAccess', _124 => _124.limit]),order_by:_optionalChain([e, 'optionalAccess', _125 => _125.orderBy])}};return(await y({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var Bt=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', _126 => _126.minimumLedgerVersion]),processorType:"events_processor"}),Ot({aptosConfig:this.config,...t})}};async function Ri(n){let{aptosConfig:t,accountAddress:e,amount:r,options:o}=n,i=_optionalChain([o, 'optionalAccess', _127 => _127.timeoutSecs])||20,{data:s}=await Kr({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await ot({aptosConfig:t,transactionHash:a,options:{timeoutSecs:i,checkSuccess:_optionalChain([o, 'optionalAccess', _128 => _128.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Ft=class{constructor(t){this.config=t}async fundAccount(t){let e=await Ri({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _129 => _129.options, 'optionalAccess', _130 => _130.waitForIndexer])!==!1&&await mn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function fr(n){let{aptosConfig:t,options:e}=n,r={query:yo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _131 => _131.where]),limit:_optionalChain([e, 'optionalAccess', _132 => _132.limit]),offset:_optionalChain([e, 'optionalAccess', _133 => _133.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:mo,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 y({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ni(n){let{aptosConfig:t,options:e}=n,r={query:po,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 y({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var sa={typeParameters:[],parameters:[xe("0x1::object::Object"),new W,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 Mt=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _140 => _140.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),fr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _141 => _141.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await fr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _142 => _142.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),zi({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _143 => _143.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ni({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return Di({aptosConfig:this.config,...t})}};async function ze(n){let{aptosConfig:t,payload:e,options:r}=n,o=await jo({...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', _144 => _144.ledgerVersion])},body:s});return a}var Kt=class{constructor(t){this.config=t}async getLedgerInfo(){return an({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return ho({aptosConfig:this.config,...t})}async getBlockByHeight(t){return To({aptosConfig:this.config,...t})}async getTableItem(t){return cn({aptosConfig:this.config,...t})}async view(t){return ze({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return bo({aptosConfig:this.config,...t})}async queryIndexer(t){return y({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return un({aptosConfig:this.config})}async getProcessorStatus(t){return pn({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 Ne(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 ve(n){let t=ca[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var In=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=ve(t),{domainName:o,subdomainName:i}=Ne(e),s=await ze({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[o,i]}}),a=In(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=ve(t),{domainName:m,subdomainName:N}=Ne(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 Gn=_nullishCoalesce(e.years, () => (1));if(Gn!==1)throw new Error("For now, names can only be registered for 1 year at a time");let es=Gn*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 hr({aptosConfig:t,name:m});if(!l)throw new Error("The domain does not exist");let Ae=e.policy==="subdomain:independent"?e.expirationDate:l;if(Ae>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(Ae/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,i,s]},options:a})}async function hr(n){let{aptosConfig:t,name:e}=n,r=ve(t),{domainName:o,subdomainName:i}=Ne(e);try{let s=await ze({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=ve(t),o=await ze({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),i=In(o[1]),s=In(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=ve(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}=Ne(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=ve(t),{domainName:o,subdomainName:i}=Ne(e),s=await ze({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[o,i]}}),a=In(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=ve(t),{domainName:a,subdomainName:c}=Ne(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=""}=Ne(e),a=(await y({aptosConfig:t,query:{query:nt,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:o},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=qt(a)),a}async function Vi(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await Tr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountNames",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _145 => _145.limit]),offset:_optionalChain([e, 'optionalAccess', _146 => _146.offset]),order_by:_optionalChain([e, 'optionalAccess', _147 => _147.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _148 => _148.options, 'optionalAccess', _149 => _149.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o}}}}})).current_aptos_names.map(qt)}async function Li(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await Tr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountDomains",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _150 => _150.limit]),offset:_optionalChain([e, 'optionalAccess', _151 => _151.offset]),order_by:_optionalChain([e, 'optionalAccess', _152 => _152.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _153 => _153.options, 'optionalAccess', _154 => _154.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_eq:""}}}}})).current_aptos_names.map(qt)}async function Hi(n){let{aptosConfig:t,options:e,accountAddress:r}=n,o=await Tr({aptosConfig:t});return(await y({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _155 => _155.limit]),offset:_optionalChain([e, 'optionalAccess', _156 => _156.offset]),order_by:_optionalChain([e, 'optionalAccess', _157 => _157.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _158 => _158.options, 'optionalAccess', _159 => _159.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:o},subdomain:{_neq:""}}}}})).current_aptos_names.map(qt)}async function Qi(n){let{aptosConfig:t,options:e,domain:r}=n;return(await y({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:nt,variables:{limit:_optionalChain([e, 'optionalAccess', _160 => _160.limit]),offset:_optionalChain([e, 'optionalAccess', _161 => _161.offset]),order_by:_optionalChain([e, 'optionalAccess', _162 => _162.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _163 => _163.options, 'optionalAccess', _164 => _164.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(qt)}async function Tr(n){let{aptosConfig:t}=n,e=ve(t),[r]=await ze({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=ve(t),a=o*31536e3,{domainName:c,subdomainName:p}=Ne(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 qt(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var $t=class{constructor(t){this.config=t}async getOwnerAddress(t){return Oi({aptosConfig:this.config,...t})}async getExpiration(t){return hr({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:Ln,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:Ln,variables:{order_by:_optionalChain([e, 'optionalAccess', _165 => _165.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:lo,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await y({aptosConfig:t,query:o})).delegated_staking_activities}var Vt=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _166 => _166.minimumLedgerVersion]),processorType:"stake_processor"}),ji({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _167 => _167.minimumLedgerVersion]),processorType:"stake_processor"}),Xi({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await T({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _168 => _168.minimumLedgerVersion]),processorType:"stake_processor"}),Yi({aptosConfig:this.config,...t})}};var Un=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 br(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 wr(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 At=class{constructor(t){this.config=t}async simple(t){return mr({aptosConfig:this.config,...t})}async multiAgent(t){return mr({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 ft=class{constructor(t){this.config=t}async simple(t){return En({aptosConfig:this.config,...t})}async multiAgent(t){return En({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [br],ft.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [br],ft.prototype,"multiAgent",1);var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Rn=()=>Math.floor(Date.now()/1e3),zn= 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=Rn();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),Rn()-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=Rn();for(;this.lastUncommintedNumber!==this.currentNumber;)Rn()-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 ht=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _169 => _169.pendingDequeue, 'access', _170 => _170.shift, 'call', _171 => _171(), 'optionalAccess', _172 => _172.resolve, 'call', _173 => _173(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 Tt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Tt=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||{}),Nn= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,o=30,i=100,s=10){super();this.taskQueue=new ht;this.transactionsQueue=new ht;this.outstandingTransactions=new ht;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new zn(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=Dt({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([o,e])}}catch(e){if(e instanceof Tt)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 Tt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let o=[];o.push(ot({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 Dn=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new Nn(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 Lt=class{constructor(t){this.config=t,this.build=new Un(this.config),this.simulate=new At(this.config),this.submit=new ft(this.config),this.batch=new Dn(this.config)}async getTransactions(t){return Go({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return ko({aptosConfig:this.config,...t})}async getTransactionByHash(t){return xt({aptosConfig:this.config,...t})}async isPendingTransaction(t){return Oo({aptosConfig:this.config,...t})}async waitForTransaction(t){return ot({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return gn({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 Pn({...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,Pn({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 Dt({aptosConfig:this.config,signer:e,transaction:r})}};var ne=class{constructor(t){this.config=new yn(t),this.account=new vt(this.config),this.ans=new $t(this.config),this.coin=new Gt(this.config),this.digitalAsset=new kt(this.config),this.event=new Bt(this.config),this.faucet=new Ft(this.config),this.fungibleAsset=new Mt(this.config),this.general=new Kt(this.config),this.staking=new Vt(this.config),this.transaction=new Lt(this.config)}};function ye(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))})}ye(ne,vt,"account");ye(ne,$t,"ans");ye(ne,Gt,"coin");ye(ne,kt,"digitalAsset");ye(ne,Bt,"event");ye(ne,Ft,"faucet");ye(ne,Mt,"fungibleAsset");ye(ne,Kt,"general");ye(ne,Vt,"staking");ye(ne,Lt,"transaction");exports.APTOS_BIP44_REGEX = ms; exports.APTOS_COIN = Wt; exports.APTOS_HARDENED_REGEX = gs; exports.Account = Ue; exports.AccountAddress = u; exports.AccountAuthenticator = Q; exports.AccountAuthenticatorEd25519 = de; exports.AccountAuthenticatorMultiEd25519 = on; exports.AccountAuthenticatorMultiKey = Je; exports.AccountAuthenticatorSingleKey = ae; exports.AccountAuthenticatorVariant = Pr; exports.AccountPublicKey = ue; exports.AccountSequenceNumber = zn; exports.AddressInvalidReason = us; exports.AnyPublicKey = q; exports.AnyPublicKeyVariant = Er; exports.AnySignature = O; exports.AnySignatureVariant = Ir; exports.Aptos = ne; exports.AptosApiError = ce; exports.AptosApiType = wt; exports.AptosConfig = yn; exports.AuthenticationKey = K; exports.Bool = E; exports.CKDPriv = Wr; exports.ChainId = ut; exports.DEFAULT_MAX_GAS_AMOUNT = Gr; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = kr; exports.DEFAULT_TXN_TIMEOUT_SEC = Qt; exports.DeriveScheme = Rr; exports.Deserializer = $r; exports.Ed25519Account = et; exports.Ed25519PrivateKey = J; exports.Ed25519PublicKey = I; exports.Ed25519Signature = U; exports.EntryFunction = Le; exports.EntryFunctionBytes = Jt; exports.FeePayerRawTransaction = Se; exports.FixedBytes = Be; exports.HARDENED_OFFSET = Lr; exports.Hex = f; exports.HexInvalidReason = ss; exports.Identifier = P; exports.KeyType = ys; exports.MimeType = Ht; exports.ModuleId = Ct; exports.MoveAbility = Ur; exports.MoveFunctionVisibility = ts; exports.MoveOption = Ee; exports.MoveString = w; exports.MoveVector = h; exports.MultiAgentRawTransaction = _e; exports.MultiEd25519PublicKey = Ye; exports.MultiEd25519Signature = Me; exports.MultiKey = rn; exports.MultiKeySignature = Jr; exports.MultiSig = Rt; exports.MultiSigTransactionPayload = zt; exports.Network = Bn; exports.NetworkToChainId = Fn; exports.NetworkToFaucetAPI = Dr; exports.NetworkToIndexerAPI = zr; exports.NetworkToNetworkName = Ea; exports.NetworkToNodeAPI = Nr; exports.ParsingError = M; exports.ProcessorType = Qe; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Or; exports.RAW_TRANSACTION_WITH_DATA_SALT = Mn; exports.RawTransaction = B; exports.RawTransactionWithData = hn; exports.RoleType = ns; exports.RotationProofChallenge = An; exports.Script = Ut; exports.ScriptTransactionArgumentVariants = bt; exports.Secp256k1PrivateKey = qe; exports.Secp256k1PublicKey = he; exports.Secp256k1Signature = Te; exports.Serializable = d; exports.Serializer = X; exports.Signature = Y; exports.SignedTransaction = me; exports.SigningScheme = De; exports.SigningSchemeInput = On; exports.SimpleTransaction = Tn; exports.SingleKeyAccount = tt; exports.StructTag = we; exports.TransactionAuthenticator = be; exports.TransactionAuthenticatorEd25519 = it; exports.TransactionAuthenticatorFeePayer = at; exports.TransactionAuthenticatorMultiAgent = st; exports.TransactionAuthenticatorMultiEd25519 = Jn; exports.TransactionAuthenticatorSingleSender = ct; exports.TransactionAuthenticatorVariant = Cr; exports.TransactionPayload = Ve; exports.TransactionPayloadEntryFunction = Et; exports.TransactionPayloadMultiSig = It; exports.TransactionPayloadScript = Pt; exports.TransactionPayloadVariants = xr; exports.TransactionResponseType = kn; exports.TransactionVariants = vr; exports.TransactionWorker = Nn; exports.TransactionWorkerEventsEnum = Ji; exports.TypeTag = R; exports.TypeTagAddress = W; exports.TypeTagBool = k; exports.TypeTagGeneric = z; exports.TypeTagParserError = v; exports.TypeTagParserErrorType = Ps; exports.TypeTagReference = fn; exports.TypeTagSigner = $e; exports.TypeTagStruct = g; exports.TypeTagU128 = lt; exports.TypeTagU16 = pt; exports.TypeTagU256 = gt; exports.TypeTagU32 = dt; exports.TypeTagU64 = $; exports.TypeTagU8 = ge; exports.TypeTagVariants = Sr; exports.TypeTagVector = x; exports.U128 = ie; exports.U16 = re; exports.U256 = se; exports.U32 = oe; exports.U64 = D; exports.U8 = G; exports.aptosCoinStructTag = Ml; exports.aptosRequest = jt; exports.buildTransaction = dr; exports.checkOrConvertArgument = yt; exports.convertArgument = pr; exports.createObjectAddress = hs; exports.createResourceAddress = cd; exports.createTokenAddress = ud; exports.deriveKey = $n; exports.deriveTransactionType = Jo; exports.deserializeFromScriptArgument = xs; exports.ensureBoolean = qn; exports.fetchEntryFunctionAbi = Ho; exports.fetchFunctionAbi = Lo; exports.fetchViewFunctionAbi = Qo; exports.findFirstNonSignerArg = Vo; exports.generateMultiSignersSignedTransaction = ks; exports.generateRawTransaction = Ds; exports.generateSignedTransaction = lr; exports.generateSignedTransactionForSimulation = Xo; exports.generateSigningMessage = gr; exports.generateTransactionPayload = Cn; exports.generateTransactionPayloadWithABI = Rs; exports.generateUserTransactionHash = fm; exports.generateViewFunctionPayload = jo; exports.generateViewFunctionPayloadWithABI = zs; exports.get = Fr; exports.getAptosFullNode = V; exports.getAuthenticatorForSimulation = vn; exports.getFunctionParts = Nt; exports.hashValues = Zo; exports.isBcsAddress = Sn; exports.isBcsBool = er; exports.isBcsFixedBytes = Es; exports.isBcsString = tr; exports.isBcsU128 = sr; exports.isBcsU16 = rr; exports.isBcsU256 = ar; exports.isBcsU32 = or; exports.isBcsU64 = ir; exports.isBcsU8 = nr; exports.isBlockMetadataTransactionResponse = ha; exports.isBool = Mo; exports.isEd25519Signature = wa; exports.isEncodedEntryFunctionArgument = qo; exports.isFeePayerSignature = xa; exports.isGenesisTransactionResponse = fa; exports.isLargeNumber = _n; exports.isMultiAgentSignature = Sa; exports.isMultiEd25519Signature = va; exports.isNull = Ko; exports.isNumber = wn; exports.isPendingTransactionResponse = ya; exports.isScriptDataInput = $o; exports.isSecp256k1Signature = _a; exports.isStateCheckpointTransactionResponse = Ta; exports.isString = mt; exports.isUserTransactionResponse = Aa; exports.isValidBIP44Path = Hr; exports.isValidHardenedPath = Qr; exports.isValidatorTransactionResponse = ba; exports.mnemonicToSeed = en; exports.objectStructTag = j; exports.optionStructTag = Kl; exports.outOfRangeErrorMessage = as; exports.paginateWithCursor = We; exports.parseTypeTag = xe; exports.post = Kn; exports.postAptosFaucet = Kr; exports.postAptosFullNode = Ge; exports.postAptosIndexer = Mr; exports.promiseFulfilledStatus = Zi; exports.request = rs; exports.sign = Yo; exports.splitPath = jr; exports.standardizeTypeTags = ur; exports.stringStructTag = S; exports.throwTypeMismatch = C; exports.validateNumberInRange = Pe;
|
|
429
429
|
//# sourceMappingURL=index.js.map
|