@aptos-labs/ts-sdk 1.28.0-zeta.1 → 1.28.0-zeta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/index.js +1 -1
- package/dist/common/index.js.map +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccountCommon.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.mjs +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/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.mjs +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/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-5HWJ3SN4.mjs → chunk-2XLMOIBB.mjs} +2 -2
- package/dist/esm/{chunk-NGIPNL7N.mjs → chunk-3PJXUJEB.mjs} +2 -2
- package/dist/esm/{chunk-KBIYKNM2.mjs → chunk-4GOLPPK3.mjs} +2 -2
- package/dist/esm/{chunk-ELPTV7ZG.mjs → chunk-4JMLZZFL.mjs} +2 -2
- package/dist/esm/{chunk-2MDJ763P.mjs → chunk-4SEHAXB2.mjs} +2 -2
- package/dist/esm/{chunk-YNLAYIFQ.mjs → chunk-4UB6MXQH.mjs} +2 -2
- package/dist/esm/{chunk-7BPKOPP7.mjs → chunk-56KUTRUI.mjs} +2 -2
- package/dist/esm/{chunk-SVO6PVAX.mjs → chunk-57VN4QFR.mjs} +2 -2
- package/dist/esm/{chunk-ZASN3QQQ.mjs → chunk-5F3DMDZI.mjs} +2 -2
- package/dist/esm/{chunk-KSOKGREZ.mjs → chunk-64HK4IEO.mjs} +2 -2
- package/dist/esm/{chunk-4I6IUAHQ.mjs → chunk-6BXB4PLA.mjs} +2 -2
- package/dist/esm/{chunk-QTTDBQAJ.mjs → chunk-76QOH2OW.mjs} +2 -2
- package/dist/esm/{chunk-YACGA3YS.mjs → chunk-7DDP75LL.mjs} +2 -2
- package/dist/esm/{chunk-BC5BEOKM.mjs → chunk-ADPKXACB.mjs} +2 -2
- package/dist/esm/{chunk-PEYLPXU6.mjs → chunk-CRTGCAMB.mjs} +2 -2
- package/dist/esm/{chunk-4QVGK2KD.mjs → chunk-CSK46KWT.mjs} +2 -2
- package/dist/esm/{chunk-PBMXWRZG.mjs → chunk-D2JMUPS3.mjs} +2 -2
- package/dist/esm/{chunk-CSNIVFPZ.mjs → chunk-D7W3LMWB.mjs} +2 -2
- package/dist/esm/{chunk-SYKVA363.mjs → chunk-E2I4A5FG.mjs} +2 -2
- package/dist/esm/{chunk-YSVXROOO.mjs → chunk-FIYHMSA6.mjs} +2 -2
- package/dist/esm/{chunk-E5LYYWAS.mjs → chunk-FR6MEI36.mjs} +2 -2
- package/dist/esm/{chunk-7T5CUI2H.mjs → chunk-G76BSSWS.mjs} +2 -2
- package/dist/esm/{chunk-K7ZPRL7C.mjs → chunk-GVAZZ3UZ.mjs} +2 -2
- package/dist/esm/{chunk-5RNKD3GW.mjs → chunk-I7CSJMDX.mjs} +2 -2
- package/dist/esm/{chunk-ADLWXCGV.mjs → chunk-IBAA7T35.mjs} +2 -2
- package/dist/esm/{chunk-CBRVPQV6.mjs → chunk-ILVZ3RHG.mjs} +2 -2
- package/dist/esm/{chunk-MZB3J6CV.mjs → chunk-ILZVHKJZ.mjs} +2 -2
- package/dist/esm/{chunk-YBZI6U43.mjs → chunk-L2EW7RS5.mjs} +2 -2
- package/dist/esm/{chunk-LY7ZRAJT.mjs → chunk-LOLHWM3E.mjs} +2 -2
- package/dist/esm/{chunk-W2KQ2TSH.mjs → chunk-LTNQQKPC.mjs} +2 -2
- package/dist/esm/{chunk-ZAHUEAGT.mjs → chunk-MCZIV5GR.mjs} +2 -2
- package/dist/esm/{chunk-ND23H3AK.mjs → chunk-MJPZBN4E.mjs} +2 -2
- package/dist/esm/{chunk-MYRN7MDF.mjs → chunk-MNT6KBEF.mjs} +2 -2
- package/dist/esm/{chunk-QIOBANW2.mjs → chunk-NK2VQHI7.mjs} +2 -2
- package/dist/esm/{chunk-QQGCMXIV.mjs → chunk-QCUNTB7G.mjs} +2 -2
- package/dist/esm/{chunk-3XX3675G.mjs → chunk-QEPPCEFH.mjs} +2 -2
- package/dist/esm/{chunk-GKRIMGKW.mjs → chunk-QRI5UKKN.mjs} +2 -2
- package/dist/esm/{chunk-ASQIKTEF.mjs → chunk-R5QDWL5W.mjs} +2 -2
- package/dist/esm/chunk-RAKS5RSI.mjs +2 -0
- package/dist/esm/chunk-RAKS5RSI.mjs.map +1 -0
- package/dist/esm/{chunk-VVWBJKEA.mjs → chunk-SH6IO5EV.mjs} +2 -2
- package/dist/esm/{chunk-E2WOZVJX.mjs → chunk-SINSCI7V.mjs} +2 -2
- package/dist/esm/{chunk-U72MLMGP.mjs → chunk-SRZWWYZP.mjs} +2 -2
- package/dist/esm/{chunk-6LC7ZJEI.mjs → chunk-TLITK5YF.mjs} +2 -2
- package/dist/esm/{chunk-NOVJ2ROD.mjs → chunk-TZWHQEAZ.mjs} +2 -2
- package/dist/esm/{chunk-P4FYT4LC.mjs → chunk-UF25MR3N.mjs} +2 -2
- package/dist/esm/{chunk-BQPQLOIW.mjs → chunk-US5DBLWO.mjs} +2 -2
- package/dist/esm/{chunk-2Z6HETKH.mjs → chunk-UZUVHKIB.mjs} +2 -2
- package/dist/esm/{chunk-B2RQPJYZ.mjs → chunk-VGBIPXYG.mjs} +2 -2
- package/dist/esm/{chunk-OOVNFKA6.mjs → chunk-VXG7T3TR.mjs} +2 -2
- package/dist/esm/{chunk-FDD6WNN6.mjs → chunk-XFG6LGA6.mjs} +2 -2
- package/dist/esm/{chunk-DYMN66K5.mjs → chunk-YKWRPFAN.mjs} +2 -2
- package/dist/esm/{chunk-UYYQZDVB.mjs → chunk-YRDU2QH5.mjs} +2 -2
- package/dist/esm/{chunk-FDTLBR6D.mjs → chunk-ZOEZVSPX.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/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.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/proof.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.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.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- 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/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/signingMessage.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/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/package.json +1 -1
- package/src/internal/keyless.ts +1 -1
- package/dist/esm/chunk-MSK4O4KB.mjs +0 -2
- package/dist/esm/chunk-MSK4O4KB.mjs.map +0 -1
- /package/dist/esm/{chunk-5HWJ3SN4.mjs.map → chunk-2XLMOIBB.mjs.map} +0 -0
- /package/dist/esm/{chunk-NGIPNL7N.mjs.map → chunk-3PJXUJEB.mjs.map} +0 -0
- /package/dist/esm/{chunk-KBIYKNM2.mjs.map → chunk-4GOLPPK3.mjs.map} +0 -0
- /package/dist/esm/{chunk-ELPTV7ZG.mjs.map → chunk-4JMLZZFL.mjs.map} +0 -0
- /package/dist/esm/{chunk-2MDJ763P.mjs.map → chunk-4SEHAXB2.mjs.map} +0 -0
- /package/dist/esm/{chunk-YNLAYIFQ.mjs.map → chunk-4UB6MXQH.mjs.map} +0 -0
- /package/dist/esm/{chunk-7BPKOPP7.mjs.map → chunk-56KUTRUI.mjs.map} +0 -0
- /package/dist/esm/{chunk-SVO6PVAX.mjs.map → chunk-57VN4QFR.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZASN3QQQ.mjs.map → chunk-5F3DMDZI.mjs.map} +0 -0
- /package/dist/esm/{chunk-KSOKGREZ.mjs.map → chunk-64HK4IEO.mjs.map} +0 -0
- /package/dist/esm/{chunk-4I6IUAHQ.mjs.map → chunk-6BXB4PLA.mjs.map} +0 -0
- /package/dist/esm/{chunk-QTTDBQAJ.mjs.map → chunk-76QOH2OW.mjs.map} +0 -0
- /package/dist/esm/{chunk-YACGA3YS.mjs.map → chunk-7DDP75LL.mjs.map} +0 -0
- /package/dist/esm/{chunk-BC5BEOKM.mjs.map → chunk-ADPKXACB.mjs.map} +0 -0
- /package/dist/esm/{chunk-PEYLPXU6.mjs.map → chunk-CRTGCAMB.mjs.map} +0 -0
- /package/dist/esm/{chunk-4QVGK2KD.mjs.map → chunk-CSK46KWT.mjs.map} +0 -0
- /package/dist/esm/{chunk-PBMXWRZG.mjs.map → chunk-D2JMUPS3.mjs.map} +0 -0
- /package/dist/esm/{chunk-CSNIVFPZ.mjs.map → chunk-D7W3LMWB.mjs.map} +0 -0
- /package/dist/esm/{chunk-SYKVA363.mjs.map → chunk-E2I4A5FG.mjs.map} +0 -0
- /package/dist/esm/{chunk-YSVXROOO.mjs.map → chunk-FIYHMSA6.mjs.map} +0 -0
- /package/dist/esm/{chunk-E5LYYWAS.mjs.map → chunk-FR6MEI36.mjs.map} +0 -0
- /package/dist/esm/{chunk-7T5CUI2H.mjs.map → chunk-G76BSSWS.mjs.map} +0 -0
- /package/dist/esm/{chunk-K7ZPRL7C.mjs.map → chunk-GVAZZ3UZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-5RNKD3GW.mjs.map → chunk-I7CSJMDX.mjs.map} +0 -0
- /package/dist/esm/{chunk-ADLWXCGV.mjs.map → chunk-IBAA7T35.mjs.map} +0 -0
- /package/dist/esm/{chunk-CBRVPQV6.mjs.map → chunk-ILVZ3RHG.mjs.map} +0 -0
- /package/dist/esm/{chunk-MZB3J6CV.mjs.map → chunk-ILZVHKJZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-YBZI6U43.mjs.map → chunk-L2EW7RS5.mjs.map} +0 -0
- /package/dist/esm/{chunk-LY7ZRAJT.mjs.map → chunk-LOLHWM3E.mjs.map} +0 -0
- /package/dist/esm/{chunk-W2KQ2TSH.mjs.map → chunk-LTNQQKPC.mjs.map} +0 -0
- /package/dist/esm/{chunk-ZAHUEAGT.mjs.map → chunk-MCZIV5GR.mjs.map} +0 -0
- /package/dist/esm/{chunk-ND23H3AK.mjs.map → chunk-MJPZBN4E.mjs.map} +0 -0
- /package/dist/esm/{chunk-MYRN7MDF.mjs.map → chunk-MNT6KBEF.mjs.map} +0 -0
- /package/dist/esm/{chunk-QIOBANW2.mjs.map → chunk-NK2VQHI7.mjs.map} +0 -0
- /package/dist/esm/{chunk-QQGCMXIV.mjs.map → chunk-QCUNTB7G.mjs.map} +0 -0
- /package/dist/esm/{chunk-3XX3675G.mjs.map → chunk-QEPPCEFH.mjs.map} +0 -0
- /package/dist/esm/{chunk-GKRIMGKW.mjs.map → chunk-QRI5UKKN.mjs.map} +0 -0
- /package/dist/esm/{chunk-ASQIKTEF.mjs.map → chunk-R5QDWL5W.mjs.map} +0 -0
- /package/dist/esm/{chunk-VVWBJKEA.mjs.map → chunk-SH6IO5EV.mjs.map} +0 -0
- /package/dist/esm/{chunk-E2WOZVJX.mjs.map → chunk-SINSCI7V.mjs.map} +0 -0
- /package/dist/esm/{chunk-U72MLMGP.mjs.map → chunk-SRZWWYZP.mjs.map} +0 -0
- /package/dist/esm/{chunk-6LC7ZJEI.mjs.map → chunk-TLITK5YF.mjs.map} +0 -0
- /package/dist/esm/{chunk-NOVJ2ROD.mjs.map → chunk-TZWHQEAZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-P4FYT4LC.mjs.map → chunk-UF25MR3N.mjs.map} +0 -0
- /package/dist/esm/{chunk-BQPQLOIW.mjs.map → chunk-US5DBLWO.mjs.map} +0 -0
- /package/dist/esm/{chunk-2Z6HETKH.mjs.map → chunk-UZUVHKIB.mjs.map} +0 -0
- /package/dist/esm/{chunk-B2RQPJYZ.mjs.map → chunk-VGBIPXYG.mjs.map} +0 -0
- /package/dist/esm/{chunk-OOVNFKA6.mjs.map → chunk-VXG7T3TR.mjs.map} +0 -0
- /package/dist/esm/{chunk-FDD6WNN6.mjs.map → chunk-XFG6LGA6.mjs.map} +0 -0
- /package/dist/esm/{chunk-DYMN66K5.mjs.map → chunk-YKWRPFAN.mjs.map} +0 -0
- /package/dist/esm/{chunk-UYYQZDVB.mjs.map → chunk-YRDU2QH5.mjs.map} +0 -0
- /package/dist/esm/{chunk-FDTLBR6D.mjs.map → chunk-ZOEZVSPX.mjs.map} +0 -0
package/dist/common/index.js
CHANGED
|
@@ -469,5 +469,5 @@
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
`;async function Xn(n){let{aptosConfig:t}=n,{data:e}=await H({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function So(n){let{aptosConfig:t,limit:e}=n;return(await f({aptosConfig:t,query:{query:po,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:i}=await Xi({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return i}async function fc(n){let{aptosConfig:t}=n;return(await f({aptosConfig:t,query:{query:Hr},originMethod:"getProcessorStatuses"})).processor_status}async function Zn(n){let t=await fc({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function Yn(n){let{aptosConfig:t,processorType:e}=n;return(await f({aptosConfig:t,query:{query:Hr,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Jn(n){let{aptosConfig:t,handle:e,data:r,options:i}=n;return(await Ne({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _54 => _54.ledgerVersion])},body:r})).data}async function xo(n){let{aptosConfig:t,options:e}=n,r={query:ho,variables:{where_condition:_optionalChain([e, 'optionalAccess', _55 => _55.where]),offset:_optionalChain([e, 'optionalAccess', _56 => _56.offset]),limit:_optionalChain([e, 'optionalAccess', _57 => _57.limit]),order_by:_optionalChain([e, 'optionalAccess', _58 => _58.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getTableItemsData"})).table_items}async function _o(n){let{aptosConfig:t,options:e}=n,r={query:bo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _59 => _59.where]),offset:_optionalChain([e, 'optionalAccess', _60 => _60.offset]),limit:_optionalChain([e, 'optionalAccess', _61 => _61.limit]),order_by:_optionalChain([e, 'optionalAccess', _62 => _62.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function xe(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await H({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function Co(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return St({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _63 => _63.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _64 => _64.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _65 => _65.limit]), () => (1e3))}})}async function er(n){return _optionalChain([n, 'access', _66 => _66.options, 'optionalAccess', _67 => _67.ledgerVersion])!==void 0?Po(n):Oe(async()=>Po(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function Po(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:i}=n,{data:o}=await H({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _68 => _68.ledgerVersion])}});return o}async function Eo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return St({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([r, 'optionalAccess', _70 => _70.limit])}})}async function Io(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return St({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _71 => _71.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _72 => _72.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _73 => _73.limit]), () => (999))}})}async function Wr(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:i}=n,{data:o}=await H({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _74 => _74.ledgerVersion])}});return o.data}async function Nt(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,i=await Wr({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(e);try{let a=await Jn({aptosConfig:t,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Uo(n){let{aptosConfig:t,accountAddress:e}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s=await f({aptosConfig:t,query:{query:co,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Ro(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _75 => _75.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _76 => _76.tokenStandard])});let s={query:so,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _77 => _77.offset]),limit:_optionalChain([r, 'optionalAccess', _78 => _78.limit]),order_by:_optionalChain([r, 'optionalAccess', _79 => _79.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Ko(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:i}=n,o=u.from(e).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _80 => _80.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _81 => _81.tokenStandard])});let c={query:ao,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _82 => _82.offset]),limit:_optionalChain([i, 'optionalAccess', _83 => _83.limit]),order_by:_optionalChain([i, 'optionalAccess', _84 => _84.orderBy])}};return(await f({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function zo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}};_optionalChain([r, 'optionalAccess', _85 => _85.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _86 => _86.tokenStandard])}});let s={query:oo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _87 => _87.offset]),limit:_optionalChain([r, 'optionalAccess', _88 => _88.limit]),order_by:_optionalChain([r, 'optionalAccess', _89 => _89.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function ko(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:uo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Do(n){let{aptosConfig:t,accountAddress:e,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===ot?s=u.A.toStringLong():s=Mr(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=u.from(i);s=d.toStringLong(),d===u.A&&(o=ot)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=u.from(e).toStringLong(),c={asset_type:{_eq:s}};o!==void 0&&(c={asset_type:{_in:[o,s]}});let p=await jr({aptosConfig:t,accountAddress:a,options:{where:c}});return p[0]?p[0].amount:0}async function jr(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i=u.from(e).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _90 => _90.where]),owner_address:{_eq:i}},s={query:io,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _91 => _91.offset]),limit:_optionalChain([r, 'optionalAccess', _92 => _92.limit]),order_by:_optionalChain([r, 'optionalAccess', _93 => _93.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Bo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:ro,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function Go(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}},s={query:jn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _94 => _94.offset]),limit:_optionalChain([r, 'optionalAccess', _95 => _95.limit]),order_by:_optionalChain([r, 'optionalAccess', _96 => _96.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Fo(n){let{aptosConfig:t,privateKey:e}=n,r=new k(e.publicKey());if(e instanceof rt){let o=D.fromPublicKey({publicKey:r}).derivedAddress();return Le.fromPrivateKey({privateKey:e,address:o})}if(e instanceof W){let i=D.fromPublicKey({publicKey:r});if(await vo({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return Le.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=D.fromPublicKey({publicKey:r.publicKey});if(await vo({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Le.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function vo(n){let{aptosConfig:t,authKey:e}=n,r=await Nt({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await xe({aptosConfig:t,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function Zr(n){let{aptosConfig:t,options:e}=n;return St({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _97 => _97.offset]),limit:_optionalChain([e, 'optionalAccess', _98 => _98.limit])}})}async function nr(n){let{aptosConfig:t}=n;return Oe(async()=>{let{data:e}=await H({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function No(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await H({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function cn(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await H({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Oo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await cn({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _99 => _99.status])===404)return!0;throw r}}async function Ac(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await H({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function Ot(n){let{aptosConfig:t,transactionHash:e,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _100 => _100.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _101 => _101.checkSuccess]), () => (!0)),s=!0,a=0,c,p,d=200,T=1.5;function w(m){if(!(m instanceof Ae)||(p=m,m.status!==404&&m.status>=400&&m.status<500))throw m}try{c=await cn({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(m){w(m)}if(s){let m=Date.now();try{c=await Ac({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(_){w(_)}a=(Date.now()-m)/1e3}for(;s&&!(a>=i);){try{if(c=await cn({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(m){w(m)}await _chunkHBPH2AD3js.b.call(void 0, d),a+=d/1e3,d*=T}if(c===void 0)throw p||new tr(`Fetching transaction ${e} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new tr(`Transaction ${e} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Xr(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function rr(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?s=await Zn({aptosConfig:t}):s=(await Yn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkHBPH2AD3js.b.call(void 0, 200)}}var tr=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Xr=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function Mo(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:i}=await H({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _102 => _102.withTransactions])}});return Vo({block:i,...n})}async function qo(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:i}=await H({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _103 => _103.withTransactions])}});return Vo({block:i,...n})}async function Vo(n){let{aptosConfig:t,block:e,options:r}=n;if(_optionalChain([r, 'optionalAccess', _104 => _104.withTransactions])){e.transactions=_nullishCoalesce(e.transactions, () => ([]));let i=e.transactions[e.transactions.length-1],o=BigInt(e.first_version),s=BigInt(e.last_version),a=_optionalChain([i, 'optionalAccess', _105 => _105.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return e;let p=[],d=100n;for(let w=c+1n;w<s;w+=BigInt(100))p.push(Zr({aptosConfig:t,options:{offset:w,limit:Math.min(Number(d),Number(s-w+1n))}}));let T=await Promise.all(p);for(let w of T)e.transactions.push(...w)}return e}async function A(n){n.minimumLedgerVersion!==void 0&&await rr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}function $o(n){return typeof n=="boolean"}function We(n){return typeof n=="string"}function hc(n){return typeof n=="number"}function ir(n){if(hc(n))return n;if(We(n)&&n!=="")return Number.parseInt(n,10)}function or(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Lo(n){return n==null}function Ho(n){return Yr(n)||ei(n)||ti(n)||ni(n)||ri(n)||ii(n)||oi(n)||sr(n)||Jr(n)||bc(n)||n instanceof h||n instanceof L}function Yr(n){return n instanceof I}function sr(n){return n instanceof u}function Jr(n){return n instanceof S}function bc(n){return n instanceof et}function ei(n){return n instanceof $}function ti(n){return n instanceof ge}function ni(n){return n instanceof me}function ri(n){return n instanceof O}function ii(n){return n instanceof ye}function oi(n){return n instanceof fe}function Qo(n){return"bytecode"in n}function U(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Wo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function un(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],i=t[2];return{moduleAddress:e,moduleName:r,functionName:i}}function jo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Xo(n){return!!n.match(/\s/)}function Tc(n){return!!n.match(/^T[0-9]+$/)}function wc(n){return!!n.match(/^&.+$/)}function Sc(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function xc(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!Xo(r))break}return e}var _c=(_=>(_.InvalidTypeTag="unknown type",_.UnexpectedGenericType="unexpected generic type",_.UnexpectedTypeArgumentClose="unexpected '>'",_.UnexpectedWhitespaceCharacter="unexpected whitespace character",_.UnexpectedComma="unexpected ','",_.TypeArgumentCountMismatch="type argument count doesn't match expected amount",_.MissingTypeArgumentClose="no matching '>' for '<'",_.MissingTypeArgument="no type argument before ','",_.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",_.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",_.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",_.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",_.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",_.InvalidAddress="struct address must be valid",_))(_c||{}),N= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Ke(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _106 => _106.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let _=pn(a,i,e);o.push(_)}let d=r.pop();if(d===void 0)throw new N(n,"unexpected '>'");if(c!==o.length)throw new N(n,"type argument count doesn't match expected amount");let{savedStr:T,savedTypes:w,savedExpectedTypes:m}=d;i=o,o=w,a=T,c=m}else if(p===","){if(r.length===0)throw new N(n,"unexpected ','");if(a.length===0)throw new N(n,"no type argument before ','");let d=pn(a,i,e);i=[],o.push(d),a="",c+=1}else if(Xo(p)){let d=!1;if(a.length!==0){let w=pn(a,i,e);i=[],o.push(w),a="",d=!0}s=xc(n,s);let T=n[s];if(s<n.length&&d&&T!==","&&T!==">")throw new N(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new N(n,"no matching '>' for '<'");switch(o.length){case 0:return pn(a,i,e);case 1:if(a==="")return o[0];throw new N(n,"unexpected ','");default:throw new N(n,"unexpected whitespace character")}}function pn(n,t,e){let r=n.trim(),i=r.toLowerCase();if(Sc(i)&&t.length>0)throw new N(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Et;case"bool":return new F;case"address":return new X;case"u8":return new ue;case"u16":return new Me;case"u32":return new qe;case"u64":return new Q;case"u128":return new Ve;case"u256":return new $e;case"vector":if(t.length!==1)throw new N(n,"vector type expected to have exactly one type argument");return new E(t[0]);default:if(wc(r)){let a=r.substring(1);return new Mn(pn(a,t,e))}if(Tc(r)){if(e)return new z(Number(r.split("T")[1]));throw new N(n,"unexpected generic type")}if(!r.match(/:/))throw new N(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new N(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch (e2){throw new N(n,"struct address must be valid")}if(!jo(o[1]))throw new N(n,"module name must only contain alphanumeric or '_' characters");if(!jo(o[2]))throw new N(n,"struct name must only contain alphanumeric or '_' characters");return new y(new Ue(s,new R(o[1]),new R(o[2]),t))}}var Pc=new TextEncoder;function ar(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _107 => _107.map, 'call', _108 => _108(t=>We(t)?Ke(t):t)]), () => ([]))}async function Zo(n,t,e,r){let i=await er({aptosConfig:r,accountAddress:n,moduleName:t});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===e)}async function Yo(n,t,e,r){let i=await Zo(n,t,e,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!i.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let o=Wo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ke(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Jo(n,t,e,r){let i=await Zo(n,t,e,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${t}::${e}'`);if(!i.is_view)throw new Error(`'${n}::${t}::${e}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Ke(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ke(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function ai(n,t,e,r,i){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let o=t.parameters[r];return Mt(e,o,r,i)}function Mt(n,t,e,r){return Ho(n)?(si(t,n,e),n):vc(n,t,e,r)}function vc(n,t,e,r){if(t.isBool()){if($o(n))return new I(n);if(We(n)){if(n==="true")return new I(!0);if(n==="false")return new I(!1)}U("boolean",e)}if(t.isAddress()){if(We(n))return u.fromString(n);U("string | AccountAddress",e)}if(t.isU8()){let i=ir(n);if(i!==void 0)return new $(i);U("number | string",e)}if(t.isU16()){let i=ir(n);if(i!==void 0)return new ge(i);U("number | string",e)}if(t.isU32()){let i=ir(n);if(i!==void 0)return new me(i);U("number | string",e)}if(t.isU64()){if(or(n))return new O(BigInt(n));U("bigint | number | string",e)}if(t.isU128()){if(or(n))return new ye(BigInt(n));U("bigint | number | string",e)}if(t.isU256()){if(or(n))return new fe(BigInt(n));U("bigint | number | string",e)}if(t.isGeneric()){let i=t.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return Mt(n,r[i],e,r)}if(t.isVector()){if(t.value.isU8()){if(We(n))return h.U8(Pc.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(i=>Mt(i,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(We(n))return new S(n);U("string",e)}if(t.isObject()){if(We(n))return u.fromString(n);U("string | AccountAddress",e)}if(t.isOption()){if(Lo(n)){let i=t.value.typeArgs[0];return i instanceof F?new L(null):i instanceof X?new L(null):i instanceof ue?new L(null):i instanceof Me?new L(null):i instanceof qe?new L(null):i instanceof Q?new L(null):i instanceof Ve?new L(null):i instanceof $e?new L(null):new L(null)}return new L(Mt(n,t.value.typeArgs[0],e,r))}throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function si(n,t,e){if(n.isBool()){if(Yr(t))return;U("Bool",e)}if(n.isAddress()){if(sr(t))return;U("AccountAddress",e)}if(n.isU8()){if(ei(t))return;U("U8",e)}if(n.isU16()){if(ti(t))return;U("U16",e)}if(n.isU32()){if(ni(t))return;U("U32",e)}if(n.isU64()){if(ri(t))return;U("U64",e)}if(n.isU128()){if(ii(t))return;U("U128",e)}if(n.isU256()){if(oi(t))return;U("U256",e)}if(n.isVector()){if(t instanceof h){t.values.length>0&&si(n.value,t.values[0],e);return}U("MoveVector",e)}if(n instanceof y){if(n.isString()){if(Jr(t))return;U("MoveString",e)}if(n.isObject()){if(sr(t))return;U("AccountAddress",e)}if(n.isOption()){if(t instanceof L){t.value!==void 0&&si(n.value.typeArgs[0],t.value,e);return}U("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}async function ur(n){if(Qo(n))return Uc(n);let{moduleAddress:t,moduleName:e,functionName:r}=un(n.function),i=await rs({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Yo});return Ec({...n,abi:i})}function Ec(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=un(n.function),o=ar(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>ai(n.function,t,c,p,o));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);let a=pt.build(`${e}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new nn(new on(c,new sn(a)))}return new tn(a)}async function es(n){let{moduleAddress:t,moduleName:e,functionName:r}=un(n.function),i=await rs({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Jo});return Ic({abi:i,...n})}function Ic(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=un(n.function),o=ar(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _109 => _109.functionArguments, 'optionalAccess', _110 => _110.map, 'call', _111 => _111((a,c)=>ai(n.function,t,a,c,o))]), () => ([]));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);return pt.build(`${e}::${r}`,i,o,s)}function Uc(n){return new en(new rn(g.fromHexInput(n.bytecode).toUint8Array(),ar(n.typeArguments),n.functionArguments))}async function Rc(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=async()=>Br[t.network]?{chainId:Br[t.network]}:{chainId:(await Xn({aptosConfig:t})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _112 => _112.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await nr({aptosConfig:t})).gas_estimate},c=async()=>{let yt=async()=>_optionalChain([i, 'optionalAccess', _113 => _113.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await xe({aptosConfig:t,accountAddress:e})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await yt()}catch (e3){return 0}else return yt()},[{chainId:p},{gasEstimate:d},T]=await Promise.all([s(),a(),c()]),{maxGasAmount:w,gasUnitPrice:m,expireTimestamp:_}={maxGasAmount:_optionalChain([i, 'optionalAccess', _114 => _114.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _115 => _115.gasUnitPrice]), () => (BigInt(d))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _116 => _116.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new pe(u.from(e),BigInt(T),r,BigInt(w),BigInt(m),BigInt(_),new Ct(p))}async function ci(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=await Rc({aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _117 => _117.secondarySignerAddresses, 'optionalAccess', _118 => _118.map, 'call', _119 => _119(c=>u.from(c))]), () => ([]));return new Ln(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new $n(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function ts(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=cr(t);if(e.feePayerAddress){let a=new lt(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(T=>cr(T)));let p=cr(i),d=new Rt(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new gt(a.raw_txn,d).bcsToBytes()}if(e.secondarySignerAddresses){let a=new dt(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(d=>cr(d));let p=new Ut(o,e.secondarySignerAddresses,c);return new gt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof be)s=new It(o.public_key,o.signature);else if(o instanceof te)s=new Kt(o);else throw new Error("Invalid public key");return new gt(e.rawTransaction,s).bcsToBytes()}function cr(n){let e=G.isInstance(n)||he.isInstance(n)||ve.isInstance(n)?new k(n):n,r=new C(new Uint8Array(64));if(P.isInstance(e))return new be(e,r);if(k.isInstance(e))return G.isInstance(e.publicKey)?new te(e,new M(Ie.getSimulationSignature())):new te(e,new M(r));throw new Error("Unsupported public key")}function ui(n){let{transaction:t,feePayerAuthenticator:e,additionalSignersAuthenticators:r}=n,i=ji(j,n.senderAuthenticator),o;if(t.feePayerAddress){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Rt(i,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:t.feePayerAddress,authenticator:e})}else if(t.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Ut(i,t.secondarySignerAddresses,r)}else i instanceof be?o=new It(i.public_key,i.signature):o=new Kt(i);return new gt(t.rawTransaction,o).bcsToBytes()}function ns(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Kc=ns(["APTOS::Transaction"]);function jh(n){let t=ui(n);return new g(ns([Kc,new Uint8Array([0]),t])).toString()}async function rs({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Oe(async()=>s(t,e,r,i),`${n}-${i.network}-${t}-${e}-${r}`,1e3*60*5)()}async function _e(n){let{aptosConfig:t,payload:e,options:r}=n,i=await es({...e,aptosConfig:t}),o=new V;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Ne({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _120 => _120.ledgerVersion])},body:s});return a}async function is(n){let{aptosConfig:t,payload:e,options:r}=n,{data:i}=await Ne({aptosConfig:t,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _121 => _121.ledgerVersion])},body:{function:e.function,type_arguments:_nullishCoalesce(e.typeArguments, () => ([])),arguments:_nullishCoalesce(e.functionArguments, () => ([]))}});return i}var dn=class{constructor(t){this.config=t}async getAccountInfo(t){return xe({aptosConfig:this.config,...t})}async getAccountModules(t){return Co({aptosConfig:this.config,...t})}async getAccountModule(t){return er({aptosConfig:this.config,...t})}async getAccountTransactions(t){return Eo({aptosConfig:this.config,...t})}async getAccountResources(t){return Io({aptosConfig:this.config,...t})}async getAccountResource(t){return Wr({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Nt({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Uo({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ro({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ko({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),zo({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),ko({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),jr({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Bo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:ot,faMetadataAddress:Vi,...t})}async getAccountCoinAmount(t){let{coinType:e,faMetadataAddress:r}=t;await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"});let i=e;if(e===void 0&&r!==void 0)try{let o=(await _e({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[r]}})).at(0);o.vec.length>0&&_chunkHBPH2AD3js.i.call(void 0, o.vec[0])&&(i=_chunkHBPH2AD3js.h.call(void 0, o.vec[0]))}catch (e4){}return Do({aptosConfig:this.config,...t,coinType:i})}async getAccountOwnedObjects(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),Go({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return Fo({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var pr=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _122 => _122.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _123 => _123.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _124 => _124.faucet]),this.pepper=_optionalChain([t, 'optionalAccess', _125 => _125.pepper]),this.prover=_optionalChain([t, 'optionalAccess', _126 => _126.prover]),this.indexer=_optionalChain([t, 'optionalAccess', _127 => _127.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _128 => _128.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _129 => _129.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _130 => _130.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _131 => _131.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _132 => _132.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 Qi[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 Wi[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 Hi[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return zr[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return kr[this.network];default:throw Error(`apiType ${t} is not supported`)}}isPepperServiceRequest(t){return zr[this.network]===t}isProverServiceRequest(t){return kr[this.network]===t}};async function b(n){let t=await kc(n);return Dc(n,t)}async function kc(n){let{aptosConfig:t,data:e}=n,r,i;return"bytecode"in e?i=await ur(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await ur(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await ur(r)),i}async function Dc(n,t){let{aptosConfig:e,sender:r,options:i}=n,o;if(Bc(n)&&(o=u.ZERO.toString()),Gc(n)){let{secondarySignerAddresses:s}=n;return ci({aptosConfig:e,sender:r,payload:t,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return ci({aptosConfig:e,sender:r,payload:t,options:i,feePayerAddress:o})}function Bc(n){return n.withFeePayer===!0}function Gc(n){return"secondarySignerAddresses"in n}function os(n){let{transaction:t}=n;return kt(t)}function dr(n){let{signer:t,transaction:e}=n;return t.signTransactionWithAuthenticator(e)}async function pi(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=ts({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Ne({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _133 => _133.options, 'optionalAccess', _134 => _134.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _137 => _137.options, 'optionalAccess', _138 => _138.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function lr(n){let{aptosConfig:t}=n,e=ui({...n}),{data:r}=await Ne({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function ln(n){let{aptosConfig:t,signer:e,transaction:r}=n;(e instanceof He||e instanceof Qn)&&await e.waitForProofFetch();let i=dr({signer:e,transaction:r});return lr({aptosConfig:t,transaction:r,senderAuthenticator:i})}var Fc={typeParameters:[],parameters:[E.u8(),new E(E.u8())]};async function ss(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>h.U8(a));return b({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[h.U8(r),new h(s)],abi:Fc},options:o})}var Nc={typeParameters:[],parameters:[new ue,E.u8(),new ue,E.u8(),E.u8(),E.u8()]};async function as(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,i=await xe({aptosConfig:t,accountAddress:e.accountAddress}),o=Le.fromPrivateKey({privateKey:r,legacy:!0}),a=new Vn({sequenceNumber:BigInt(i.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=e.sign(a),p=o.sign(a),d=await b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new $(e.signingScheme),h.U8(e.publicKey.toUint8Array()),new $(o.signingScheme),h.U8(o.publicKey.toUint8Array()),h.U8(c.toUint8Array()),h.U8(p.toUint8Array())],abi:Nc}});return ln({aptosConfig:t,signer:e,transaction:d})}var Oc={typeParameters:[{constraints:[]}],parameters:[new X,new Q]};async function cs(n){let{aptosConfig:t,sender:e,recipient:r,amount:i,coinType:o,options:s}=n;return b({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (ot))],functionArguments:[r,i],abi:Oc},options:s})}var gn=class{constructor(t){this.config=t}async transferCoinTransaction(t){return cs({aptosConfig:this.config,...t})}};var je={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},de="0x4::token::Token";async function us(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:wo,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ps(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};return(await f({aptosConfig:t,query:{query:Qr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ds(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},o={query:Qr,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _139 => _139.offset]),limit:_optionalChain([r, 'optionalAccess', _140 => _140.limit]),order_by:_optionalChain([r, 'optionalAccess', _141 => _141.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function ls(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,i={token_data_id:{_eq:u.from(e).toStringLong()}},o={query:To,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _142 => _142.offset]),limit:_optionalChain([r, 'optionalAccess', _143 => _143.limit]),order_by:_optionalChain([r, 'optionalAccess', _144 => _144.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Mc={typeParameters:[],parameters:[new y(v()),new Q,new y(v()),new y(v()),new F,new F,new F,new F,new F,new F,new F,new F,new F,new Q,new Q]};async function gs(n){let{aptosConfig:t,options:e,creator:r}=n;return b({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new S(n.description),new O(_nullishCoalesce(n.maxSupply, () => (Ye))),new S(n.name),new S(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 O(_nullishCoalesce(n.royaltyNumerator, () => (0))),new O(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Mc},options:e})}async function qt(n){let{aptosConfig:t,options:e}=n,r=_optionalChain([e, 'optionalAccess', _145 => _145.where]);_optionalChain([e, 'optionalAccess', _146 => _146.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _147 => _147.tokenStandard]), () => ("v2"))});let i={query:lo,variables:{where_condition:r,offset:_optionalChain([e, 'optionalAccess', _148 => _148.offset]),limit:_optionalChain([e, 'optionalAccess', _149 => _149.limit])}};return(await f({aptosConfig:t,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function ms(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:i}=n,o=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _150 => _150.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _151 => _151.tokenStandard]), () => ("v2"))}),qt({aptosConfig:t,options:{...i,where:s}})}async function ys(n){let{aptosConfig:t,creatorAddress:e,options:r}=n,o={creator_address:{_eq:u.from(e).toStringLong()}};return _optionalChain([r, 'optionalAccess', _152 => _152.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),qt({aptosConfig:t,options:{...r,where:o}})}async function fs(n){let{aptosConfig:t,collectionId:e,options:r}=n,o={collection_id:{_eq:u.from(e).toStringLong()}};return _optionalChain([r, 'optionalAccess', _154 => _154.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),qt({aptosConfig:t,options:{...r,where:o}})}async function As(n){let{creatorAddress:t,collectionName:e,options:r,aptosConfig:i}=n,o=u.from(t),s={collection_name:{_eq:e},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _156 => _156.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _157 => _157.tokenStandard]), () => ("v2"))}),(await qt({aptosConfig:i,options:{where:s}})).collection_id}var qc={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new E(new y(v())),new E(new y(v())),new E(E.u8())]};async function hs(n){let{aptosConfig:t,options:e,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:d}=n,T=_optionalChain([p, 'optionalAccess', _158 => _158.map, 'call', _159 => _159(w=>je[w])]);return b({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new S(i),new S(o),new S(s),new S(a),h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(T, () => ([]))),Ks(_nullishCoalesce(d, () => ([])),_nullishCoalesce(T, () => ([])))],abi:qc},options:e})}var Vc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new X]};async function bs(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(r),u.from(i)],abi:Vc},options:s})}var $c={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new E(new y(v())),new E(new y(v())),new E(E.u8()),new X]};async function Ts(n){let{aptosConfig:t,account:e,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:d,options:T}=n;if(_optionalChain([c, 'optionalAccess', _160 => _160.length])!==_optionalChain([d, 'optionalAccess', _161 => _161.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _162 => _162.length])!==_optionalChain([d, 'optionalAccess', _163 => _163.length]))throw new Error("Property types and property values counts do not match");let w=_optionalChain([p, 'optionalAccess', _164 => _164.map, 'call', _165 => _165(m=>je[m])]);return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(w, () => ([]))),Ks(_nullishCoalesce(d, () => ([])),_nullishCoalesce(w, () => ([]))),a],abi:$c},options:T})}var Lc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0)))]};async function ws(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (de))],functionArguments:[u.from(r)],abi:Lc},options:o})}var Hc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0)))]};async function Ss(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (de))],functionArguments:[r],abi:Hc},options:o})}var Qc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0)))]};async function xs(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (de))],functionArguments:[r],abi:Qc},options:o})}var Wc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function _s(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:Wc},options:s})}var jc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function Ps(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:jc},options:s})}var Xc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function vs(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:Xc},options:s})}var Zc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v()),new y(v()),E.u8()]};async function Cs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (de))],functionArguments:[u.from(s),new S(r),new S(je[i]),h.U8(di(o,je[i]))],abi:Zc},options:c})}var Yc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function Es(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:Yc},options:s})}var Jc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v()),new y(v()),E.u8()]};async function Is(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (de))],functionArguments:[u.from(s),new S(r),new S(je[i]),di(o,je[i])],abi:Jc},options:c})}var eu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(ie(new z(0))),new y(v()),new z(1)]};async function Us(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (de)),je[i]],functionArguments:[u.from(s),new S(r),o],abi:eu},options:c})}var tu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(ie(new z(0))),new y(v()),new z(1)]};async function Rs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (de)),je[i]],functionArguments:[u.from(s),new S(r),o],abi:tu},options:c})}function Ks(n,t){let e=new Array;return t.forEach((r,i)=>{e.push(di(n[i],r))}),e}function di(n,t){let e=Ke(t);return Mt(n,e,0,[]).bcsToBytes()}var mn=class{constructor(t){this.config=t}async getCollectionData(t){await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:e,collectionName:r,options:i}=t,o=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _166 => _166.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _167 => _167.tokenStandard]), () => ("v2"))}),qt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ms({aptosConfig:this.config,...t})}async getCollectionDataByCreatorAddress(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ys({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),fs({aptosConfig:this.config,...t})}async getCollectionId(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),As({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),us({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ps({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ds({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ls({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return gs({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return hs({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return bs({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Ts({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return ws({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Ss({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return xs({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return _s({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return Ps({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return vs({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return Cs({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return Es({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return Is({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return Us({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return Rs({aptosConfig:this.config,...t})}};var zs=300,nu=n=>{if(n&&n.length>zs)throw new Error(`Event type length exceeds the maximum length of ${zs}`)};async function ks(n){let{aptosConfig:t,eventType:e,options:r}=n,i={_or:[{account_address:{_eq:e.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:e}};return yn({aptosConfig:t,options:{...r,where:i}})}async function Ds(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:i}=n,s={account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}};return yn({aptosConfig:e,options:{...i,where:s}})}async function Bs(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:i}=n,s={account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}};return yn({aptosConfig:e,options:{...i,where:s}})}async function yn(n){let{aptosConfig:t,options:e}=n;nu(_optionalChain([e, 'optionalAccess', _168 => _168.where, 'optionalAccess', _169 => _169.indexed_type, 'optionalAccess', _170 => _170._eq]));let r={query:yo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _171 => _171.where]),offset:_optionalChain([e, 'optionalAccess', _172 => _172.offset]),limit:_optionalChain([e, 'optionalAccess', _173 => _173.limit]),order_by:_optionalChain([e, 'optionalAccess', _174 => _174.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var fn=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ks({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Ds({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Bs({aptosConfig:this.config,...t})}async getEvents(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _175 => _175.minimumLedgerVersion]),processorType:"events_processor"}),yn({aptosConfig:this.config,...t})}};async function Gs(n){let{aptosConfig:t,accountAddress:e,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _176 => _176.timeoutSecs])||20,{data:s}=await Zi({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:o,checkSuccess:_optionalChain([i, 'optionalAccess', _177 => _177.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var An=class{constructor(t){this.config=t}async fundAccount(t){let e=await Gs({aptosConfig:this.config,...t});return(_optionalChain([t, 'access', _178 => _178.options, 'optionalAccess', _179 => _179.waitForIndexer])===void 0||_optionalChain([t, 'access', _180 => _180.options, 'optionalAccess', _181 => _181.waitForIndexer]))&&await rr({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version),processorType:"fungible_asset_processor"}),e}};async function gr(n){let{aptosConfig:t,options:e}=n,r={query:Ao,variables:{where_condition:_optionalChain([e, 'optionalAccess', _182 => _182.where]),limit:_optionalChain([e, 'optionalAccess', _183 => _183.limit]),offset:_optionalChain([e, 'optionalAccess', _184 => _184.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Fs(n){let{aptosConfig:t,options:e}=n,r={query:fo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _185 => _185.where]),limit:_optionalChain([e, 'optionalAccess', _186 => _186.limit]),offset:_optionalChain([e, 'optionalAccess', _187 => _187.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ns(n){let{aptosConfig:t,options:e}=n,r={query:go,variables:{where_condition:_optionalChain([e, 'optionalAccess', _188 => _188.where]),limit:_optionalChain([e, 'optionalAccess', _189 => _189.limit]),offset:_optionalChain([e, 'optionalAccess', _190 => _190.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ru={typeParameters:[{constraints:[]}],parameters:[Ke("0x1::object::Object"),new X,new Q]};async function Os(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ru},options:s})}var hn=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _191 => _191.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),gr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _192 => _192.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await gr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await gr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(t.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _194 => _194.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Fs({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _195 => _195.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ns({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return Os({aptosConfig:this.config,...t})}};var bn=class{constructor(t){this.config=t}async getLedgerInfo(){return Xn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return Mo({aptosConfig:this.config,...t})}async getBlockByHeight(t){return qo({aptosConfig:this.config,...t})}async view(t){return _e({aptosConfig:this.config,...t})}async viewJson(t){return is({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return So({aptosConfig:this.config,...t})}async queryIndexer(t){return f({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return Zn({aptosConfig:this.config})}async getProcessorStatus(t){return Yn({aptosConfig:this.config,processorType:t})}};var Ms=["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 qs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Xe(n){let[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(!qs(t))throw new Error(`${t} is not valid. ${Ms}`);if(e&&!qs(e))throw new Error(`${e} is not valid. ${Ms}`);return{domainName:e||t,subdomainName:e?t:void 0}}function Vs(n){if(!n)return!1;let t=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),e=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&t?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!e}var iu="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",ou={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:iu,custom:null,devnet:null};function ze(n){let t=ou[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var mr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function $s(n){let{aptosConfig:t,name:e}=n,r=ze(t),{domainName:i,subdomainName:o}=Xe(e),s=await _e({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=mr(s[0]);return a?u.from(a):void 0}async function Ls(n){let{aptosConfig:t,expiration:e,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=ze(t),{domainName:d,subdomainName:T}=Xe(r),w=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(T&&!w)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(w&&!T)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let Tr=_nullishCoalesce(e.years, () => (1));if(Tr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let pa=Tr*31536e3;return await b({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[d,pa,o,s]},options:a})}if(!T)throw new Error(`${e.policy} requires a subdomain to be provided.`);let m=await li({aptosConfig:t,name:d});if(!m)throw new Error("The domain does not exist");let _=e.policy==="subdomain:independent"?e.expirationDate:m;if(_>m)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await b({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[d,T,Math.round(_/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function li(n){let{aptosConfig:t,name:e}=n,r=ze(t),{domainName:i,subdomainName:o}=Xe(e);try{let s=await _e({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e5){return}}async function Hs(n){let{aptosConfig:t,address:e}=n,r=ze(t),i=await _e({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),o=mr(i[1]),s=mr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Qs(n){let{aptosConfig:t,sender:e,name:r,options:i}=n,o=ze(t);if(!r)return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Xe(r);return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ws(n){let{aptosConfig:t,name:e}=n,r=ze(t),{domainName:i,subdomainName:o}=Xe(e),s=await _e({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=mr(s[0]);return a?u.from(a):void 0}async function js(n){let{aptosConfig:t,sender:e,name:r,address:i,options:o}=n,s=ze(t),{domainName:a,subdomainName:c}=Xe(r);return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Xs(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:i=""}=Xe(e),a=(await f({aptosConfig:t,query:{query:Ft,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Tn(a)),Vs(a)?a:void 0}async function Zs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await gi({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountNames",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _196 => _196.limit]),offset:_optionalChain([e, 'optionalAccess', _197 => _197.offset]),order_by:_optionalChain([e, 'optionalAccess', _198 => _198.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _199 => _199.options, 'optionalAccess', _200 => _200.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Tn)}async function Ys(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await gi({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountDomains",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _201 => _201.limit]),offset:_optionalChain([e, 'optionalAccess', _202 => _202.offset]),order_by:_optionalChain([e, 'optionalAccess', _203 => _203.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Tn)}async function Js(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await gi({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _206 => _206.limit]),offset:_optionalChain([e, 'optionalAccess', _207 => _207.offset]),order_by:_optionalChain([e, 'optionalAccess', _208 => _208.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _209 => _209.options, 'optionalAccess', _210 => _210.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Tn)}async function ea(n){let{aptosConfig:t,options:e,domain:r}=n;return(await f({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _211 => _211.limit]),offset:_optionalChain([e, 'optionalAccess', _212 => _212.offset]),order_by:_optionalChain([e, 'optionalAccess', _213 => _213.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Tn).filter(Vs)}async function gi(n){let{aptosConfig:t}=n,e=ze(t),[r]=await _e({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function ta(n){let{aptosConfig:t,sender:e,name:r,years:i=1,options:o}=n,s=ze(t),a=i*31536e3,{domainName:c,subdomainName:p}=Xe(r);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Tn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var wn=class{constructor(t){this.config=t}async getOwnerAddress(t){return $s({aptosConfig:this.config,...t})}async getExpiration(t){return li({aptosConfig:this.config,...t})}async getTargetAddress(t){return Ws({aptosConfig:this.config,...t})}async setTargetAddress(t){return js({aptosConfig:this.config,...t})}async getPrimaryName(t){return Hs({aptosConfig:this.config,...t})}async setPrimaryName(t){return Qs({aptosConfig:this.config,...t})}async registerName(t){return Ls({aptosConfig:this.config,...t})}async renewDomain(t){return ta({aptosConfig:this.config,...t})}async getName(t){return Xs({aptosConfig:this.config,...t})}async getAccountNames(t){return Zs({aptosConfig:this.config,...t})}async getAccountDomains(t){return Ys({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Js({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return ea({aptosConfig:this.config,...t})}};async function na(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Lr,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function ra(n){let{aptosConfig:t,options:e}=n,r={query:Lr,variables:{order_by:_optionalChain([e, 'optionalAccess', _216 => _216.orderBy])}};return(await f({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function ia(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,i={query:mo,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:t,query:i})).delegated_staking_activities}var Sn=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"stake_processor"}),na({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _218 => _218.minimumLedgerVersion]),processorType:"stake_processor"}),ra({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _219 => _219.minimumLedgerVersion]),processorType:"stake_processor"}),ia({aptosConfig:this.config,...t})}};var yr=class{constructor(t){this.config=t}async simple(t){return b({aptosConfig:this.config,...t})}async multiAgent(t){return b({aptosConfig:this.config,...t})}};function mi(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},e}function yi(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,i)},e}var Vt=class{constructor(t){this.config=t}async simple(t){return pi({aptosConfig:this.config,...t})}async multiAgent(t){return pi({aptosConfig:this.config,...t})}};_chunkHBPH2AD3js.a.call(void 0, [yi],Vt.prototype,"simple",1),_chunkHBPH2AD3js.a.call(void 0, [yi],Vt.prototype,"multiAgent",1);var $t=class{constructor(t){this.config=t}async simple(t){return lr({aptosConfig:this.config,...t})}async multiAgent(t){return lr({aptosConfig:this.config,...t})}};_chunkHBPH2AD3js.a.call(void 0, [mi],$t.prototype,"simple",1),_chunkHBPH2AD3js.a.call(void 0, [mi],$t.prototype,"multiAgent",1);var fr=class{constructor(t,e,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkHBPH2AD3js.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=_chunkHBPH2AD3js.c.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkHBPH2AD3js.b.call(void 0, this.sleepTime),_chunkHBPH2AD3js.c.call(void 0, )-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 xe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await xe({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 _chunkHBPH2AD3js.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=_chunkHBPH2AD3js.c.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkHBPH2AD3js.c.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkHBPH2AD3js.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 Lt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _220 => _220.pendingDequeue, 'access', _221 => _221.shift, 'call', _222 => _222(), 'optionalAccess', _223 => _223.resolve, 'call', _224 => _224(t)]);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new Ht("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Ht=class extends Error{};var oa="fulfilled",sa= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(sa||{}),Ar= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,i=30,o=100,s=10){super();this.taskQueue=new Lt;this.transactionsQueue=new Lt;this.outstandingTransactions=new Lt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new fr(e,r,i,o,s)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let i=ln({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof Ht)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(e.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),e.push(i),r.push(o);let s=await Promise.allSettled(e);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===oa?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(e){if(e instanceof Ht)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let i=[];i.push(Ot({aptosConfig:this.aptosConfig,transactionHash:e.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===oa?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return b({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var hr=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new Ar(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:i}=e;for(let o of r)this.transactionWorker.push(o,i)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:r,data:i,options:o}=e;this.start({sender:r}),this.push({data:i,options:o})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var xn=class{constructor(t){this.config=t,this.build=new yr(this.config),this.simulate=new Vt(this.config),this.submit=new $t(this.config),this.batch=new hr(this.config)}async getTransactions(t){return Zr({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return No({aptosConfig:this.config,...t})}async getTransactionByHash(t){return cn({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 nr({aptosConfig:this.config})}getSigningMessage(t){return os(t)}async publishPackageTransaction(t){return ss({aptosConfig:this.config,...t})}async rotateAuthKey(t){return as({aptosConfig:this.config,...t})}sign(t){return dr({...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,dr({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:i}=t;this.batch.forSingleAccount({sender:e,data:r,options:i})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return ln({aptosConfig:this.config,signer:e,transaction:r})}};var _n=class{constructor(t){this.config=t}async getTableItem(t){return Jn({aptosConfig:this.config,...t})}async getTableItemsData(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),xo({aptosConfig:this.config,...t})}async getTableItemsMetadata(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),_o({aptosConfig:this.config,...t})}};async function br(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Yi({aptosConfig:t,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return g.fromHexInput(a.pepper).toUint8Array()}async function fi(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,pepper:i=await br(n),uidKey:o="sub"}=n;if(g.fromHexInput(i).toUint8Array().length!==Qe.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Qe.PEPPER_LENGTH} bytes`);let{maxExpHorizonSecs:s}=await to({aptosConfig:t});if(s<r.expiryDateSecs-_jwtdecode.jwtDecode.call(void 0, e).iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let a={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:g.fromHexInput(i).toStringWithoutPrefix(),uid_key:o};console.log(JSON.stringify(a));let{data:c}=await Ji({aptosConfig:t,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}});console.log(JSON.stringify(c));let p=c.proof,d=new _t({a:p.a,b:p.b,c:p.c});return new ce({proof:new Pt(d,0),trainingWheelsSignature:we.fromHex(c.training_wheels_signature),expHorizonSecs:s})}async function aa(n){let{aptosConfig:t,jwt:e,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await br(n)}=n,a=fi({...n,pepper:s}),c=o?a:await a;if(r!==void 0){let T=he.fromJwtAndPepper({jwt:e,pepper:s,jwkAddress:r,uidKey:i}),w=await Nt({aptosConfig:t,authenticationKey:T.authKey().derivedAddress()});return Hn.create({...n,address:w,proof:c,pepper:s,proofFetchCallback:o,jwkAddress:r})}let p=G.fromJwtAndPepper({jwt:e,pepper:s,uidKey:i}),d=await Nt({aptosConfig:t,authenticationKey:p.authKey().derivedAddress()});return Qe.create({...n,address:d,proof:c,pepper:s,proofFetchCallback:o})}async function ca(n){let{aptosConfig:t,sender:e,iss:r}=n,i=_nullishCoalesce(n.jwksUrl, () => ((r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`))),o=await fetch(i);if(!o.ok)throw new Error(`Failed to fetch JWKS: ${o.status} ${o.statusText}`);let s=await o.json();return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,h.MoveString(s.keys.map(a=>a.kid)),h.MoveString(s.keys.map(a=>a.alg)),h.MoveString(s.keys.map(a=>a.e)),h.MoveString(s.keys.map(a=>a.n))]}})}var Pn=class{constructor(t){this.config=t}async getPepper(t){return br({aptosConfig:this.config,...t})}async getProof(t){return fi({aptosConfig:this.config,...t})}async deriveKeylessAccount(t){return aa({aptosConfig:this.config,...t})}async updateFederatedKeylessJwkSetTransaction(t){return ca({aptosConfig:this.config,...t})}};async function uu(n){let{aptosConfig:t,options:e}=n,r={query:jn,variables:{where_condition:_optionalChain([e, 'optionalAccess', _225 => _225.where]),offset:_optionalChain([e, 'optionalAccess', _226 => _226.offset]),limit:_optionalChain([e, 'optionalAccess', _227 => _227.limit]),order_by:_optionalChain([e, 'optionalAccess', _228 => _228.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getObjectData"})).current_objects}async function ua(n){let{aptosConfig:t,objectAddress:e,options:r}=n,o={object_address:{_eq:u.from(e).toStringLong()}};return(await uu({aptosConfig:t,options:{...r,where:o}}))[0]}var vn=class{constructor(t){this.config=t}async getObjectDataByObjectAddress(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"objects_processor"}),ua({aptosConfig:this.config,...t})}};var Z=class{constructor(t){this.config=new pr(t),this.account=new dn(this.config),this.ans=new wn(this.config),this.coin=new gn(this.config),this.digitalAsset=new mn(this.config),this.event=new fn(this.config),this.faucet=new An(this.config),this.fungibleAsset=new hn(this.config),this.general=new bn(this.config),this.staking=new Sn(this.config),this.transaction=new xn(this.config),this.table=new _n(this.config),this.keyless=new Pn(this.config),this.object=new vn(this.config)}};function oe(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(t.prototype,r);i&&(i.value=function(...o){return this[e][r](...o)},Object.defineProperty(n.prototype,r,i))})}oe(Z,dn,"account");oe(Z,wn,"ans");oe(Z,gn,"coin");oe(Z,mn,"digitalAsset");oe(Z,fn,"event");oe(Z,An,"faucet");oe(Z,hn,"fungibleAsset");oe(Z,bn,"general");oe(Z,Sn,"staking");oe(Z,xn,"transaction");oe(Z,_n,"table");oe(Z,Pn,"keyless");oe(Z,vn,"object");exports.APTOS_BIP44_REGEX = xa; exports.APTOS_COIN = ot; exports.APTOS_FA = Vi; exports.APTOS_HARDENED_REGEX = Sa; exports.Account = Le; exports.AccountAddress = u; exports.AccountAuthenticator = j; exports.AccountAuthenticatorEd25519 = be; exports.AccountAuthenticatorMultiEd25519 = On; exports.AccountAuthenticatorMultiKey = ct; exports.AccountAuthenticatorSingleKey = te; exports.AccountAuthenticatorVariant = Pi; exports.AccountPublicKey = ee; exports.AccountSequenceNumber = fr; exports.AddressInvalidReason = ha; exports.AnyPublicKey = k; exports.AnyPublicKeyVariant = Kn; exports.AnySignature = M; exports.AnySignatureVariant = vi; exports.Aptos = Z; exports.AptosApiError = Ae; exports.AptosApiType = wt; exports.AptosConfig = pr; exports.AuthenticationKey = D; exports.Bool = I; exports.CKDPriv = Di; exports.ChainId = Ct; exports.DEFAULT_MAX_GAS_AMOUNT = Mi; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = qi; exports.DEFAULT_TXN_TIMEOUT_SEC = Fn; exports.DeriveScheme = Ii; exports.Deserializer = q; exports.EPK_HORIZON_SECS = ql; exports.Ed25519Account = Dt; exports.Ed25519PrivateKey = W; exports.Ed25519PublicKey = P; exports.Ed25519Signature = C; exports.EntryFunction = pt; exports.EntryFunctionBytes = Un; exports.EphemeralCertificate = xt; exports.EphemeralCertificateVariant = xr; exports.EphemeralKeyPair = mt; exports.EphemeralPublicKey = it; exports.EphemeralPublicKeyVariant = Sr; exports.EphemeralSignature = we; exports.EphemeralSignatureVariant = Ci; exports.FederatedKeylessAccount = Hn; exports.FederatedKeylessPublicKey = he; exports.FeePayerRawTransaction = lt; exports.FixedBytes = et; exports.Groth16Zkp = _t; exports.HARDENED_OFFSET = Ki; exports.Hex = g; exports.HexInvalidReason = ga; exports.Identifier = R; exports.KeyType = _a; exports.KeylessAccount = Qe; exports.KeylessAccountCommon = He; exports.KeylessConfiguration = Nr; exports.KeylessPublicKey = G; exports.KeylessSignature = Ie; exports.MAX_AUD_VAL_BYTES = ec; exports.MAX_COMMITED_EPK_BYTES = Hl; exports.MAX_EXTRA_FIELD_BYTES = $l; exports.MAX_ISS_VAL_BYTES = Vl; exports.MAX_JWT_HEADER_B64_BYTES = Ll; exports.MAX_UID_KEY_BYTES = tc; exports.MAX_UID_VAL_BYTES = nc; exports.MimeType = Rn; exports.ModuleId = Jt; exports.MoveAbility = Ei; exports.MoveFunctionVisibility = ya; exports.MoveOption = L; exports.MoveString = S; exports.MoveVector = h; exports.MultiAgentRawTransaction = dt; exports.MultiAgentTransaction = Ln; exports.MultiEd25519PublicKey = ht; exports.MultiEd25519Signature = nt; exports.MultiKey = vt; exports.MultiKeyAccount = Qn; exports.MultiKeySignature = at; exports.MultiSig = on; exports.MultiSigTransactionPayload = sn; exports.Network = Dr; exports.NetworkToChainId = Br; exports.NetworkToFaucetAPI = Wi; exports.NetworkToIndexerAPI = Hi; exports.NetworkToNetworkName = Vd; exports.NetworkToNodeAPI = Qi; exports.NetworkToPepperAPI = zr; exports.NetworkToProverAPI = kr; exports.ParsingError = J; exports.ProcessorType = Ce; exports.PublicKey = tt; exports.RAW_TRANSACTION_SALT = $i; exports.RAW_TRANSACTION_WITH_DATA_SALT = Rr; exports.RawTransaction = pe; exports.RawTransactionWithData = qn; exports.RoleType = fa; exports.RotationProofChallenge = Vn; exports.Script = rn; exports.ScriptTransactionArgumentVariants = Wt; exports.Secp256k1PrivateKey = rt; exports.Secp256k1PublicKey = ve; exports.Secp256k1Signature = Tt; exports.Serializable = l; exports.Serialized = jt; exports.Serializer = V; exports.Signature = B; exports.SignedTransaction = gt; exports.SigningScheme = le; exports.SigningSchemeInput = vr; exports.SimpleTransaction = $n; exports.SingleKeyAccount = Bt; exports.StructTag = Ue; exports.TransactionAndProof = $r; exports.TransactionAuthenticator = Re; exports.TransactionAuthenticatorEd25519 = It; exports.TransactionAuthenticatorFeePayer = Rt; exports.TransactionAuthenticatorMultiAgent = Ut; exports.TransactionAuthenticatorMultiEd25519 = qr; exports.TransactionAuthenticatorSingleSender = Kt; exports.TransactionAuthenticatorVariant = _i; exports.TransactionPayload = ut; exports.TransactionPayloadEntryFunction = tn; exports.TransactionPayloadMultiSig = nn; exports.TransactionPayloadScript = en; exports.TransactionPayloadVariants = Si; exports.TransactionResponseType = Pr; exports.TransactionVariants = xi; exports.TransactionWorker = Ar; exports.TransactionWorkerEventsEnum = sa; exports.TypeTag = K; exports.TypeTagAddress = X; exports.TypeTagBool = F; exports.TypeTagGeneric = z; exports.TypeTagParserError = N; exports.TypeTagParserErrorType = _c; exports.TypeTagReference = Mn; exports.TypeTagSigner = Et; exports.TypeTagStruct = y; exports.TypeTagU128 = Ve; exports.TypeTagU16 = Me; exports.TypeTagU256 = $e; exports.TypeTagU32 = qe; exports.TypeTagU64 = Q; exports.TypeTagU8 = ue; exports.TypeTagVariants = wi; exports.TypeTagVector = E; exports.U128 = ye; exports.U16 = ge; exports.U256 = fe; exports.U32 = me; exports.U64 = O; exports.U8 = $; exports.ZeroKnowledgeSig = ce; exports.ZkProof = Pt; exports.ZkpVariant = _r; exports.aptosCoinStructTag = Cm; exports.aptosRequest = Nn; exports.base64UrlDecode = _chunkHBPH2AD3js.e; exports.buildTransaction = ci; exports.checkOrConvertArgument = Mt; exports.convertAmountFromHumanReadableToOnChain = _chunkHBPH2AD3js.f; exports.convertAmountFromOnChainToHumanReadable = _chunkHBPH2AD3js.g; exports.convertArgument = ai; exports.convertNumber = ir; exports.createObjectAddress = Mr; exports.createResourceAddress = rm; exports.createTokenAddress = im; exports.deriveKey = Cr; exports.deriveTransactionType = Vr; exports.deserializeFromScriptArgument = sc; exports.ensureBoolean = wr; exports.fetchEntryFunctionAbi = Yo; exports.fetchFunctionAbi = Zo; exports.fetchViewFunctionAbi = Jo; exports.findFirstNonSignerArg = Wo; exports.floorToWholeHour = _chunkHBPH2AD3js.d; exports.generateRawTransaction = Rc; exports.generateSignedTransaction = ui; exports.generateSignedTransactionForSimulation = ts; exports.generateSigningMessage = zt; exports.generateSigningMessageForSerializable = Ny; exports.generateSigningMessageForTransaction = kt; exports.generateTransactionPayload = ur; exports.generateTransactionPayloadWithABI = Ec; exports.generateUserTransactionHash = jh; exports.generateViewFunctionPayload = es; exports.generateViewFunctionPayloadWithABI = Ic; exports.get = Gr; exports.getAptosFullNode = H; exports.getAptosPepperService = ll; exports.getAuthenticatorForSimulation = cr; exports.getFunctionParts = un; exports.getKeylessConfig = to; exports.hashValues = ns; exports.isBcsAddress = sr; exports.isBcsBool = Yr; exports.isBcsFixedBytes = bc; exports.isBcsString = Jr; exports.isBcsU128 = ii; exports.isBcsU16 = ti; exports.isBcsU256 = oi; exports.isBcsU32 = ni; exports.isBcsU64 = ri; exports.isBcsU8 = ei; exports.isBlockEpilogueTransactionResponse = Ou; exports.isBlockMetadataTransactionResponse = Gu; exports.isBool = $o; exports.isCanonicalEd25519Signature = va; exports.isEd25519Signature = Mu; exports.isEmptyOption = Lo; exports.isEncodedEntryFunctionArgument = Ho; exports.isEncodedStruct = _chunkHBPH2AD3js.i; exports.isFeePayerSignature = $u; exports.isGenesisTransactionResponse = Bu; exports.isLargeNumber = or; exports.isMultiAgentSignature = Vu; exports.isMultiEd25519Signature = Lu; exports.isNumber = hc; exports.isPendingTransactionResponse = ku; exports.isScriptDataInput = Qo; exports.isSecp256k1Signature = qu; exports.isStateCheckpointTransactionResponse = Fu; exports.isString = We; exports.isUserTransactionResponse = Du; exports.isValidBIP44Path = zi; exports.isValidHardenedPath = ki; exports.isValidatorTransactionResponse = Nu; exports.mnemonicToSeed = zn; exports.normalizeBundle = ji; exports.nowInSeconds = _chunkHBPH2AD3js.c; exports.objectStructTag = ie; exports.optionStructTag = Em; exports.outOfRangeErrorMessage = ma; exports.paginateWithCursor = St; exports.parseEncodedStruct = _chunkHBPH2AD3js.h; exports.parseTypeTag = Ke; exports.post = Yt; exports.postAptosFaucet = Zi; exports.postAptosFullNode = Ne; exports.postAptosIndexer = Xi; exports.postAptosPepperService = Yi; exports.postAptosProvingService = Ji; exports.promiseFulfilledStatus = oa; exports.request = Ya; exports.sleep = _chunkHBPH2AD3js.b; exports.splitPath = Bi; exports.standardizeTypeTags = ar; exports.stringStructTag = v; exports.throwTypeMismatch = U; exports.validateNumberInRange = De;
|
|
472
|
+
`;async function Xn(n){let{aptosConfig:t}=n,{data:e}=await H({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function So(n){let{aptosConfig:t,limit:e}=n;return(await f({aptosConfig:t,query:{query:po,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:i}=await Xi({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return i}async function fc(n){let{aptosConfig:t}=n;return(await f({aptosConfig:t,query:{query:Hr},originMethod:"getProcessorStatuses"})).processor_status}async function Zn(n){let t=await fc({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function Yn(n){let{aptosConfig:t,processorType:e}=n;return(await f({aptosConfig:t,query:{query:Hr,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Jn(n){let{aptosConfig:t,handle:e,data:r,options:i}=n;return(await Ne({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _54 => _54.ledgerVersion])},body:r})).data}async function xo(n){let{aptosConfig:t,options:e}=n,r={query:ho,variables:{where_condition:_optionalChain([e, 'optionalAccess', _55 => _55.where]),offset:_optionalChain([e, 'optionalAccess', _56 => _56.offset]),limit:_optionalChain([e, 'optionalAccess', _57 => _57.limit]),order_by:_optionalChain([e, 'optionalAccess', _58 => _58.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getTableItemsData"})).table_items}async function _o(n){let{aptosConfig:t,options:e}=n,r={query:bo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _59 => _59.where]),offset:_optionalChain([e, 'optionalAccess', _60 => _60.offset]),limit:_optionalChain([e, 'optionalAccess', _61 => _61.limit]),order_by:_optionalChain([e, 'optionalAccess', _62 => _62.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function xe(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await H({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function Co(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return St({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _63 => _63.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _64 => _64.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _65 => _65.limit]), () => (1e3))}})}async function er(n){return _optionalChain([n, 'access', _66 => _66.options, 'optionalAccess', _67 => _67.ledgerVersion])!==void 0?Po(n):Oe(async()=>Po(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function Po(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:i}=n,{data:o}=await H({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _68 => _68.ledgerVersion])}});return o}async function Eo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return St({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([r, 'optionalAccess', _70 => _70.limit])}})}async function Io(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return St({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _71 => _71.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _72 => _72.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _73 => _73.limit]), () => (999))}})}async function Wr(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:i}=n,{data:o}=await H({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _74 => _74.ledgerVersion])}});return o.data}async function Nt(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,i=await Wr({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(e);try{let a=await Jn({aptosConfig:t,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Uo(n){let{aptosConfig:t,accountAddress:e}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},s=await f({aptosConfig:t,query:{query:co,variables:{where_condition:i}},originMethod:"getAccountTokensCount"});return s.current_token_ownerships_v2_aggregate.aggregate?s.current_token_ownerships_v2_aggregate.aggregate.count:0}async function Ro(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _75 => _75.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _76 => _76.tokenStandard])});let s={query:so,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _77 => _77.offset]),limit:_optionalChain([r, 'optionalAccess', _78 => _78.limit]),order_by:_optionalChain([r, 'optionalAccess', _79 => _79.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Ko(n){let{aptosConfig:t,accountAddress:e,collectionAddress:r,options:i}=n,o=u.from(e).toStringLong(),s=u.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _80 => _80.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _81 => _81.tokenStandard])});let c={query:ao,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _82 => _82.offset]),limit:_optionalChain([i, 'optionalAccess', _83 => _83.limit]),order_by:_optionalChain([i, 'optionalAccess', _84 => _84.orderBy])}};return(await f({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function zo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}};_optionalChain([r, 'optionalAccess', _85 => _85.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _86 => _86.tokenStandard])}});let s={query:oo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _87 => _87.offset]),limit:_optionalChain([r, 'optionalAccess', _88 => _88.limit]),order_by:_optionalChain([r, 'optionalAccess', _89 => _89.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function ko(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:uo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function Do(n){let{aptosConfig:t,accountAddress:e,coinType:r,faMetadataAddress:i}=n,o=r,s;if(r!==void 0&&i!==void 0)s=u.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===ot?s=u.A.toStringLong():s=Mr(u.A,r).toStringLong();else if(r===void 0&&i!==void 0){let d=u.from(i);s=d.toStringLong(),d===u.A&&(o=ot)}else throw new Error("Either coinType, fungibleAssetAddress, or both must be provided");let a=u.from(e).toStringLong(),c={asset_type:{_eq:s}};o!==void 0&&(c={asset_type:{_in:[o,s]}});let p=await jr({aptosConfig:t,accountAddress:a,options:{where:c}});return p[0]?p[0].amount:0}async function jr(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i=u.from(e).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _90 => _90.where]),owner_address:{_eq:i}},s={query:io,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _91 => _91.offset]),limit:_optionalChain([r, 'optionalAccess', _92 => _92.limit]),order_by:_optionalChain([r, 'optionalAccess', _93 => _93.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Bo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:ro,variables:{address:r}},originMethod:"getAccountCoinsCount"});if(!o.current_fungible_asset_balances_aggregate.aggregate)throw Error("Failed to get the count of account coins");return o.current_fungible_asset_balances_aggregate.aggregate.count}async function Go(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}},s={query:jn,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _94 => _94.offset]),limit:_optionalChain([r, 'optionalAccess', _95 => _95.limit]),order_by:_optionalChain([r, 'optionalAccess', _96 => _96.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function Fo(n){let{aptosConfig:t,privateKey:e}=n,r=new k(e.publicKey());if(e instanceof rt){let o=D.fromPublicKey({publicKey:r}).derivedAddress();return Le.fromPrivateKey({privateKey:e,address:o})}if(e instanceof W){let i=D.fromPublicKey({publicKey:r});if(await vo({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return Le.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=D.fromPublicKey({publicKey:r.publicKey});if(await vo({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return Le.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function vo(n){let{aptosConfig:t,authKey:e}=n,r=await Nt({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await xe({aptosConfig:t,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function Zr(n){let{aptosConfig:t,options:e}=n;return St({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _97 => _97.offset]),limit:_optionalChain([e, 'optionalAccess', _98 => _98.limit])}})}async function nr(n){let{aptosConfig:t}=n;return Oe(async()=>{let{data:e}=await H({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function No(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await H({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function cn(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await H({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function Oo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await cn({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _99 => _99.status])===404)return!0;throw r}}async function Ac(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await H({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function Ot(n){let{aptosConfig:t,transactionHash:e,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _100 => _100.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _101 => _101.checkSuccess]), () => (!0)),s=!0,a=0,c,p,d=200,T=1.5;function w(m){if(!(m instanceof Ae)||(p=m,m.status!==404&&m.status>=400&&m.status<500))throw m}try{c=await cn({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(m){w(m)}if(s){let m=Date.now();try{c=await Ac({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(_){w(_)}a=(Date.now()-m)/1e3}for(;s&&!(a>=i);){try{if(c=await cn({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(m){w(m)}await _chunkHBPH2AD3js.b.call(void 0, d),a+=d/1e3,d*=T}if(c===void 0)throw p||new tr(`Fetching transaction ${e} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new tr(`Transaction ${e} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Xr(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function rr(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?s=await Zn({aptosConfig:t}):s=(await Yn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkHBPH2AD3js.b.call(void 0, 200)}}var tr=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Xr=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function Mo(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:i}=await H({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _102 => _102.withTransactions])}});return Vo({block:i,...n})}async function qo(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:i}=await H({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _103 => _103.withTransactions])}});return Vo({block:i,...n})}async function Vo(n){let{aptosConfig:t,block:e,options:r}=n;if(_optionalChain([r, 'optionalAccess', _104 => _104.withTransactions])){e.transactions=_nullishCoalesce(e.transactions, () => ([]));let i=e.transactions[e.transactions.length-1],o=BigInt(e.first_version),s=BigInt(e.last_version),a=_optionalChain([i, 'optionalAccess', _105 => _105.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return e;let p=[],d=100n;for(let w=c+1n;w<s;w+=BigInt(100))p.push(Zr({aptosConfig:t,options:{offset:w,limit:Math.min(Number(d),Number(s-w+1n))}}));let T=await Promise.all(p);for(let w of T)e.transactions.push(...w)}return e}async function A(n){n.minimumLedgerVersion!==void 0&&await rr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}function $o(n){return typeof n=="boolean"}function We(n){return typeof n=="string"}function hc(n){return typeof n=="number"}function ir(n){if(hc(n))return n;if(We(n)&&n!=="")return Number.parseInt(n,10)}function or(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Lo(n){return n==null}function Ho(n){return Yr(n)||ei(n)||ti(n)||ni(n)||ri(n)||ii(n)||oi(n)||sr(n)||Jr(n)||bc(n)||n instanceof h||n instanceof L}function Yr(n){return n instanceof I}function sr(n){return n instanceof u}function Jr(n){return n instanceof S}function bc(n){return n instanceof et}function ei(n){return n instanceof $}function ti(n){return n instanceof ge}function ni(n){return n instanceof me}function ri(n){return n instanceof O}function ii(n){return n instanceof ye}function oi(n){return n instanceof fe}function Qo(n){return"bytecode"in n}function U(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Wo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function un(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],i=t[2];return{moduleAddress:e,moduleName:r,functionName:i}}function jo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Xo(n){return!!n.match(/\s/)}function Tc(n){return!!n.match(/^T[0-9]+$/)}function wc(n){return!!n.match(/^&.+$/)}function Sc(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function xc(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!Xo(r))break}return e}var _c=(_=>(_.InvalidTypeTag="unknown type",_.UnexpectedGenericType="unexpected generic type",_.UnexpectedTypeArgumentClose="unexpected '>'",_.UnexpectedWhitespaceCharacter="unexpected whitespace character",_.UnexpectedComma="unexpected ','",_.TypeArgumentCountMismatch="type argument count doesn't match expected amount",_.MissingTypeArgumentClose="no matching '>' for '<'",_.MissingTypeArgument="no type argument before ','",_.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",_.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",_.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",_.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",_.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",_.InvalidAddress="struct address must be valid",_))(_c||{}),N= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Ke(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _106 => _106.allowGenerics]), () => (!1)),r=[],i=[],o=[],s=0,a="",c=1;for(;s<n.length;){let p=n[s];if(p==="<")r.push({savedExpectedTypes:c,savedStr:a,savedTypes:o}),a="",o=[],c=1;else if(p===">"){if(a!==""){let _=pn(a,i,e);o.push(_)}let d=r.pop();if(d===void 0)throw new N(n,"unexpected '>'");if(c!==o.length)throw new N(n,"type argument count doesn't match expected amount");let{savedStr:T,savedTypes:w,savedExpectedTypes:m}=d;i=o,o=w,a=T,c=m}else if(p===","){if(r.length===0)throw new N(n,"unexpected ','");if(a.length===0)throw new N(n,"no type argument before ','");let d=pn(a,i,e);i=[],o.push(d),a="",c+=1}else if(Xo(p)){let d=!1;if(a.length!==0){let w=pn(a,i,e);i=[],o.push(w),a="",d=!0}s=xc(n,s);let T=n[s];if(s<n.length&&d&&T!==","&&T!==">")throw new N(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new N(n,"no matching '>' for '<'");switch(o.length){case 0:return pn(a,i,e);case 1:if(a==="")return o[0];throw new N(n,"unexpected ','");default:throw new N(n,"unexpected whitespace character")}}function pn(n,t,e){let r=n.trim(),i=r.toLowerCase();if(Sc(i)&&t.length>0)throw new N(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Et;case"bool":return new F;case"address":return new X;case"u8":return new ue;case"u16":return new Me;case"u32":return new qe;case"u64":return new Q;case"u128":return new Ve;case"u256":return new $e;case"vector":if(t.length!==1)throw new N(n,"vector type expected to have exactly one type argument");return new E(t[0]);default:if(wc(r)){let a=r.substring(1);return new Mn(pn(a,t,e))}if(Tc(r)){if(e)return new z(Number(r.split("T")[1]));throw new N(n,"unexpected generic type")}if(!r.match(/:/))throw new N(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new N(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=u.fromString(o[0])}catch (e2){throw new N(n,"struct address must be valid")}if(!jo(o[1]))throw new N(n,"module name must only contain alphanumeric or '_' characters");if(!jo(o[2]))throw new N(n,"struct name must only contain alphanumeric or '_' characters");return new y(new Ue(s,new R(o[1]),new R(o[2]),t))}}var Pc=new TextEncoder;function ar(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _107 => _107.map, 'call', _108 => _108(t=>We(t)?Ke(t):t)]), () => ([]))}async function Zo(n,t,e,r){let i=await er({aptosConfig:r,accountAddress:n,moduleName:t});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===e)}async function Yo(n,t,e,r){let i=await Zo(n,t,e,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${t}::${e}'`);if(!i.is_entry)throw new Error(`'${n}::${t}::${e}' is not an entry function`);let o=Wo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ke(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Jo(n,t,e,r){let i=await Zo(n,t,e,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${t}::${e}'`);if(!i.is_view)throw new Error(`'${n}::${t}::${e}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Ke(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ke(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function ai(n,t,e,r,i){if(r>=t.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${t.parameters.length}`);let o=t.parameters[r];return Mt(e,o,r,i)}function Mt(n,t,e,r){return Ho(n)?(si(t,n,e),n):vc(n,t,e,r)}function vc(n,t,e,r){if(t.isBool()){if($o(n))return new I(n);if(We(n)){if(n==="true")return new I(!0);if(n==="false")return new I(!1)}U("boolean",e)}if(t.isAddress()){if(We(n))return u.fromString(n);U("string | AccountAddress",e)}if(t.isU8()){let i=ir(n);if(i!==void 0)return new $(i);U("number | string",e)}if(t.isU16()){let i=ir(n);if(i!==void 0)return new ge(i);U("number | string",e)}if(t.isU32()){let i=ir(n);if(i!==void 0)return new me(i);U("number | string",e)}if(t.isU64()){if(or(n))return new O(BigInt(n));U("bigint | number | string",e)}if(t.isU128()){if(or(n))return new ye(BigInt(n));U("bigint | number | string",e)}if(t.isU256()){if(or(n))return new fe(BigInt(n));U("bigint | number | string",e)}if(t.isGeneric()){let i=t.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return Mt(n,r[i],e,r)}if(t.isVector()){if(t.value.isU8()){if(We(n))return h.U8(Pc.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(i=>Mt(i,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(We(n))return new S(n);U("string",e)}if(t.isObject()){if(We(n))return u.fromString(n);U("string | AccountAddress",e)}if(t.isOption()){if(Lo(n)){let i=t.value.typeArgs[0];return i instanceof F?new L(null):i instanceof X?new L(null):i instanceof ue?new L(null):i instanceof Me?new L(null):i instanceof qe?new L(null):i instanceof Q?new L(null):i instanceof Ve?new L(null):i instanceof $e?new L(null):new L(null)}return new L(Mt(n,t.value.typeArgs[0],e,r))}throw new Error(`Unsupported struct input type for argument ${e}, type '${t.toString()}'`)}throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}function si(n,t,e){if(n.isBool()){if(Yr(t))return;U("Bool",e)}if(n.isAddress()){if(sr(t))return;U("AccountAddress",e)}if(n.isU8()){if(ei(t))return;U("U8",e)}if(n.isU16()){if(ti(t))return;U("U16",e)}if(n.isU32()){if(ni(t))return;U("U32",e)}if(n.isU64()){if(ri(t))return;U("U64",e)}if(n.isU128()){if(ii(t))return;U("U128",e)}if(n.isU256()){if(oi(t))return;U("U256",e)}if(n.isVector()){if(t instanceof h){t.values.length>0&&si(n.value,t.values[0],e);return}U("MoveVector",e)}if(n instanceof y){if(n.isString()){if(Jr(t))return;U("MoveString",e)}if(n.isObject()){if(sr(t))return;U("AccountAddress",e)}if(n.isOption()){if(t instanceof L){t.value!==void 0&&si(n.value.typeArgs[0],t.value,e);return}U("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}async function ur(n){if(Qo(n))return Uc(n);let{moduleAddress:t,moduleName:e,functionName:r}=un(n.function),i=await rs({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Yo});return Ec({...n,abi:i})}function Ec(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=un(n.function),o=ar(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>ai(n.function,t,c,p,o));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);let a=pt.build(`${e}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new nn(new on(c,new sn(a)))}return new tn(a)}async function es(n){let{moduleAddress:t,moduleName:e,functionName:r}=un(n.function),i=await rs({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Jo});return Ic({abi:i,...n})}function Ic(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=un(n.function),o=ar(n.typeArguments);if(o.length!==t.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${t.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _109 => _109.functionArguments, 'optionalAccess', _110 => _110.map, 'call', _111 => _111((a,c)=>ai(n.function,t,a,c,o))]), () => ([]));if(s.length!==t.parameters.length)throw new Error(`Too few arguments for '${e}::${r}::${i}', expected ${t.parameters.length} but got ${s.length}`);return pt.build(`${e}::${r}`,i,o,s)}function Uc(n){return new en(new rn(g.fromHexInput(n.bytecode).toUint8Array(),ar(n.typeArguments),n.functionArguments))}async function Rc(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=async()=>Br[t.network]?{chainId:Br[t.network]}:{chainId:(await Xn({aptosConfig:t})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _112 => _112.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await nr({aptosConfig:t})).gas_estimate},c=async()=>{let yt=async()=>_optionalChain([i, 'optionalAccess', _113 => _113.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await xe({aptosConfig:t,accountAddress:e})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await yt()}catch (e3){return 0}else return yt()},[{chainId:p},{gasEstimate:d},T]=await Promise.all([s(),a(),c()]),{maxGasAmount:w,gasUnitPrice:m,expireTimestamp:_}={maxGasAmount:_optionalChain([i, 'optionalAccess', _114 => _114.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _115 => _115.gasUnitPrice]), () => (BigInt(d))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _116 => _116.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new pe(u.from(e),BigInt(T),r,BigInt(w),BigInt(m),BigInt(_),new Ct(p))}async function ci(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=await Rc({aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _117 => _117.secondarySignerAddresses, 'optionalAccess', _118 => _118.map, 'call', _119 => _119(c=>u.from(c))]), () => ([]));return new Ln(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new $n(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function ts(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=cr(t);if(e.feePayerAddress){let a=new lt(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(T=>cr(T)));let p=cr(i),d=new Rt(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new gt(a.raw_txn,d).bcsToBytes()}if(e.secondarySignerAddresses){let a=new dt(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(d=>cr(d));let p=new Ut(o,e.secondarySignerAddresses,c);return new gt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof be)s=new It(o.public_key,o.signature);else if(o instanceof te)s=new Kt(o);else throw new Error("Invalid public key");return new gt(e.rawTransaction,s).bcsToBytes()}function cr(n){let e=G.isInstance(n)||he.isInstance(n)||ve.isInstance(n)?new k(n):n,r=new C(new Uint8Array(64));if(P.isInstance(e))return new be(e,r);if(k.isInstance(e))return G.isInstance(e.publicKey)?new te(e,new M(Ie.getSimulationSignature())):new te(e,new M(r));throw new Error("Unsupported public key")}function ui(n){let{transaction:t,feePayerAuthenticator:e,additionalSignersAuthenticators:r}=n,i=ji(j,n.senderAuthenticator),o;if(t.feePayerAddress){if(!e)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Rt(i,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:t.feePayerAddress,authenticator:e})}else if(t.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Ut(i,t.secondarySignerAddresses,r)}else i instanceof be?o=new It(i.public_key,i.signature):o=new Kt(i);return new gt(t.rawTransaction,o).bcsToBytes()}function ns(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var Kc=ns(["APTOS::Transaction"]);function jh(n){let t=ui(n);return new g(ns([Kc,new Uint8Array([0]),t])).toString()}async function rs({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Oe(async()=>s(t,e,r,i),`${n}-${i.network}-${t}-${e}-${r}`,1e3*60*5)()}async function _e(n){let{aptosConfig:t,payload:e,options:r}=n,i=await es({...e,aptosConfig:t}),o=new V;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Ne({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _120 => _120.ledgerVersion])},body:s});return a}async function is(n){let{aptosConfig:t,payload:e,options:r}=n,{data:i}=await Ne({aptosConfig:t,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _121 => _121.ledgerVersion])},body:{function:e.function,type_arguments:_nullishCoalesce(e.typeArguments, () => ([])),arguments:_nullishCoalesce(e.functionArguments, () => ([]))}});return i}var dn=class{constructor(t){this.config=t}async getAccountInfo(t){return xe({aptosConfig:this.config,...t})}async getAccountModules(t){return Co({aptosConfig:this.config,...t})}async getAccountModule(t){return er({aptosConfig:this.config,...t})}async getAccountTransactions(t){return Eo({aptosConfig:this.config,...t})}async getAccountResources(t){return Io({aptosConfig:this.config,...t})}async getAccountResource(t){return Wr({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Nt({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),Uo({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ro({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ko({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),zo({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),ko({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),jr({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Bo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:ot,faMetadataAddress:Vi,...t})}async getAccountCoinAmount(t){let{coinType:e,faMetadataAddress:r}=t;await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"});let i=e;if(e===void 0&&r!==void 0)try{let o=(await _e({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[r]}})).at(0);o.vec.length>0&&_chunkHBPH2AD3js.i.call(void 0, o.vec[0])&&(i=_chunkHBPH2AD3js.h.call(void 0, o.vec[0]))}catch (e4){}return Do({aptosConfig:this.config,...t,coinType:i})}async getAccountOwnedObjects(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),Go({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return Fo({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var pr=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _122 => _122.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _123 => _123.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _124 => _124.faucet]),this.pepper=_optionalChain([t, 'optionalAccess', _125 => _125.pepper]),this.prover=_optionalChain([t, 'optionalAccess', _126 => _126.prover]),this.indexer=_optionalChain([t, 'optionalAccess', _127 => _127.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _128 => _128.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _129 => _129.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _130 => _130.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _131 => _131.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _132 => _132.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 Qi[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 Wi[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 Hi[this.network];case"Pepper":if(this.pepper!==void 0)return this.pepper;if(this.network==="custom")throw new Error("Please provide a custom pepper service url");return zr[this.network];case"Prover":if(this.prover!==void 0)return this.prover;if(this.network==="custom")throw new Error("Please provide a custom prover service url");return kr[this.network];default:throw Error(`apiType ${t} is not supported`)}}isPepperServiceRequest(t){return zr[this.network]===t}isProverServiceRequest(t){return kr[this.network]===t}};async function b(n){let t=await kc(n);return Dc(n,t)}async function kc(n){let{aptosConfig:t,data:e}=n,r,i;return"bytecode"in e?i=await ur(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await ur(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await ur(r)),i}async function Dc(n,t){let{aptosConfig:e,sender:r,options:i}=n,o;if(Bc(n)&&(o=u.ZERO.toString()),Gc(n)){let{secondarySignerAddresses:s}=n;return ci({aptosConfig:e,sender:r,payload:t,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return ci({aptosConfig:e,sender:r,payload:t,options:i,feePayerAddress:o})}function Bc(n){return n.withFeePayer===!0}function Gc(n){return"secondarySignerAddresses"in n}function os(n){let{transaction:t}=n;return kt(t)}function dr(n){let{signer:t,transaction:e}=n;return t.signTransactionWithAuthenticator(e)}async function pi(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=ts({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await Ne({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _133 => _133.options, 'optionalAccess', _134 => _134.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _137 => _137.options, 'optionalAccess', _138 => _138.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function lr(n){let{aptosConfig:t}=n,e=ui({...n}),{data:r}=await Ne({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function ln(n){let{aptosConfig:t,signer:e,transaction:r}=n;(e instanceof He||e instanceof Qn)&&await e.waitForProofFetch();let i=dr({signer:e,transaction:r});return lr({aptosConfig:t,transaction:r,senderAuthenticator:i})}var Fc={typeParameters:[],parameters:[E.u8(),new E(E.u8())]};async function ss(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>h.U8(a));return b({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[h.U8(r),new h(s)],abi:Fc},options:o})}var Nc={typeParameters:[],parameters:[new ue,E.u8(),new ue,E.u8(),E.u8(),E.u8()]};async function as(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,i=await xe({aptosConfig:t,accountAddress:e.accountAddress}),o=Le.fromPrivateKey({privateKey:r,legacy:!0}),a=new Vn({sequenceNumber:BigInt(i.sequence_number),originator:e.accountAddress,currentAuthKey:u.from(i.authentication_key),newPublicKey:o.publicKey}).bcsToBytes(),c=e.sign(a),p=o.sign(a),d=await b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new $(e.signingScheme),h.U8(e.publicKey.toUint8Array()),new $(o.signingScheme),h.U8(o.publicKey.toUint8Array()),h.U8(c.toUint8Array()),h.U8(p.toUint8Array())],abi:Nc}});return ln({aptosConfig:t,signer:e,transaction:d})}var Oc={typeParameters:[{constraints:[]}],parameters:[new X,new Q]};async function cs(n){let{aptosConfig:t,sender:e,recipient:r,amount:i,coinType:o,options:s}=n;return b({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (ot))],functionArguments:[r,i],abi:Oc},options:s})}var gn=class{constructor(t){this.config=t}async transferCoinTransaction(t){return cs({aptosConfig:this.config,...t})}};var je={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},de="0x4::token::Token";async function us(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:wo,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ps(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};return(await f({aptosConfig:t,query:{query:Qr,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ds(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},o={query:Qr,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _139 => _139.offset]),limit:_optionalChain([r, 'optionalAccess', _140 => _140.limit]),order_by:_optionalChain([r, 'optionalAccess', _141 => _141.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function ls(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,i={token_data_id:{_eq:u.from(e).toStringLong()}},o={query:To,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _142 => _142.offset]),limit:_optionalChain([r, 'optionalAccess', _143 => _143.limit]),order_by:_optionalChain([r, 'optionalAccess', _144 => _144.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Mc={typeParameters:[],parameters:[new y(v()),new Q,new y(v()),new y(v()),new F,new F,new F,new F,new F,new F,new F,new F,new F,new Q,new Q]};async function gs(n){let{aptosConfig:t,options:e,creator:r}=n;return b({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new S(n.description),new O(_nullishCoalesce(n.maxSupply, () => (Ye))),new S(n.name),new S(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 O(_nullishCoalesce(n.royaltyNumerator, () => (0))),new O(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Mc},options:e})}async function qt(n){let{aptosConfig:t,options:e}=n,r=_optionalChain([e, 'optionalAccess', _145 => _145.where]);_optionalChain([e, 'optionalAccess', _146 => _146.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([e, 'optionalAccess', _147 => _147.tokenStandard]), () => ("v2"))});let i={query:lo,variables:{where_condition:r,offset:_optionalChain([e, 'optionalAccess', _148 => _148.offset]),limit:_optionalChain([e, 'optionalAccess', _149 => _149.limit])}};return(await f({aptosConfig:t,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function ms(n){let{aptosConfig:t,creatorAddress:e,collectionName:r,options:i}=n,o=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _150 => _150.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _151 => _151.tokenStandard]), () => ("v2"))}),qt({aptosConfig:t,options:{...i,where:s}})}async function ys(n){let{aptosConfig:t,creatorAddress:e,options:r}=n,o={creator_address:{_eq:u.from(e).toStringLong()}};return _optionalChain([r, 'optionalAccess', _152 => _152.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _153 => _153.tokenStandard]), () => ("v2"))}),qt({aptosConfig:t,options:{...r,where:o}})}async function fs(n){let{aptosConfig:t,collectionId:e,options:r}=n,o={collection_id:{_eq:u.from(e).toStringLong()}};return _optionalChain([r, 'optionalAccess', _154 => _154.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _155 => _155.tokenStandard]), () => ("v2"))}),qt({aptosConfig:t,options:{...r,where:o}})}async function As(n){let{creatorAddress:t,collectionName:e,options:r,aptosConfig:i}=n,o=u.from(t),s={collection_name:{_eq:e},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _156 => _156.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _157 => _157.tokenStandard]), () => ("v2"))}),(await qt({aptosConfig:i,options:{where:s}})).collection_id}var qc={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new E(new y(v())),new E(new y(v())),new E(E.u8())]};async function hs(n){let{aptosConfig:t,options:e,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:d}=n,T=_optionalChain([p, 'optionalAccess', _158 => _158.map, 'call', _159 => _159(w=>je[w])]);return b({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new S(i),new S(o),new S(s),new S(a),h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(T, () => ([]))),Ks(_nullishCoalesce(d, () => ([])),_nullishCoalesce(T, () => ([])))],abi:qc},options:e})}var Vc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new X]};async function bs(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(r),u.from(i)],abi:Vc},options:s})}var $c={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new E(new y(v())),new E(new y(v())),new E(E.u8()),new X]};async function Ts(n){let{aptosConfig:t,account:e,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:d,options:T}=n;if(_optionalChain([c, 'optionalAccess', _160 => _160.length])!==_optionalChain([d, 'optionalAccess', _161 => _161.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _162 => _162.length])!==_optionalChain([d, 'optionalAccess', _163 => _163.length]))throw new Error("Property types and property values counts do not match");let w=_optionalChain([p, 'optionalAccess', _164 => _164.map, 'call', _165 => _165(m=>je[m])]);return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,h.MoveString(_nullishCoalesce(c, () => ([]))),h.MoveString(_nullishCoalesce(w, () => ([]))),Ks(_nullishCoalesce(d, () => ([])),_nullishCoalesce(w, () => ([]))),a],abi:$c},options:T})}var Lc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0)))]};async function ws(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (de))],functionArguments:[u.from(r)],abi:Lc},options:o})}var Hc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0)))]};async function Ss(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (de))],functionArguments:[r],abi:Hc},options:o})}var Qc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0)))]};async function xs(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (de))],functionArguments:[r],abi:Qc},options:o})}var Wc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function _s(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:Wc},options:s})}var jc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function Ps(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:jc},options:s})}var Xc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function vs(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:Xc},options:s})}var Zc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v()),new y(v()),E.u8()]};async function Cs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (de))],functionArguments:[u.from(s),new S(r),new S(je[i]),h.U8(di(o,je[i]))],abi:Zc},options:c})}var Yc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v())]};async function Es(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (de))],functionArguments:[u.from(i),new S(r)],abi:Yc},options:s})}var Jc={typeParameters:[{constraints:["key"]}],parameters:[new y(ie(new z(0))),new y(v()),new y(v()),E.u8()]};async function Is(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (de))],functionArguments:[u.from(s),new S(r),new S(je[i]),di(o,je[i])],abi:Jc},options:c})}var eu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(ie(new z(0))),new y(v()),new z(1)]};async function Us(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (de)),je[i]],functionArguments:[u.from(s),new S(r),o],abi:eu},options:c})}var tu={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(ie(new z(0))),new y(v()),new z(1)]};async function Rs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (de)),je[i]],functionArguments:[u.from(s),new S(r),o],abi:tu},options:c})}function Ks(n,t){let e=new Array;return t.forEach((r,i)=>{e.push(di(n[i],r))}),e}function di(n,t){let e=Ke(t);return Mt(n,e,0,[]).bcsToBytes()}var mn=class{constructor(t){this.config=t}async getCollectionData(t){await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:e,collectionName:r,options:i}=t,o=u.from(e),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _166 => _166.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _167 => _167.tokenStandard]), () => ("v2"))}),qt({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ms({aptosConfig:this.config,...t})}async getCollectionDataByCreatorAddress(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ys({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),fs({aptosConfig:this.config,...t})}async getCollectionId(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),As({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),us({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ps({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ds({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),ls({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return gs({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return hs({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return bs({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Ts({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return ws({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Ss({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return xs({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return _s({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return Ps({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return vs({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return Cs({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return Es({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return Is({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return Us({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return Rs({aptosConfig:this.config,...t})}};var zs=300,nu=n=>{if(n&&n.length>zs)throw new Error(`Event type length exceeds the maximum length of ${zs}`)};async function ks(n){let{aptosConfig:t,eventType:e,options:r}=n,i={_or:[{account_address:{_eq:e.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:e}};return yn({aptosConfig:t,options:{...r,where:i}})}async function Ds(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:i}=n,s={account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}};return yn({aptosConfig:e,options:{...i,where:s}})}async function Bs(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:i}=n,s={account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}};return yn({aptosConfig:e,options:{...i,where:s}})}async function yn(n){let{aptosConfig:t,options:e}=n;nu(_optionalChain([e, 'optionalAccess', _168 => _168.where, 'optionalAccess', _169 => _169.indexed_type, 'optionalAccess', _170 => _170._eq]));let r={query:yo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _171 => _171.where]),offset:_optionalChain([e, 'optionalAccess', _172 => _172.offset]),limit:_optionalChain([e, 'optionalAccess', _173 => _173.limit]),order_by:_optionalChain([e, 'optionalAccess', _174 => _174.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var fn=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ks({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Ds({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),Bs({aptosConfig:this.config,...t})}async getEvents(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _175 => _175.minimumLedgerVersion]),processorType:"events_processor"}),yn({aptosConfig:this.config,...t})}};async function Gs(n){let{aptosConfig:t,accountAddress:e,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _176 => _176.timeoutSecs])||20,{data:s}=await Zi({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:o,checkSuccess:_optionalChain([i, 'optionalAccess', _177 => _177.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var An=class{constructor(t){this.config=t}async fundAccount(t){let e=await Gs({aptosConfig:this.config,...t});return(_optionalChain([t, 'access', _178 => _178.options, 'optionalAccess', _179 => _179.waitForIndexer])===void 0||_optionalChain([t, 'access', _180 => _180.options, 'optionalAccess', _181 => _181.waitForIndexer]))&&await rr({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version),processorType:"fungible_asset_processor"}),e}};async function gr(n){let{aptosConfig:t,options:e}=n,r={query:Ao,variables:{where_condition:_optionalChain([e, 'optionalAccess', _182 => _182.where]),limit:_optionalChain([e, 'optionalAccess', _183 => _183.limit]),offset:_optionalChain([e, 'optionalAccess', _184 => _184.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Fs(n){let{aptosConfig:t,options:e}=n,r={query:fo,variables:{where_condition:_optionalChain([e, 'optionalAccess', _185 => _185.where]),limit:_optionalChain([e, 'optionalAccess', _186 => _186.limit]),offset:_optionalChain([e, 'optionalAccess', _187 => _187.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ns(n){let{aptosConfig:t,options:e}=n,r={query:go,variables:{where_condition:_optionalChain([e, 'optionalAccess', _188 => _188.where]),limit:_optionalChain([e, 'optionalAccess', _189 => _189.limit]),offset:_optionalChain([e, 'optionalAccess', _190 => _190.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ru={typeParameters:[{constraints:[]}],parameters:[Ke("0x1::object::Object"),new X,new Q]};async function Os(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ru},options:s})}var hn=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _191 => _191.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),gr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _192 => _192.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await gr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _193 => _193.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await gr({aptosConfig:this.config,options:{where:{creator_address:{_eq:u.from(t.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _194 => _194.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Fs({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _195 => _195.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ns({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return Os({aptosConfig:this.config,...t})}};var bn=class{constructor(t){this.config=t}async getLedgerInfo(){return Xn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return Mo({aptosConfig:this.config,...t})}async getBlockByHeight(t){return qo({aptosConfig:this.config,...t})}async view(t){return _e({aptosConfig:this.config,...t})}async viewJson(t){return is({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return So({aptosConfig:this.config,...t})}async queryIndexer(t){return f({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return Zn({aptosConfig:this.config})}async getProcessorStatus(t){return Yn({aptosConfig:this.config,processorType:t})}};var Ms=["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 qs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Xe(n){let[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(!qs(t))throw new Error(`${t} is not valid. ${Ms}`);if(e&&!qs(e))throw new Error(`${e} is not valid. ${Ms}`);return{domainName:e||t,subdomainName:e?t:void 0}}function Vs(n){if(!n)return!1;let t=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),e=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&t?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!e}var iu="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",ou={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:iu,custom:null,devnet:null};function ze(n){let t=ou[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var mr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function $s(n){let{aptosConfig:t,name:e}=n,r=ze(t),{domainName:i,subdomainName:o}=Xe(e),s=await _e({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=mr(s[0]);return a?u.from(a):void 0}async function Ls(n){let{aptosConfig:t,expiration:e,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=ze(t),{domainName:d,subdomainName:T}=Xe(r),w=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(T&&!w)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(w&&!T)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let Tr=_nullishCoalesce(e.years, () => (1));if(Tr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let pa=Tr*31536e3;return await b({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[d,pa,o,s]},options:a})}if(!T)throw new Error(`${e.policy} requires a subdomain to be provided.`);let m=await li({aptosConfig:t,name:d});if(!m)throw new Error("The domain does not exist");let _=e.policy==="subdomain:independent"?e.expirationDate:m;if(_>m)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await b({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[d,T,Math.round(_/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function li(n){let{aptosConfig:t,name:e}=n,r=ze(t),{domainName:i,subdomainName:o}=Xe(e);try{let s=await _e({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e5){return}}async function Hs(n){let{aptosConfig:t,address:e}=n,r=ze(t),i=await _e({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),o=mr(i[1]),s=mr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Qs(n){let{aptosConfig:t,sender:e,name:r,options:i}=n,o=ze(t);if(!r)return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Xe(r);return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ws(n){let{aptosConfig:t,name:e}=n,r=ze(t),{domainName:i,subdomainName:o}=Xe(e),s=await _e({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=mr(s[0]);return a?u.from(a):void 0}async function js(n){let{aptosConfig:t,sender:e,name:r,address:i,options:o}=n,s=ze(t),{domainName:a,subdomainName:c}=Xe(r);return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Xs(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:i=""}=Xe(e),a=(await f({aptosConfig:t,query:{query:Ft,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Tn(a)),Vs(a)?a:void 0}async function Zs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await gi({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountNames",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _196 => _196.limit]),offset:_optionalChain([e, 'optionalAccess', _197 => _197.offset]),order_by:_optionalChain([e, 'optionalAccess', _198 => _198.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _199 => _199.options, 'optionalAccess', _200 => _200.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Tn)}async function Ys(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await gi({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountDomains",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _201 => _201.limit]),offset:_optionalChain([e, 'optionalAccess', _202 => _202.offset]),order_by:_optionalChain([e, 'optionalAccess', _203 => _203.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Tn)}async function Js(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await gi({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _206 => _206.limit]),offset:_optionalChain([e, 'optionalAccess', _207 => _207.offset]),order_by:_optionalChain([e, 'optionalAccess', _208 => _208.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _209 => _209.options, 'optionalAccess', _210 => _210.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Tn)}async function ea(n){let{aptosConfig:t,options:e,domain:r}=n;return(await f({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:Ft,variables:{limit:_optionalChain([e, 'optionalAccess', _211 => _211.limit]),offset:_optionalChain([e, 'optionalAccess', _212 => _212.offset]),order_by:_optionalChain([e, 'optionalAccess', _213 => _213.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Tn).filter(Vs)}async function gi(n){let{aptosConfig:t}=n,e=ze(t),[r]=await _e({aptosConfig:t,payload:{function:`${e}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function ta(n){let{aptosConfig:t,sender:e,name:r,years:i=1,options:o}=n,s=ze(t),a=i*31536e3,{domainName:c,subdomainName:p}=Xe(r);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await b({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function Tn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var wn=class{constructor(t){this.config=t}async getOwnerAddress(t){return $s({aptosConfig:this.config,...t})}async getExpiration(t){return li({aptosConfig:this.config,...t})}async getTargetAddress(t){return Ws({aptosConfig:this.config,...t})}async setTargetAddress(t){return js({aptosConfig:this.config,...t})}async getPrimaryName(t){return Hs({aptosConfig:this.config,...t})}async setPrimaryName(t){return Qs({aptosConfig:this.config,...t})}async registerName(t){return Ls({aptosConfig:this.config,...t})}async renewDomain(t){return ta({aptosConfig:this.config,...t})}async getName(t){return Xs({aptosConfig:this.config,...t})}async getAccountNames(t){return Zs({aptosConfig:this.config,...t})}async getAccountDomains(t){return Ys({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Js({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return ea({aptosConfig:this.config,...t})}};async function na(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Lr,variables:{where_condition:{pool_address:{_eq:r}}}}});return o.num_active_delegator_per_pool[0]?o.num_active_delegator_per_pool[0].num_active_delegator:0}async function ra(n){let{aptosConfig:t,options:e}=n,r={query:Lr,variables:{order_by:_optionalChain([e, 'optionalAccess', _216 => _216.orderBy])}};return(await f({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function ia(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,i={query:mo,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:t,query:i})).delegated_staking_activities}var Sn=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"stake_processor"}),na({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _218 => _218.minimumLedgerVersion]),processorType:"stake_processor"}),ra({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await A({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _219 => _219.minimumLedgerVersion]),processorType:"stake_processor"}),ia({aptosConfig:this.config,...t})}};var yr=class{constructor(t){this.config=t}async simple(t){return b({aptosConfig:this.config,...t})}async multiAgent(t){return b({aptosConfig:this.config,...t})}};function mi(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerAuthenticator)throw new Error("You are submitting a Fee Payer transaction but missing the feePayerAuthenticator");return r.apply(this,i)},e}function yi(n,t,e){let r=e.value;return e.value=async function(...i){let[o]=i;if(o.transaction.feePayerAddress&&!o.feePayerPublicKey)throw new Error("You are simulating a Fee Payer transaction but missing the feePayerPublicKey");return r.apply(this,i)},e}var Vt=class{constructor(t){this.config=t}async simple(t){return pi({aptosConfig:this.config,...t})}async multiAgent(t){return pi({aptosConfig:this.config,...t})}};_chunkHBPH2AD3js.a.call(void 0, [yi],Vt.prototype,"simple",1),_chunkHBPH2AD3js.a.call(void 0, [yi],Vt.prototype,"multiAgent",1);var $t=class{constructor(t){this.config=t}async simple(t){return lr({aptosConfig:this.config,...t})}async multiAgent(t){return lr({aptosConfig:this.config,...t})}};_chunkHBPH2AD3js.a.call(void 0, [mi],$t.prototype,"simple",1),_chunkHBPH2AD3js.a.call(void 0, [mi],$t.prototype,"multiAgent",1);var fr=class{constructor(t,e,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkHBPH2AD3js.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=_chunkHBPH2AD3js.c.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkHBPH2AD3js.b.call(void 0, this.sleepTime),_chunkHBPH2AD3js.c.call(void 0, )-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 xe({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await xe({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 _chunkHBPH2AD3js.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=_chunkHBPH2AD3js.c.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkHBPH2AD3js.c.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkHBPH2AD3js.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 Lt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _220 => _220.pendingDequeue, 'access', _221 => _221.shift, 'call', _222 => _222(), 'optionalAccess', _223 => _223.resolve, 'call', _224 => _224(t)]);return}this.queue.push(t)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((t,e)=>{this.pendingDequeue.push({resolve:t,reject:e})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:t})=>{t(new Ht("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Ht=class extends Error{};var oa="fulfilled",sa= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(sa||{}),Ar= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,i=30,o=100,s=10){super();this.taskQueue=new Lt;this.transactionsQueue=new Lt;this.outstandingTransactions=new Lt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new fr(e,r,i,o,s)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let i=ln({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof Ht)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async processTransactions(){try{for(;;){let e=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(e.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),e.push(i),r.push(o);let s=await Promise.allSettled(e);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===oa?(this.sentTransactions.push([c.value.hash,o,null]),this.emit("transactionSent",{message:`transaction hash ${c.value.hash} has been committed to chain`,transactionHash:c.value.hash}),await this.checkTransaction(c,o)):(this.sentTransactions.push([c.status,o,c.reason]),this.emit("transactionSendFailed",{message:`failed to commit transaction ${this.sentTransactions.length} with error ${c.reason}`,error:c.reason}))}this.emit("executionFinish",{message:`execute ${s.length} transactions finished`})}}catch(e){if(e instanceof Ht)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let i=[];i.push(Ot({aptosConfig:this.aptosConfig,transactionHash:e.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===oa?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return b({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var hr=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new Ar(this.config,r),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:r,options:i}=e;for(let o of r)this.transactionWorker.push(o,i)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:r,data:i,options:o}=e;this.start({sender:r}),this.push({data:i,options:o})}catch(r){throw new Error(`failed to submit transactions with error: ${r}`)}}};var xn=class{constructor(t){this.config=t,this.build=new yr(this.config),this.simulate=new Vt(this.config),this.submit=new $t(this.config),this.batch=new hr(this.config)}async getTransactions(t){return Zr({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return No({aptosConfig:this.config,...t})}async getTransactionByHash(t){return cn({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 nr({aptosConfig:this.config})}getSigningMessage(t){return os(t)}async publishPackageTransaction(t){return ss({aptosConfig:this.config,...t})}async rotateAuthKey(t){return as({aptosConfig:this.config,...t})}sign(t){return dr({...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,dr({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:i}=t;this.batch.forSingleAccount({sender:e,data:r,options:i})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return ln({aptosConfig:this.config,signer:e,transaction:r})}};var _n=class{constructor(t){this.config=t}async getTableItem(t){return Jn({aptosConfig:this.config,...t})}async getTableItemsData(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),xo({aptosConfig:this.config,...t})}async getTableItemsMetadata(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),_o({aptosConfig:this.config,...t})}};async function br(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Yi({aptosConfig:t,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return g.fromHexInput(a.pepper).toUint8Array()}async function fi(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,pepper:i=await br(n),uidKey:o="sub"}=n;if(g.fromHexInput(i).toUint8Array().length!==Qe.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${Qe.PEPPER_LENGTH} bytes`);let{maxExpHorizonSecs:s}=await to({aptosConfig:t});if(s<r.expiryDateSecs-_jwtdecode.jwtDecode.call(void 0, e).iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let a={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:999999999999,pepper:g.fromHexInput(i).toStringWithoutPrefix(),uid_key:o};console.log(JSON.stringify(a));let{data:c}=await Ji({aptosConfig:t,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}});console.log(JSON.stringify(c));let p=c.proof,d=new _t({a:p.a,b:p.b,c:p.c});return new ce({proof:new Pt(d,0),trainingWheelsSignature:we.fromHex(c.training_wheels_signature),expHorizonSecs:s})}async function aa(n){let{aptosConfig:t,jwt:e,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await br(n)}=n,a=fi({...n,pepper:s}),c=o?a:await a;if(r!==void 0){let T=he.fromJwtAndPepper({jwt:e,pepper:s,jwkAddress:r,uidKey:i}),w=await Nt({aptosConfig:t,authenticationKey:T.authKey().derivedAddress()});return Hn.create({...n,address:w,proof:c,pepper:s,proofFetchCallback:o,jwkAddress:r})}let p=G.fromJwtAndPepper({jwt:e,pepper:s,uidKey:i}),d=await Nt({aptosConfig:t,authenticationKey:p.authKey().derivedAddress()});return Qe.create({...n,address:d,proof:c,pepper:s,proofFetchCallback:o})}async function ca(n){let{aptosConfig:t,sender:e,iss:r}=n,i=_nullishCoalesce(n.jwksUrl, () => ((r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`))),o=await fetch(i);if(!o.ok)throw new Error(`Failed to fetch JWKS: ${o.status} ${o.statusText}`);let s=await o.json();return b({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,h.MoveString(s.keys.map(a=>a.kid)),h.MoveString(s.keys.map(a=>a.alg)),h.MoveString(s.keys.map(a=>a.e)),h.MoveString(s.keys.map(a=>a.n))]}})}var Pn=class{constructor(t){this.config=t}async getPepper(t){return br({aptosConfig:this.config,...t})}async getProof(t){return fi({aptosConfig:this.config,...t})}async deriveKeylessAccount(t){return aa({aptosConfig:this.config,...t})}async updateFederatedKeylessJwkSetTransaction(t){return ca({aptosConfig:this.config,...t})}};async function uu(n){let{aptosConfig:t,options:e}=n,r={query:jn,variables:{where_condition:_optionalChain([e, 'optionalAccess', _225 => _225.where]),offset:_optionalChain([e, 'optionalAccess', _226 => _226.offset]),limit:_optionalChain([e, 'optionalAccess', _227 => _227.limit]),order_by:_optionalChain([e, 'optionalAccess', _228 => _228.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getObjectData"})).current_objects}async function ua(n){let{aptosConfig:t,objectAddress:e,options:r}=n,o={object_address:{_eq:u.from(e).toStringLong()}};return(await uu({aptosConfig:t,options:{...r,where:o}}))[0]}var vn=class{constructor(t){this.config=t}async getObjectDataByObjectAddress(t){return await A({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"objects_processor"}),ua({aptosConfig:this.config,...t})}};var Z=class{constructor(t){this.config=new pr(t),this.account=new dn(this.config),this.ans=new wn(this.config),this.coin=new gn(this.config),this.digitalAsset=new mn(this.config),this.event=new fn(this.config),this.faucet=new An(this.config),this.fungibleAsset=new hn(this.config),this.general=new bn(this.config),this.staking=new Sn(this.config),this.transaction=new xn(this.config),this.table=new _n(this.config),this.keyless=new Pn(this.config),this.object=new vn(this.config)}};function oe(n,t,e){Object.getOwnPropertyNames(t.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(t.prototype,r);i&&(i.value=function(...o){return this[e][r](...o)},Object.defineProperty(n.prototype,r,i))})}oe(Z,dn,"account");oe(Z,wn,"ans");oe(Z,gn,"coin");oe(Z,mn,"digitalAsset");oe(Z,fn,"event");oe(Z,An,"faucet");oe(Z,hn,"fungibleAsset");oe(Z,bn,"general");oe(Z,Sn,"staking");oe(Z,xn,"transaction");oe(Z,_n,"table");oe(Z,Pn,"keyless");oe(Z,vn,"object");exports.APTOS_BIP44_REGEX = xa; exports.APTOS_COIN = ot; exports.APTOS_FA = Vi; exports.APTOS_HARDENED_REGEX = Sa; exports.Account = Le; exports.AccountAddress = u; exports.AccountAuthenticator = j; exports.AccountAuthenticatorEd25519 = be; exports.AccountAuthenticatorMultiEd25519 = On; exports.AccountAuthenticatorMultiKey = ct; exports.AccountAuthenticatorSingleKey = te; exports.AccountAuthenticatorVariant = Pi; exports.AccountPublicKey = ee; exports.AccountSequenceNumber = fr; exports.AddressInvalidReason = ha; exports.AnyPublicKey = k; exports.AnyPublicKeyVariant = Kn; exports.AnySignature = M; exports.AnySignatureVariant = vi; exports.Aptos = Z; exports.AptosApiError = Ae; exports.AptosApiType = wt; exports.AptosConfig = pr; exports.AuthenticationKey = D; exports.Bool = I; exports.CKDPriv = Di; exports.ChainId = Ct; exports.DEFAULT_MAX_GAS_AMOUNT = Mi; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = qi; exports.DEFAULT_TXN_TIMEOUT_SEC = Fn; exports.DeriveScheme = Ii; exports.Deserializer = q; exports.EPK_HORIZON_SECS = ql; exports.Ed25519Account = Dt; exports.Ed25519PrivateKey = W; exports.Ed25519PublicKey = P; exports.Ed25519Signature = C; exports.EntryFunction = pt; exports.EntryFunctionBytes = Un; exports.EphemeralCertificate = xt; exports.EphemeralCertificateVariant = xr; exports.EphemeralKeyPair = mt; exports.EphemeralPublicKey = it; exports.EphemeralPublicKeyVariant = Sr; exports.EphemeralSignature = we; exports.EphemeralSignatureVariant = Ci; exports.FederatedKeylessAccount = Hn; exports.FederatedKeylessPublicKey = he; exports.FeePayerRawTransaction = lt; exports.FixedBytes = et; exports.Groth16Zkp = _t; exports.HARDENED_OFFSET = Ki; exports.Hex = g; exports.HexInvalidReason = ga; exports.Identifier = R; exports.KeyType = _a; exports.KeylessAccount = Qe; exports.KeylessAccountCommon = He; exports.KeylessConfiguration = Nr; exports.KeylessPublicKey = G; exports.KeylessSignature = Ie; exports.MAX_AUD_VAL_BYTES = ec; exports.MAX_COMMITED_EPK_BYTES = Hl; exports.MAX_EXTRA_FIELD_BYTES = $l; exports.MAX_ISS_VAL_BYTES = Vl; exports.MAX_JWT_HEADER_B64_BYTES = Ll; exports.MAX_UID_KEY_BYTES = tc; exports.MAX_UID_VAL_BYTES = nc; exports.MimeType = Rn; exports.ModuleId = Jt; exports.MoveAbility = Ei; exports.MoveFunctionVisibility = ya; exports.MoveOption = L; exports.MoveString = S; exports.MoveVector = h; exports.MultiAgentRawTransaction = dt; exports.MultiAgentTransaction = Ln; exports.MultiEd25519PublicKey = ht; exports.MultiEd25519Signature = nt; exports.MultiKey = vt; exports.MultiKeyAccount = Qn; exports.MultiKeySignature = at; exports.MultiSig = on; exports.MultiSigTransactionPayload = sn; exports.Network = Dr; exports.NetworkToChainId = Br; exports.NetworkToFaucetAPI = Wi; exports.NetworkToIndexerAPI = Hi; exports.NetworkToNetworkName = Vd; exports.NetworkToNodeAPI = Qi; exports.NetworkToPepperAPI = zr; exports.NetworkToProverAPI = kr; exports.ParsingError = J; exports.ProcessorType = Ce; exports.PublicKey = tt; exports.RAW_TRANSACTION_SALT = $i; exports.RAW_TRANSACTION_WITH_DATA_SALT = Rr; exports.RawTransaction = pe; exports.RawTransactionWithData = qn; exports.RoleType = fa; exports.RotationProofChallenge = Vn; exports.Script = rn; exports.ScriptTransactionArgumentVariants = Wt; exports.Secp256k1PrivateKey = rt; exports.Secp256k1PublicKey = ve; exports.Secp256k1Signature = Tt; exports.Serializable = l; exports.Serialized = jt; exports.Serializer = V; exports.Signature = B; exports.SignedTransaction = gt; exports.SigningScheme = le; exports.SigningSchemeInput = vr; exports.SimpleTransaction = $n; exports.SingleKeyAccount = Bt; exports.StructTag = Ue; exports.TransactionAndProof = $r; exports.TransactionAuthenticator = Re; exports.TransactionAuthenticatorEd25519 = It; exports.TransactionAuthenticatorFeePayer = Rt; exports.TransactionAuthenticatorMultiAgent = Ut; exports.TransactionAuthenticatorMultiEd25519 = qr; exports.TransactionAuthenticatorSingleSender = Kt; exports.TransactionAuthenticatorVariant = _i; exports.TransactionPayload = ut; exports.TransactionPayloadEntryFunction = tn; exports.TransactionPayloadMultiSig = nn; exports.TransactionPayloadScript = en; exports.TransactionPayloadVariants = Si; exports.TransactionResponseType = Pr; exports.TransactionVariants = xi; exports.TransactionWorker = Ar; exports.TransactionWorkerEventsEnum = sa; exports.TypeTag = K; exports.TypeTagAddress = X; exports.TypeTagBool = F; exports.TypeTagGeneric = z; exports.TypeTagParserError = N; exports.TypeTagParserErrorType = _c; exports.TypeTagReference = Mn; exports.TypeTagSigner = Et; exports.TypeTagStruct = y; exports.TypeTagU128 = Ve; exports.TypeTagU16 = Me; exports.TypeTagU256 = $e; exports.TypeTagU32 = qe; exports.TypeTagU64 = Q; exports.TypeTagU8 = ue; exports.TypeTagVariants = wi; exports.TypeTagVector = E; exports.U128 = ye; exports.U16 = ge; exports.U256 = fe; exports.U32 = me; exports.U64 = O; exports.U8 = $; exports.ZeroKnowledgeSig = ce; exports.ZkProof = Pt; exports.ZkpVariant = _r; exports.aptosCoinStructTag = Cm; exports.aptosRequest = Nn; exports.base64UrlDecode = _chunkHBPH2AD3js.e; exports.buildTransaction = ci; exports.checkOrConvertArgument = Mt; exports.convertAmountFromHumanReadableToOnChain = _chunkHBPH2AD3js.f; exports.convertAmountFromOnChainToHumanReadable = _chunkHBPH2AD3js.g; exports.convertArgument = ai; exports.convertNumber = ir; exports.createObjectAddress = Mr; exports.createResourceAddress = rm; exports.createTokenAddress = im; exports.deriveKey = Cr; exports.deriveTransactionType = Vr; exports.deserializeFromScriptArgument = sc; exports.ensureBoolean = wr; exports.fetchEntryFunctionAbi = Yo; exports.fetchFunctionAbi = Zo; exports.fetchViewFunctionAbi = Jo; exports.findFirstNonSignerArg = Wo; exports.floorToWholeHour = _chunkHBPH2AD3js.d; exports.generateRawTransaction = Rc; exports.generateSignedTransaction = ui; exports.generateSignedTransactionForSimulation = ts; exports.generateSigningMessage = zt; exports.generateSigningMessageForSerializable = Ny; exports.generateSigningMessageForTransaction = kt; exports.generateTransactionPayload = ur; exports.generateTransactionPayloadWithABI = Ec; exports.generateUserTransactionHash = jh; exports.generateViewFunctionPayload = es; exports.generateViewFunctionPayloadWithABI = Ic; exports.get = Gr; exports.getAptosFullNode = H; exports.getAptosPepperService = ll; exports.getAuthenticatorForSimulation = cr; exports.getFunctionParts = un; exports.getKeylessConfig = to; exports.hashValues = ns; exports.isBcsAddress = sr; exports.isBcsBool = Yr; exports.isBcsFixedBytes = bc; exports.isBcsString = Jr; exports.isBcsU128 = ii; exports.isBcsU16 = ti; exports.isBcsU256 = oi; exports.isBcsU32 = ni; exports.isBcsU64 = ri; exports.isBcsU8 = ei; exports.isBlockEpilogueTransactionResponse = Ou; exports.isBlockMetadataTransactionResponse = Gu; exports.isBool = $o; exports.isCanonicalEd25519Signature = va; exports.isEd25519Signature = Mu; exports.isEmptyOption = Lo; exports.isEncodedEntryFunctionArgument = Ho; exports.isEncodedStruct = _chunkHBPH2AD3js.i; exports.isFeePayerSignature = $u; exports.isGenesisTransactionResponse = Bu; exports.isLargeNumber = or; exports.isMultiAgentSignature = Vu; exports.isMultiEd25519Signature = Lu; exports.isNumber = hc; exports.isPendingTransactionResponse = ku; exports.isScriptDataInput = Qo; exports.isSecp256k1Signature = qu; exports.isStateCheckpointTransactionResponse = Fu; exports.isString = We; exports.isUserTransactionResponse = Du; exports.isValidBIP44Path = zi; exports.isValidHardenedPath = ki; exports.isValidatorTransactionResponse = Nu; exports.mnemonicToSeed = zn; exports.normalizeBundle = ji; exports.nowInSeconds = _chunkHBPH2AD3js.c; exports.objectStructTag = ie; exports.optionStructTag = Em; exports.outOfRangeErrorMessage = ma; exports.paginateWithCursor = St; exports.parseEncodedStruct = _chunkHBPH2AD3js.h; exports.parseTypeTag = Ke; exports.post = Yt; exports.postAptosFaucet = Zi; exports.postAptosFullNode = Ne; exports.postAptosIndexer = Xi; exports.postAptosPepperService = Yi; exports.postAptosProvingService = Ji; exports.promiseFulfilledStatus = oa; exports.request = Ya; exports.sleep = _chunkHBPH2AD3js.b; exports.splitPath = Bi; exports.standardizeTypeTags = ar; exports.stringStructTag = v; exports.throwTypeMismatch = U; exports.validateNumberInRange = De;
|
|
473
473
|
//# sourceMappingURL=index.js.map
|