@aptos-labs/ts-sdk 1.14.0-zeta.6 → 1.14.0-zeta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/index.d.ts +15 -3
- package/dist/common/index.js +25 -25
- 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/KeylessAccount.d.mts +11 -3
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +2 -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.d.mts +1 -0
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/aptosConfig.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.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.d.mts +1 -0
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +1 -0
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/staking.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/sign.mjs.map +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/cryptoHasher.d.mts +15 -0
- package/dist/esm/bcs/cryptoHasher.mjs +2 -0
- package/dist/esm/bcs/cryptoHasher.mjs.map +1 -0
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/{chunk-KL3HNMT5.mjs → chunk-2UGYQCPV.mjs} +2 -2
- package/dist/esm/{chunk-3S3GIUQY.mjs → chunk-2VJKN67Y.mjs} +2 -2
- package/dist/esm/{chunk-3CUVYW32.mjs → chunk-37BUI3TW.mjs} +2 -2
- package/dist/esm/{chunk-HXQADNOJ.mjs → chunk-47TJ5KHD.mjs} +2 -2
- package/dist/esm/{chunk-2OMAM2OW.mjs → chunk-4GMDXDLT.mjs} +2 -2
- package/dist/esm/{chunk-HHVAU5HU.mjs → chunk-54U22YPJ.mjs} +2 -2
- package/dist/esm/{chunk-XXBIY3E4.mjs → chunk-5EIBVKRN.mjs} +2 -2
- package/dist/esm/chunk-5YI2GEG5.mjs +2 -0
- package/dist/esm/chunk-5YI2GEG5.mjs.map +1 -0
- package/dist/esm/{chunk-VDTM2LUI.mjs → chunk-6AB7OAN2.mjs} +2 -2
- package/dist/esm/{chunk-TGXWKN2U.mjs → chunk-6AL2JZW5.mjs} +2 -2
- package/dist/esm/{chunk-MTL6MT2Z.mjs → chunk-72FVDESD.mjs} +2 -2
- package/dist/esm/{chunk-2DIO35OD.mjs → chunk-7FGQTVUK.mjs} +2 -2
- package/dist/esm/{chunk-TICM455H.mjs → chunk-7H3HRFVM.mjs} +2 -2
- package/dist/esm/{chunk-KDXECPCS.mjs → chunk-7JJJAYSG.mjs} +2 -2
- package/dist/esm/{chunk-PGCBIU33.mjs → chunk-ABLLZAVR.mjs} +2 -2
- package/dist/esm/{chunk-65QG6O26.mjs → chunk-AYD7KIVE.mjs} +2 -2
- package/dist/esm/{chunk-ARV2BH5D.mjs → chunk-BI5CFPF4.mjs} +2 -2
- package/dist/esm/{chunk-YV7OBLK2.mjs → chunk-BUBB2DYK.mjs} +2 -2
- package/dist/esm/{chunk-QEZJZOEX.mjs → chunk-CC4BOUIE.mjs} +2 -2
- package/dist/esm/{chunk-HLN6GUIY.mjs → chunk-CNRBJYBM.mjs} +2 -2
- package/dist/esm/{chunk-4OSXWFTW.mjs → chunk-DHURWEN4.mjs} +2 -2
- package/dist/esm/{chunk-H7NNUC3D.mjs → chunk-ECTOKZKG.mjs} +2 -2
- package/dist/esm/{chunk-TZ2MX7WB.mjs → chunk-EITBGYIX.mjs} +2 -2
- package/dist/esm/{chunk-XTO3FQND.mjs → chunk-GL4NI3HS.mjs} +2 -2
- package/dist/esm/{chunk-XX3J6NRH.mjs → chunk-GXYWMAXZ.mjs} +2 -2
- package/dist/esm/{chunk-RJ4PSGZ4.mjs → chunk-IEZO4PIG.mjs} +2 -2
- package/dist/esm/{chunk-JLWKIYHV.mjs → chunk-IUOPNE62.mjs} +2 -2
- package/dist/esm/{chunk-DYUF5UID.mjs → chunk-JZRM73CF.mjs} +2 -2
- package/dist/esm/{chunk-YUONW2LQ.mjs → chunk-K5ZOVBFV.mjs} +2 -2
- package/dist/esm/{chunk-TNJDICBE.mjs → chunk-KHQHZYQY.mjs} +2 -2
- package/dist/esm/{chunk-EM2TYSMT.mjs → chunk-KP6TYSUT.mjs} +2 -2
- package/dist/esm/chunk-KPZDC5ZE.mjs +2 -0
- package/dist/esm/chunk-KPZDC5ZE.mjs.map +1 -0
- package/dist/esm/{chunk-T5CGXM6S.mjs → chunk-LTXQUNQU.mjs} +2 -2
- package/dist/esm/{chunk-SI7MPP6G.mjs → chunk-M72JTOIP.mjs} +2 -2
- package/dist/esm/{chunk-NNIHTVLA.mjs → chunk-MKUAW7KW.mjs} +2 -2
- package/dist/esm/chunk-NGSZ4XZO.mjs +2 -0
- package/dist/esm/chunk-NGSZ4XZO.mjs.map +1 -0
- package/dist/esm/{chunk-ROAJCETX.mjs → chunk-OHJLP5GD.mjs} +2 -2
- package/dist/esm/{chunk-HYDDIAJ6.mjs → chunk-PKRPABA4.mjs} +2 -2
- package/dist/esm/{chunk-OWIDLQOG.mjs → chunk-QETTUZ2U.mjs} +2 -2
- package/dist/esm/{chunk-VY2DCR3F.mjs → chunk-SDMFOG4O.mjs} +2 -2
- package/dist/esm/{chunk-57VQMRBX.mjs → chunk-SS7WKVGS.mjs} +2 -2
- package/dist/esm/{chunk-FUWIJEE6.mjs → chunk-W23D4Z3O.mjs} +2 -2
- package/dist/esm/{chunk-52ECIIIH.mjs → chunk-W637YAND.mjs} +2 -2
- package/dist/esm/{chunk-LEMNHXB6.mjs → chunk-WDN2MTVR.mjs} +2 -2
- package/dist/esm/{chunk-BVBPBQK5.mjs → chunk-XOZZBQBR.mjs} +2 -2
- package/dist/esm/{chunk-4SSWQOHR.mjs → chunk-XXURUIE6.mjs} +2 -2
- package/dist/esm/{chunk-7WJTKYRG.mjs → chunk-Z2ZR4PTF.mjs} +2 -2
- package/dist/esm/{chunk-25H3DXTL.mjs → chunk-ZYU2WJ6J.mjs} +2 -2
- package/dist/esm/cli/index.mjs +1 -1
- 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/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.d.mts +3 -2
- 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.d.mts +1 -0
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/staking.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.d.mts +2 -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.d.mts +2 -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.d.mts +6 -5
- 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/account/KeylessAccount.ts +7 -3
- package/src/bcs/cryptoHasher.ts +6 -0
- package/src/transactions/transactionBuilder/signingMessage.ts +4 -4
- package/dist/esm/chunk-2LCP7PAJ.mjs +0 -2
- package/dist/esm/chunk-2LCP7PAJ.mjs.map +0 -1
- package/dist/esm/chunk-56NB52W6.mjs +0 -2
- package/dist/esm/chunk-56NB52W6.mjs.map +0 -1
- /package/dist/esm/{chunk-KL3HNMT5.mjs.map → chunk-2UGYQCPV.mjs.map} +0 -0
- /package/dist/esm/{chunk-3S3GIUQY.mjs.map → chunk-2VJKN67Y.mjs.map} +0 -0
- /package/dist/esm/{chunk-3CUVYW32.mjs.map → chunk-37BUI3TW.mjs.map} +0 -0
- /package/dist/esm/{chunk-HXQADNOJ.mjs.map → chunk-47TJ5KHD.mjs.map} +0 -0
- /package/dist/esm/{chunk-2OMAM2OW.mjs.map → chunk-4GMDXDLT.mjs.map} +0 -0
- /package/dist/esm/{chunk-HHVAU5HU.mjs.map → chunk-54U22YPJ.mjs.map} +0 -0
- /package/dist/esm/{chunk-XXBIY3E4.mjs.map → chunk-5EIBVKRN.mjs.map} +0 -0
- /package/dist/esm/{chunk-VDTM2LUI.mjs.map → chunk-6AB7OAN2.mjs.map} +0 -0
- /package/dist/esm/{chunk-TGXWKN2U.mjs.map → chunk-6AL2JZW5.mjs.map} +0 -0
- /package/dist/esm/{chunk-MTL6MT2Z.mjs.map → chunk-72FVDESD.mjs.map} +0 -0
- /package/dist/esm/{chunk-2DIO35OD.mjs.map → chunk-7FGQTVUK.mjs.map} +0 -0
- /package/dist/esm/{chunk-TICM455H.mjs.map → chunk-7H3HRFVM.mjs.map} +0 -0
- /package/dist/esm/{chunk-KDXECPCS.mjs.map → chunk-7JJJAYSG.mjs.map} +0 -0
- /package/dist/esm/{chunk-PGCBIU33.mjs.map → chunk-ABLLZAVR.mjs.map} +0 -0
- /package/dist/esm/{chunk-65QG6O26.mjs.map → chunk-AYD7KIVE.mjs.map} +0 -0
- /package/dist/esm/{chunk-ARV2BH5D.mjs.map → chunk-BI5CFPF4.mjs.map} +0 -0
- /package/dist/esm/{chunk-YV7OBLK2.mjs.map → chunk-BUBB2DYK.mjs.map} +0 -0
- /package/dist/esm/{chunk-QEZJZOEX.mjs.map → chunk-CC4BOUIE.mjs.map} +0 -0
- /package/dist/esm/{chunk-HLN6GUIY.mjs.map → chunk-CNRBJYBM.mjs.map} +0 -0
- /package/dist/esm/{chunk-4OSXWFTW.mjs.map → chunk-DHURWEN4.mjs.map} +0 -0
- /package/dist/esm/{chunk-H7NNUC3D.mjs.map → chunk-ECTOKZKG.mjs.map} +0 -0
- /package/dist/esm/{chunk-TZ2MX7WB.mjs.map → chunk-EITBGYIX.mjs.map} +0 -0
- /package/dist/esm/{chunk-XTO3FQND.mjs.map → chunk-GL4NI3HS.mjs.map} +0 -0
- /package/dist/esm/{chunk-XX3J6NRH.mjs.map → chunk-GXYWMAXZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-RJ4PSGZ4.mjs.map → chunk-IEZO4PIG.mjs.map} +0 -0
- /package/dist/esm/{chunk-JLWKIYHV.mjs.map → chunk-IUOPNE62.mjs.map} +0 -0
- /package/dist/esm/{chunk-DYUF5UID.mjs.map → chunk-JZRM73CF.mjs.map} +0 -0
- /package/dist/esm/{chunk-YUONW2LQ.mjs.map → chunk-K5ZOVBFV.mjs.map} +0 -0
- /package/dist/esm/{chunk-TNJDICBE.mjs.map → chunk-KHQHZYQY.mjs.map} +0 -0
- /package/dist/esm/{chunk-EM2TYSMT.mjs.map → chunk-KP6TYSUT.mjs.map} +0 -0
- /package/dist/esm/{chunk-T5CGXM6S.mjs.map → chunk-LTXQUNQU.mjs.map} +0 -0
- /package/dist/esm/{chunk-SI7MPP6G.mjs.map → chunk-M72JTOIP.mjs.map} +0 -0
- /package/dist/esm/{chunk-NNIHTVLA.mjs.map → chunk-MKUAW7KW.mjs.map} +0 -0
- /package/dist/esm/{chunk-ROAJCETX.mjs.map → chunk-OHJLP5GD.mjs.map} +0 -0
- /package/dist/esm/{chunk-HYDDIAJ6.mjs.map → chunk-PKRPABA4.mjs.map} +0 -0
- /package/dist/esm/{chunk-OWIDLQOG.mjs.map → chunk-QETTUZ2U.mjs.map} +0 -0
- /package/dist/esm/{chunk-VY2DCR3F.mjs.map → chunk-SDMFOG4O.mjs.map} +0 -0
- /package/dist/esm/{chunk-57VQMRBX.mjs.map → chunk-SS7WKVGS.mjs.map} +0 -0
- /package/dist/esm/{chunk-FUWIJEE6.mjs.map → chunk-W23D4Z3O.mjs.map} +0 -0
- /package/dist/esm/{chunk-52ECIIIH.mjs.map → chunk-W637YAND.mjs.map} +0 -0
- /package/dist/esm/{chunk-LEMNHXB6.mjs.map → chunk-WDN2MTVR.mjs.map} +0 -0
- /package/dist/esm/{chunk-BVBPBQK5.mjs.map → chunk-XOZZBQBR.mjs.map} +0 -0
- /package/dist/esm/{chunk-4SSWQOHR.mjs.map → chunk-XXURUIE6.mjs.map} +0 -0
- /package/dist/esm/{chunk-7WJTKYRG.mjs.map → chunk-Z2ZR4PTF.mjs.map} +0 -0
- /package/dist/esm/{chunk-25H3DXTL.mjs.map → chunk-ZYU2WJ6J.mjs.map} +0 -0
package/dist/common/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkKSEUZTKYjs = require('./chunk-KSEUZTKY.js');var fn=255,An=65535,Se=4294967295,Fe=18446744073709551615n,Dt=340282366920938463463374607431768211455n,hn=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var ee=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeOptionStr(){if(this.deserializeUleb128AsU32()===1)return this.deserializeStr()}deserializeOption(t){if(this.deserializeUleb128AsU32()===1)return this.deserialize(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<Se;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>Se)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<e;i+=1)r.push(this.deserialize(t));return r}};var _utils = require('@noble/hashes/utils');var V=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var Fs=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(Fs||{}),g= exports.Hex =class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new V("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new V("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, e))}catch(r){throw new V(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _4 => _4.message])}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,r)=>e===t.data[r])}};var d=class{bcsToBytes(){let t=new L;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return g.fromHexInput(t)}},L= exports.Serializer =class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,r){this.ensureBufferWillHandleSize(e);let i=new DataView(this.buffer,this.offset);t.apply(i,[0,r,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){cr(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(Se),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&Fe,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&Dt,r=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(r)}serializeU32AsUleb128(t){let e=t,r=[];for(;e>>>7;)r.push(e&127|128),e>>>=7;r.push(e),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}serializeOption(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),t.serialize(this))}serializeOptionStr(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(t))}};_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,fn)],L.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,An)],L.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,Se)],L.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(BigInt(0),Fe)],L.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(BigInt(0),Dt)],L.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(BigInt(0),hn)],L.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,Se)],L.prototype,"serializeU32AsUleb128",1);function cr(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var Gs=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function Ue(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(Gs(n,t,e))}function Ge(n,t){return(e,r,i)=>{let o=i.value;return i.value=function(a){return Ue(a,n,t),o.apply(this,[a])},i}}var Me=class n extends d{constructor(e){super();this.value=g.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let i=e.deserializeFixedBytes(r);return new n(i)}};var Tn=class n extends d{constructor(e){super();this.value=new Me(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let i=Me.deserialize(e,r);return new n(i.value)}};var bn=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(bn||{}),ri= exports.TypeTagVariants =(l=>(l[l.Bool=0]="Bool",l[l.U8=1]="U8",l[l.U64=2]="U64",l[l.U128=3]="U128",l[l.Address=4]="Address",l[l.Signer=5]="Signer",l[l.Vector=6]="Vector",l[l.Struct=7]="Struct",l[l.U16=8]="U16",l[l.U32=9]="U32",l[l.U256=10]="U256",l[l.Reference=254]="Reference",l[l.Generic=255]="Generic",l))(ri||{}),Bt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Bt||{}),ii= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(ii||{}),oi= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(oi||{}),si= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(si||{}),ai= exports.AccountAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(ai||{}),ur= exports.AnyPublicKeyVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ur||{}),ci= exports.AnySignatureVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ci||{}),pr= exports.EphemeralPublicKeyVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(pr||{}),ui= exports.EphemeralSignatureVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(ui||{}),dr= exports.EphemeralCertificateVariant =(t=>(t[t.ZkProof=0]="ZkProof",t))(dr||{}),lr= exports.ZkpVariant =(t=>(t[t.Groth16=0]="Groth16",t))(lr||{}),gr= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(gr||{});function tu(n){return n.type==="pending_transaction"}function nu(n){return n.type==="user_transaction"}function ru(n){return n.type==="genesis_transaction"}function iu(n){return n.type==="block_metadata_transaction"}function ou(n){return n.type==="state_checkpoint_transaction"}function su(n){return n.type==="validator_transaction"}function au(n){return"signature"in n&&n.signature==="ed25519_signature"}function cu(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function uu(n){return n.type==="multi_agent_signature"}function pu(n){return n.type==="fee_payer_signature"}function du(n){return n.type==="multi_ed25519_signature"}var Ms=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(Ms||{}),pi= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(pi||{}),qs= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))(qs||{}),fe= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(fe||{}),mr= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(mr||{}),$s= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))($s||{});var R=class n extends d{constructor(e){super();cr(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},O= exports.U8 =class n extends d{constructor(e){super();Ue(e,0,fn),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},ce= exports.U16 =class n extends d{constructor(e){super();Ue(e,0,An),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},ue= exports.U32 =class n extends d{constructor(e){super();Ue(e,0,Se),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},B= exports.U64 =class n extends d{constructor(e){super();Ue(e,BigInt(0),Fe),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},pe= exports.U128 =class n extends d{constructor(e){super();Ue(e,BigInt(0),Dt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},de= exports.U256 =class n extends d{constructor(e){super();Ue(e,BigInt(0),hn),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super();this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(!(this.values[0]instanceof O)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let i=g.fromHexInput(e);r=Array.from(i.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(i=>new O(i)))}static U16(e){return new n(e.map(r=>new ce(r)))}static U32(e){return new n(e.map(r=>new ue(r)))}static U64(e){return new n(e.map(r=>new B(r)))}static U128(e){return new n(e.map(r=>new pe(r)))}static U256(e){return new n(e.map(r=>new de(r)))}static Bool(e){return new n(e.map(r=>new R(r)))}static MoveString(e){return new n(e.map(r=>new w(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1)o.push(r.deserialize(e));return new n(o)}},w= exports.MoveString =class n extends d{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=this.bcsToBytes().slice(1);T.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Re= exports.MoveOption =class n extends d{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new T([e]):this.vec=new T([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new O(e):void 0)}static U16(e){return new n(e!=null?new ce(e):void 0)}static U32(e){return new n(e!=null?new ue(e):void 0)}static U64(e){return new n(e!=null?new B(e):void 0)}static U128(e){return new n(e!=null?new pe(e):void 0)}static U256(e){return new n(e!=null?new de(e):void 0)}static Bool(e){return new n(e!=null?new R(e):void 0)}static MoveString(e){return new n(e!=null?new w(e):void 0)}static deserialize(e,r){let i=T.deserialize(e,r);return new n(i.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Vs=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(Vs||{}),S=class S extends d{constructor(e){super();if(e.length!==S.LENGTH)throw new V("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(S.LENGTH);return new S(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new V("Hex string must start with a leading 0x.","leading_zero_x_required");let r=S.fromString(e);if(e.length!==S.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new V(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new V(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e){let r=e;if(e.startsWith("0x")&&(r=e.slice(2)),r.length===0)throw new V("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new V("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let i;try{i=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(o){throw new V(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}return new S(i)}static from(e){return e instanceof S?e:e instanceof Uint8Array?new S(e):S.fromString(e)}static fromStrict(e){return e instanceof S?e:e instanceof Uint8Array?new S(e):S.fromStringStrict(e)}static isValid(e){try{return e.strict?S.fromStrict(e.input):S.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,i)=>r===e.data[i])}};S.LENGTH=32,S.LONG_STRING_LENGTH=64,S.ZERO=S.from("0x0"),S.ONE=S.from("0x1"),S.TWO=S.from("0x2"),S.THREE=S.from("0x3"),S.FOUR=S.from("0x4");var u=S;var ze=class ze extends d{constructor(e){super();let{data:r}=e,i=g.fromHexInput(r);if(i.toUint8Array().length!==ze.LENGTH)throw new Error(`Authentication Key length should be ${ze.LENGTH}`);this.data=i}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(ze.LENGTH);return new ze({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:r,input:i}=e,o=g.fromHexInput(i).toUint8Array(),s=new Uint8Array([...o,r]),a=_sha3.sha3_256.create();a.update(s);let c=a.digest();return new ze({data:c})}static fromPublicKeyAndScheme(e){let{publicKey:r}=e;return r.authKey()}static fromPublicKey(e){let{publicKey:r}=e;return r.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};ze.LENGTH=32;var F=ze;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var li = _interopRequireWildcard(_bip39);var js=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Xs= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Ys= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(Ys||{}),gi= exports.HARDENED_OFFSET =2147483648;function mi(n){return Xs.test(n)}function yi(n){return js.test(n)}var yr=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},fi= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return yr(t,s)},Zs=n=>n.replace("'",""),Ai= exports.splitPath =n=>n.split("/").slice(1).map(Zs),wn= exports.mnemonicToSeed =n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return li.mnemonicToSeedSync(t)};var qe=class extends d{toString(){let t=this.toUint8Array();return g.fromHexInput(t).toString()}},te= exports.AccountPublicKey =class extends qe{};var N=class extends d{toString(){let t=this.toUint8Array();return g.fromHexInput(t).toString()}};var ot=n=>typeof n=="string"?g.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var hi=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16],$e=class $e extends te{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==$e.LENGTH)throw new Error(`PublicKey length should be ${$e.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof _))return!1;let o=ot(r),s=g.fromHexInput(o).toUint8Array(),a=i.toUint8Array(),c=this.key.toUint8Array();return i.isCanonicalSignature()?_ed25519.ed25519.verify(a,s,c):!1}authKey(){return F.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new $e(r)}static isPublicKey(e){return e instanceof $e}};$e.LENGTH=32;var P=$e,ne=class ne extends d{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==ne.LENGTH)throw new Error(`PrivateKey length should be ${ne.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new ne(e)}static fromDerivationPath(e,r){if(!yi(e))throw new Error(`Invalid derivation path ${e}`);return ne.fromDerivationPathInner(e,wn(r))}static fromDerivationPathInner(e,r,i=gi){let{key:o,chainCode:s}=yr(ne.SLIP_0010_SEED,r),a=Ai(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,m)=>fi(p,m+i),{key:o,chainCode:s});return new ne(c)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let r=ot(e),i=g.fromHexInput(r).toUint8Array(),o=_ed25519.ed25519.sign(i,this.signingKey.toUint8Array());return new _(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ne(r)}static isPrivateKey(e){return e instanceof ne}};ne.LENGTH=32,ne.SLIP_0010_SEED="ed25519 seed";var M=ne,st=class st extends N{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==st.LENGTH)throw new Error(`Signature length should be ${st.LENGTH}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new st(r)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let r=e.length-1;r>=0;r-=1){if(e[r]<hi[r])return!0;if(e[r]>hi[r])return!1}return!1}};st.LENGTH=64;var _=st;var re=class re extends te{constructor(e){super();let{publicKeys:r,threshold:i}=e;if(r.length>re.MAX_KEYS||r.length<re.MIN_KEYS)throw new Error(`Must have between ${re.MIN_KEYS} and ${re.MAX_KEYS} public keys, inclusive`);if(i<re.MIN_THRESHOLD||i>r.length)throw new Error(`Threshold must be between ${re.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=i}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof He))return!1;let o=[];for(let s=0;s<4;s+=1)for(let a=0;a<8;a+=1)if((i.bitmap[s]&1<<7-a)!==0){let p=s*8+a;o.push(p)}if(o.length!==i.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let s=0;s<o.length;s+=1)if(!this.publicKeys[o[s]].verifySignature({message:r,signature:i.signatures[s]}))return!1;return!0}authKey(){return F.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((r,i)=>{e.set(r.toUint8Array(),i*P.LENGTH)}),e[this.publicKeys.length*P.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=P.LENGTH){let a=s;o.push(new P(r.subarray(a,a+P.LENGTH)))}return new re({publicKeys:o,threshold:i})}};re.MAX_KEYS=32,re.MIN_KEYS=2,re.MIN_THRESHOLD=1;var at=re,W=class W extends N{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>W.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${W.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r,!(i instanceof Uint8Array))this.bitmap=W.createBitmap({bits:i});else{if(i.length!==W.BITMAP_LEN)throw new Error(`"bitmap" length should be ${W.BITMAP_LEN}`);this.bitmap=i}}toUint8Array(){let e=new Uint8Array(this.signatures.length*_.LENGTH+W.BITMAP_LEN);return this.signatures.forEach((r,i)=>{e.set(r.toUint8Array(),i*_.LENGTH)}),e.set(this.bitmap,this.signatures.length*_.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r.subarray(r.length-4),o=[];for(let s=0;s<r.length-i.length;s+=_.LENGTH){let a=s;o.push(new _(r.subarray(a,a+_.LENGTH)))}return new W({signatures:o,bitmap:i})}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(a>=W.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${W.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");if(c>0&&a<=r[c-1])throw new Error("The bits need to be sorted in ascending order.");s.add(a);let p=Math.floor(a/8),m=o[p];m|=i>>a%8,o[p]=m}),o}};W.MAX_SIGNATURES_SUPPORTED=32,W.BITMAP_LEN=4;var He=W;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ve=class Ve extends qe{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==Ve.LENGTH)throw new Error(`PublicKey length should be ${Ve.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof xe))return!1;let o=ot(r),s=g.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ve(r)}static isPublicKey(e){return e instanceof Ve}};Ve.LENGTH=65;var he=Ve,Ae=class Ae extends d{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==Ae.LENGTH)throw new Error(`PrivateKey length should be ${Ae.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ae(e)}static fromDerivationPath(e,r){if(!mi(e))throw new Error(`Invalid derivation path ${e}`);return Ae.fromDerivationPathInner(e,wn(r))}static fromDerivationPathInner(e,r){let{privateKey:i}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(i===null)throw new Error("Invalid key");return new Ae(i)}sign(e){let r=ot(e),i=g.fromHexInput(r),o=_sha3.sha3_256.call(void 0, i.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new xe(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new he(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ae(r)}static isPrivateKey(e){return e instanceof Ae}};Ae.LENGTH=32;var Le=Ae,ct=class ct extends N{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==ct.LENGTH)throw new Error(`Signature length should be ${ct.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ct(r)}};ct.LENGTH=64;var xe=ct;var Qe=class n extends qe{constructor(e){super();let r=e.constructor.name;switch(r){case P.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${r}`)}}toUint8Array(){return this.bcsToBytes()}verifySignature(e){let{message:r,signature:i}=e;return this.publicKey.verifySignature({message:r,signature:i})}serialize(e){if(this.publicKey instanceof P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}}static isPublicKey(e){return e instanceof n}},le= exports.EphemeralSignature =class n extends N{constructor(e){super();let r=e.constructor.name;switch(r){case _.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${r}`)}}toUint8Array(){return this.bcsToBytes()}static fromHex(e){let r=g.fromHexInput(e),i=new ee(r.toUint8Array());return n.deserialize(i)}serialize(e){if(this.signature instanceof _)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(_.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${r}`)}}};var _poseidonlite = require('poseidon-lite');var fa=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],wi=31,Aa=16,bi=(Aa-1)*wi;function _n(n,t){let r=new TextEncoder().encode(n);return ha(r,t)}function ha(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);let e=fr(n,t);return Ft(e)}function Ta(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);let e=Sa(n,t);return ba(e)}function fr(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return Ta(n,t).concat([BigInt(n.length)])}function ba(n){if(n.length>bi)throw new Error(`Can't pack more than ${bi}. Was given ${n.length} bytes`);return wa(n,wi).map(t=>Ot(t))}function wa(n,t){let e=[];for(let r=0;r<n.length;r+=t)e.push(n.subarray(r,r+t));return e}function Ot(n){let t=BigInt(0);for(let e=n.length-1;e>=0;e-=1)t=t<<BigInt(8)|BigInt(n[e]);return t}function Si(n,t){let e=new Uint8Array(t);for(let r=0;r<t;r+=1)e[r]=Number(n&BigInt(255)),n>>=BigInt(8);return e}function Sa(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let e=new Uint8Array(t);e.set(n);for(let r=n.length;r<t;r+=1)e[r]=0;return e}function Ft(n){let t=fa[n.length-1];if(t)return t(n);throw new Error(`Unable to hash input of length ${n.length}`)}var vn=class extends d{toString(){let t=this.bcsToBytes();return g.fromHexInput(t).toString()}};var Mt=1e7,xa= exports.MAX_AUD_VAL_BYTES =120,_a= exports.MAX_UID_KEY_BYTES =30,va= exports.MAX_UID_VAL_BYTES =330,gd= exports.MAX_ISS_VAL_BYTES =120,md= exports.MAX_EXTRA_FIELD_BYTES =350,yd= exports.MAX_JWT_HEADER_B64_BYTES =300,fd= exports.MAX_COMMITED_EPK_BYTES =93,_e=class _e extends te{constructor(e,r){super();let i=g.fromHexInput(r).toUint8Array();if(i.length!==_e.ID_COMMITMENT_LENGTH)throw new Error(`Address seed length in bytes should be ${_e.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=i}authKey(){let e=new L;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),F.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return g.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new _e(r,i)}static load(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new _e(r,i)}static isPublicKey(e){return e instanceof _e}static create(e){return xi(e),new _e(e.iss,xi(e))}};_e.ID_COMMITMENT_LENGTH=32;var ge=_e;function xi(n){let{uidKey:t,uidVal:e,aud:r,pepper:i}=n,o=[Ot(g.fromHexInput(i).toUint8Array()),_n(r,xa),_n(e,va),_n(t,_a)];return Si(Ft(o),ge.ID_COMMITMENT_LENGTH)}var We=class n extends N{constructor(e){super();let{jwtHeader:r,ephemeralCertificate:i,expiryDateSecs:o,ephemeralPublicKey:s,ephemeralSignature:a}=e;this.jwtHeader=r,this.ephemeralCertificate=i,this.expiryDateSecs=o,this.ephemeralPublicKey=s,this.ephemeralSignature=a}toUint8Array(){return this.bcsToBytes()}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let r=ut.deserialize(e),i=e.deserializeStr(),o=e.deserializeU64(),s=Qe.deserialize(e),a=le.deserialize(e);return new n({jwtHeader:i,expiryDateSecs:o,ephemeralCertificate:r,ephemeralPublicKey:s,ephemeralSignature:a})}static load(e){let r=ut.deserialize(e),i=e.deserializeStr(),o=e.deserializeU64(),s=Qe.deserialize(e),a=le.deserialize(e);return new n({jwtHeader:i,expiryDateSecs:o,ephemeralCertificate:r,ephemeralPublicKey:s,ephemeralSignature:a})}static isSignature(e){return e instanceof n}},ut= exports.EphemeralCertificate =class n extends N{constructor(e,r){super();this.signature=e,this.variant=r}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(Ke.deserialize(e),r);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${r}`)}}},Gt= exports.Groth16Zkp =class n extends vn{constructor(e){super();let{a:r,b:i,c:o}=e;this.a=g.fromHexInput(r).toUint8Array(),this.b=g.fromHexInput(i).toUint8Array(),this.c=g.fromHexInput(o).toUint8Array()}serialize(e){e.serializeFixedBytes(this.a),e.serializeFixedBytes(this.b),e.serializeFixedBytes(this.c)}static deserialize(e){let r=e.deserializeFixedBytes(32),i=e.deserializeFixedBytes(64),o=e.deserializeFixedBytes(32);return new n({a:r,b:i,c:o})}},pt= exports.ZkProof =class n extends d{constructor(e,r){super();this.proof=e,this.variant=r}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(Gt.deserialize(e),r);default:throw new Error(`Unknown variant index for ZkProof: ${r}`)}}},Ke= exports.ZeroKnowledgeSig =class n extends N{constructor(e){super();let{proof:r,expHorizonSecs:i=BigInt(Mt),trainingWheelsSignature:o,extraField:s,overrideAudVal:a}=e;this.proof=r,this.expHorizonSecs=i,this.trainingWheelsSignature=o,this.extraField=s,this.overrideAudVal=a}toUint8Array(){return this.bcsToBytes()}static fromBytes(e){return n.deserialize(new ee(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let r=pt.deserialize(e),i=e.deserializeU64(),o=e.deserializeOptionStr(),s=e.deserializeOptionStr(),a=e.deserializeOption(le);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:a,extraField:o,overrideAudVal:s})}static load(e){let r=pt.deserialize(e),i=e.deserializeU64(),o=e.deserializeOptionStr(),s=e.deserializeOptionStr(),a=e.deserializeOption(le);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:a,extraField:o,overrideAudVal:s})}};var k=class n extends te{constructor(e){super();if(this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof he)this.variant=1;else if(e instanceof ge)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:i}=e;return i instanceof D?this.publicKey.verifySignature({message:r,signature:i.signature}):!1}authKey(){return F.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=P.deserialize(e);break;case 1:i=he.deserialize(e);break;case 3:i=ge.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new n(i)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof P}isSecp256k1PublicKey(){return this.publicKey instanceof he}},D= exports.AnySignature =class n extends N{constructor(e){super();if(this.signature=e,e instanceof _)this.variant=0;else if(e instanceof xe)this.variant=1;else if(e instanceof We)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=_.deserialize(e);break;case 1:i=xe.deserialize(e);break;case 3:i=We.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(i)}};function Pa(n){let t=n;return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}var dt=class n extends te{constructor(e){super();let{publicKeys:r,signaturesRequired:i}=e;if(i<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<i)throw new Error(`Provided ${r.length} public keys is smaller than the ${i} required signatures`);this.publicKeys=r.map(o=>o instanceof k?o:new k(o)),this.signaturesRequired=i}verifySignature(e){throw new Error("not implemented")}authKey(){return F.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(k),i=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:i})}createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(c+1>this.publicKeys.length)throw new Error(`Signature index ${c+1} is out of public keys range, ${this.publicKeys.length}.`);if(s.has(a))throw new Error(`Duplicate bit ${a} detected.`);s.add(a);let p=Math.floor(a/8),m=o[p];m|=i>>a%8,o[p]=m}),o}getIndex(e){let r=e instanceof k?e:new k(e),i=this.publicKeys.findIndex(o=>o.toString()===r.toString());if(i!==-1)return i;throw new Error("Public key not found in MultiKey")}},j=class j extends N{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>j.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${j.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(s=>s instanceof D?s:new D(s)),!(i instanceof Uint8Array))this.bitmap=j.createBitmap({bits:i});else{if(i.length!==j.BITMAP_LEN)throw new Error(`"bitmap" length should be ${j.BITMAP_LEN}`);this.bitmap=i}let o=this.bitmap.reduce((s,a)=>s+Pa(a),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach(a=>{if(a>=j.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${j.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");s.add(a);let c=Math.floor(a/8),p=o[c];p|=i>>a%8,o[c]=p}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeVector(D),i=e.deserializeBytes();return new j({signatures:r,bitmap:i})}};j.BITMAP_LEN=4,j.MAX_SIGNATURES_SUPPORTED=j.BITMAP_LEN*8;var je=j;var q=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return me.load(t);case 1:return Pn.load(t);case 2:return $.load(t);case 3:return Xe.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof me}isMultiEd25519(){return this instanceof Pn}isSingleKey(){return this instanceof $}isMultiKey(){return this instanceof Xe}},me= exports.AccountAuthenticatorEd25519 =class n extends q{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=P.deserialize(e),i=_.deserialize(e);return new n(r,i)}},Pn= exports.AccountAuthenticatorMultiEd25519 =class n extends q{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=at.deserialize(e),i=He.deserialize(e);return new n(r,i)}},$= exports.AccountAuthenticatorSingleKey =class n extends q{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=k.deserialize(e),i=D.deserialize(e);return new n(r,i)}},Xe= exports.AccountAuthenticatorMultiKey =class n extends q{constructor(e,r){super();this.public_keys=e,this.signatures=r}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let r=dt.deserialize(e),i=je.deserialize(e);return new n(r,i)}};var qt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(qt||{}),_i= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,vi= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Cn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,En= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Pi= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",Ar= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",lt= exports.ProcessorType =(a=>(a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a))(lt||{});var gt=class n extends d{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new n(r)}};var U=class n extends d{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new n(r)}};var $t=class n extends d{constructor(e,r){super();this.address=e,this.name=r}static fromStr(e){let r=e.split("::");if(r.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(r[0]),new U(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),i=U.deserialize(e);return new n(r,i)}};var z=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return G.load(t);case 1:return Te.load(t);case 2:return Q.load(t);case 3:return ft.load(t);case 4:return X.load(t);case 5:return Ye.load(t);case 6:return C.load(t);case 7:return y.load(t);case 8:return mt.load(t);case 9:return yt.load(t);case 10:return At.load(t);case 255:return K.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof G}isAddress(){return this instanceof X}isGeneric(){return this instanceof K}isSigner(){return this instanceof Ye}isVector(){return this instanceof C}isStruct(){return this instanceof y}isU8(){return this instanceof Te}isU16(){return this instanceof mt}isU32(){return this instanceof yt}isU64(){return this instanceof Q}isU128(){return this instanceof ft}isU256(){return this instanceof At}},G= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},Te= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},mt= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},yt= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},Q= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},ft= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},At= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},X= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},Ye= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},In= exports.TypeTagReference =class n extends z{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=z.deserialize(e);return new n(r)}},K= exports.TypeTagGeneric =class n extends z{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let r=e.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends z{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new Te)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=z.deserialize(e);return new n(r)}},y= exports.TypeTagStruct =class n extends z{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let r=ve.deserialize(e);return new n(r)}isTypeTag(e,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(e)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},ve= exports.StructTag =class n extends d{constructor(e,r,i,o){super();this.address=e,this.moduleName=r,this.name=i,this.typeArgs=o}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let r=u.deserialize(e),i=U.deserialize(e),o=U.deserialize(e),s=e.deserializeVector(z);return new n(r,i,o,s)}};function Pl(){return new ve(u.ONE,new U("aptos_coin"),new U("AptosCoin"),[])}function v(){return new ve(u.ONE,new U("string"),new U("String"),[])}function Cl(n){return new ve(u.ONE,new U("option"),new U("Option"),[n])}function Y(n){return new ve(u.ONE,new U("object"),new U("Object"),[n])}function Ca(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return O.deserialize(n);case 1:return B.deserialize(n);case 2:return pe.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,O);case 5:return R.deserialize(n);case 6:return ce.deserialize(n);case 7:return ue.deserialize(n);case 8:return de.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var Ze=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ht.load(t);case 2:return Vt.load(t);case 3:return Lt.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Ht= exports.TransactionPayloadScript =class n extends Ze{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=Qt.deserialize(e);return new n(r)}},Vt= exports.TransactionPayloadEntryFunction =class n extends Ze{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=Je.deserialize(e);return new n(r)}},Lt= exports.TransactionPayloadMultiSig =class n extends Ze{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Wt.deserialize(e);return new n(r)}},Je= exports.EntryFunction =class n{constructor(t,e,r,i){this.module_name=t,this.function_name=e,this.type_args=r,this.args=i}static build(t,e,r,i){return new n($t.fromStr(t),new U(e),r,i)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=$t.deserialize(t),r=U.deserialize(t),i=t.deserializeVector(z),o=t.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=t.deserializeUleb128AsU32(),p=Tn.deserialize(t,c);s.push(p)}return new n(e,r,i,s)}},Qt= exports.Script =class n{constructor(t,e,r){this.bytecode=t,this.type_args=e,this.args=r}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),r=t.deserializeVector(z),i=t.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Ca(t);o.push(a)}return new n(e,r,o)}},Wt= exports.MultiSig =class n{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=u.deserialize(t),r=t.deserializeBool(),i;return r&&(i=jt.deserialize(t)),new n(e,i)}},jt= exports.MultiSigTransactionPayload =class n extends d{constructor(e){super();this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(Je.deserialize(e))}};var ie=class n extends d{constructor(e,r,i,o,s,a,c){super();this.sender=e,this.sequence_number=r,this.payload=i,this.max_gas_amount=o,this.gas_unit_price=s,this.expiration_timestamp_secs=a,this.chain_id=c}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let r=u.deserialize(e),i=e.deserializeU64(),o=Ze.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=gt.deserialize(e);return new n(r,i,o,s,a,c,p)}},Un= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return et.load(t);case 1:return tt.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},et= exports.MultiAgentRawTransaction =class n extends Un{constructor(e,r){super();this.raw_txn=e,this.secondary_signer_addresses=r}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let r=ie.deserialize(e),i=e.deserializeVector(u);return new n(r,i)}},tt= exports.FeePayerRawTransaction =class n extends Un{constructor(e,r,i){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=i}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let r=ie.deserialize(e),i=e.deserializeVector(u),o=u.deserialize(e);return new n(r,i,o)}};var Rn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new B(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=T.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var Pe=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return ht.load(t);case 1:return hr.load(t);case 2:return Tt.load(t);case 3:return bt.load(t);case 4:return wt.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},ht= exports.TransactionAuthenticatorEd25519 =class n extends Pe{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=P.deserialize(e),i=_.deserialize(e);return new n(r,i)}},hr= exports.TransactionAuthenticatorMultiEd25519 =class n extends Pe{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=at.deserialize(e),i=He.deserialize(e);return new n(r,i)}},Tt= exports.TransactionAuthenticatorMultiAgent =class n extends Pe{constructor(e,r,i){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=q.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(q);return new n(r,i,o)}},bt= exports.TransactionAuthenticatorFeePayer =class n extends Pe{constructor(e,r,i,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i,this.fee_payer=o}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let r=q.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(q),s=u.deserialize(e),a=q.deserialize(e),c={address:s,authenticator:a};return new n(r,i,o,c)}},wt= exports.TransactionAuthenticatorSingleSender =class n extends Pe{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=q.deserialize(e);return new n(r)}};var nt=class n extends d{constructor(e,r){super();this.raw_txn=e,this.authenticator=r}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let r=ie.deserialize(e),i=Pe.deserialize(e);return new n(r,i)}};var zn=class n extends d{constructor(e,r){super();this.rawTransaction=e,this.feePayerAddress=r}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=ie.deserialize(e),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(r,o)}};var Kn=class n extends d{constructor(e,r,i){super();this.rawTransaction=e,this.feePayerAddress=i,this.secondarySignerAddresses=r}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=ie.deserialize(e),i=e.deserializeVector(u),o=e.deserializeBool(),s;return o&&(s=u.deserialize(e)),new n(r,i,s)}};function Tr(n){return n.feePayerAddress?new tt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new et(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function kn(n,t){let e=_sha3.sha3_256.create();if(!t.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${t}`);e.update(t);let r=e.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function Ci(n){return kn(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function St(n){let t=Tr(n);return n.feePayerAddress?kn(t.bcsToBytes(),Ar):n.secondarySignerAddresses?kn(t.bcsToBytes(),Ar):kn(t.bcsToBytes(),Pi)}var xt=class n{constructor(t){this.signingScheme=0;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=e.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let t=M.generate();return new n({privateKey:t})}static fromDerivationPath(t){let{path:e,mnemonic:r}=t,i=M.fromDerivationPath(e,r);return new n({privateKey:i})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){return new me(this.publicKey,this.privateKey.sign(t))}signTransactionWithAuthenticator(t){return new me(this.publicKey,this.signTransaction(t))}sign(t){return this.privateKey.sign(t)}signTransaction(t){return this.sign(St(t))}};var _t=class n{constructor(t){this.signingScheme=2;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=new k(e.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(t={}){let{scheme:e=0}=t,r;switch(e){case 0:r=M.generate();break;case 2:r=Le.generate();break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:r})}static fromDerivationPath(t){let{scheme:e=0,path:r,mnemonic:i}=t,o;switch(e){case 0:o=M.fromDerivationPath(r,i);break;case 2:o=Le.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:o})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){return new $(this.publicKey,this.sign(t))}signTransactionWithAuthenticator(t){return new $(this.publicKey,this.signTransaction(t))}sign(t){return new D(this.privateKey.sign(t))}signTransaction(t){return this.sign(St(t))}};var ke=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?xt.generate():_t.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:i=!0}=t;return e instanceof M&&i?new xt({privateKey:e,address:r}):new _t({privateKey:e,address:r})}static fromPrivateKeyAndAddress(t){return this.fromPrivateKey(t)}static fromDerivationPath(t){let{scheme:e=0,mnemonic:r,path:i,legacy:o=!0}=t;return e===0&&o?xt.fromDerivationPath({mnemonic:r,path:i}):_t.fromDerivationPath({scheme:e,mnemonic:r,path:i})}static authKey(t){let{publicKey:e}=t;return e.authKey()}verifySignature(t){return this.publicKey.verifySignature(t)}};var vt=class vt extends d{constructor(e){super();let{privateKey:r,expiryDateSecs:i,blinder:o}=e;this.privateKey=r,this.publicKey=new Qe(r.publicKey()),this.expiryDateSecs=i||BigInt(za(Ra()+Mt)),this.blinder=o!==void 0?g.fromHexInput(o).toUint8Array():Ua(),this.nonce=this.generateNonce()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=M.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}let o=e.deserializeU64(),s=e.deserializeFixedBytes(31);return new vt({privateKey:i,expiryDateSecs:o,blinder:s})}static fromBytes(e){return vt.deserialize(new ee(e))}static generate(e){let r;switch(_optionalChain([e, 'optionalAccess', _8 => _8.scheme])){case 0:default:r=M.generate()}return new vt({privateKey:r,expiryDateSecs:_optionalChain([e, 'optionalAccess', _9 => _9.expiryDateSecs])})}generateNonce(){let e=fr(this.publicKey.bcsToBytes(),93);return e.push(BigInt(this.expiryDateSecs)),e.push(Ot(this.blinder)),Ft(e).toString()}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new le(this.privateKey.sign(e))}};vt.BLINDER_LENGTH=31;var Xt=vt;function Ua(){return _utils.randomBytes.call(void 0, Xt.BLINDER_LENGTH)}function Ra(){return Math.floor(new Date().getTime()/1e3)}function za(n){let t=new Date(n*1e3);return t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),Math.floor(t.getTime()/1e3)}var _jwtdecode = require('jwt-decode');var _jwksrsa = require('jwks-rsa');var _jsbase64 = require('js-base64');var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Da={"https://accounts.google.com":"https://www.googleapis.com/oauth2/v3/certs"},Ba= exports.KeylessErrorType =(o=>(o[o.JWK_EXPIRED=0]="JWK_EXPIRED",o[o.EPK_EXPIRED=1]="EPK_EXPIRED",o[o.PROOF_NOT_FOUND=2]="PROOF_NOT_FOUND",o[o.UNKNOWN_INVALID_SIGNATURE=3]="UNKNOWN_INVALID_SIGNATURE",o[o.UNKNOWN=4]="UNKNOWN",o))(Ba||{}),Yt= exports.KeylessError =class n extends Error{constructor(e){super();this.type=e}static async fromAptosApiError(e,r){return e.data.message.includes("INVALID_SIGNATURE")?r.isExpired()?new n(1):await r.checkJwkValidity()?new n(3):new n(0):new n(4)}},Ne=class Ne extends d{constructor(e){super();let{address:r,ephemeralKeyPair:i,uidKey:o,uidVal:s,aud:a,pepper:c,proofOrFetcher:p,proofFetchCallback:m,jwt:x}=e;if(this.ephemeralKeyPair=i,this.publicKey=ge.create(e),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=s,this.aud=a,this.jwt=x,this.emitter=new _eventemitter32.default,this.proofOrPromise=p,p instanceof Ke)this.proof=p;else{if(m===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async l=>{await m(l),this.emitter.removeAllListeners()}),this.init(p)}this.signingScheme=2;let A=g.fromHexInput(c).toUint8Array();if(A.length!==Ne.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${Ne.PEPPER_LENGTH}`);this.pepper=A,this.isJwtValid=!0}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeFixedBytes(31),s=Xt.deserialize(e),a=Ke.deserialize(e);return Ne.fromJWTAndProof({proof:a,pepper:o,uidKey:i,jwt:r,ephemeralKeyPair:s})}isExpired(){return this.ephemeralKeyPair.isExpired()}async checkJwkValidity(){if(!this.isJwtValid)return!1;let e=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0}),r=new (0, _jwksrsa.JwksClient)({jwksUri:Da[this.publicKey.iss]});try{return await r.getSigningKey(e.kid),!0}catch (e2){return this.isJwtValid=!1,!1}}signWithAuthenticator(e){let r=new D(this.sign(e)),i=new k(this.publicKey);return new $(i,r)}signTransactionWithAuthenticator(e){let r=new D(this.signTransaction(e)),i=new k(this.publicKey);return new $(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw new Yt(1);if(this.proof===void 0)throw new Yt(2);if(!this.isJwtValid)throw new Yt(0);let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(e);return new We({jwtHeader:Oa(this.jwt.split(".")[0]),ephemeralCertificate:new ut(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let r=Tr(e),i=new br(r,this.proof.proof),o=Ci(i);return this.sign(o)}verifySignature(e){throw new Error("Not implemented")}static fromBytes(e){return Ne.deserialize(new ee(e))}static fromJWTAndProof(e){let{proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,proofFetchCallback:a}=e,c=_nullishCoalesce(e.uidKey, () => ("sub")),p=_jwtdecode.jwtDecode.call(void 0, i),m=p.iss;if(typeof p.aud!="string")throw new Error("aud was not found or an array of values");let x=p.aud,A=p[c];return new Ne({proofOrFetcher:r,ephemeralKeyPair:o,iss:m,uidKey:c,uidVal:A,aud:x,pepper:s,jwt:i,proofFetchCallback:a})}};Ne.PEPPER_LENGTH=31;var be=Ne,br=class extends d{constructor(e,r){super();this.transaction=e,this.proof=r}serialize(e){e.serializeFixedBytes(this.transaction.bcsToBytes()),e.serializeOption(this.proof)}};function Oa(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),e=t+"==".substring(0,(3-t.length%3)%3);return _jsbase64.decode.call(void 0, e)}var Nn=class n{constructor(t){let{multiKey:e,signers:r}=t;this.publicKey=e,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let i=[];for(let s of r)i.push(this.publicKey.getIndex(s.publicKey));let o=r.map((s,a)=>[s,i[a]]);o.sort((s,a)=>s[1]-a[1]),this.signers=o.map(s=>s[0]),this.signerIndicies=o.map(s=>s[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:i})}static fromPublicKeysAndSigners(t){let{publicKeys:e,signaturesRequired:r,signers:i}=t,o=new dt({publicKeys:e,signaturesRequired:r});return new n({multiKey:o,signers:i})}static isMultiKeySigner(t){return t instanceof n}signWithAuthenticator(t){return new Xe(this.publicKey,this.sign(t))}signTransactionWithAuthenticator(t){return new Xe(this.publicKey,this.signTransaction(t))}async waitForProofFetch(){let t=this.signers.filter(e=>e instanceof be);await Promise.all(t.filter(e=>e.proof instanceof Promise).map(e=>e.proof))}sign(t){let e=[];for(let r of this.signers)e.push(r.sign(t));return new je({signatures:e,bitmap:this.signaturesBitmap})}signTransaction(t){let e=[];for(let r of this.signers)e.push(r.signTransaction(t));return new je({signatures:e,bitmap:this.signaturesBitmap})}verifySignature(t){let{message:e,signature:r}=t;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:e,signature:s}))return!1}return!0}};var oe=class extends Error{constructor(e,r,i){super(i);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var Ii="1.14.0";var Ui={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},Ri= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},zi= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},wr= exports.NetworkToPepperAPI ={mainnet:"https://pepper.keyless.mainnet.aptoslabs.com/v0",testnet:"https://pepper.keyless.testnet.aptoslabs.com/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"http://127.0.0.1:8000/v0"},Sr= exports.NetworkToProverAPI ={mainnet:"https://prover.keyless.mainnet.aptoslabs.com/v0",testnet:"https://prover.keyless.testnet.aptoslabs.com/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"http://127.0.0.1:8083/v0"},xr= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(xr||{}),_r= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},iy= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};function Ki(n,t){let e=t.bcsToBytes(),r=new ee(e);return n.deserialize(r)}var ki={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function Fa(n,t){let{url:e,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _10 => _10.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Ii}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _11 => _11.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _12 => _12.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _13 => _13.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _14 => _14.API_KEY])}`),t.provider({url:e,method:r,body:i,params:s,headers:p,overrides:a})}async function Dn(n,t,e){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Fa({...n,url:o},t.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new oe(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new oe(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}if(a.status>=200&&a.status<300)return a;if(a.status>=500)throw new oe(n,a,`${s.data}`);if(t.isPepperServiceRequest(r)||t.isProverServiceRequest(r))throw new oe(n,a,`${s.data}`);let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in ki?c=ki[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new oe(n,a,`${e} error: ${c}`)}async function vr(n){let{aptosConfig:t,overrides:e,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return Dn({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...t.clientConfig,...e}},t,n.type)}async function Z(n){let{aptosConfig:t}=n;return vr({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _15 => _15.clientConfig, 'optionalAccess', _16 => _16.HEADERS]),..._optionalChain([t, 'access', _17 => _17.fullnodeConfig, 'optionalAccess', _18 => _18.HEADERS])}}})}async function Py(n){return vr({...n,type:"Pepper"})}async function Pt(n){let t=[],e,r=n.params;do{let i=await vr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=i.headers["x-aptos-cursor"],delete i.headers,t.push(...i.data),r.start=e}while(e!=null);return t}async function Zt(n){let{type:t,originMethod:e,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,m=c.getRequestUrl(t);return Dn({url:m,method:"POST",originMethod:e,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function rt(n){let{aptosConfig:t}=n;return Zt({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _19 => _19.clientConfig, 'optionalAccess', _20 => _20.HEADERS]),..._optionalChain([t, 'access', _21 => _21.fullnodeConfig, 'optionalAccess', _22 => _22.HEADERS])}}})}async function Ni(n){let{aptosConfig:t}=n;return Zt({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _23 => _23.clientConfig, 'optionalAccess', _24 => _24.HEADERS]),..._optionalChain([t, 'access', _25 => _25.indexerConfig, 'optionalAccess', _26 => _26.HEADERS])}}})}async function Di(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _27 => _27.clientConfig, 'optionalAccess', _28 => delete _28.API_KEY]),Zt({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _29 => _29.clientConfig, 'optionalAccess', _30 => _30.HEADERS]),..._optionalChain([e, 'access', _31 => _31.faucetConfig, 'optionalAccess', _32 => _32.HEADERS])}}})}async function Bi(n){return Zt({...n,type:"Pepper"})}async function Oi(n){return Zt({...n,type:"Prover"})}var Ga=`
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var _chunkKSEUZTKYjs = require('./chunk-KSEUZTKY.js');var fn=255,An=65535,Se=4294967295,Fe=18446744073709551615n,Nt=340282366920938463463374607431768211455n,hn=115792089237316195423570985008687907853269984665640564039457584007913129639935n;var ee=class{constructor(t){this.buffer=new ArrayBuffer(t.length),new Uint8Array(this.buffer).set(t,0),this.offset=0}read(t){if(this.offset+t>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}deserializeStr(){let t=this.deserializeBytes();return new TextDecoder().decode(t)}deserializeOptionStr(){if(this.deserializeUleb128AsU32()===1)return this.deserializeStr()}deserializeOption(t){if(this.deserializeUleb128AsU32()===1)return this.deserialize(t)}deserializeBytes(){let t=this.deserializeUleb128AsU32();return new Uint8Array(this.read(t))}deserializeFixedBytes(t){return new Uint8Array(this.read(t))}deserializeBool(){let t=new Uint8Array(this.read(1))[0];if(t!==1&&t!==0)throw new Error("Invalid boolean value");return t===1}deserializeU8(){return new DataView(this.read(1)).getUint8(0)}deserializeU16(){return new DataView(this.read(2)).getUint16(0,!0)}deserializeU32(){return new DataView(this.read(4)).getUint32(0,!0)}deserializeU64(){let t=this.deserializeU32(),e=this.deserializeU32();return BigInt(BigInt(e)<<BigInt(32)|BigInt(t))}deserializeU128(){let t=this.deserializeU64(),e=this.deserializeU64();return BigInt(e<<BigInt(64)|t)}deserializeU256(){let t=this.deserializeU128(),e=this.deserializeU128();return BigInt(e<<BigInt(128)|t)}deserializeUleb128AsU32(){let t=BigInt(0),e=0;for(;t<Se;){let r=this.deserializeU8();if(t|=BigInt(r&127)<<BigInt(e),!(r&128))break;e+=7}if(t>Se)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(t)}deserialize(t){return t.deserialize(this)}deserializeVector(t){let e=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<e;i+=1)r.push(this.deserialize(t));return r}};var _utils = require('@noble/hashes/utils');var V=class extends Error{constructor(e,r){super(e);this.invalidReason=r}};var Gs=(r=>(r.TOO_SHORT="too_short",r.INVALID_LENGTH="invalid_length",r.INVALID_HEX_CHARS="invalid_hex_chars",r))(Gs||{}),g= exports.Hex =class n{constructor(t){this.data=t}toUint8Array(){return this.data}toStringWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(t){let e=t;if(e.startsWith("0x")&&(e=e.slice(2)),e.length===0)throw new V("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(e.length%2!==0)throw new V("Hex string must be an even number of hex characters.","invalid_length");try{return new n(_utils.hexToBytes.call(void 0, e))}catch(r){throw new V(`Hex string contains invalid hex characters: ${_optionalChain([r, 'optionalAccess', _2 => _2.message])}`,"invalid_hex_chars")}}static fromHexInput(t){return t instanceof Uint8Array?new n(t):n.fromHexString(t)}static isValid(t){try{return n.fromHexString(t),{valid:!0}}catch(e){return{valid:!1,invalidReason:_optionalChain([e, 'optionalAccess', _3 => _3.invalidReason]),invalidReasonMessage:_optionalChain([e, 'optionalAccess', _4 => _4.message])}}}equals(t){return this.data.length!==t.data.length?!1:this.data.every((e,r)=>e===t.data[r])}};var d=class{bcsToBytes(){let t=new L;return this.serialize(t),t.toUint8Array()}bcsToHex(){let t=this.bcsToBytes();return g.fromHexInput(t)}},L= exports.Serializer =class{constructor(t=64){if(t<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(t),this.offset=0}ensureBufferWillHandleSize(t){for(;this.buffer.byteLength<this.offset+t;){let e=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(e).set(new Uint8Array(this.buffer)),this.buffer=e}}appendToBuffer(t){this.ensureBufferWillHandleSize(t.length),new Uint8Array(this.buffer,this.offset).set(t),this.offset+=t.length}serializeWithFunction(t,e,r){this.ensureBufferWillHandleSize(e);let i=new DataView(this.buffer,this.offset);t.apply(i,[0,r,!0]),this.offset+=e}serializeStr(t){let e=new TextEncoder;this.serializeBytes(e.encode(t))}serializeBytes(t){this.serializeU32AsUleb128(t.length),this.appendToBuffer(t)}serializeFixedBytes(t){this.appendToBuffer(t)}serializeBool(t){ur(t);let e=t?1:0;this.appendToBuffer(new Uint8Array([e]))}serializeU8(t){this.appendToBuffer(new Uint8Array([t]))}serializeU16(t){this.serializeWithFunction(DataView.prototype.setUint16,2,t)}serializeU32(t){this.serializeWithFunction(DataView.prototype.setUint32,4,t)}serializeU64(t){let e=BigInt(t)&BigInt(Se),r=BigInt(t)>>BigInt(32);this.serializeU32(Number(e)),this.serializeU32(Number(r))}serializeU128(t){let e=BigInt(t)&Fe,r=BigInt(t)>>BigInt(64);this.serializeU64(e),this.serializeU64(r)}serializeU256(t){let e=BigInt(t)&Nt,r=BigInt(t)>>BigInt(128);this.serializeU128(e),this.serializeU128(r)}serializeU32AsUleb128(t){let e=t,r=[];for(;e>>>7;)r.push(e&127|128),e>>>=7;r.push(e),this.appendToBuffer(new Uint8Array(r))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(t){t.serialize(this)}serializeVector(t){this.serializeU32AsUleb128(t.length),t.forEach(e=>{e.serialize(this)})}serializeOption(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),t.serialize(this))}serializeOptionStr(t){t===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(t))}};_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,fn)],L.prototype,"serializeU8",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,An)],L.prototype,"serializeU16",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,Se)],L.prototype,"serializeU32",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(BigInt(0),Fe)],L.prototype,"serializeU64",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(BigInt(0),Nt)],L.prototype,"serializeU128",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(BigInt(0),hn)],L.prototype,"serializeU256",1),_chunkKSEUZTKYjs.a.call(void 0, [Ge(0,Se)],L.prototype,"serializeU32AsUleb128",1);function ur(n){if(typeof n!="boolean")throw new Error(`${n} is not a boolean value`)}var Ms=(n,t,e)=>`${n} is out of range: [${t}, ${e}]`;function Ue(n,t,e){let r=BigInt(n);if(r>BigInt(e)||r<BigInt(t))throw new Error(Ms(n,t,e))}function Ge(n,t){return(e,r,i)=>{let o=i.value;return i.value=function(a){return Ue(a,n,t),o.apply(this,[a])},i}}var Me=class n extends d{constructor(e){super();this.value=g.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,r){let i=e.deserializeFixedBytes(r);return new n(i)}};var Tn=class n extends d{constructor(e){super();this.value=new Me(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,r){let i=Me.deserialize(e,r);return new n(i.value)}};var bn=(i=>(i.JSON="application/json",i.BCS="application/x-bcs",i.BCS_SIGNED_TRANSACTION="application/x.aptos.signed_transaction+bcs",i.BCS_VIEW_FUNCTION="application/x.aptos.view_function+bcs",i))(bn||{}),ii= exports.TypeTagVariants =(l=>(l[l.Bool=0]="Bool",l[l.U8=1]="U8",l[l.U64=2]="U64",l[l.U128=3]="U128",l[l.Address=4]="Address",l[l.Signer=5]="Signer",l[l.Vector=6]="Vector",l[l.Struct=7]="Struct",l[l.U16=8]="U16",l[l.U32=9]="U32",l[l.U256=10]="U256",l[l.Reference=254]="Reference",l[l.Generic=255]="Generic",l))(ii||{}),Bt= exports.ScriptTransactionArgumentVariants =(p=>(p[p.U8=0]="U8",p[p.U64=1]="U64",p[p.U128=2]="U128",p[p.Address=3]="Address",p[p.U8Vector=4]="U8Vector",p[p.Bool=5]="Bool",p[p.U16=6]="U16",p[p.U32=7]="U32",p[p.U256=8]="U256",p))(Bt||{}),oi= exports.TransactionPayloadVariants =(r=>(r[r.Script=0]="Script",r[r.EntryFunction=2]="EntryFunction",r[r.Multisig=3]="Multisig",r))(oi||{}),si= exports.TransactionVariants =(e=>(e[e.MultiAgentTransaction=0]="MultiAgentTransaction",e[e.FeePayerTransaction=1]="FeePayerTransaction",e))(si||{}),ai= exports.TransactionAuthenticatorVariant =(o=>(o[o.Ed25519=0]="Ed25519",o[o.MultiEd25519=1]="MultiEd25519",o[o.MultiAgent=2]="MultiAgent",o[o.FeePayer=3]="FeePayer",o[o.SingleSender=4]="SingleSender",o))(ai||{}),ci= exports.AccountAuthenticatorVariant =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(ci||{}),pr= exports.AnyPublicKeyVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(pr||{}),ui= exports.AnySignatureVariant =(r=>(r[r.Ed25519=0]="Ed25519",r[r.Secp256k1=1]="Secp256k1",r[r.Keyless=3]="Keyless",r))(ui||{}),dr= exports.EphemeralPublicKeyVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(dr||{}),pi= exports.EphemeralSignatureVariant =(t=>(t[t.Ed25519=0]="Ed25519",t))(pi||{}),lr= exports.EphemeralCertificateVariant =(t=>(t[t.ZkProof=0]="ZkProof",t))(lr||{}),gr= exports.ZkpVariant =(t=>(t[t.Groth16=0]="Groth16",t))(gr||{}),mr= exports.TransactionResponseType =(s=>(s.Pending="pending_transaction",s.User="user_transaction",s.Genesis="genesis_transaction",s.BlockMetadata="block_metadata_transaction",s.StateCheckpoint="state_checkpoint_transaction",s.Validator="validator_transaction",s))(mr||{});function nu(n){return n.type==="pending_transaction"}function ru(n){return n.type==="user_transaction"}function iu(n){return n.type==="genesis_transaction"}function ou(n){return n.type==="block_metadata_transaction"}function su(n){return n.type==="state_checkpoint_transaction"}function au(n){return n.type==="validator_transaction"}function cu(n){return"signature"in n&&n.signature==="ed25519_signature"}function uu(n){return"signature"in n&&n.signature==="secp256k1_ecdsa_signature"}function pu(n){return n.type==="multi_agent_signature"}function du(n){return n.type==="fee_payer_signature"}function lu(n){return n.type==="multi_ed25519_signature"}var qs=(r=>(r.PRIVATE="private",r.PUBLIC="public",r.FRIEND="friend",r))(qs||{}),di= exports.MoveAbility =(i=>(i.STORE="store",i.DROP="drop",i.KEY="key",i.COPY="copy",i))(di||{}),$s= exports.RoleType =(e=>(e.VALIDATOR="validator",e.FULL_NODE="full_node",e))($s||{}),fe= exports.SigningScheme =(i=>(i[i.Ed25519=0]="Ed25519",i[i.MultiEd25519=1]="MultiEd25519",i[i.SingleKey=2]="SingleKey",i[i.MultiKey=3]="MultiKey",i))(fe||{}),yr= exports.SigningSchemeInput =(e=>(e[e.Ed25519=0]="Ed25519",e[e.Secp256k1Ecdsa=2]="Secp256k1Ecdsa",e))(yr||{}),Hs= exports.DeriveScheme =(o=>(o[o.DeriveAuid=251]="DeriveAuid",o[o.DeriveObjectAddressFromObject=252]="DeriveObjectAddressFromObject",o[o.DeriveObjectAddressFromGuid=253]="DeriveObjectAddressFromGuid",o[o.DeriveObjectAddressFromSeed=254]="DeriveObjectAddressFromSeed",o[o.DeriveResourceAccountAddress=255]="DeriveResourceAccountAddress",o))(Hs||{});var R=class n extends d{constructor(e){super();ur(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}static deserialize(e){return new n(e.deserializeBool())}},O= exports.U8 =class n extends d{constructor(e){super();Ue(e,0,fn),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},ce= exports.U16 =class n extends d{constructor(e){super();Ue(e,0,An),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},ue= exports.U32 =class n extends d{constructor(e){super();Ue(e,0,Se),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},B= exports.U64 =class n extends d{constructor(e){super();Ue(e,BigInt(0),Fe),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},pe= exports.U128 =class n extends d{constructor(e){super();Ue(e,BigInt(0),Nt),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},de= exports.U256 =class n extends d{constructor(e){super();Ue(e,BigInt(0),hn),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var T=class n extends d{constructor(e){super();this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(!(this.values[0]instanceof O)&&this.values[0]!==void 0)throw new Error("Script function arguments only accept u8 vectors");e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let i=g.fromHexInput(e);r=Array.from(i.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type");return new n(r.map(i=>new O(i)))}static U16(e){return new n(e.map(r=>new ce(r)))}static U32(e){return new n(e.map(r=>new ue(r)))}static U64(e){return new n(e.map(r=>new B(r)))}static U128(e){return new n(e.map(r=>new pe(r)))}static U256(e){return new n(e.map(r=>new de(r)))}static Bool(e){return new n(e.map(r=>new R(r)))}static MoveString(e){return new n(e.map(r=>new w(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1)o.push(r.deserialize(e));return new n(o)}},w= exports.MoveString =class n extends d{constructor(e){super();this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=this.bcsToBytes().slice(1);T.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Re= exports.MoveOption =class n extends d{constructor(e){super();typeof e<"u"&&e!==null?this.vec=new T([e]):this.vec=new T([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new n(e!=null?new O(e):void 0)}static U16(e){return new n(e!=null?new ce(e):void 0)}static U32(e){return new n(e!=null?new ue(e):void 0)}static U64(e){return new n(e!=null?new B(e):void 0)}static U128(e){return new n(e!=null?new pe(e):void 0)}static U256(e){return new n(e!=null?new de(e):void 0)}static Bool(e){return new n(e!=null?new R(e):void 0)}static MoveString(e){return new n(e!=null?new w(e):void 0)}static deserialize(e,r){let i=T.deserialize(e,r);return new n(i.values[0])}};var _ed25519 = require('@noble/curves/ed25519');var _sha3 = require('@noble/hashes/sha3');var Ls=(a=>(a.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",a.INVALID_HEX_CHARS="invalid_hex_chars",a.TOO_SHORT="too_short",a.TOO_LONG="too_long",a.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",a.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",a.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",a))(Ls||{}),S=class S extends d{constructor(e){super();if(e.length!==S.LENGTH)throw new V("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=_utils.bytesToHex.call(void 0, this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return _utils.bytesToHex.call(void 0, this.data)}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(S.LENGTH);return new S(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new V("Hex string must start with a leading 0x.","leading_zero_x_required");let r=S.fromString(e);if(e.length!==S.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new V(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new V(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e){let r=e;if(e.startsWith("0x")&&(r=e.slice(2)),r.length===0)throw new V("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(r.length>64)throw new V("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");let i;try{i=_utils.hexToBytes.call(void 0, r.padStart(64,"0"))}catch(o){throw new V(`Hex characters are invalid: ${_optionalChain([o, 'optionalAccess', _5 => _5.message])}`,"invalid_hex_chars")}return new S(i)}static from(e){return e instanceof S?e:e instanceof Uint8Array?new S(e):S.fromString(e)}static fromStrict(e){return e instanceof S?e:e instanceof Uint8Array?new S(e):S.fromStringStrict(e)}static isValid(e){try{return e.strict?S.fromStrict(e.input):S.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:_optionalChain([r, 'optionalAccess', _6 => _6.invalidReason]),invalidReasonMessage:_optionalChain([r, 'optionalAccess', _7 => _7.message])}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,i)=>r===e.data[i])}};S.LENGTH=32,S.LONG_STRING_LENGTH=64,S.ZERO=S.from("0x0"),S.ONE=S.from("0x1"),S.TWO=S.from("0x2"),S.THREE=S.from("0x3"),S.FOUR=S.from("0x4");var u=S;var ze=class ze extends d{constructor(e){super();let{data:r}=e,i=g.fromHexInput(r);if(i.toUint8Array().length!==ze.LENGTH)throw new Error(`Authentication Key length should be ${ze.LENGTH}`);this.data=i}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeFixedBytes(ze.LENGTH);return new ze({data:r})}toString(){return this.data.toString()}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:r,input:i}=e,o=g.fromHexInput(i).toUint8Array(),s=new Uint8Array([...o,r]),a=_sha3.sha3_256.create();a.update(s);let c=a.digest();return new ze({data:c})}static fromPublicKeyAndScheme(e){let{publicKey:r}=e;return r.authKey()}static fromPublicKey(e){let{publicKey:r}=e;return r.authKey()}derivedAddress(){return new u(this.data.toUint8Array())}};ze.LENGTH=32;var F=ze;var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var gi = _interopRequireWildcard(_bip39);var Xs=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ys= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Zs= exports.KeyType =(t=>(t.ED25519="ed25519 seed",t))(Zs||{}),mi= exports.HARDENED_OFFSET =2147483648;function yi(n){return Ys.test(n)}function fi(n){return Xs.test(n)}var fr=(n,t)=>{let e=_hmac.hmac.create(_sha512.sha512,n).update(t).digest();return{key:e.slice(0,32),chainCode:e.slice(32)}},Ai= exports.CKDPriv =({key:n,chainCode:t},e)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,e);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return fr(t,s)},Js=n=>n.replace("'",""),hi= exports.splitPath =n=>n.split("/").slice(1).map(Js),wn= exports.mnemonicToSeed =n=>{let t=n.trim().split(/\s+/).map(e=>e.toLowerCase()).join(" ");return gi.mnemonicToSeedSync(t)};var qe=class extends d{toString(){let t=this.toUint8Array();return g.fromHexInput(t).toString()}},te= exports.AccountPublicKey =class extends qe{};var D=class extends d{toString(){let t=this.toUint8Array();return g.fromHexInput(t).toString()}};var ot=n=>typeof n=="string"?g.isValid(n).valid?n:Buffer.from(n,"utf8"):n;var Ti=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16],$e=class $e extends te{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==$e.LENGTH)throw new Error(`PublicKey length should be ${$e.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof _))return!1;let o=ot(r),s=g.fromHexInput(o).toUint8Array(),a=i.toUint8Array(),c=this.key.toUint8Array();return i.isCanonicalSignature()?_ed25519.ed25519.verify(a,s,c):!1}authKey(){return F.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new $e(r)}static isPublicKey(e){return e instanceof $e}};$e.LENGTH=32;var P=$e,ne=class ne extends d{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==ne.LENGTH)throw new Error(`PrivateKey length should be ${ne.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new ne(e)}static fromDerivationPath(e,r){if(!fi(e))throw new Error(`Invalid derivation path ${e}`);return ne.fromDerivationPathInner(e,wn(r))}static fromDerivationPathInner(e,r,i=mi){let{key:o,chainCode:s}=fr(ne.SLIP_0010_SEED,r),a=hi(e).map(p=>parseInt(p,10)),{key:c}=a.reduce((p,m)=>Ai(p,m+i),{key:o,chainCode:s});return new ne(c)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new P(e)}sign(e){let r=ot(e),i=g.fromHexInput(r).toUint8Array(),o=_ed25519.ed25519.sign(i,this.signingKey.toUint8Array());return new _(o)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.signingKey.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ne(r)}static isPrivateKey(e){return e instanceof ne}};ne.LENGTH=32,ne.SLIP_0010_SEED="ed25519 seed";var M=ne,st=class st extends D{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==st.LENGTH)throw new Error(`Signature length should be ${st.LENGTH}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new st(r)}isCanonicalSignature(){let e=this.toUint8Array().slice(32);for(let r=e.length-1;r>=0;r-=1){if(e[r]<Ti[r])return!0;if(e[r]>Ti[r])return!1}return!1}};st.LENGTH=64;var _=st;var re=class re extends te{constructor(e){super();let{publicKeys:r,threshold:i}=e;if(r.length>re.MAX_KEYS||r.length<re.MIN_KEYS)throw new Error(`Must have between ${re.MIN_KEYS} and ${re.MAX_KEYS} public keys, inclusive`);if(i<re.MIN_THRESHOLD||i>r.length)throw new Error(`Threshold must be between ${re.MIN_THRESHOLD} and ${r.length}, inclusive`);this.publicKeys=r,this.threshold=i}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof He))return!1;let o=[];for(let s=0;s<4;s+=1)for(let a=0;a<8;a+=1)if((i.bitmap[s]&1<<7-a)!==0){let p=s*8+a;o.push(p)}if(o.length!==i.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(o.length<this.threshold)throw new Error("Not enough signatures");for(let s=0;s<o.length;s+=1)if(!this.publicKeys[o[s]].verifySignature({message:r,signature:i.signatures[s]}))return!1;return!0}authKey(){return F.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*P.LENGTH+1);return this.publicKeys.forEach((r,i)=>{e.set(r.toUint8Array(),i*P.LENGTH)}),e[this.publicKeys.length*P.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r[r.length-1],o=[];for(let s=0;s<r.length-1;s+=P.LENGTH){let a=s;o.push(new P(r.subarray(a,a+P.LENGTH)))}return new re({publicKeys:o,threshold:i})}};re.MAX_KEYS=32,re.MIN_KEYS=2,re.MIN_THRESHOLD=1;var at=re,W=class W extends D{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>W.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${W.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r,!(i instanceof Uint8Array))this.bitmap=W.createBitmap({bits:i});else{if(i.length!==W.BITMAP_LEN)throw new Error(`"bitmap" length should be ${W.BITMAP_LEN}`);this.bitmap=i}}toUint8Array(){let e=new Uint8Array(this.signatures.length*_.LENGTH+W.BITMAP_LEN);return this.signatures.forEach((r,i)=>{e.set(r.toUint8Array(),i*_.LENGTH)}),e.set(this.bitmap,this.signatures.length*_.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes(),i=r.subarray(r.length-4),o=[];for(let s=0;s<r.length-i.length;s+=_.LENGTH){let a=s;o.push(new _(r.subarray(a,a+_.LENGTH)))}return new W({signatures:o,bitmap:i})}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(a>=W.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${W.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");if(c>0&&a<=r[c-1])throw new Error("The bits need to be sorted in ascending order.");s.add(a);let p=Math.floor(a/8),m=o[p];m|=i>>a%8,o[p]=m}),o}};W.MAX_SIGNATURES_SUPPORTED=32,W.BITMAP_LEN=4;var He=W;var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ve=class Ve extends qe{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==Ve.LENGTH)throw new Error(`PublicKey length should be ${Ve.LENGTH}`);this.key=r}verifySignature(e){let{message:r,signature:i}=e;if(!(i instanceof xe))return!1;let o=ot(r),s=g.fromHexInput(o).toUint8Array(),a=_sha3.sha3_256.call(void 0, s),c=i.toUint8Array();return _secp256k1.secp256k1.verify(c,a,this.key.toUint8Array(),{lowS:!0})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ve(r)}static isPublicKey(e){return e instanceof Ve}};Ve.LENGTH=65;var he=Ve,Ae=class Ae extends d{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==Ae.LENGTH)throw new Error(`PrivateKey length should be ${Ae.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ae(e)}static fromDerivationPath(e,r){if(!yi(e))throw new Error(`Invalid derivation path ${e}`);return Ae.fromDerivationPathInner(e,wn(r))}static fromDerivationPathInner(e,r){let{privateKey:i}=_bip32.HDKey.fromMasterSeed(r).derive(e);if(i===null)throw new Error("Invalid key");return new Ae(i)}sign(e){let r=ot(e),i=g.fromHexInput(r),o=_sha3.sha3_256.call(void 0, i.toUint8Array()),s=_secp256k1.secp256k1.sign(o,this.key.toUint8Array(),{lowS:!0});return new xe(s.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new he(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.key.toString()}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new Ae(r)}static isPrivateKey(e){return e instanceof Ae}};Ae.LENGTH=32;var Le=Ae,ct=class ct extends D{constructor(e){super();let r=g.fromHexInput(e);if(r.toUint8Array().length!==ct.LENGTH)throw new Error(`Signature length should be ${ct.LENGTH}, received ${r.toUint8Array().length}`);this.data=r}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let r=e.deserializeBytes();return new ct(r)}};ct.LENGTH=64;var xe=ct;var Qe=class n extends qe{constructor(e){super();let r=e.constructor.name;switch(r){case P.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${r}`)}}toUint8Array(){return this.bcsToBytes()}verifySignature(e){let{message:r,signature:i}=e;return this.publicKey.verifySignature({message:r,signature:i})}serialize(e){if(this.publicKey instanceof P)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(P.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}}static isPublicKey(e){return e instanceof n}},le= exports.EphemeralSignature =class n extends D{constructor(e){super();let r=e.constructor.name;switch(r){case _.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${r}`)}}toUint8Array(){return this.bcsToBytes()}static fromHex(e){let r=g.fromHexInput(e),i=new ee(r.toUint8Array());return n.deserialize(i)}serialize(e){if(this.signature instanceof _)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(_.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${r}`)}}};var _poseidonlite = require('poseidon-lite');var Aa=[_poseidonlite.poseidon1,_poseidonlite.poseidon2,_poseidonlite.poseidon3,_poseidonlite.poseidon4,_poseidonlite.poseidon5,_poseidonlite.poseidon6,_poseidonlite.poseidon7,_poseidonlite.poseidon8,_poseidonlite.poseidon9,_poseidonlite.poseidon10,_poseidonlite.poseidon11,_poseidonlite.poseidon12,_poseidonlite.poseidon13,_poseidonlite.poseidon14,_poseidonlite.poseidon15,_poseidonlite.poseidon16],Si=31,ha=16,wi=(ha-1)*Si;function _n(n,t){let r=new TextEncoder().encode(n);return Ta(r,t)}function Ta(n,t){if(n.length>t)throw new Error(`Inputted bytes of length ${n} is longer than ${t}`);let e=Ar(n,t);return Ft(e)}function ba(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);let e=xa(n,t);return wa(e)}function Ar(n,t){if(n.length>t)throw new Error(`Input bytes of length ${n} is longer than ${t}`);return ba(n,t).concat([BigInt(n.length)])}function wa(n){if(n.length>wi)throw new Error(`Can't pack more than ${wi}. Was given ${n.length} bytes`);return Sa(n,Si).map(t=>Ot(t))}function Sa(n,t){let e=[];for(let r=0;r<n.length;r+=t)e.push(n.subarray(r,r+t));return e}function Ot(n){let t=BigInt(0);for(let e=n.length-1;e>=0;e-=1)t=t<<BigInt(8)|BigInt(n[e]);return t}function xi(n,t){let e=new Uint8Array(t);for(let r=0;r<t;r+=1)e[r]=Number(n&BigInt(255)),n>>=BigInt(8);return e}function xa(n,t){if(t<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let e=new Uint8Array(t);e.set(n);for(let r=n.length;r<t;r+=1)e[r]=0;return e}function Ft(n){let t=Aa[n.length-1];if(t)return t(n);throw new Error(`Unable to hash input of length ${n.length}`)}var vn=class extends d{toString(){let t=this.bcsToBytes();return g.fromHexInput(t).toString()}};var Mt=1e7,_a= exports.MAX_AUD_VAL_BYTES =120,va= exports.MAX_UID_KEY_BYTES =30,Pa= exports.MAX_UID_VAL_BYTES =330,md= exports.MAX_ISS_VAL_BYTES =120,yd= exports.MAX_EXTRA_FIELD_BYTES =350,fd= exports.MAX_JWT_HEADER_B64_BYTES =300,Ad= exports.MAX_COMMITED_EPK_BYTES =93,_e=class _e extends te{constructor(e,r){super();let i=g.fromHexInput(r).toUint8Array();if(i.length!==_e.ID_COMMITMENT_LENGTH)throw new Error(`Address seed length in bytes should be ${_e.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=i}authKey(){let e=new L;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),F.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}toString(){return g.fromHexInput(this.toUint8Array()).toString()}verifySignature(e){throw new Error("Not yet implemented")}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new _e(r,i)}static load(e){let r=e.deserializeStr(),i=e.deserializeBytes();return new _e(r,i)}static isPublicKey(e){return e instanceof _e}static create(e){return _i(e),new _e(e.iss,_i(e))}};_e.ID_COMMITMENT_LENGTH=32;var ge=_e;function _i(n){let{uidKey:t,uidVal:e,aud:r,pepper:i}=n,o=[Ot(g.fromHexInput(i).toUint8Array()),_n(r,_a),_n(e,Pa),_n(t,va)];return xi(Ft(o),ge.ID_COMMITMENT_LENGTH)}var We=class n extends D{constructor(e){super();let{jwtHeader:r,ephemeralCertificate:i,expiryDateSecs:o,ephemeralPublicKey:s,ephemeralSignature:a}=e;this.jwtHeader=r,this.ephemeralCertificate=i,this.expiryDateSecs=o,this.ephemeralPublicKey=s,this.ephemeralSignature=a}toUint8Array(){return this.bcsToBytes()}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let r=ut.deserialize(e),i=e.deserializeStr(),o=e.deserializeU64(),s=Qe.deserialize(e),a=le.deserialize(e);return new n({jwtHeader:i,expiryDateSecs:o,ephemeralCertificate:r,ephemeralPublicKey:s,ephemeralSignature:a})}static load(e){let r=ut.deserialize(e),i=e.deserializeStr(),o=e.deserializeU64(),s=Qe.deserialize(e),a=le.deserialize(e);return new n({jwtHeader:i,expiryDateSecs:o,ephemeralCertificate:r,ephemeralPublicKey:s,ephemeralSignature:a})}static isSignature(e){return e instanceof n}},ut= exports.EphemeralCertificate =class n extends D{constructor(e,r){super();this.signature=e,this.variant=r}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(Ke.deserialize(e),r);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${r}`)}}},Gt= exports.Groth16Zkp =class n extends vn{constructor(e){super();let{a:r,b:i,c:o}=e;this.a=g.fromHexInput(r).toUint8Array(),this.b=g.fromHexInput(i).toUint8Array(),this.c=g.fromHexInput(o).toUint8Array()}serialize(e){e.serializeFixedBytes(this.a),e.serializeFixedBytes(this.b),e.serializeFixedBytes(this.c)}static deserialize(e){let r=e.deserializeFixedBytes(32),i=e.deserializeFixedBytes(64),o=e.deserializeFixedBytes(32);return new n({a:r,b:i,c:o})}},pt= exports.ZkProof =class n extends d{constructor(e,r){super();this.proof=e,this.variant=r}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32();switch(r){case 0:return new n(Gt.deserialize(e),r);default:throw new Error(`Unknown variant index for ZkProof: ${r}`)}}},Ke= exports.ZeroKnowledgeSig =class n extends D{constructor(e){super();let{proof:r,expHorizonSecs:i=BigInt(Mt),trainingWheelsSignature:o,extraField:s,overrideAudVal:a}=e;this.proof=r,this.expHorizonSecs=i,this.trainingWheelsSignature=o,this.extraField=s,this.overrideAudVal=a}toUint8Array(){return this.bcsToBytes()}static fromBytes(e){return n.deserialize(new ee(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOptionStr(this.extraField),e.serializeOptionStr(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let r=pt.deserialize(e),i=e.deserializeU64(),o=e.deserializeOptionStr(),s=e.deserializeOptionStr(),a=e.deserializeOption(le);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:a,extraField:o,overrideAudVal:s})}static load(e){let r=pt.deserialize(e),i=e.deserializeU64(),o=e.deserializeOptionStr(),s=e.deserializeOptionStr(),a=e.deserializeOption(le);return new n({proof:r,expHorizonSecs:i,trainingWheelsSignature:a,extraField:o,overrideAudVal:s})}};var k=class n extends te{constructor(e){super();if(this.publicKey=e,e instanceof P)this.variant=0;else if(e instanceof he)this.variant=1;else if(e instanceof ge)this.variant=3;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:r,signature:i}=e;return i instanceof N?this.publicKey.verifySignature({message:r,signature:i.signature}):!1}authKey(){return F.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=P.deserialize(e);break;case 1:i=he.deserialize(e);break;case 3:i=ge.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${r}`)}return new n(i)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof P}isSecp256k1PublicKey(){return this.publicKey instanceof he}},N= exports.AnySignature =class n extends D{constructor(e){super();if(this.signature=e,e instanceof _)this.variant=0;else if(e instanceof xe)this.variant=1;else if(e instanceof We)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=_.deserialize(e);break;case 1:i=xe.deserialize(e);break;case 3:i=We.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${r}`)}return new n(i)}};function Ca(n){let t=n;return t-=t>>1&1431655765,t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}var dt=class n extends te{constructor(e){super();let{publicKeys:r,signaturesRequired:i}=e;if(i<1)throw new Error("The number of required signatures needs to be greater than 0");if(r.length<i)throw new Error(`Provided ${r.length} public keys is smaller than the ${i} required signatures`);this.publicKeys=r.map(o=>o instanceof k?o:new k(o)),this.signaturesRequired=i}verifySignature(e){throw new Error("not implemented")}authKey(){return F.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let r=e.deserializeVector(k),i=e.deserializeU8();return new n({publicKeys:r,signaturesRequired:i})}createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach((a,c)=>{if(c+1>this.publicKeys.length)throw new Error(`Signature index ${c+1} is out of public keys range, ${this.publicKeys.length}.`);if(s.has(a))throw new Error(`Duplicate bit ${a} detected.`);s.add(a);let p=Math.floor(a/8),m=o[p];m|=i>>a%8,o[p]=m}),o}getIndex(e){let r=e instanceof k?e:new k(e),i=this.publicKeys.findIndex(o=>o.toString()===r.toString());if(i!==-1)return i;throw new Error("Public key not found in MultiKey")}},j=class j extends D{constructor(e){super();let{signatures:r,bitmap:i}=e;if(r.length>j.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${j.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=r.map(s=>s instanceof N?s:new N(s)),!(i instanceof Uint8Array))this.bitmap=j.createBitmap({bits:i});else{if(i.length!==j.BITMAP_LEN)throw new Error(`"bitmap" length should be ${j.BITMAP_LEN}`);this.bitmap=i}let o=this.bitmap.reduce((s,a)=>s+Ca(a),0);if(o!==this.signatures.length)throw new Error(`Expecting ${o} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:r}=e,i=128,o=new Uint8Array([0,0,0,0]),s=new Set;return r.forEach(a=>{if(a>=j.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${j.MAX_SIGNATURES_SUPPORTED-1}.`);if(s.has(a))throw new Error("Duplicate bits detected.");s.add(a);let c=Math.floor(a/8),p=o[c];p|=i>>a%8,o[c]=p}),o}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let r=e.deserializeVector(N),i=e.deserializeBytes();return new j({signatures:r,bitmap:i})}};j.BITMAP_LEN=4,j.MAX_SIGNATURES_SUPPORTED=j.BITMAP_LEN*8;var je=j;var q=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return me.load(t);case 1:return Pn.load(t);case 2:return $.load(t);case 3:return Xe.load(t);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${e}`)}}isEd25519(){return this instanceof me}isMultiEd25519(){return this instanceof Pn}isSingleKey(){return this instanceof $}isMultiKey(){return this instanceof Xe}},me= exports.AccountAuthenticatorEd25519 =class n extends q{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=P.deserialize(e),i=_.deserialize(e);return new n(r,i)}},Pn= exports.AccountAuthenticatorMultiEd25519 =class n extends q{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=at.deserialize(e),i=He.deserialize(e);return new n(r,i)}},$= exports.AccountAuthenticatorSingleKey =class n extends q{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=k.deserialize(e),i=N.deserialize(e);return new n(r,i)}},Xe= exports.AccountAuthenticatorMultiKey =class n extends q{constructor(e,r){super();this.public_keys=e,this.signatures=r}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let r=dt.deserialize(e),i=je.deserialize(e);return new n(r,i)}};var qt=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(qt||{}),vi= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,Pi= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,Cn= exports.DEFAULT_TXN_TIMEOUT_SEC =20,En= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Ci= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",hr= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",lt= exports.ProcessorType =(a=>(a.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",a.DEFAULT="default_processor",a.EVENTS_PROCESSOR="events_processor",a.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",a.STAKE_PROCESSOR="stake_processor",a.TOKEN_V2_PROCESSOR="token_v2_processor",a.USER_TRANSACTION_PROCESSOR="user_transaction_processor",a))(lt||{});var gt=class n extends d{constructor(e){super();this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new n(r)}};var U=class n extends d{constructor(e){super();this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new n(r)}};var $t=class n extends d{constructor(e,r){super();this.address=e,this.name=r}static fromStr(e){let r=e.split("::");if(r.length!==2)throw new Error("Invalid module id.");return new n(u.fromString(r[0]),new U(r[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let r=u.deserialize(e),i=U.deserialize(e);return new n(r,i)}};var z=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return G.load(t);case 1:return Te.load(t);case 2:return Q.load(t);case 3:return ft.load(t);case 4:return X.load(t);case 5:return Ye.load(t);case 6:return C.load(t);case 7:return y.load(t);case 8:return mt.load(t);case 9:return yt.load(t);case 10:return At.load(t);case 255:return K.load(t);default:throw new Error(`Unknown variant index for TypeTag: ${e}`)}}isBool(){return this instanceof G}isAddress(){return this instanceof X}isGeneric(){return this instanceof K}isSigner(){return this instanceof Ye}isVector(){return this instanceof C}isStruct(){return this instanceof y}isU8(){return this instanceof Te}isU16(){return this instanceof mt}isU32(){return this instanceof yt}isU64(){return this instanceof Q}isU128(){return this instanceof ft}isU256(){return this instanceof At}},G= exports.TypeTagBool =class n extends z{toString(){return"bool"}serialize(t){t.serializeU32AsUleb128(0)}static load(t){return new n}},Te= exports.TypeTagU8 =class n extends z{toString(){return"u8"}serialize(t){t.serializeU32AsUleb128(1)}static load(t){return new n}},mt= exports.TypeTagU16 =class n extends z{toString(){return"u16"}serialize(t){t.serializeU32AsUleb128(8)}static load(t){return new n}},yt= exports.TypeTagU32 =class n extends z{toString(){return"u32"}serialize(t){t.serializeU32AsUleb128(9)}static load(t){return new n}},Q= exports.TypeTagU64 =class n extends z{toString(){return"u64"}serialize(t){t.serializeU32AsUleb128(2)}static load(t){return new n}},ft= exports.TypeTagU128 =class n extends z{toString(){return"u128"}serialize(t){t.serializeU32AsUleb128(3)}static load(t){return new n}},At= exports.TypeTagU256 =class n extends z{toString(){return"u256"}serialize(t){t.serializeU32AsUleb128(10)}static load(t){return new n}},X= exports.TypeTagAddress =class n extends z{toString(){return"address"}serialize(t){t.serializeU32AsUleb128(4)}static load(t){return new n}},Ye= exports.TypeTagSigner =class n extends z{toString(){return"signer"}serialize(t){t.serializeU32AsUleb128(5)}static load(t){return new n}},In= exports.TypeTagReference =class n extends z{constructor(e){super();this.value=e}toString(){return`&${this.value.toString()}`}serialize(e){e.serializeU32AsUleb128(254)}static load(e){let r=z.deserialize(e);return new n(r)}},K= exports.TypeTagGeneric =class n extends z{constructor(e){super();this.value=e;if(e<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(e){e.serializeU32AsUleb128(255),e.serializeU32(this.value)}static load(e){let r=e.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends z{constructor(e){super();this.value=e}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new Te)}serialize(e){e.serializeU32AsUleb128(6),this.value.serialize(e)}static load(e){let r=z.deserialize(e);return new n(r)}},y= exports.TypeTagStruct =class n extends z{constructor(e){super();this.value=e}toString(){let e="";return this.value.typeArgs.length>0&&(e=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${e}`}serialize(e){e.serializeU32AsUleb128(7),this.value.serialize(e)}static load(e){let r=ve.deserialize(e);return new n(r)}isTypeTag(e,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(e)}isString(){return this.isTypeTag(u.ONE,"string","String")}isOption(){return this.isTypeTag(u.ONE,"option","Option")}isObject(){return this.isTypeTag(u.ONE,"object","Object")}},ve= exports.StructTag =class n extends d{constructor(e,r,i,o){super();this.address=e,this.moduleName=r,this.name=i,this.typeArgs=o}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let r=u.deserialize(e),i=U.deserialize(e),o=U.deserialize(e),s=e.deserializeVector(z);return new n(r,i,o,s)}};function Cl(){return new ve(u.ONE,new U("aptos_coin"),new U("AptosCoin"),[])}function v(){return new ve(u.ONE,new U("string"),new U("String"),[])}function El(n){return new ve(u.ONE,new U("option"),new U("Option"),[n])}function Y(n){return new ve(u.ONE,new U("object"),new U("Object"),[n])}function Ea(n){let t=n.deserializeUleb128AsU32();switch(t){case 0:return O.deserialize(n);case 1:return B.deserialize(n);case 2:return pe.deserialize(n);case 3:return u.deserialize(n);case 4:return T.deserialize(n,O);case 5:return R.deserialize(n);case 6:return ce.deserialize(n);case 7:return ue.deserialize(n);case 8:return de.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${t}`)}}var Ze=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return Ht.load(t);case 2:return Vt.load(t);case 3:return Lt.load(t);default:throw new Error(`Unknown variant index for TransactionPayload: ${e}`)}}},Ht= exports.TransactionPayloadScript =class n extends Ze{constructor(e){super();this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let r=Qt.deserialize(e);return new n(r)}},Vt= exports.TransactionPayloadEntryFunction =class n extends Ze{constructor(e){super();this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let r=Je.deserialize(e);return new n(r)}},Lt= exports.TransactionPayloadMultiSig =class n extends Ze{constructor(e){super();this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let r=Wt.deserialize(e);return new n(r)}},Je= exports.EntryFunction =class n{constructor(t,e,r,i){this.module_name=t,this.function_name=e,this.type_args=r,this.args=i}static build(t,e,r,i){return new n($t.fromStr(t),new U(e),r,i)}serialize(t){this.module_name.serialize(t),this.function_name.serialize(t),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForEntryFunction(t)})}static deserialize(t){let e=$t.deserialize(t),r=U.deserialize(t),i=t.deserializeVector(z),o=t.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=t.deserializeUleb128AsU32(),p=Tn.deserialize(t,c);s.push(p)}return new n(e,r,i,s)}},Qt= exports.Script =class n{constructor(t,e,r){this.bytecode=t,this.type_args=e,this.args=r}serialize(t){t.serializeBytes(this.bytecode),t.serializeVector(this.type_args),t.serializeU32AsUleb128(this.args.length),this.args.forEach(e=>{e.serializeForScriptFunction(t)})}static deserialize(t){let e=t.deserializeBytes(),r=t.deserializeVector(z),i=t.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=Ea(t);o.push(a)}return new n(e,r,o)}},Wt= exports.MultiSig =class n{constructor(t,e){this.multisig_address=t,this.transaction_payload=e}serialize(t){this.multisig_address.serialize(t),this.transaction_payload===void 0?t.serializeBool(!1):(t.serializeBool(!0),this.transaction_payload.serialize(t))}static deserialize(t){let e=u.deserialize(t),r=t.deserializeBool(),i;return r&&(i=jt.deserialize(t)),new n(e,i)}},jt= exports.MultiSigTransactionPayload =class n extends d{constructor(e){super();this.transaction_payload=e}serialize(e){e.serializeU32AsUleb128(0),this.transaction_payload.serialize(e)}static deserialize(e){return e.deserializeUleb128AsU32(),new n(Je.deserialize(e))}};var ie=class n extends d{constructor(e,r,i,o,s,a,c){super();this.sender=e,this.sequence_number=r,this.payload=i,this.max_gas_amount=o,this.gas_unit_price=s,this.expiration_timestamp_secs=a,this.chain_id=c}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let r=u.deserialize(e),i=e.deserializeU64(),o=Ze.deserialize(e),s=e.deserializeU64(),a=e.deserializeU64(),c=e.deserializeU64(),p=gt.deserialize(e);return new n(r,i,o,s,a,c,p)}},Un= exports.RawTransactionWithData =class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return et.load(t);case 1:return tt.load(t);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${e}`)}}},et= exports.MultiAgentRawTransaction =class n extends Un{constructor(e,r){super();this.raw_txn=e,this.secondary_signer_addresses=r}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let r=ie.deserialize(e),i=e.deserializeVector(u);return new n(r,i)}},tt= exports.FeePayerRawTransaction =class n extends Un{constructor(e,r,i){super();this.raw_txn=e,this.secondary_signer_addresses=r,this.fee_payer_address=i}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let r=ie.deserialize(e),i=e.deserializeVector(u),o=u.deserialize(e);return new n(r,i,o)}};var Rn=class extends d{constructor(e){super();this.accountAddress=u.ONE;this.moduleName=new w("account");this.structName=new w("RotationProofChallenge");this.sequenceNumber=new B(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=T.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}};var Pe=class extends d{static deserialize(t){let e=t.deserializeUleb128AsU32();switch(e){case 0:return ht.load(t);case 1:return Tr.load(t);case 2:return Tt.load(t);case 3:return bt.load(t);case 4:return wt.load(t);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${e}`)}}},ht= exports.TransactionAuthenticatorEd25519 =class n extends Pe{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=P.deserialize(e),i=_.deserialize(e);return new n(r,i)}},Tr= exports.TransactionAuthenticatorMultiEd25519 =class n extends Pe{constructor(e,r){super();this.public_key=e,this.signature=r}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let r=at.deserialize(e),i=He.deserialize(e);return new n(r,i)}},Tt= exports.TransactionAuthenticatorMultiAgent =class n extends Pe{constructor(e,r,i){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let r=q.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(q);return new n(r,i,o)}},bt= exports.TransactionAuthenticatorFeePayer =class n extends Pe{constructor(e,r,i,o){super();this.sender=e,this.secondary_signer_addresses=r,this.secondary_signers=i,this.fee_payer=o}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let r=q.deserialize(e),i=e.deserializeVector(u),o=e.deserializeVector(q),s=u.deserialize(e),a=q.deserialize(e),c={address:s,authenticator:a};return new n(r,i,o,c)}},wt= exports.TransactionAuthenticatorSingleSender =class n extends Pe{constructor(e){super();this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let r=q.deserialize(e);return new n(r)}};var nt=class n extends d{constructor(e,r){super();this.raw_txn=e,this.authenticator=r}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let r=ie.deserialize(e),i=Pe.deserialize(e);return new n(r,i)}};var zn=class n extends d{constructor(e,r){super();this.rawTransaction=e,this.feePayerAddress=r}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=ie.deserialize(e),i=e.deserializeBool(),o;return i&&(o=u.deserialize(e)),new n(r,o)}};var Kn=class n extends d{constructor(e,r,i){super();this.rawTransaction=e,this.feePayerAddress=i,this.secondarySignerAddresses=r}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let r=ie.deserialize(e),i=e.deserializeVector(u),o=e.deserializeBool(),s;return o&&(s=u.deserialize(e)),new n(r,i,s)}};function br(n){return n.feePayerAddress?new tt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new et(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function kn(n,t){let e=_sha3.sha3_256.create();if(!t.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${t}`);e.update(t);let r=e.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function Ei(n){return kn(n.bcsToBytes(),n.domainSeparator)}function St(n){let t=br(n);return n.feePayerAddress?kn(t.bcsToBytes(),hr):n.secondarySignerAddresses?kn(t.bcsToBytes(),hr):kn(t.bcsToBytes(),Ci)}var xt=class n{constructor(t){this.signingScheme=0;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=e.publicKey(),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let t=M.generate();return new n({privateKey:t})}static fromDerivationPath(t){let{path:e,mnemonic:r}=t,i=M.fromDerivationPath(e,r);return new n({privateKey:i})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){return new me(this.publicKey,this.privateKey.sign(t))}signTransactionWithAuthenticator(t){return new me(this.publicKey,this.signTransaction(t))}sign(t){return this.privateKey.sign(t)}signTransaction(t){return this.sign(St(t))}};var _t=class n{constructor(t){this.signingScheme=2;let{privateKey:e,address:r}=t;this.privateKey=e,this.publicKey=new k(e.publicKey()),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress()}static generate(t={}){let{scheme:e=0}=t,r;switch(e){case 0:r=M.generate();break;case 2:r=Le.generate();break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:r})}static fromDerivationPath(t){let{scheme:e=0,path:r,mnemonic:i}=t,o;switch(e){case 0:o=M.fromDerivationPath(r,i);break;case 2:o=Le.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${e}`)}return new n({privateKey:o})}verifySignature(t){return this.publicKey.verifySignature(t)}signWithAuthenticator(t){return new $(this.publicKey,this.sign(t))}signTransactionWithAuthenticator(t){return new $(this.publicKey,this.signTransaction(t))}sign(t){return new N(this.privateKey.sign(t))}signTransaction(t){return this.sign(St(t))}};var ke=class{static generate(t={}){let{scheme:e=0,legacy:r=!0}=t;return e===0&&r?xt.generate():_t.generate({scheme:e})}static fromPrivateKey(t){let{privateKey:e,address:r,legacy:i=!0}=t;return e instanceof M&&i?new xt({privateKey:e,address:r}):new _t({privateKey:e,address:r})}static fromPrivateKeyAndAddress(t){return this.fromPrivateKey(t)}static fromDerivationPath(t){let{scheme:e=0,mnemonic:r,path:i,legacy:o=!0}=t;return e===0&&o?xt.fromDerivationPath({mnemonic:r,path:i}):_t.fromDerivationPath({scheme:e,mnemonic:r,path:i})}static authKey(t){let{publicKey:e}=t;return e.authKey()}verifySignature(t){return this.publicKey.verifySignature(t)}};var vt=class vt extends d{constructor(e){super();let{privateKey:r,expiryDateSecs:i,blinder:o}=e;this.privateKey=r,this.publicKey=new Qe(r.publicKey()),this.expiryDateSecs=i||BigInt(Ka(za()+Mt)),this.blinder=o!==void 0?g.fromHexInput(o).toUint8Array():Ra(),this.nonce=this.generateNonce()}getPublicKey(){return this.publicKey}isExpired(){return Math.floor(Date.now()/1e3)>this.expiryDateSecs}serialize(e){e.serializeU32AsUleb128(this.publicKey.variant),e.serializeBytes(this.privateKey.toUint8Array()),e.serializeU64(this.expiryDateSecs),e.serializeFixedBytes(this.blinder)}static deserialize(e){let r=e.deserializeUleb128AsU32(),i;switch(r){case 0:i=M.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${r}`)}let o=e.deserializeU64(),s=e.deserializeFixedBytes(31);return new vt({privateKey:i,expiryDateSecs:o,blinder:s})}static fromBytes(e){return vt.deserialize(new ee(e))}static generate(e){let r;switch(_optionalChain([e, 'optionalAccess', _8 => _8.scheme])){case 0:default:r=M.generate()}return new vt({privateKey:r,expiryDateSecs:_optionalChain([e, 'optionalAccess', _9 => _9.expiryDateSecs])})}generateNonce(){let e=Ar(this.publicKey.bcsToBytes(),93);return e.push(BigInt(this.expiryDateSecs)),e.push(Ot(this.blinder)),Ft(e).toString()}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new le(this.privateKey.sign(e))}};vt.BLINDER_LENGTH=31;var Xt=vt;function Ra(){return _utils.randomBytes.call(void 0, Xt.BLINDER_LENGTH)}function za(){return Math.floor(new Date().getTime()/1e3)}function Ka(n){let t=new Date(n*1e3);return t.setMinutes(0),t.setSeconds(0),t.setMilliseconds(0),Math.floor(t.getTime()/1e3)}var _jwtdecode = require('jwt-decode');var _jwksrsa = require('jwks-rsa');var _jsbase64 = require('js-base64');var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);var Dn=class extends d{};var Ba={"https://accounts.google.com":"https://www.googleapis.com/oauth2/v3/certs"},Oa= exports.KeylessErrorType =(o=>(o[o.JWK_EXPIRED=0]="JWK_EXPIRED",o[o.EPK_EXPIRED=1]="EPK_EXPIRED",o[o.PROOF_NOT_FOUND=2]="PROOF_NOT_FOUND",o[o.UNKNOWN_INVALID_SIGNATURE=3]="UNKNOWN_INVALID_SIGNATURE",o[o.UNKNOWN=4]="UNKNOWN",o))(Oa||{}),Yt= exports.KeylessError =class n extends Error{constructor(e){super();this.type=e}static async fromAptosApiError(e,r){return e.data.message.includes("INVALID_SIGNATURE")?r.isExpired()?new n(1):await r.checkJwkValidity()?new n(3):new n(0):new n(4)}},De=class De extends d{constructor(e){super();let{address:r,ephemeralKeyPair:i,uidKey:o,uidVal:s,aud:a,pepper:c,proofOrFetcher:p,proofFetchCallback:m,jwt:x}=e;if(this.ephemeralKeyPair=i,this.publicKey=ge.create(e),this.accountAddress=r?u.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=o,this.uidVal=s,this.aud=a,this.jwt=x,this.emitter=new _eventemitter32.default,this.proofOrPromise=p,p instanceof Ke)this.proof=p;else{if(m===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async l=>{await m(l),this.emitter.removeAllListeners()}),this.init(p)}this.signingScheme=2;let A=g.fromHexInput(c).toUint8Array();if(A.length!==De.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${De.PEPPER_LENGTH}`);this.pepper=A,this.isJwtValid=!0}async init(e){try{this.proof=await e,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(e){if(e.serializeStr(this.jwt),e.serializeStr(this.uidKey),e.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(e),this.proof===void 0)throw new Error("Connot serialize - proof undefined");this.proof.serialize(e)}static deserialize(e){let r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeFixedBytes(31),s=Xt.deserialize(e),a=Ke.deserialize(e);return De.fromJWTAndProof({proof:a,pepper:o,uidKey:i,jwt:r,ephemeralKeyPair:s})}isExpired(){return this.ephemeralKeyPair.isExpired()}async checkJwkValidity(){if(!this.isJwtValid)return!1;let e=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0}),r=new (0, _jwksrsa.JwksClient)({jwksUri:Ba[this.publicKey.iss]});try{return await r.getSigningKey(e.kid),!0}catch (e2){return this.isJwtValid=!1,!1}}signWithAuthenticator(e){let r=new N(this.sign(e)),i=new k(this.publicKey);return new $(i,r)}signTransactionWithAuthenticator(e){let r=new N(this.signTransaction(e)),i=new k(this.publicKey);return new $(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}sign(e){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw new Yt(1);if(this.proof===void 0)throw new Yt(2);if(!this.isJwtValid)throw new Yt(0);let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(e);return new We({jwtHeader:Fa(this.jwt.split(".")[0]),ephemeralCertificate:new ut(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(e){if(this.proof===void 0)throw new Error("Proof not found");let r=br(e),i=new wr(r,this.proof.proof),o=Ei(i);return this.sign(o)}verifySignature(e){throw new Error("Not implemented")}static fromBytes(e){return De.deserialize(new ee(e))}static fromJWTAndProof(e){let{proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,proofFetchCallback:a}=e,c=_nullishCoalesce(e.uidKey, () => ("sub")),p=_jwtdecode.jwtDecode.call(void 0, i),m=p.iss;if(typeof p.aud!="string")throw new Error("aud was not found or an array of values");let x=p.aud,A=p[c];return new De({proofOrFetcher:r,ephemeralKeyPair:o,iss:m,uidKey:c,uidVal:A,aud:x,pepper:s,jwt:i,proofFetchCallback:a})}};De.PEPPER_LENGTH=31;var be=De,wr= exports.TransactionAndProof =class extends Dn{constructor(e,r){super();this.transaction=e,this.proof=r,this.domainSeparator="APTOS::TransactionAndProof"}serialize(e){e.serializeFixedBytes(this.transaction.bcsToBytes()),e.serializeOption(this.proof)}};function Fa(n){let t=n.replace(/-/g,"+").replace(/_/g,"/"),e=t+"==".substring(0,(3-t.length%3)%3);return _jsbase64.decode.call(void 0, e)}var Nn=class n{constructor(t){let{multiKey:e,signers:r}=t;this.publicKey=e,this.signingScheme=3,this.accountAddress=this.publicKey.authKey().derivedAddress();let i=[];for(let s of r)i.push(this.publicKey.getIndex(s.publicKey));let o=r.map((s,a)=>[s,i[a]]);o.sort((s,a)=>s[1]-a[1]),this.signers=o.map(s=>s[0]),this.signerIndicies=o.map(s=>s[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:i})}static fromPublicKeysAndSigners(t){let{publicKeys:e,signaturesRequired:r,signers:i}=t,o=new dt({publicKeys:e,signaturesRequired:r});return new n({multiKey:o,signers:i})}static isMultiKeySigner(t){return t instanceof n}signWithAuthenticator(t){return new Xe(this.publicKey,this.sign(t))}signTransactionWithAuthenticator(t){return new Xe(this.publicKey,this.signTransaction(t))}async waitForProofFetch(){let t=this.signers.filter(e=>e instanceof be);await Promise.all(t.filter(e=>e.proof instanceof Promise).map(e=>e.proof))}sign(t){let e=[];for(let r of this.signers)e.push(r.sign(t));return new je({signatures:e,bitmap:this.signaturesBitmap})}signTransaction(t){let e=[];for(let r of this.signers)e.push(r.signTransaction(t));return new je({signatures:e,bitmap:this.signaturesBitmap})}verifySignature(t){let{message:e,signature:r}=t;if(!this.signerIndicies.every((o,s)=>s===0||o>=this.signerIndicies[s-1]))return!1;for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKey.publicKeys[this.signerIndicies[o]].verifySignature({message:e,signature:s}))return!1}return!0}};var oe=class extends Error{constructor(e,r,i){super(i);this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=e}};var Ui="1.14.0";var Ri={mainnet:"https://api.mainnet.aptoslabs.com/v1/graphql",testnet:"https://api.testnet.aptoslabs.com/v1/graphql",devnet:"https://api.devnet.aptoslabs.com/v1/graphql",local:"http://127.0.0.1:8090/v1/graphql"},zi= exports.NetworkToNodeAPI ={mainnet:"https://api.mainnet.aptoslabs.com/v1",testnet:"https://api.testnet.aptoslabs.com/v1",devnet:"https://api.devnet.aptoslabs.com/v1",local:"http://127.0.0.1:8080/v1"},Ki= exports.NetworkToFaucetAPI ={mainnet:"https://faucet.mainnet.aptoslabs.com",testnet:"https://faucet.testnet.aptoslabs.com",devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},Sr= exports.NetworkToPepperAPI ={mainnet:"https://pepper.keyless.mainnet.aptoslabs.com/v0",testnet:"https://pepper.keyless.testnet.aptoslabs.com/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"http://127.0.0.1:8000/v0"},xr= exports.NetworkToProverAPI ={mainnet:"https://prover.keyless.mainnet.aptoslabs.com/v0",testnet:"https://prover.keyless.testnet.aptoslabs.com/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"http://127.0.0.1:8083/v0"},_r= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(_r||{}),vr= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},uy= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};function ki(n,t){let e=t.bcsToBytes(),r=new ee(e);return n.deserialize(r)}var Di={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable"};async function Ga(n,t){let{url:e,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _10 => _10.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${Ui}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _11 => _11.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _12 => _12.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _13 => _13.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _14 => _14.API_KEY])}`),t.provider({url:e,method:r,body:i,params:s,headers:p,overrides:a})}async function Bn(n,t,e){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Ga({...n,url:o},t.client),a={status:s.status,statusText:s.statusText,data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new oe(n,a,`Error: ${a.data}`);if(e==="Indexer"){let p=a.data;if(p.errors)throw new oe(n,a,_nullishCoalesce(`Indexer error: ${p.errors[0].message}`, () => (`Indexer unhandled Error ${s.status} : ${s.statusText}`)));a.data=p.data}if(a.status>=200&&a.status<300)return a;if(a.status>=500)throw new oe(n,a,`${s.data}`);if(t.isPepperServiceRequest(r)||t.isProverServiceRequest(r))throw new oe(n,a,`${s.data}`);let c;throw a&&a.data&&"message"in a.data&&"error_code"in a.data?c=JSON.stringify(a.data):a.status in Di?c=Di[a.status]:c=`Unhandled Error ${a.status} : ${a.statusText}`,new oe(n,a,`${e} error: ${c}`)}async function Pr(n){let{aptosConfig:t,overrides:e,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=t.getRequestUrl(c);return Bn({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...t.clientConfig,...e}},t,n.type)}async function Z(n){let{aptosConfig:t}=n;return Pr({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _15 => _15.clientConfig, 'optionalAccess', _16 => _16.HEADERS]),..._optionalChain([t, 'access', _17 => _17.fullnodeConfig, 'optionalAccess', _18 => _18.HEADERS])}}})}async function Ry(n){return Pr({...n,type:"Pepper"})}async function Pt(n){let t=[],e,r=n.params;do{let i=await Pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});e=i.headers["x-aptos-cursor"],delete i.headers,t.push(...i.data),r.start=e}while(e!=null);return t}async function Zt(n){let{type:t,originMethod:e,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,m=c.getRequestUrl(t);return Bn({url:m,method:"POST",originMethod:e,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function rt(n){let{aptosConfig:t}=n;return Zt({...n,type:"Fullnode",overrides:{...t.clientConfig,...t.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _19 => _19.clientConfig, 'optionalAccess', _20 => _20.HEADERS]),..._optionalChain([t, 'access', _21 => _21.fullnodeConfig, 'optionalAccess', _22 => _22.HEADERS])}}})}async function Ni(n){let{aptosConfig:t}=n;return Zt({...n,type:"Indexer",overrides:{...t.clientConfig,...t.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _23 => _23.clientConfig, 'optionalAccess', _24 => _24.HEADERS]),..._optionalChain([t, 'access', _25 => _25.indexerConfig, 'optionalAccess', _26 => _26.HEADERS])}}})}async function Bi(n){let{aptosConfig:t}=n,e={...t,clientConfig:{...t.clientConfig}};return _optionalChainDelete([e, 'optionalAccess', _27 => _27.clientConfig, 'optionalAccess', _28 => delete _28.API_KEY]),Zt({...n,type:"Faucet",overrides:{...e.clientConfig,...e.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _29 => _29.clientConfig, 'optionalAccess', _30 => _30.HEADERS]),..._optionalChain([e, 'access', _31 => _31.faucetConfig, 'optionalAccess', _32 => _32.HEADERS])}}})}async function Oi(n){return Zt({...n,type:"Pepper"})}async function Fi(n){return Zt({...n,type:"Prover"})}var Ma=`
|
|
2
2
|
fragment TokenActivitiesFields on token_activities_v2 {
|
|
3
3
|
after_value
|
|
4
4
|
before_value
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
transaction_version
|
|
17
17
|
type
|
|
18
18
|
}
|
|
19
|
-
`,
|
|
19
|
+
`,qa=`
|
|
20
20
|
fragment AnsTokenFragment on current_aptos_names {
|
|
21
21
|
domain
|
|
22
22
|
expiration_timestamp
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
is_primary
|
|
27
27
|
owner_address
|
|
28
28
|
}
|
|
29
|
-
`,
|
|
29
|
+
`,On=`
|
|
30
30
|
fragment CurrentTokenOwnershipFields on current_token_ownerships_v2 {
|
|
31
31
|
token_standard
|
|
32
32
|
token_properties_mutated_v1
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
`,
|
|
76
|
+
`,Gi=`
|
|
77
77
|
query getAccountCoinsCount($address: String) {
|
|
78
78
|
current_fungible_asset_balances_aggregate(
|
|
79
79
|
where: {owner_address: {_eq: $address}}
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
`,
|
|
86
|
+
`,Mi=`
|
|
87
87
|
query getAccountCoinsData($where_condition: current_fungible_asset_balances_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_fungible_asset_balances_order_by!]) {
|
|
88
88
|
current_fungible_asset_balances(
|
|
89
89
|
where: $where_condition
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
`,
|
|
119
|
+
`,qi=`
|
|
120
120
|
query getAccountCollectionsWithOwnedTokens($where_condition: current_collection_ownership_v2_view_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_collection_ownership_v2_view_order_by!]) {
|
|
121
121
|
current_collection_ownership_v2_view(
|
|
122
122
|
where: $where_condition
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
single_token_uri
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
`,$i=`
|
|
154
154
|
query getAccountOwnedObjects($where_condition: current_objects_bool_exp, $offset: Int, $limit: Int, $order_by: [current_objects_order_by!]) {
|
|
155
155
|
current_objects(
|
|
156
156
|
where: $where_condition
|
|
@@ -167,7 +167,7 @@
|
|
|
167
167
|
is_deleted
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
|
|
170
|
+
`,Hi=`
|
|
171
171
|
query getAccountOwnedTokens($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
172
172
|
current_token_ownerships_v2(
|
|
173
173
|
where: $where_condition
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
...CurrentTokenOwnershipFields
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
${
|
|
181
|
+
${On}`,My=`
|
|
182
182
|
query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
183
183
|
current_token_ownerships_v2(
|
|
184
184
|
where: $where_condition
|
|
@@ -189,7 +189,7 @@
|
|
|
189
189
|
...CurrentTokenOwnershipFields
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
${
|
|
192
|
+
${On}`,Vi=`
|
|
193
193
|
query getAccountOwnedTokensFromCollection($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
194
194
|
current_token_ownerships_v2(
|
|
195
195
|
where: $where_condition
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
...CurrentTokenOwnershipFields
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
${
|
|
203
|
+
${On}`,Li=`
|
|
204
204
|
query getAccountTokensCount($where_condition: current_token_ownerships_v2_bool_exp, $offset: Int, $limit: Int) {
|
|
205
205
|
current_token_ownerships_v2_aggregate(
|
|
206
206
|
where: $where_condition
|
|
@@ -212,7 +212,7 @@
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
`,
|
|
215
|
+
`,Qi=`
|
|
216
216
|
query getAccountTransactionsCount($address: String) {
|
|
217
217
|
account_transactions_aggregate(where: {account_address: {_eq: $address}}) {
|
|
218
218
|
aggregate {
|
|
@@ -220,13 +220,13 @@
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
`,
|
|
223
|
+
`,Wi=`
|
|
224
224
|
query getChainTopUserTransactions($limit: Int) {
|
|
225
225
|
user_transactions(limit: $limit, order_by: {version: desc}) {
|
|
226
226
|
version
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
`,
|
|
229
|
+
`,Cr=`
|
|
230
230
|
query getCollectionData($where_condition: current_collections_v2_bool_exp!) {
|
|
231
231
|
current_collections_v2(where: $where_condition) {
|
|
232
232
|
collection_id
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
uri
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
`,
|
|
248
|
+
`,ji=`
|
|
249
249
|
query getCurrentFungibleAssetBalances($where_condition: current_fungible_asset_balances_bool_exp, $offset: Int, $limit: Int) {
|
|
250
250
|
current_fungible_asset_balances(
|
|
251
251
|
where: $where_condition
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
token_standard
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
|
-
`,
|
|
266
|
+
`,Xi=`
|
|
267
267
|
query getDelegatedStakingActivities($delegatorAddress: String, $poolAddress: String) {
|
|
268
268
|
delegated_staking_activities(
|
|
269
269
|
where: {delegator_address: {_eq: $delegatorAddress}, pool_address: {_eq: $poolAddress}}
|
|
@@ -276,7 +276,7 @@
|
|
|
276
276
|
transaction_version
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
`,
|
|
279
|
+
`,Yi=`
|
|
280
280
|
query getEvents($where_condition: events_bool_exp, $offset: Int, $limit: Int, $order_by: [events_order_by!]) {
|
|
281
281
|
events(
|
|
282
282
|
where: $where_condition
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
indexed_type
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
`,
|
|
298
|
+
`,Zi=`
|
|
299
299
|
query getFungibleAssetActivities($where_condition: fungible_asset_activities_bool_exp, $offset: Int, $limit: Int) {
|
|
300
300
|
fungible_asset_activities(
|
|
301
301
|
where: $where_condition
|
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
type
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
|
-
`,
|
|
323
|
+
`,Ji=`
|
|
324
324
|
query getFungibleAssetMetadata($where_condition: fungible_asset_metadata_bool_exp, $offset: Int, $limit: Int) {
|
|
325
325
|
fungible_asset_metadata(where: $where_condition, offset: $offset, limit: $limit) {
|
|
326
326
|
icon_uri
|
|
@@ -348,14 +348,14 @@
|
|
|
348
348
|
...AnsTokenFragment
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
${
|
|
351
|
+
${qa}`,Er=`
|
|
352
352
|
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
353
353
|
num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
|
|
354
354
|
num_active_delegator
|
|
355
355
|
pool_address
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
`,
|
|
358
|
+
`,Ir=`
|
|
359
359
|
query getProcessorStatus($where_condition: processor_status_bool_exp) {
|
|
360
360
|
processor_status(where: $where_condition) {
|
|
361
361
|
last_success_version
|
|
@@ -363,7 +363,7 @@
|
|
|
363
363
|
last_updated
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
|
-
`,
|
|
366
|
+
`,eo=`
|
|
367
367
|
query getTokenActivity($where_condition: token_activities_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [token_activities_v2_order_by!]) {
|
|
368
368
|
token_activities_v2(
|
|
369
369
|
where: $where_condition
|
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
...TokenActivitiesFields
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
|
-
${
|
|
377
|
+
${Ma}`,Ur=`
|
|
378
378
|
query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
379
379
|
current_token_ownerships_v2(
|
|
380
380
|
where: $where_condition
|
|
@@ -385,7 +385,7 @@
|
|
|
385
385
|
...CurrentTokenOwnershipFields
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
${
|
|
388
|
+
${On}`,to=`
|
|
389
389
|
query getTokenData($where_condition: current_token_datas_v2_bool_exp, $offset: Int, $limit: Int, $order_by: [current_token_datas_v2_order_by!]) {
|
|
390
390
|
current_token_datas_v2(
|
|
391
391
|
where: $where_condition
|
|
@@ -425,5 +425,5 @@
|
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
`;async function On(n){let{aptosConfig:t}=n,{data:e}=await Z({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function to(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _33 => _33.withTransactions])}});return i}async function no(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _34 => _34.withTransactions])}});return i}async function Fn(n){let{aptosConfig:t,handle:e,data:r,options:i}=n;return(await rt({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _35 => _35.ledgerVersion])},body:r})).data}async function ro(n){let{aptosConfig:t,limit:e}=n;return(await f({aptosConfig:t,query:{query:Qi,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:i}=await Ni({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return i}async function qa(n){let{aptosConfig:t}=n;return(await f({aptosConfig:t,query:{query:Er},originMethod:"getProcessorStatuses"})).processor_status}async function Gn(n){let t=await qa({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function Mn(n){let{aptosConfig:t,processorType:e}=n;return(await f({aptosConfig:t,query:{query:Er,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var Ur=new Map;function Et(n,t,e){return async(...r)=>{if(Ur.has(t)){let{value:o,timestamp:s}=Ur.get(t);if(e===void 0||Date.now()-s<=e)return o}let i=await n(...r);return Ur.set(t,{value:i,timestamp:Date.now()}),i}}async function we(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function so(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Pt({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _36 => _36.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _37 => _37.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _38 => _38.limit]), () => (1e3))}})}async function qn(n){return _optionalChain([n, 'access', _39 => _39.options, 'optionalAccess', _40 => _40.ledgerVersion])!==void 0?io(n):Et(async()=>io(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function io(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _41 => _41.ledgerVersion])}});return o}async function ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Pt({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _42 => _42.offset]),limit:_optionalChain([r, 'optionalAccess', _43 => _43.limit])}})}async function co(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Pt({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _44 => _44.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _45 => _45.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _46 => _46.limit]), () => (999))}})}async function Rr(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _47 => _47.ledgerVersion])}});return o.data}async function zr(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,i=await Rr({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(e);try{let a=await Fn({aptosConfig:t,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return u.from(a)}catch(a){if(a instanceof oe&&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:Vi,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 po(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _48 => _48.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _49 => _49.tokenStandard])});let s={query:$i,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _50 => _50.offset]),limit:_optionalChain([r, 'optionalAccess', _51 => _51.limit]),order_by:_optionalChain([r, 'optionalAccess', _52 => _52.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function lo(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', _53 => _53.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _54 => _54.tokenStandard])});let c={query:Hi,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _55 => _55.offset]),limit:_optionalChain([i, 'optionalAccess', _56 => _56.limit]),order_by:_optionalChain([i, 'optionalAccess', _57 => _57.orderBy])}};return(await f({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function go(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _58 => _58.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _59 => _59.tokenStandard])}});let s={query:Mi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _60 => _60.offset]),limit:_optionalChain([r, 'optionalAccess', _61 => _61.limit]),order_by:_optionalChain([r, 'optionalAccess', _62 => _62.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function mo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Li,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function yo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,i=u.from(e).toStringLong(),o=await Kr({aptosConfig:t,accountAddress:i,options:{where:{asset_type:{_eq:r}}}});return o[0]?o[0].amount:0}async function Kr(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i=u.from(e).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _63 => _63.where]),owner_address:{_eq:i}},s={query:Gi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _64 => _64.offset]),limit:_optionalChain([r, 'optionalAccess', _65 => _65.limit]),order_by:_optionalChain([r, 'optionalAccess', _66 => _66.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function fo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Fi,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 Ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}},s={query:qi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _67 => _67.offset]),limit:_optionalChain([r, 'optionalAccess', _68 => _68.limit]),order_by:_optionalChain([r, 'optionalAccess', _69 => _69.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function ho(n){let{aptosConfig:t,privateKey:e}=n,r=new k(e.publicKey());if(e instanceof Le){let o=F.fromPublicKey({publicKey:r}).derivedAddress();return ke.fromPrivateKey({privateKey:e,address:o})}if(e instanceof M){let i=F.fromPublicKey({publicKey:r});if(await oo({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return ke.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=F.fromPublicKey({publicKey:r.publicKey});if(await oo({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return ke.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function oo(n){let{aptosConfig:t,authKey:e}=n,r=await zr({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await we({aptosConfig:t,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function To(n){let{aptosConfig:t,options:e}=n;return Pt({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _70 => _70.offset]),limit:_optionalChain([e, 'optionalAccess', _71 => _71.limit])}})}async function Hn(n){let{aptosConfig:t}=n;return Et(async()=>{let{data:e}=await Z({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function bo(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function Jt(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function wo(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await Jt({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _72 => _72.status])===404)return!0;throw r}}async function $a(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function It(n){let{aptosConfig:t,transactionHash:e,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _73 => _73.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _74 => _74.checkSuccess]), () => (!0)),s=!0,a=0,c,p,m=200,x=1.5;function A(l){if(!(l instanceof oe)||(p=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await Jt({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(l){A(l)}if(s){let l=Date.now();try{c=await $a({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(ae){A(ae)}a=(Date.now()-l)/1e3}for(;s&&!(a>=i);){try{if(c=await Jt({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(l){A(l)}await _chunkKSEUZTKYjs.b.call(void 0, m),a+=m/1e3,m*=x}if(c===void 0)throw p||new $n(`Fetching transaction ${e} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new $n(`Transaction ${e} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new kr(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function Vn(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 Gn({aptosConfig:t}):s=(await Mn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var $n=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},kr=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function b(n){n.minimumLedgerVersion!==void 0&&await Vn({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var en=class{constructor(t){this.config=t}async getAccountInfo(t){return we({aptosConfig:this.config,...t})}async getAccountModules(t){return so({aptosConfig:this.config,...t})}async getAccountModule(t){return qn({aptosConfig:this.config,...t})}async getAccountTransactions(t){return ao({aptosConfig:this.config,...t})}async getAccountResources(t){return co({aptosConfig:this.config,...t})}async getAccountResource(t){return Rr({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return zr({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),uo({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),po({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),lo({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),go({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),mo({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Kr({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),fo({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:En,...t})}async getAccountCoinAmount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),yo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),Ao({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return ho({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Ln=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _75 => _75.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _76 => _76.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _77 => _77.faucet]),this.pepper=_optionalChain([t, 'optionalAccess', _78 => _78.pepper]),this.prover=_optionalChain([t, 'optionalAccess', _79 => _79.prover]),this.indexer=_optionalChain([t, 'optionalAccess', _80 => _80.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _81 => _81.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _82 => _82.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _83 => _83.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _84 => _84.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _85 => _85.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 Ri[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 zi[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 Ui[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 wr[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 Sr[this.network];default:throw Error(`apiType ${t} is not supported`)}}isPepperServiceRequest(t){return wr[this.network]===t}isProverServiceRequest(t){return Sr[this.network]===t}};function So(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function xo(n){return!!n.match(/\s/)}function Va(n){return!!n.match(/^T[0-9]+$/)}function La(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!xo(r))break}return e}var Qa=(A=>(A.InvalidTypeTag="unknown type",A.UnexpectedGenericType="unexpected generic type",A.UnexpectedTypeArgumentClose="unexpected '>'",A.UnexpectedWhitespaceCharacter="unexpected whitespace character",A.UnexpectedComma="unexpected ','",A.TypeArgumentCountMismatch="type argument count doesn't match expected amount",A.MissingTypeArgumentClose="no matching '>' for '<'",A.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",A.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",A.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",A.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",A.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",A))(Qa||{}),E= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Ce(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _86 => _86.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 ae=Qn(a,i,e);o.push(ae)}let m=r.pop();if(m===void 0)throw new E(n,"unexpected '>'");if(c!==o.length)throw new E(n,"type argument count doesn't match expected amount");let{savedStr:x,savedTypes:A,savedExpectedTypes:l}=m;i=o,o=A,a=x,c=l}else if(p===","){if(a.length!==0){let m=Qn(a,i,e);i=[],o.push(m),a="",c+=1}}else if(xo(p)){let m=!1;if(a.length!==0){let A=Qn(a,i,e);i=[],o.push(A),a="",m=!0}s=La(n,s);let x=n[s];if(s<n.length&&m&&x!==","&&x!==">")throw new E(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new E(n,"no matching '>' for '<'");switch(o.length){case 0:return Qn(a,i,e);case 1:if(a==="")return o[0];throw new E(n,"unexpected ','");default:throw new E(n,"unexpected whitespace character")}}function Qn(n,t,e){switch(n){case"&signer":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new In(new Ye);case"signer":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Ye;case"bool":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new G;case"address":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new X;case"u8":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Te;case"u16":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new mt;case"u32":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new yt;case"u64":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Q;case"u128":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new ft;case"u256":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new At;case"vector":if(t.length!==1)throw new E(n,"vector type expected to have exactly one type argument");return new C(t[0]);default:if(Va(n)){if(e)return new K(Number(n.split("T")[1]));throw new E(n,"unexpected generic type")}if(!n.match(/:/))throw new E(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new E(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!So(r[1]))throw new E(n,"module name must only contain alphanumeric or '_' characters");if(!So(r[2]))throw new E(n,"struct name must only contain alphanumeric or '_' characters");return new y(new ve(u.fromString(r[0]),new U(r[1]),new U(r[2]),t))}}function _o(n){return typeof n=="boolean"}function Ut(n){return typeof n=="string"}function Wn(n){return typeof n=="number"}function jn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function vo(n){return n==null}function Po(n){return Nr(n)||Br(n)||Or(n)||Fr(n)||Gr(n)||Mr(n)||qr(n)||Xn(n)||Dr(n)||Wa(n)||n instanceof T||n instanceof Re}function Nr(n){return n instanceof R}function Xn(n){return n instanceof u}function Dr(n){return n instanceof w}function Wa(n){return n instanceof Me}function Br(n){return n instanceof O}function Or(n){return n instanceof ce}function Fr(n){return n instanceof ue}function Gr(n){return n instanceof B}function Mr(n){return n instanceof pe}function qr(n){return n instanceof de}function Co(n){return"bytecode"in n}function I(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Eo(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function tn(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],i=t[2];return{moduleAddress:e,moduleName:r,functionName:i}}var ja=new TextEncoder;function Hr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _87 => _87.map, 'call', _88 => _88(t=>Ut(t)?Ce(t):t)]), () => ([]))}async function Io(n,t,e,r){let i=await qn({aptosConfig:r,accountAddress:n,moduleName:t});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===e)}async function Uo(n,t,e,r){let i=await Io(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=Eo(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ce(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Ro(n,t,e,r){let i=await Io(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(Ce(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ce(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Vr(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 Rt(e,o,r,i)}function Rt(n,t,e,r){return Po(n)?($r(t,n,e),n):Xa(n,t,e,r)}function Xa(n,t,e,r){if(t.isBool()){if(_o(n))return new R(n);I("boolean",e)}if(t.isAddress()){if(Ut(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isU8()){if(Wn(n))return new O(n);I("number",e)}if(t.isU16()){if(Wn(n))return new ce(n);I("number",e)}if(t.isU32()){if(Wn(n))return new ue(n);I("number",e)}if(t.isU64()){if(jn(n))return new B(BigInt(n));I("bigint | number | string",e)}if(t.isU128()){if(jn(n))return new pe(BigInt(n));I("bigint | number | string",e)}if(t.isU256()){if(jn(n))return new de(BigInt(n));I("bigint | number | string",e)}if(t.isGeneric()){let i=t.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return Rt(n,r[i],e,r)}if(t.isVector()){if(t.value.isU8()){if(Ut(n))return T.U8(ja.encode(n));if(n instanceof Uint8Array)return T.U8(n);if(n instanceof ArrayBuffer)return T.U8(new Uint8Array(n))}if(Array.isArray(n))return new T(n.map(i=>Rt(i,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(Ut(n))return new w(n);I("string",e)}if(t.isObject()){if(Ut(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isOption())return vo(n)?new Re(null):new Re(Rt(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 $r(n,t,e){if(n.isBool()){if(Nr(t))return;I("Bool",e)}if(n.isAddress()){if(Xn(t))return;I("AccountAddress",e)}if(n.isU8()){if(Br(t))return;I("U8",e)}if(n.isU16()){if(Or(t))return;I("U16",e)}if(n.isU32()){if(Fr(t))return;I("U32",e)}if(n.isU64()){if(Gr(t))return;I("U64",e)}if(n.isU128()){if(Mr(t))return;I("U128",e)}if(n.isU256()){if(qr(t))return;I("U256",e)}if(n.isVector()){if(t instanceof T){t.values.length>0&&$r(n.value,t.values[0],e);return}I("MoveVector",e)}if(n instanceof y){if(n.isString()){if(Dr(t))return;I("MoveString",e)}if(n.isObject()){if(Xn(t))return;I("AccountAddress",e)}if(n.isOption()){if(t instanceof Re){t.value!==void 0&&$r(n.value.typeArgs[0],t.value,e);return}I("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}async function Zn(n){if(Co(n))return ec(n);let{moduleAddress:t,moduleName:e,functionName:r}=tn(n.function),i=await No({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Uo});return Za({...n,abi:i})}function Za(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=tn(n.function),o=Hr(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)=>Vr(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=Je.build(`${e}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Lt(new Wt(c,new jt(a)))}return new Vt(a)}async function zo(n){let{moduleAddress:t,moduleName:e,functionName:r}=tn(n.function),i=await No({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ro});return Ja({abi:i,...n})}function Ja(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=tn(n.function),o=Hr(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', _89 => _89.functionArguments, 'optionalAccess', _90 => _90.map, 'call', _91 => _91((a,c)=>Vr(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 Je.build(`${e}::${r}`,i,o,s)}function ec(n){return new Ht(new Qt(g.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function tc(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=async()=>_r[t.network]?{chainId:_r[t.network]}:{chainId:(await On({aptosConfig:t})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _92 => _92.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Hn({aptosConfig:t})).gas_estimate},c=async()=>{let it=async()=>_optionalChain([i, 'optionalAccess', _93 => _93.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await we({aptosConfig:t,accountAddress:e})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await it()}catch (e3){return 0}else return it()},[{chainId:p},{gasEstimate:m},x]=await Promise.all([s(),a(),c()]),{maxGasAmount:A,gasUnitPrice:l,expireTimestamp:ae}={maxGasAmount:_optionalChain([i, 'optionalAccess', _94 => _94.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _95 => _95.gasUnitPrice]), () => (BigInt(m))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _96 => _96.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new ie(u.from(e),BigInt(x),r,BigInt(A),BigInt(l),BigInt(ae),new gt(p))}async function Lr(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=await tc({aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _97 => _97.secondarySignerAddresses, 'optionalAccess', _98 => _98.map, 'call', _99 => _99(c=>u.from(c))]), () => ([]));return new Kn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new zn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function Ko(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Yn(t);if(e.feePayerAddress){let a=new tt(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(x=>Yn(x)));let p=Yn(i),m=new bt(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new nt(a.raw_txn,m).bcsToBytes()}if(e.secondarySignerAddresses){let a=new et(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(m=>Yn(m));let p=new Tt(o,e.secondarySignerAddresses,c);return new nt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof me)s=new ht(o.public_key,o.signature);else if(o instanceof $)s=new wt(o);else throw new Error("Invalid public key");return new nt(e.rawTransaction,s).bcsToBytes()}function Yn(n){let t=n;if((t instanceof ge||t instanceof he)&&(t=new k(t)),t instanceof k){if(t.publicKey instanceof P)return new $(t,new D(new _(new Uint8Array(64))));if(t.publicKey instanceof he)return new $(t,new D(new xe(new Uint8Array(64))));if(t.publicKey instanceof ge)return new $(t,new D(new _(new Uint8Array(64))))}return new me(new P(t.toUint8Array()),new _(new Uint8Array(64)))}function Qr(n){let{transaction:t,feePayerAuthenticator:e,additionalSignersAuthenticators:r}=n,i=Ki(q,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 bt(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 Tt(i,t.secondarySignerAddresses,r)}else i instanceof me?o=new ht(i.public_key,i.signature):o=new wt(i);return new nt(t.rawTransaction,o).bcsToBytes()}function ko(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var nc=ko(["APTOS::Transaction"]);function oA(n){let t=Qr(n);return new g(ko([nc,new Uint8Array([0]),t])).toString()}async function No({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Et(async()=>s(t,e,r,i),`${n}-${i.network}-${t}-${e}-${r}`,1e3*60*5)()}async function h(n){let t=await rc(n);return ic(n,t)}async function rc(n){let{aptosConfig:t,data:e}=n,r,i;return"bytecode"in e?i=await Zn(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await Zn(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await Zn(r)),i}async function ic(n,t){let{aptosConfig:e,sender:r,options:i}=n,o;if(oc(n)&&(o=u.ZERO.toString()),sc(n)){let{secondarySignerAddresses:s}=n;return Lr({aptosConfig:e,sender:r,payload:t,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Lr({aptosConfig:e,sender:r,payload:t,options:i,feePayerAddress:o})}function oc(n){return n.withFeePayer===!0}function sc(n){return"secondarySignerAddresses"in n}function Do(n){let{transaction:t}=n;return St(t)}function Jn(n){let{signer:t,transaction:e}=n;return t.signTransactionWithAuthenticator(e)}async function Wr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Ko({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await rt({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _100 => _100.options, 'optionalAccess', _101 => _101.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _102 => _102.options, 'optionalAccess', _103 => _103.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _104 => _104.options, 'optionalAccess', _105 => _105.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function er(n){let{aptosConfig:t}=n,e=Qr({...n}),{data:r}=await rt({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function nn(n){let{aptosConfig:t,signer:e,transaction:r}=n;(e instanceof be||e instanceof Nn)&&await e.waitForProofFetch();let i=Jn({signer:e,transaction:r});return er({aptosConfig:t,transaction:r,senderAuthenticator:i})}var ac={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Bo(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>T.U8(a));return h({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:ac},options:o})}var cc={typeParameters:[],parameters:[new Te,C.u8(),new Te,C.u8(),C.u8(),C.u8()]};async function Oo(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,i=await we({aptosConfig:t,accountAddress:e.accountAddress}),o=ke.fromPrivateKey({privateKey:r,legacy:!0}),a=new Rn({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),m=await h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new O(e.signingScheme),T.U8(e.publicKey.toUint8Array()),new O(o.signingScheme),T.U8(o.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:cc}});return nn({aptosConfig:t,signer:e,transaction:m})}var uc={typeParameters:[{constraints:[]}],parameters:[new X,new Q]};async function Fo(n){let{aptosConfig:t,sender:e,recipient:r,amount:i,coinType:o,options:s}=n;return h({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (En))],functionArguments:[r,i],abi:uc},options:s})}var rn=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Fo({aptosConfig:this.config,...t})}};var De={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},se="0x4::token::Token";async function Go(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:eo,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function Mo(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:Ir,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function qo(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},o={query:Ir,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _106 => _106.offset]),limit:_optionalChain([r, 'optionalAccess', _107 => _107.limit]),order_by:_optionalChain([r, 'optionalAccess', _108 => _108.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function $o(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,i={token_data_id:{_eq:u.from(e).toStringLong()}},o={query:Ji,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _109 => _109.offset]),limit:_optionalChain([r, 'optionalAccess', _110 => _110.limit]),order_by:_optionalChain([r, 'optionalAccess', _111 => _111.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var pc={typeParameters:[],parameters:[new y(v()),new Q,new y(v()),new y(v()),new G,new G,new G,new G,new G,new G,new G,new G,new G,new Q,new Q]};async function Ho(n){let{aptosConfig:t,options:e,creator:r}=n;return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new B(_nullishCoalesce(n.maxSupply, () => (Fe))),new w(n.name),new w(n.uri),new R(_nullishCoalesce(n.mutableDescription, () => (!0))),new R(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new R(_nullishCoalesce(n.mutableURI, () => (!0))),new R(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new R(_nullishCoalesce(n.mutableTokenName, () => (!0))),new R(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new R(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new R(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new R(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new B(_nullishCoalesce(n.royaltyNumerator, () => (0))),new B(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:pc},options:e})}async function jr(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', _112 => _112.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _113 => _113.tokenStandard]), () => ("v2"))}),(await f({aptosConfig:t,query:{query:Pr,variables:{where_condition:s}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Vo(n){let{aptosConfig:t,collectionId:e}=n,i={collection_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:Pr,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Lo(n){return(await jr(n)).collection_id}var dc={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new C(new y(v())),new C(new y(v())),new C(C.u8())]};async function Qo(n){let{aptosConfig:t,options:e,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:m}=n,x=_optionalChain([p, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(A=>De[A])]);return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(i),new w(o),new w(s),new w(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(x, () => ([]))),as(_nullishCoalesce(m, () => ([])),_nullishCoalesce(x, () => ([])))],abi:dc},options:e})}var lc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new X]};async function Wo(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(r),u.from(i)],abi:lc},options:s})}var gc={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new C(new y(v())),new C(new y(v())),new C(C.u8()),new X]};async function jo(n){let{aptosConfig:t,account:e,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:m,options:x}=n;if(_optionalChain([c, 'optionalAccess', _116 => _116.length])!==_optionalChain([m, 'optionalAccess', _117 => _117.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _118 => _118.length])!==_optionalChain([m, 'optionalAccess', _119 => _119.length]))throw new Error("Property types and property values counts do not match");let A=_optionalChain([p, 'optionalAccess', _120 => _120.map, 'call', _121 => _121(l=>De[l])]);return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(A, () => ([]))),as(_nullishCoalesce(m, () => ([])),_nullishCoalesce(A, () => ([]))),a],abi:gc},options:x})}var mc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0)))]};async function Xo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (se))],functionArguments:[u.from(r)],abi:mc},options:o})}var yc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0)))]};async function Yo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (se))],functionArguments:[r],abi:yc},options:o})}var fc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0)))]};async function Zo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (se))],functionArguments:[r],abi:fc},options:o})}var Ac={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function Jo(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:Ac},options:s})}var hc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function es(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:hc},options:s})}var Tc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function ts(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:Tc},options:s})}var bc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v()),new y(v()),C.u8()]};async function ns(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (se))],functionArguments:[u.from(s),new w(r),new w(De[i]),T.U8(Xr(o,De[i]))],abi:bc},options:c})}var wc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function rs(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:wc},options:s})}var Sc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v()),new y(v()),C.u8()]};async function is(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (se))],functionArguments:[u.from(s),new w(r),new w(De[i]),Xr(o,De[i])],abi:Sc},options:c})}var xc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(Y(new K(0))),new y(v()),new K(1)]};async function os(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (se)),De[i]],functionArguments:[u.from(s),new w(r),o],abi:xc},options:c})}var _c={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(Y(new K(0))),new y(v()),new K(1)]};async function ss(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (se)),De[i]],functionArguments:[u.from(s),new w(r),o],abi:_c},options:c})}function as(n,t){let e=new Array;return t.forEach((r,i)=>{e.push(Xr(n[i],r))}),e}function Xr(n,t){let e=Ce(t);return Rt(n,e,0,[]).bcsToBytes()}var on=class{constructor(t){this.config=t}async getCollectionData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),jr({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Vo({aptosConfig:this.config,...t})}async getCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Lo({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Go({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Mo({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),qo({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),$o({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Ho({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return Qo({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return Wo({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return jo({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return Xo({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Yo({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return Zo({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return Jo({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return es({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return ts({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return ns({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return rs({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return is({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return os({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return ss({aptosConfig:this.config,...t})}};var cs=300,vc=n=>{if(n&&n.length>cs)throw new Error(`Event type length exceeds the maximum length of ${cs}`)};async function us(n){let{aptosConfig:t,eventType:e,options:r}=n,o={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _122 => _122.orderBy])};return sn({aptosConfig:t,options:o})}async function ps(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _123 => _123.orderBy])};return sn({aptosConfig:e,options:a})}async function ds(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _124 => _124.orderBy])};return sn({aptosConfig:e,options:a})}async function sn(n){let{aptosConfig:t,options:e}=n;vc(_optionalChain([e, 'optionalAccess', _125 => _125.where, 'optionalAccess', _126 => _126.indexed_type, 'optionalAccess', _127 => _127._eq]));let r={query:Xi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _128 => _128.where]),offset:_optionalChain([e, 'optionalAccess', _129 => _129.offset]),limit:_optionalChain([e, 'optionalAccess', _130 => _130.limit]),order_by:_optionalChain([e, 'optionalAccess', _131 => _131.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var an=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),us({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ps({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ds({aptosConfig:this.config,...t})}async getEvents(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _132 => _132.minimumLedgerVersion]),processorType:"events_processor"}),sn({aptosConfig:this.config,...t})}};async function ls(n){let{aptosConfig:t,accountAddress:e,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _133 => _133.timeoutSecs])||20,{data:s}=await Di({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await It({aptosConfig:t,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _134 => _134.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var cn=class{constructor(t){this.config=t}async fundAccount(t){let e=await ls({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.waitForIndexer])!==!1&&await Vn({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function Yr(n){let{aptosConfig:t,options:e}=n,r={query:Zi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _137 => _137.where]),limit:_optionalChain([e, 'optionalAccess', _138 => _138.limit]),offset:_optionalChain([e, 'optionalAccess', _139 => _139.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function gs(n){let{aptosConfig:t,options:e}=n,r={query:Yi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _140 => _140.where]),limit:_optionalChain([e, 'optionalAccess', _141 => _141.limit]),offset:_optionalChain([e, 'optionalAccess', _142 => _142.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ms(n){let{aptosConfig:t,options:e}=n,r={query:Wi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _143 => _143.where]),limit:_optionalChain([e, 'optionalAccess', _144 => _144.limit]),offset:_optionalChain([e, 'optionalAccess', _145 => _145.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Pc={typeParameters:[{constraints:[]}],parameters:[Ce("0x1::object::Object"),new X,new Q]};async function ys(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:Pc},options:s})}var un=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _146 => _146.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Yr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _147 => _147.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Yr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _148 => _148.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),gs({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _149 => _149.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ms({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return ys({aptosConfig:this.config,...t})}};async function Be(n){let{aptosConfig:t,payload:e,options:r}=n,i=await zo({...e,aptosConfig:t}),o=new L;i.serialize(o);let s=o.toUint8Array(),{data:a}=await rt({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _150 => _150.ledgerVersion])},body:s});return a}var pn=class{constructor(t){this.config=t}async getLedgerInfo(){return On({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return to({aptosConfig:this.config,...t})}async getBlockByHeight(t){return no({aptosConfig:this.config,...t})}async getTableItem(t){return Fn({aptosConfig:this.config,...t})}async view(t){return Be({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return ro({aptosConfig:this.config,...t})}async queryIndexer(t){return f({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return Gn({aptosConfig:this.config})}async getProcessorStatus(t){return Mn({aptosConfig:this.config,processorType:t})}};var fs=["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 As(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Oe(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(!As(t))throw new Error(`${t} is not valid. ${fs}`);if(e&&!As(e))throw new Error(`${e} is not valid. ${fs}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Cc="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Ec={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Cc,custom:null,devnet:null};function Ee(n){let t=Ec[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var tr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function hs(n){let{aptosConfig:t,name:e}=n,r=Ee(t),{domainName:i,subdomainName:o}=Oe(e),s=await Be({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=tr(s[0]);return a?u.from(a):void 0}async function Ts(n){let{aptosConfig:t,expiration:e,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=Ee(t),{domainName:m,subdomainName:x}=Oe(r),A=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(x&&!A)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(A&&!x)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let ar=_nullishCoalesce(e.years, () => (1));if(ar!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Ds=ar*31536e3;return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[m,Ds,o,s]},options:a})}if(!x)throw new Error(`${e.policy} requires a subdomain to be provided.`);let l=await Zr({aptosConfig:t,name:m});if(!l)throw new Error("The domain does not exist");let ae=e.policy==="subdomain:independent"?e.expirationDate:l;if(ae>l)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[m,x,Math.round(ae/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function Zr(n){let{aptosConfig:t,name:e}=n,r=Ee(t),{domainName:i,subdomainName:o}=Oe(e);try{let s=await Be({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e4){return}}async function bs(n){let{aptosConfig:t,address:e}=n,r=Ee(t),i=await Be({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),o=tr(i[1]),s=tr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function ws(n){let{aptosConfig:t,sender:e,name:r,options:i}=n,o=Ee(t);if(!r)return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Oe(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ss(n){let{aptosConfig:t,name:e}=n,r=Ee(t),{domainName:i,subdomainName:o}=Oe(e),s=await Be({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=tr(s[0]);return a?u.from(a):void 0}async function xs(n){let{aptosConfig:t,sender:e,name:r,address:i,options:o}=n,s=Ee(t),{domainName:a,subdomainName:c}=Oe(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function _s(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:i=""}=Oe(e),a=(await f({aptosConfig:t,query:{query:Ct,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=dn(a)),a}async function vs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Jr({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountNames",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _151 => _151.limit]),offset:_optionalChain([e, 'optionalAccess', _152 => _152.offset]),order_by:_optionalChain([e, 'optionalAccess', _153 => _153.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _154 => _154.options, 'optionalAccess', _155 => _155.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(dn)}async function Ps(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Jr({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountDomains",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _156 => _156.limit]),offset:_optionalChain([e, 'optionalAccess', _157 => _157.offset]),order_by:_optionalChain([e, 'optionalAccess', _158 => _158.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _159 => _159.options, 'optionalAccess', _160 => _160.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(dn)}async function Cs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await Jr({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _161 => _161.limit]),offset:_optionalChain([e, 'optionalAccess', _162 => _162.offset]),order_by:_optionalChain([e, 'optionalAccess', _163 => _163.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _164 => _164.options, 'optionalAccess', _165 => _165.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(dn)}async function Es(n){let{aptosConfig:t,options:e,domain:r}=n;return(await f({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _166 => _166.limit]),offset:_optionalChain([e, 'optionalAccess', _167 => _167.offset]),order_by:_optionalChain([e, 'optionalAccess', _168 => _168.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _169 => _169.options, 'optionalAccess', _170 => _170.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(dn)}async function Jr(n){let{aptosConfig:t}=n,e=Ee(t),[r]=await Be({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 Is(n){let{aptosConfig:t,sender:e,name:r,years:i=1,options:o}=n,s=Ee(t),a=i*31536e3,{domainName:c,subdomainName:p}=Oe(r);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function dn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var ln=class{constructor(t){this.config=t}async getOwnerAddress(t){return hs({aptosConfig:this.config,...t})}async getExpiration(t){return Zr({aptosConfig:this.config,...t})}async getTargetAddress(t){return Ss({aptosConfig:this.config,...t})}async setTargetAddress(t){return xs({aptosConfig:this.config,...t})}async getPrimaryName(t){return bs({aptosConfig:this.config,...t})}async setPrimaryName(t){return ws({aptosConfig:this.config,...t})}async registerName(t){return Ts({aptosConfig:this.config,...t})}async renewDomain(t){return Is({aptosConfig:this.config,...t})}async getName(t){return _s({aptosConfig:this.config,...t})}async getAccountNames(t){return vs({aptosConfig:this.config,...t})}async getAccountDomains(t){return Ps({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Cs({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return Es({aptosConfig:this.config,...t})}};async function Us(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Cr,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 Rs(n){let{aptosConfig:t,options:e}=n,r={query:Cr,variables:{order_by:_optionalChain([e, 'optionalAccess', _171 => _171.orderBy])}};return(await f({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function zs(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,i={query:ji,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:t,query:i})).delegated_staking_activities}var gn=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _172 => _172.minimumLedgerVersion]),processorType:"stake_processor"}),Us({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _173 => _173.minimumLedgerVersion]),processorType:"stake_processor"}),Rs({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _174 => _174.minimumLedgerVersion]),processorType:"stake_processor"}),zs({aptosConfig:this.config,...t})}};var nr=class{constructor(t){this.config=t}async simple(t){return h({aptosConfig:this.config,...t})}async multiAgent(t){return h({aptosConfig:this.config,...t})}};function ei(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 ti(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 zt=class{constructor(t){this.config=t}async simple(t){return Wr({aptosConfig:this.config,...t})}async multiAgent(t){return Wr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [ti],zt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [ti],zt.prototype,"multiAgent",1);var Kt=class{constructor(t){this.config=t}async simple(t){return er({aptosConfig:this.config,...t})}async multiAgent(t){return er({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [ei],Kt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [ei],Kt.prototype,"multiAgent",1);var rr=()=>Math.floor(Date.now()/1e3),ir= exports.AccountSequenceNumber =class{constructor(t,e,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=rr();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),rr()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=rr();for(;this.lastUncommintedNumber!==this.currentNumber;)rr()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var kt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _175 => _175.pendingDequeue, 'access', _176 => _176.shift, 'call', _177 => _177(), 'optionalAccess', _178 => _178.resolve, 'call', _179 => _179(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 Nt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Nt=class extends Error{};var Ks="fulfilled",ks= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(ks||{}),or= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,i=30,o=100,s=10){super();this.taskQueue=new kt;this.transactionsQueue=new kt;this.outstandingTransactions=new kt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new ir(e,r,i,o,s)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let i=nn({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof Nt)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===Ks?(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 Nt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let i=[];i.push(It({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===Ks?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return h({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var sr=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new or(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 mn=class{constructor(t){this.config=t,this.build=new nr(this.config),this.simulate=new zt(this.config),this.submit=new Kt(this.config),this.batch=new sr(this.config)}async getTransactions(t){return To({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return bo({aptosConfig:this.config,...t})}async getTransactionByHash(t){return Jt({aptosConfig:this.config,...t})}async isPendingTransaction(t){return wo({aptosConfig:this.config,...t})}async waitForTransaction(t){return It({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return Hn({aptosConfig:this.config})}getSigningMessage(t){return Do(t)}async publishPackageTransaction(t){return Bo({aptosConfig:this.config,...t})}async rotateAuthKey(t){return Oo({aptosConfig:this.config,...t})}sign(t){return Jn({...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,Jn({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:i}=t;this.batch.forSingleAccount({sender:e,data:r,options:i})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return nn({aptosConfig:this.config,signer:e,transaction:r})}};async function ni(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,uidKey:i,derivationPath:o}=n,s={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Bi({aptosConfig:t,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return g.fromHexInput(a.pepper).toUint8Array()}async function zc(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,pepper:i,uidKey:o,extraFieldKey:s}=n,a={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),exp_horizon_secs:Mt,pepper:g.fromHexInput(i).toStringWithoutPrefix(),extra_field:s,uid_key:o||"sub"},{data:c}=await Oi({aptosConfig:t,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),p=c.proof,m=new Gt({a:p.a,b:p.b,c:p.c}),x;if(s){let ae=_jwtdecode.jwtDecode.call(void 0, e)[s];x=`"${s}":"${ae}",`}return new Ke({proof:new pt(m,0),extraField:x,trainingWheelsSignature:le.fromHex(c.training_wheels_signature)})}async function Ns(n){let{proofFetchCallback:t}=n,{pepper:e}=n;if(e===void 0)e=await ni(n);else if(g.fromHexInput(e).toUint8Array().length!==be.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${be.PEPPER_LENGTH} bytes`);let r=zc({...n,pepper:e}),i=t?r:await r;return be.fromJWTAndProof({...n,proof:i,pepper:e,proofFetchCallback:t})}var yn=class{constructor(t){this.config=t}async getPepper(t){return ni({aptosConfig:this.config,...t})}async deriveKeylessAccount(t){return Ns({aptosConfig:this.config,...t})}};var J=class{constructor(t){this.config=new Ln(t),this.account=new en(this.config),this.ans=new ln(this.config),this.coin=new rn(this.config),this.digitalAsset=new on(this.config),this.event=new an(this.config),this.faucet=new cn(this.config),this.fungibleAsset=new un(this.config),this.general=new pn(this.config),this.staking=new gn(this.config),this.transaction=new mn(this.config),this.keyless=new yn(this.config)}};function ye(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))})}ye(J,en,"account");ye(J,ln,"ans");ye(J,rn,"coin");ye(J,on,"digitalAsset");ye(J,an,"event");ye(J,cn,"faucet");ye(J,un,"fungibleAsset");ye(J,pn,"general");ye(J,gn,"staking");ye(J,mn,"transaction");ye(J,yn,"keyless");exports.APTOS_BIP44_REGEX = Xs; exports.APTOS_COIN = En; exports.APTOS_HARDENED_REGEX = js; exports.Account = ke; exports.AccountAddress = u; exports.AccountAuthenticator = q; exports.AccountAuthenticatorEd25519 = me; exports.AccountAuthenticatorMultiEd25519 = Pn; exports.AccountAuthenticatorMultiKey = Xe; exports.AccountAuthenticatorSingleKey = $; exports.AccountAuthenticatorVariant = ai; exports.AccountPublicKey = te; exports.AccountSequenceNumber = ir; exports.AddressInvalidReason = Vs; exports.AnyPublicKey = k; exports.AnyPublicKeyVariant = ur; exports.AnySignature = D; exports.AnySignatureVariant = ci; exports.Aptos = J; exports.AptosApiError = oe; exports.AptosApiType = qt; exports.AptosConfig = Ln; exports.AuthenticationKey = F; exports.Bool = R; exports.CKDPriv = fi; exports.ChainId = gt; exports.DEFAULT_MAX_GAS_AMOUNT = _i; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = vi; exports.DEFAULT_TXN_TIMEOUT_SEC = Cn; exports.DeriveScheme = $s; exports.Deserializer = ee; exports.EPK_HORIZON_SECS = Mt; exports.Ed25519Account = xt; exports.Ed25519PrivateKey = M; exports.Ed25519PublicKey = P; exports.Ed25519Signature = _; exports.EntryFunction = Je; exports.EntryFunctionBytes = Tn; exports.EphemeralCertificate = ut; exports.EphemeralCertificateVariant = dr; exports.EphemeralKeyPair = Xt; exports.EphemeralPublicKey = Qe; exports.EphemeralPublicKeyVariant = pr; exports.EphemeralSignature = le; exports.EphemeralSignatureVariant = ui; exports.FeePayerRawTransaction = tt; exports.FixedBytes = Me; exports.Groth16Zkp = Gt; exports.HARDENED_OFFSET = gi; exports.Hex = g; exports.HexInvalidReason = Fs; exports.Identifier = U; exports.IssuerToJwkEndpoint = Da; exports.KeyType = Ys; exports.KeylessAccount = be; exports.KeylessError = Yt; exports.KeylessErrorType = Ba; exports.KeylessPublicKey = ge; exports.KeylessSignature = We; exports.MAX_AUD_VAL_BYTES = xa; exports.MAX_COMMITED_EPK_BYTES = fd; exports.MAX_EXTRA_FIELD_BYTES = md; exports.MAX_ISS_VAL_BYTES = gd; exports.MAX_JWT_HEADER_B64_BYTES = yd; exports.MAX_UID_KEY_BYTES = _a; exports.MAX_UID_VAL_BYTES = va; exports.MimeType = bn; exports.ModuleId = $t; exports.MoveAbility = pi; exports.MoveFunctionVisibility = Ms; exports.MoveOption = Re; exports.MoveString = w; exports.MoveVector = T; exports.MultiAgentRawTransaction = et; exports.MultiAgentTransaction = Kn; exports.MultiEd25519PublicKey = at; exports.MultiEd25519Signature = He; exports.MultiKey = dt; exports.MultiKeyAccount = Nn; exports.MultiKeySignature = je; exports.MultiSig = Wt; exports.MultiSigTransactionPayload = jt; exports.Network = xr; exports.NetworkToChainId = _r; exports.NetworkToFaucetAPI = zi; exports.NetworkToIndexerAPI = Ui; exports.NetworkToNetworkName = iy; exports.NetworkToNodeAPI = Ri; exports.NetworkToPepperAPI = wr; exports.NetworkToProverAPI = Sr; exports.ParsingError = V; exports.ProcessorType = lt; exports.PublicKey = qe; exports.RAW_TRANSACTION_SALT = Pi; exports.RAW_TRANSACTION_WITH_DATA_SALT = Ar; exports.RawTransaction = ie; exports.RawTransactionWithData = Un; exports.RoleType = qs; exports.RotationProofChallenge = Rn; exports.Script = Qt; exports.ScriptTransactionArgumentVariants = Bt; exports.Secp256k1PrivateKey = Le; exports.Secp256k1PublicKey = he; exports.Secp256k1Signature = xe; exports.Serializable = d; exports.Serializer = L; exports.Signature = N; exports.SignedTransaction = nt; exports.SigningScheme = fe; exports.SigningSchemeInput = mr; exports.SimpleTransaction = zn; exports.SingleKeyAccount = _t; exports.StructTag = ve; exports.TransactionAuthenticator = Pe; exports.TransactionAuthenticatorEd25519 = ht; exports.TransactionAuthenticatorFeePayer = bt; exports.TransactionAuthenticatorMultiAgent = Tt; exports.TransactionAuthenticatorMultiEd25519 = hr; exports.TransactionAuthenticatorSingleSender = wt; exports.TransactionAuthenticatorVariant = si; exports.TransactionPayload = Ze; exports.TransactionPayloadEntryFunction = Vt; exports.TransactionPayloadMultiSig = Lt; exports.TransactionPayloadScript = Ht; exports.TransactionPayloadVariants = ii; exports.TransactionResponseType = gr; exports.TransactionVariants = oi; exports.TransactionWorker = or; exports.TransactionWorkerEventsEnum = ks; exports.TypeTag = z; exports.TypeTagAddress = X; exports.TypeTagBool = G; exports.TypeTagGeneric = K; exports.TypeTagParserError = E; exports.TypeTagParserErrorType = Qa; exports.TypeTagReference = In; exports.TypeTagSigner = Ye; exports.TypeTagStruct = y; exports.TypeTagU128 = ft; exports.TypeTagU16 = mt; exports.TypeTagU256 = At; exports.TypeTagU32 = yt; exports.TypeTagU64 = Q; exports.TypeTagU8 = Te; exports.TypeTagVariants = ri; exports.TypeTagVector = C; exports.U128 = pe; exports.U16 = ce; exports.U256 = de; exports.U32 = ue; exports.U64 = B; exports.U8 = O; exports.ZeroKnowledgeSig = Ke; exports.ZkProof = pt; exports.ZkpVariant = lr; exports.aptosCoinStructTag = Pl; exports.aptosRequest = Dn; exports.buildTransaction = Lr; exports.checkOrConvertArgument = Rt; exports.convertArgument = Vr; exports.deriveKey = yr; exports.deriveTransactionType = Tr; exports.deserializeFromScriptArgument = Ca; exports.ensureBoolean = cr; exports.fetchEntryFunctionAbi = Uo; exports.fetchFunctionAbi = Io; exports.fetchViewFunctionAbi = Ro; exports.findFirstNonSignerArg = Eo; exports.generateRawTransaction = tc; exports.generateSignedTransaction = Qr; exports.generateSignedTransactionForSimulation = Ko; exports.generateSigningMessage = kn; exports.generateSigningMessageForSerializable = Ci; exports.generateSigningMessageForTransaction = St; exports.generateTransactionPayload = Zn; exports.generateTransactionPayloadWithABI = Za; exports.generateUserTransactionHash = oA; exports.generateViewFunctionPayload = zo; exports.generateViewFunctionPayloadWithABI = Ja; exports.get = vr; exports.getAptosFullNode = Z; exports.getAptosPepperService = Py; exports.getAuthenticatorForSimulation = Yn; exports.getFunctionParts = tn; exports.hashValues = ko; exports.isBcsAddress = Xn; exports.isBcsBool = Nr; exports.isBcsFixedBytes = Wa; exports.isBcsString = Dr; exports.isBcsU128 = Mr; exports.isBcsU16 = Or; exports.isBcsU256 = qr; exports.isBcsU32 = Fr; exports.isBcsU64 = Gr; exports.isBcsU8 = Br; exports.isBlockMetadataTransactionResponse = iu; exports.isBool = _o; exports.isEd25519Signature = au; exports.isEncodedEntryFunctionArgument = Po; exports.isFeePayerSignature = pu; exports.isGenesisTransactionResponse = ru; exports.isLargeNumber = jn; exports.isMultiAgentSignature = uu; exports.isMultiEd25519Signature = du; exports.isNull = vo; exports.isNumber = Wn; exports.isPendingTransactionResponse = tu; exports.isScriptDataInput = Co; exports.isSecp256k1Signature = cu; exports.isStateCheckpointTransactionResponse = ou; exports.isString = Ut; exports.isUserTransactionResponse = nu; exports.isValidBIP44Path = mi; exports.isValidHardenedPath = yi; exports.isValidatorTransactionResponse = su; exports.mnemonicToSeed = wn; exports.normalizeBundle = Ki; exports.objectStructTag = Y; exports.optionStructTag = Cl; exports.outOfRangeErrorMessage = Gs; exports.paginateWithCursor = Pt; exports.parseTypeTag = Ce; exports.post = Zt; exports.postAptosFaucet = Di; exports.postAptosFullNode = rt; exports.postAptosIndexer = Ni; exports.postAptosPepperService = Bi; exports.postAptosProvingService = Oi; exports.promiseFulfilledStatus = Ks; exports.request = Fa; exports.splitPath = Ai; exports.standardizeTypeTags = Hr; exports.stringStructTag = v; exports.throwTypeMismatch = I; exports.validateNumberInRange = Ue;
|
|
428
|
+
`;async function Fn(n){let{aptosConfig:t}=n,{data:e}=await Z({aptosConfig:t,originMethod:"getLedgerInfo",path:""});return e}async function no(n){let{aptosConfig:t,ledgerVersion:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByVersion",path:`blocks/by_version/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _33 => _33.withTransactions])}});return i}async function ro(n){let{aptosConfig:t,blockHeight:e,options:r}=n,{data:i}=await Z({aptosConfig:t,originMethod:"getBlockByHeight",path:`blocks/by_height/${e}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _34 => _34.withTransactions])}});return i}async function Gn(n){let{aptosConfig:t,handle:e,data:r,options:i}=n;return(await rt({aptosConfig:t,originMethod:"getTableItem",path:`tables/${e}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _35 => _35.ledgerVersion])},body:r})).data}async function io(n){let{aptosConfig:t,limit:e}=n;return(await f({aptosConfig:t,query:{query:Wi,variables:{limit:e}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function f(n){let{aptosConfig:t,query:e,originMethod:r}=n,{data:i}=await Ni({aptosConfig:t,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:e,overrides:{WITH_CREDENTIALS:!1}});return i}async function $a(n){let{aptosConfig:t}=n;return(await f({aptosConfig:t,query:{query:Ir},originMethod:"getProcessorStatuses"})).processor_status}async function Mn(n){let t=await $a({aptosConfig:n.aptosConfig});return BigInt(t[0].last_success_version)}async function qn(n){let{aptosConfig:t,processorType:e}=n;return(await f({aptosConfig:t,query:{query:Ir,variables:{where_condition:{processor:{_eq:e}}}},originMethod:"getProcessorStatus"})).processor_status[0]}var Rr=new Map;function Et(n,t,e){return async(...r)=>{if(Rr.has(t)){let{value:o,timestamp:s}=Rr.get(t);if(e===void 0||Date.now()-s<=e)return o}let i=await n(...r);return Rr.set(t,{value:i,timestamp:Date.now()}),i}}async function we(n){let{aptosConfig:t,accountAddress:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getInfo",path:`accounts/${u.from(e).toString()}`});return r}async function ao(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Pt({aptosConfig:t,originMethod:"getModules",path:`accounts/${u.from(e).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _36 => _36.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _37 => _37.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _38 => _38.limit]), () => (1e3))}})}async function $n(n){return _optionalChain([n, 'access', _39 => _39.options, 'optionalAccess', _40 => _40.ledgerVersion])!==void 0?oo(n):Et(async()=>oo(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function oo(n){let{aptosConfig:t,accountAddress:e,moduleName:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getModule",path:`accounts/${u.from(e).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _41 => _41.ledgerVersion])}});return o}async function co(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Pt({aptosConfig:t,originMethod:"getTransactions",path:`accounts/${u.from(e).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _42 => _42.offset]),limit:_optionalChain([r, 'optionalAccess', _43 => _43.limit])}})}async function uo(n){let{aptosConfig:t,accountAddress:e,options:r}=n;return Pt({aptosConfig:t,originMethod:"getResources",path:`accounts/${u.from(e).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _44 => _44.ledgerVersion]),start:_optionalChain([r, 'optionalAccess', _45 => _45.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _46 => _46.limit]), () => (999))}})}async function zr(n){let{aptosConfig:t,accountAddress:e,resourceType:r,options:i}=n,{data:o}=await Z({aptosConfig:t,originMethod:"getResource",path:`accounts/${u.from(e).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _47 => _47.ledgerVersion])}});return o.data}async function Kr(n){let{aptosConfig:t,authenticationKey:e,options:r}=n,i=await zr({aptosConfig:t,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=u.from(e);try{let a=await Gn({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 oe&&a.data.error_code==="table_item_not_found")return s;throw a}}async function po(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:Li,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 lo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _48 => _48.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _49 => _49.tokenStandard])});let s={query:Hi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _50 => _50.offset]),limit:_optionalChain([r, 'optionalAccess', _51 => _51.limit]),order_by:_optionalChain([r, 'optionalAccess', _52 => _52.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function go(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', _53 => _53.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _54 => _54.tokenStandard])});let c={query:Vi,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _55 => _55.offset]),limit:_optionalChain([i, 'optionalAccess', _56 => _56.limit]),order_by:_optionalChain([i, 'optionalAccess', _57 => _57.orderBy])}};return(await f({aptosConfig:t,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function mo(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _58 => _58.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _59 => _59.tokenStandard])}});let s={query:qi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _60 => _60.offset]),limit:_optionalChain([r, 'optionalAccess', _61 => _61.limit]),order_by:_optionalChain([r, 'optionalAccess', _62 => _62.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function yo(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Qi,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function fo(n){let{aptosConfig:t,accountAddress:e,coinType:r}=n,i=u.from(e).toStringLong(),o=await kr({aptosConfig:t,accountAddress:i,options:{where:{asset_type:{_eq:r}}}});return o[0]?o[0].amount:0}async function kr(n){let{aptosConfig:t,accountAddress:e,options:r}=n,i=u.from(e).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _63 => _63.where]),owner_address:{_eq:i}},s={query:Mi,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _64 => _64.offset]),limit:_optionalChain([r, 'optionalAccess', _65 => _65.limit]),order_by:_optionalChain([r, 'optionalAccess', _66 => _66.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Ao(n){let{aptosConfig:t,accountAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Gi,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 ho(n){let{aptosConfig:t,accountAddress:e,options:r}=n,o={owner_address:{_eq:u.from(e).toStringLong()}},s={query:$i,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _67 => _67.offset]),limit:_optionalChain([r, 'optionalAccess', _68 => _68.limit]),order_by:_optionalChain([r, 'optionalAccess', _69 => _69.orderBy])}};return(await f({aptosConfig:t,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function To(n){let{aptosConfig:t,privateKey:e}=n,r=new k(e.publicKey());if(e instanceof Le){let o=F.fromPublicKey({publicKey:r}).derivedAddress();return ke.fromPrivateKey({privateKey:e,address:o})}if(e instanceof M){let i=F.fromPublicKey({publicKey:r});if(await so({authKey:i,aptosConfig:t})){let c=i.derivedAddress();return ke.fromPrivateKey({privateKey:e,address:c,legacy:!1})}let s=F.fromPublicKey({publicKey:r.publicKey});if(await so({authKey:s,aptosConfig:t})){let c=s.derivedAddress();return ke.fromPrivateKey({privateKey:e,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${e}`)}async function so(n){let{aptosConfig:t,authKey:e}=n,r=await Kr({aptosConfig:t,authenticationKey:e.derivedAddress()});try{return await we({aptosConfig:t,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}async function bo(n){let{aptosConfig:t,options:e}=n;return Pt({aptosConfig:t,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([e, 'optionalAccess', _70 => _70.offset]),limit:_optionalChain([e, 'optionalAccess', _71 => _71.limit])}})}async function Vn(n){let{aptosConfig:t}=n;return Et(async()=>{let{data:e}=await Z({aptosConfig:t,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return e},`gas-price-${t.network}`,1e3*60*5)()}async function wo(n){let{aptosConfig:t,ledgerVersion:e}=n,{data:r}=await Z({aptosConfig:t,originMethod:"getTransactionByVersion",path:`transactions/by_version/${e}`});return r}async function Jt(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/by_hash/${e}`,originMethod:"getTransactionByHash"});return r}async function So(n){let{aptosConfig:t,transactionHash:e}=n;try{return(await Jt({aptosConfig:t,transactionHash:e})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _72 => _72.status])===404)return!0;throw r}}async function Ha(n){let{aptosConfig:t,transactionHash:e}=n,{data:r}=await Z({aptosConfig:t,path:`transactions/wait_by_hash/${e}`,originMethod:"longWaitForTransaction"});return r}async function It(n){let{aptosConfig:t,transactionHash:e,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _73 => _73.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _74 => _74.checkSuccess]), () => (!0)),s=!0,a=0,c,p,m=200,x=1.5;function A(l){if(!(l instanceof oe)||(p=l,l.status!==404&&l.status>=400&&l.status<500))throw l}try{c=await Jt({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(l){A(l)}if(s){let l=Date.now();try{c=await Ha({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction"}catch(ae){A(ae)}a=(Date.now()-l)/1e3}for(;s&&!(a>=i);){try{if(c=await Jt({aptosConfig:t,transactionHash:e}),s=c.type==="pending_transaction",!s)break}catch(l){A(l)}await _chunkKSEUZTKYjs.b.call(void 0, m),a+=m/1e3,m*=x}if(c===void 0)throw p||new Hn(`Fetching transaction ${e} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Hn(`Transaction ${e} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Dr(`Transaction ${e} failed with an error: ${c.vm_status}`,c);return c}async function Ln(n){let{aptosConfig:t,processorType:e}=n,r=BigInt(n.minimumLedgerVersion),i=3e3,o=new Date().getTime(),s=BigInt(-1);for(;s<r;){if(new Date().getTime()-o>i)throw new Error("waitForLastSuccessIndexerVersionSync timeout");if(e===void 0?s=await Mn({aptosConfig:t}):s=(await qn({aptosConfig:t,processorType:e})).last_success_version,s>=r)break;await _chunkKSEUZTKYjs.b.call(void 0, 200)}}var Hn=class extends Error{constructor(e,r){super(e);this.lastSubmittedTransaction=r}},Dr=class extends Error{constructor(e,r){super(e);this.transaction=r}};async function b(n){n.minimumLedgerVersion!==void 0&&await Ln({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}var en=class{constructor(t){this.config=t}async getAccountInfo(t){return we({aptosConfig:this.config,...t})}async getAccountModules(t){return ao({aptosConfig:this.config,...t})}async getAccountModule(t){return $n({aptosConfig:this.config,...t})}async getAccountTransactions(t){return co({aptosConfig:this.config,...t})}async getAccountResources(t){return uo({aptosConfig:this.config,...t})}async getAccountResource(t){return zr({aptosConfig:this.config,...t})}async lookupOriginalAccountAddress(t){return Kr({aptosConfig:this.config,...t})}async getAccountTokensCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),po({aptosConfig:this.config,...t})}async getAccountOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),lo({aptosConfig:this.config,...t})}async getAccountOwnedTokensFromCollectionAddress(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),go({aptosConfig:this.config,...t})}async getAccountCollectionsWithOwnedTokens(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),mo({aptosConfig:this.config,...t})}async getAccountTransactionsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"account_transactions_processor"}),yo({aptosConfig:this.config,...t})}async getAccountCoinsData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),kr({aptosConfig:this.config,...t})}async getAccountCoinsCount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ao({aptosConfig:this.config,...t})}async getAccountAPTAmount(t){return this.getAccountCoinAmount({coinType:En,...t})}async getAccountCoinAmount(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"fungible_asset_processor"}),fo({aptosConfig:this.config,...t})}async getAccountOwnedObjects(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"default_processor"}),ho({aptosConfig:this.config,...t})}async deriveAccountFromPrivateKey(t){return To({aptosConfig:this.config,...t})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Qn=class{constructor(t){this.network=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _75 => _75.network]), () => ("devnet")),this.fullnode=_optionalChain([t, 'optionalAccess', _76 => _76.fullnode]),this.faucet=_optionalChain([t, 'optionalAccess', _77 => _77.faucet]),this.pepper=_optionalChain([t, 'optionalAccess', _78 => _78.pepper]),this.prover=_optionalChain([t, 'optionalAccess', _79 => _79.prover]),this.indexer=_optionalChain([t, 'optionalAccess', _80 => _80.indexer]),this.client=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _81 => _81.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _82 => _82.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _83 => _83.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _84 => _84.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _85 => _85.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 zi[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 Ki[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 Ri[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 Sr[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 xr[this.network];default:throw Error(`apiType ${t} is not supported`)}}isPepperServiceRequest(t){return Sr[this.network]===t}isProverServiceRequest(t){return xr[this.network]===t}};function xo(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function _o(n){return!!n.match(/\s/)}function La(n){return!!n.match(/^T[0-9]+$/)}function Qa(n,t){let e=t;for(;e<n.length;e+=1){let r=n[e];if(!_o(r))break}return e}var Wa=(A=>(A.InvalidTypeTag="unknown type",A.UnexpectedGenericType="unexpected generic type",A.UnexpectedTypeArgumentClose="unexpected '>'",A.UnexpectedWhitespaceCharacter="unexpected whitespace character",A.UnexpectedComma="unexpected ','",A.TypeArgumentCountMismatch="type argument count doesn't match expected amount",A.MissingTypeArgumentClose="no matching '>' for '<'",A.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",A.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",A.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",A.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",A.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",A))(Wa||{}),E= exports.TypeTagParserError =class extends Error{constructor(t,e){super(`Failed to parse typeTag '${t}', ${e}`)}};function Ce(n,t){let e=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _86 => _86.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 ae=Wn(a,i,e);o.push(ae)}let m=r.pop();if(m===void 0)throw new E(n,"unexpected '>'");if(c!==o.length)throw new E(n,"type argument count doesn't match expected amount");let{savedStr:x,savedTypes:A,savedExpectedTypes:l}=m;i=o,o=A,a=x,c=l}else if(p===","){if(a.length!==0){let m=Wn(a,i,e);i=[],o.push(m),a="",c+=1}}else if(_o(p)){let m=!1;if(a.length!==0){let A=Wn(a,i,e);i=[],o.push(A),a="",m=!0}s=Qa(n,s);let x=n[s];if(s<n.length&&m&&x!==","&&x!==">")throw new E(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new E(n,"no matching '>' for '<'");switch(o.length){case 0:return Wn(a,i,e);case 1:if(a==="")return o[0];throw new E(n,"unexpected ','");default:throw new E(n,"unexpected whitespace character")}}function Wn(n,t,e){switch(n){case"&signer":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new In(new Ye);case"signer":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Ye;case"bool":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new G;case"address":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new X;case"u8":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Te;case"u16":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new mt;case"u32":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new yt;case"u64":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new Q;case"u128":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new ft;case"u256":if(t.length>0)throw new E(n,"primitive types not expected to have type arguments");return new At;case"vector":if(t.length!==1)throw new E(n,"vector type expected to have exactly one type argument");return new C(t[0]);default:if(La(n)){if(e)return new K(Number(n.split("T")[1]));throw new E(n,"unexpected generic type")}if(!n.match(/:/))throw new E(n,"unknown type");let r=n.split("::");if(r.length!==3)throw new E(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");if(!xo(r[1]))throw new E(n,"module name must only contain alphanumeric or '_' characters");if(!xo(r[2]))throw new E(n,"struct name must only contain alphanumeric or '_' characters");return new y(new ve(u.fromString(r[0]),new U(r[1]),new U(r[2]),t))}}function vo(n){return typeof n=="boolean"}function Ut(n){return typeof n=="string"}function jn(n){return typeof n=="number"}function Xn(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Po(n){return n==null}function Co(n){return Nr(n)||Or(n)||Fr(n)||Gr(n)||Mr(n)||qr(n)||$r(n)||Yn(n)||Br(n)||ja(n)||n instanceof T||n instanceof Re}function Nr(n){return n instanceof R}function Yn(n){return n instanceof u}function Br(n){return n instanceof w}function ja(n){return n instanceof Me}function Or(n){return n instanceof O}function Fr(n){return n instanceof ce}function Gr(n){return n instanceof ue}function Mr(n){return n instanceof B}function qr(n){return n instanceof pe}function $r(n){return n instanceof de}function Eo(n){return"bytecode"in n}function I(n,t){throw new Error(`Type mismatch for argument ${t}, expected '${n}'`)}function Io(n){let t=n.params.findIndex(e=>e!=="signer"&&e!=="&signer");return t<0?n.params.length:t}function tn(n){let t=n.split("::");if(t.length!==3)throw new Error(`Invalid function ${n}`);let e=t[0],r=t[1],i=t[2];return{moduleAddress:e,moduleName:r,functionName:i}}var Xa=new TextEncoder;function Vr(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _87 => _87.map, 'call', _88 => _88(t=>Ut(t)?Ce(t):t)]), () => ([]))}async function Uo(n,t,e,r){let i=await $n({aptosConfig:r,accountAddress:n,moduleName:t});if(i.abi)return i.abi.exposed_functions.find(o=>o.name===e)}async function Ro(n,t,e,r){let i=await Uo(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=Io(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ce(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function zo(n,t,e,r){let i=await Uo(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(Ce(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ce(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Lr(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 Rt(e,o,r,i)}function Rt(n,t,e,r){return Co(n)?(Hr(t,n,e),n):Ya(n,t,e,r)}function Ya(n,t,e,r){if(t.isBool()){if(vo(n))return new R(n);I("boolean",e)}if(t.isAddress()){if(Ut(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isU8()){if(jn(n))return new O(n);I("number",e)}if(t.isU16()){if(jn(n))return new ce(n);I("number",e)}if(t.isU32()){if(jn(n))return new ue(n);I("number",e)}if(t.isU64()){if(Xn(n))return new B(BigInt(n));I("bigint | number | string",e)}if(t.isU128()){if(Xn(n))return new pe(BigInt(n));I("bigint | number | string",e)}if(t.isU256()){if(Xn(n))return new de(BigInt(n));I("bigint | number | string",e)}if(t.isGeneric()){let i=t.value;if(i<0||i>=r.length)throw new Error(`Generic argument ${t.toString()} is invalid for argument ${e}`);return Rt(n,r[i],e,r)}if(t.isVector()){if(t.value.isU8()){if(Ut(n))return T.U8(Xa.encode(n));if(n instanceof Uint8Array)return T.U8(n);if(n instanceof ArrayBuffer)return T.U8(new Uint8Array(n))}if(Array.isArray(n))return new T(n.map(i=>Rt(i,t.value,e,r)));throw new Error(`Type mismatch for argument ${e}, type '${t.toString()}'`)}if(t.isStruct()){if(t.isString()){if(Ut(n))return new w(n);I("string",e)}if(t.isObject()){if(Ut(n))return u.fromString(n);I("string | AccountAddress",e)}if(t.isOption())return Po(n)?new Re(null):new Re(Rt(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 Hr(n,t,e){if(n.isBool()){if(Nr(t))return;I("Bool",e)}if(n.isAddress()){if(Yn(t))return;I("AccountAddress",e)}if(n.isU8()){if(Or(t))return;I("U8",e)}if(n.isU16()){if(Fr(t))return;I("U16",e)}if(n.isU32()){if(Gr(t))return;I("U32",e)}if(n.isU64()){if(Mr(t))return;I("U64",e)}if(n.isU128()){if(qr(t))return;I("U128",e)}if(n.isU256()){if($r(t))return;I("U256",e)}if(n.isVector()){if(t instanceof T){t.values.length>0&&Hr(n.value,t.values[0],e);return}I("MoveVector",e)}if(n instanceof y){if(n.isString()){if(Br(t))return;I("MoveString",e)}if(n.isObject()){if(Yn(t))return;I("AccountAddress",e)}if(n.isOption()){if(t instanceof Re){t.value!==void 0&&Hr(n.value.typeArgs[0],t.value,e);return}I("MoveOption",e)}}throw new Error(`Type mismatch for argument ${e}, expected '${n.toString()}'`)}async function Jn(n){if(Eo(n))return tc(n);let{moduleAddress:t,moduleName:e,functionName:r}=tn(n.function),i=await No({key:"entry-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Ro});return Ja({...n,abi:i})}function Ja(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=tn(n.function),o=Vr(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)=>Lr(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=Je.build(`${e}::${r}`,i,o,s);if("multisigAddress"in n){let c=u.from(n.multisigAddress);return new Lt(new Wt(c,new jt(a)))}return new Vt(a)}async function Ko(n){let{moduleAddress:t,moduleName:e,functionName:r}=tn(n.function),i=await No({key:"view-function",moduleAddress:t,moduleName:e,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:zo});return ec({abi:i,...n})}function ec(n){let t=n.abi,{moduleAddress:e,moduleName:r,functionName:i}=tn(n.function),o=Vr(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', _89 => _89.functionArguments, 'optionalAccess', _90 => _90.map, 'call', _91 => _91((a,c)=>Lr(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 Je.build(`${e}::${r}`,i,o,s)}function tc(n){return new Ht(new Qt(g.fromHexInput(n.bytecode).toUint8Array(),_nullishCoalesce(n.typeArguments, () => ([])),n.functionArguments))}async function nc(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=async()=>vr[t.network]?{chainId:vr[t.network]}:{chainId:(await Fn({aptosConfig:t})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _92 => _92.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Vn({aptosConfig:t})).gas_estimate},c=async()=>{let it=async()=>_optionalChain([i, 'optionalAccess', _93 => _93.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await we({aptosConfig:t,accountAddress:e})).sequence_number;if(o&&u.from(o).equals(u.ZERO))try{return await it()}catch (e3){return 0}else return it()},[{chainId:p},{gasEstimate:m},x]=await Promise.all([s(),a(),c()]),{maxGasAmount:A,gasUnitPrice:l,expireTimestamp:ae}={maxGasAmount:_optionalChain([i, 'optionalAccess', _94 => _94.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _95 => _95.gasUnitPrice]), () => (BigInt(m))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _96 => _96.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new ie(u.from(e),BigInt(x),r,BigInt(A),BigInt(l),BigInt(ae),new gt(p))}async function Qr(n){let{aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o}=n,s=await nc({aptosConfig:t,sender:e,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _97 => _97.secondarySignerAddresses, 'optionalAccess', _98 => _98.map, 'call', _99 => _99(c=>u.from(c))]), () => ([]));return new Kn(s,a,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}return new zn(s,n.feePayerAddress?u.from(n.feePayerAddress):void 0)}function ko(n){let{signerPublicKey:t,transaction:e,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=Zn(t);if(e.feePayerAddress){let a=new tt(e.rawTransaction,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),e.feePayerAddress),c=[];r&&(c=r.map(x=>Zn(x)));let p=Zn(i),m=new bt(o,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),c,{address:e.feePayerAddress,authenticator:p});return new nt(a.raw_txn,m).bcsToBytes()}if(e.secondarySignerAddresses){let a=new et(e.rawTransaction,e.secondarySignerAddresses),c=[];c=r.map(m=>Zn(m));let p=new Tt(o,e.secondarySignerAddresses,c);return new nt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof me)s=new ht(o.public_key,o.signature);else if(o instanceof $)s=new wt(o);else throw new Error("Invalid public key");return new nt(e.rawTransaction,s).bcsToBytes()}function Zn(n){let t=n;if((t instanceof ge||t instanceof he)&&(t=new k(t)),t instanceof k){if(t.publicKey instanceof P)return new $(t,new N(new _(new Uint8Array(64))));if(t.publicKey instanceof he)return new $(t,new N(new xe(new Uint8Array(64))));if(t.publicKey instanceof ge)return new $(t,new N(new _(new Uint8Array(64))))}return new me(new P(t.toUint8Array()),new _(new Uint8Array(64)))}function Wr(n){let{transaction:t,feePayerAuthenticator:e,additionalSignersAuthenticators:r}=n,i=ki(q,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 bt(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 Tt(i,t.secondarySignerAddresses,r)}else i instanceof me?o=new ht(i.public_key,i.signature):o=new wt(i);return new nt(t.rawTransaction,o).bcsToBytes()}function Do(n){let t=_sha3.sha3_256.create();for(let e of n)t.update(e);return t.digest()}var rc=Do(["APTOS::Transaction"]);function pA(n){let t=Wr(n);return new g(Do([rc,new Uint8Array([0]),t])).toString()}async function No({key:n,moduleAddress:t,moduleName:e,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:Et(async()=>s(t,e,r,i),`${n}-${i.network}-${t}-${e}-${r}`,1e3*60*5)()}async function h(n){let t=await ic(n);return oc(n,t)}async function ic(n){let{aptosConfig:t,data:e}=n,r,i;return"bytecode"in e?i=await Jn(e):"multisigAddress"in e?(r={aptosConfig:t,multisigAddress:e.multisigAddress,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await Jn(r)):(r={aptosConfig:t,function:e.function,functionArguments:e.functionArguments,typeArguments:e.typeArguments,abi:e.abi},i=await Jn(r)),i}async function oc(n,t){let{aptosConfig:e,sender:r,options:i}=n,o;if(sc(n)&&(o=u.ZERO.toString()),ac(n)){let{secondarySignerAddresses:s}=n;return Qr({aptosConfig:e,sender:r,payload:t,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Qr({aptosConfig:e,sender:r,payload:t,options:i,feePayerAddress:o})}function sc(n){return n.withFeePayer===!0}function ac(n){return"secondarySignerAddresses"in n}function Bo(n){let{transaction:t}=n;return St(t)}function er(n){let{signer:t,transaction:e}=n;return t.signTransactionWithAuthenticator(e)}async function jr(n){let{aptosConfig:t,transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=ko({transaction:e,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await rt({aptosConfig:t,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _100 => _100.options, 'optionalAccess', _101 => _101.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _102 => _102.options, 'optionalAccess', _103 => _103.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _104 => _104.options, 'optionalAccess', _105 => _105.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function tr(n){let{aptosConfig:t}=n,e=Wr({...n}),{data:r}=await rt({aptosConfig:t,body:e,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}async function nn(n){let{aptosConfig:t,signer:e,transaction:r}=n;(e instanceof be||e instanceof Nn)&&await e.waitForProofFetch();let i=er({signer:e,transaction:r});return tr({aptosConfig:t,transaction:r,senderAuthenticator:i})}var cc={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Oo(n){let{aptosConfig:t,account:e,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>T.U8(a));return h({aptosConfig:t,sender:u.from(e),data:{function:"0x1::code::publish_package_txn",functionArguments:[T.U8(r),new T(s)],abi:cc},options:o})}var uc={typeParameters:[],parameters:[new Te,C.u8(),new Te,C.u8(),C.u8(),C.u8()]};async function Fo(n){let{aptosConfig:t,fromAccount:e,toNewPrivateKey:r}=n,i=await we({aptosConfig:t,accountAddress:e.accountAddress}),o=ke.fromPrivateKey({privateKey:r,legacy:!0}),a=new Rn({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),m=await h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new O(e.signingScheme),T.U8(e.publicKey.toUint8Array()),new O(o.signingScheme),T.U8(o.publicKey.toUint8Array()),T.U8(c.toUint8Array()),T.U8(p.toUint8Array())],abi:uc}});return nn({aptosConfig:t,signer:e,transaction:m})}var pc={typeParameters:[{constraints:[]}],parameters:[new X,new Q]};async function Go(n){let{aptosConfig:t,sender:e,recipient:r,amount:i,coinType:o,options:s}=n;return h({aptosConfig:t,sender:e,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (En))],functionArguments:[r,i],abi:pc},options:s})}var rn=class{constructor(t){this.config=t}async transferCoinTransaction(t){return Go({aptosConfig:this.config,...t})}};var Ne={BOOLEAN:"bool",U8:"u8",U16:"u16",U32:"u32",U64:"u64",U128:"u128",U256:"u256",ADDRESS:"address",STRING:"0x1::string::String",ARRAY:"vector<u8>"},se="0x4::token::Token";async function Mo(n){let{aptosConfig:t,digitalAssetAddress:e}=n,r={token_data_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:to,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function qo(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:Ur,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function $o(n){let{aptosConfig:t,ownerAddress:e,options:r}=n,i={owner_address:{_eq:u.from(e).toStringLong()},amount:{_gt:0}},o={query:Ur,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _106 => _106.offset]),limit:_optionalChain([r, 'optionalAccess', _107 => _107.limit]),order_by:_optionalChain([r, 'optionalAccess', _108 => _108.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function Ho(n){let{aptosConfig:t,digitalAssetAddress:e,options:r}=n,i={token_data_id:{_eq:u.from(e).toStringLong()}},o={query:eo,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _109 => _109.offset]),limit:_optionalChain([r, 'optionalAccess', _110 => _110.limit]),order_by:_optionalChain([r, 'optionalAccess', _111 => _111.orderBy])}};return(await f({aptosConfig:t,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var dc={typeParameters:[],parameters:[new y(v()),new Q,new y(v()),new y(v()),new G,new G,new G,new G,new G,new G,new G,new G,new G,new Q,new Q]};async function Vo(n){let{aptosConfig:t,options:e,creator:r}=n;return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new w(n.description),new B(_nullishCoalesce(n.maxSupply, () => (Fe))),new w(n.name),new w(n.uri),new R(_nullishCoalesce(n.mutableDescription, () => (!0))),new R(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new R(_nullishCoalesce(n.mutableURI, () => (!0))),new R(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new R(_nullishCoalesce(n.mutableTokenName, () => (!0))),new R(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new R(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new R(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new R(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new B(_nullishCoalesce(n.royaltyNumerator, () => (0))),new B(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:dc},options:e})}async function Xr(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', _112 => _112.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _113 => _113.tokenStandard]), () => ("v2"))}),(await f({aptosConfig:t,query:{query:Cr,variables:{where_condition:s}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Lo(n){let{aptosConfig:t,collectionId:e}=n,i={collection_id:{_eq:u.from(e).toStringLong()}};return(await f({aptosConfig:t,query:{query:Cr,variables:{where_condition:i}},originMethod:"getCollectionData"})).current_collections_v2[0]}async function Qo(n){return(await Xr(n)).collection_id}var lc={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new C(new y(v())),new C(new y(v())),new C(C.u8())]};async function Wo(n){let{aptosConfig:t,options:e,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:m}=n,x=_optionalChain([p, 'optionalAccess', _114 => _114.map, 'call', _115 => _115(A=>Ne[A])]);return h({aptosConfig:t,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new w(i),new w(o),new w(s),new w(a),T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(x, () => ([]))),cs(_nullishCoalesce(m, () => ([])),_nullishCoalesce(x, () => ([])))],abi:lc},options:e})}var gc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new X]};async function jo(n){let{aptosConfig:t,sender:e,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(r),u.from(i)],abi:gc},options:s})}var mc={typeParameters:[],parameters:[new y(v()),new y(v()),new y(v()),new y(v()),new C(new y(v())),new C(new y(v())),new C(C.u8()),new X]};async function Xo(n){let{aptosConfig:t,account:e,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:m,options:x}=n;if(_optionalChain([c, 'optionalAccess', _116 => _116.length])!==_optionalChain([m, 'optionalAccess', _117 => _117.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _118 => _118.length])!==_optionalChain([m, 'optionalAccess', _119 => _119.length]))throw new Error("Property types and property values counts do not match");let A=_optionalChain([p, 'optionalAccess', _120 => _120.map, 'call', _121 => _121(l=>Ne[l])]);return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,T.MoveString(_nullishCoalesce(c, () => ([]))),T.MoveString(_nullishCoalesce(A, () => ([]))),cs(_nullishCoalesce(m, () => ([])),_nullishCoalesce(A, () => ([]))),a],abi:mc},options:x})}var yc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0)))]};async function Yo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (se))],functionArguments:[u.from(r)],abi:yc},options:o})}var fc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0)))]};async function Zo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (se))],functionArguments:[r],abi:fc},options:o})}var Ac={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0)))]};async function Jo(n){let{aptosConfig:t,creator:e,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (se))],functionArguments:[r],abi:Ac},options:o})}var hc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function es(n){let{aptosConfig:t,creator:e,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:hc},options:s})}var Tc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function ts(n){let{aptosConfig:t,creator:e,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:Tc},options:s})}var bc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function ns(n){let{aptosConfig:t,creator:e,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:bc},options:s})}var wc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v()),new y(v()),C.u8()]};async function rs(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (se))],functionArguments:[u.from(s),new w(r),new w(Ne[i]),T.U8(Yr(o,Ne[i]))],abi:wc},options:c})}var Sc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v())]};async function is(n){let{aptosConfig:t,creator:e,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (se))],functionArguments:[u.from(i),new w(r)],abi:Sc},options:s})}var xc={typeParameters:[{constraints:["key"]}],parameters:[new y(Y(new K(0))),new y(v()),new y(v()),C.u8()]};async function os(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (se))],functionArguments:[u.from(s),new w(r),new w(Ne[i]),Yr(o,Ne[i])],abi:xc},options:c})}var _c={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(Y(new K(0))),new y(v()),new K(1)]};async function ss(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (se)),Ne[i]],functionArguments:[u.from(s),new w(r),o],abi:_c},options:c})}var vc={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new y(Y(new K(0))),new y(v()),new K(1)]};async function as(n){let{aptosConfig:t,creator:e,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (se)),Ne[i]],functionArguments:[u.from(s),new w(r),o],abi:vc},options:c})}function cs(n,t){let e=new Array;return t.forEach((r,i)=>{e.push(Yr(n[i],r))}),e}function Yr(n,t){let e=Ce(t);return Rt(n,e,0,[]).bcsToBytes()}var on=class{constructor(t){this.config=t}async getCollectionData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Xr({aptosConfig:this.config,...t})}async getCollectionDataByCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Lo({aptosConfig:this.config,...t})}async getCollectionId(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Qo({aptosConfig:this.config,...t})}async getDigitalAssetData(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Mo({aptosConfig:this.config,...t})}async getCurrentDigitalAssetOwnership(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),qo({aptosConfig:this.config,...t})}async getOwnedDigitalAssets(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),$o({aptosConfig:this.config,...t})}async getDigitalAssetActivity(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"token_v2_processor"}),Ho({aptosConfig:this.config,...t})}async createCollectionTransaction(t){return Vo({aptosConfig:this.config,...t})}async mintDigitalAssetTransaction(t){return Wo({aptosConfig:this.config,...t})}async transferDigitalAssetTransaction(t){return jo({aptosConfig:this.config,...t})}async mintSoulBoundTransaction(t){return Xo({aptosConfig:this.config,...t})}async burnDigitalAssetTransaction(t){return Yo({aptosConfig:this.config,...t})}async freezeDigitalAssetTransaferTransaction(t){return Zo({aptosConfig:this.config,...t})}async unfreezeDigitalAssetTransaferTransaction(t){return Jo({aptosConfig:this.config,...t})}async setDigitalAssetDescriptionTransaction(t){return es({aptosConfig:this.config,...t})}async setDigitalAssetNameTransaction(t){return ts({aptosConfig:this.config,...t})}async setDigitalAssetURITransaction(t){return ns({aptosConfig:this.config,...t})}async addDigitalAssetPropertyTransaction(t){return rs({aptosConfig:this.config,...t})}async removeDigitalAssetPropertyTransaction(t){return is({aptosConfig:this.config,...t})}async updateDigitalAssetPropertyTransaction(t){return os({aptosConfig:this.config,...t})}async addDigitalAssetTypedPropertyTransaction(t){return ss({aptosConfig:this.config,...t})}async updateDigitalAssetTypedPropertyTransaction(t){return as({aptosConfig:this.config,...t})}};var us=300,Pc=n=>{if(n&&n.length>us)throw new Error(`Event type length exceeds the maximum length of ${us}`)};async function ps(n){let{aptosConfig:t,eventType:e,options:r}=n,o={where:{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},creation_number:{_eq:"0"},sequence_number:{_eq:"0"},indexed_type:{_eq:e}},pagination:r,orderBy:_optionalChain([r, 'optionalAccess', _122 => _122.orderBy])};return sn({aptosConfig:t,options:o})}async function ds(n){let{accountAddress:t,aptosConfig:e,creationNumber:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},creation_number:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _123 => _123.orderBy])};return sn({aptosConfig:e,options:a})}async function ls(n){let{accountAddress:t,aptosConfig:e,eventType:r,options:i}=n,a={where:{account_address:{_eq:u.from(t).toStringLong()},indexed_type:{_eq:r}},pagination:i,orderBy:_optionalChain([i, 'optionalAccess', _124 => _124.orderBy])};return sn({aptosConfig:e,options:a})}async function sn(n){let{aptosConfig:t,options:e}=n;Pc(_optionalChain([e, 'optionalAccess', _125 => _125.where, 'optionalAccess', _126 => _126.indexed_type, 'optionalAccess', _127 => _127._eq]));let r={query:Yi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _128 => _128.where]),offset:_optionalChain([e, 'optionalAccess', _129 => _129.offset]),limit:_optionalChain([e, 'optionalAccess', _130 => _130.limit]),order_by:_optionalChain([e, 'optionalAccess', _131 => _131.orderBy])}};return(await f({aptosConfig:t,query:r,originMethod:"getEvents"})).events}var an=class{constructor(t){this.config=t}async getModuleEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ps({aptosConfig:this.config,...t})}async getAccountEventsByCreationNumber(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ds({aptosConfig:this.config,...t})}async getAccountEventsByEventType(t){return await b({config:this.config,minimumLedgerVersion:t.minimumLedgerVersion,processorType:"events_processor"}),ls({aptosConfig:this.config,...t})}async getEvents(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _132 => _132.minimumLedgerVersion]),processorType:"events_processor"}),sn({aptosConfig:this.config,...t})}};async function gs(n){let{aptosConfig:t,accountAddress:e,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _133 => _133.timeoutSecs])||20,{data:s}=await Bi({aptosConfig:t,path:"fund",body:{address:u.from(e).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await It({aptosConfig:t,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _134 => _134.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var cn=class{constructor(t){this.config=t}async fundAccount(t){let e=await gs({aptosConfig:this.config,...t});return _optionalChain([t, 'access', _135 => _135.options, 'optionalAccess', _136 => _136.waitForIndexer])!==!1&&await Ln({aptosConfig:this.config,minimumLedgerVersion:BigInt(e.version)}),e}};async function Zr(n){let{aptosConfig:t,options:e}=n,r={query:Ji,variables:{where_condition:_optionalChain([e, 'optionalAccess', _137 => _137.where]),limit:_optionalChain([e, 'optionalAccess', _138 => _138.limit]),offset:_optionalChain([e, 'optionalAccess', _139 => _139.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function ms(n){let{aptosConfig:t,options:e}=n,r={query:Zi,variables:{where_condition:_optionalChain([e, 'optionalAccess', _140 => _140.where]),limit:_optionalChain([e, 'optionalAccess', _141 => _141.limit]),offset:_optionalChain([e, 'optionalAccess', _142 => _142.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function ys(n){let{aptosConfig:t,options:e}=n,r={query:ji,variables:{where_condition:_optionalChain([e, 'optionalAccess', _143 => _143.where]),limit:_optionalChain([e, 'optionalAccess', _144 => _144.limit]),offset:_optionalChain([e, 'optionalAccess', _145 => _145.offset])}};return(await f({aptosConfig:t,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var Cc={typeParameters:[{constraints:[]}],parameters:[Ce("0x1::object::Object"),new X,new Q]};async function fs(n){let{aptosConfig:t,sender:e,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return h({aptosConfig:t,sender:e.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:Cc},options:s})}var un=class{constructor(t){this.config=t}async getFungibleAssetMetadata(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _146 => _146.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Zr({aptosConfig:this.config,...t})}async getFungibleAssetMetadataByAssetType(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _147 => _147.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Zr({aptosConfig:this.config,options:{where:{asset_type:{_eq:t.assetType}}}}))[0]}async getFungibleAssetActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _148 => _148.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ms({aptosConfig:this.config,...t})}async getCurrentFungibleAssetBalances(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _149 => _149.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),ys({aptosConfig:this.config,...t})}async transferFungibleAsset(t){return fs({aptosConfig:this.config,...t})}};async function Be(n){let{aptosConfig:t,payload:e,options:r}=n,i=await Ko({...e,aptosConfig:t}),o=new L;i.serialize(o);let s=o.toUint8Array(),{data:a}=await rt({aptosConfig:t,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _150 => _150.ledgerVersion])},body:s});return a}var pn=class{constructor(t){this.config=t}async getLedgerInfo(){return Fn({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(t){return no({aptosConfig:this.config,...t})}async getBlockByHeight(t){return ro({aptosConfig:this.config,...t})}async getTableItem(t){return Gn({aptosConfig:this.config,...t})}async view(t){return Be({aptosConfig:this.config,...t})}async getChainTopUserTransactions(t){return io({aptosConfig:this.config,...t})}async queryIndexer(t){return f({aptosConfig:this.config,...t})}async getIndexerLastSuccessVersion(){return Mn({aptosConfig:this.config})}async getProcessorStatus(t){return qn({aptosConfig:this.config,processorType:t})}};var As=["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 hs(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function Oe(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(!hs(t))throw new Error(`${t} is not valid. ${As}`);if(e&&!hs(e))throw new Error(`${e} is not valid. ${As}`);return{domainName:e||t,subdomainName:e?t:void 0}}var Ec="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",Ic={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:Ec,custom:null,devnet:null};function Ee(n){let t=Ic[n.network];if(!t)throw new Error(`The ANS contract is not deployed to ${n.network}`);return t}var nr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ts(n){let{aptosConfig:t,name:e}=n,r=Ee(t),{domainName:i,subdomainName:o}=Oe(e),s=await Be({aptosConfig:t,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=nr(s[0]);return a?u.from(a):void 0}async function bs(n){let{aptosConfig:t,expiration:e,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=Ee(t),{domainName:m,subdomainName:x}=Oe(r),A=e.policy==="subdomain:independent"||e.policy==="subdomain:follow-domain";if(x&&!A)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(A&&!x)throw new Error(`Policy is set to ${e.policy} but no subdomain was provided`);if(e.policy==="domain"){let cr=_nullishCoalesce(e.years, () => (1));if(cr!==1)throw new Error("For now, names can only be registered for 1 year at a time");let Bs=cr*31536e3;return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[m,Bs,o,s]},options:a})}if(!x)throw new Error(`${e.policy} requires a subdomain to be provided.`);let l=await Jr({aptosConfig:t,name:m});if(!l)throw new Error("The domain does not exist");let ae=e.policy==="subdomain:independent"?e.expirationDate:l;if(ae>l)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await h({aptosConfig:t,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[m,x,Math.round(ae/1e3),e.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function Jr(n){let{aptosConfig:t,name:e}=n,r=Ee(t),{domainName:i,subdomainName:o}=Oe(e);try{let s=await Be({aptosConfig:t,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e4){return}}async function ws(n){let{aptosConfig:t,address:e}=n,r=Ee(t),i=await Be({aptosConfig:t,payload:{function:`${r}::router::get_primary_name`,functionArguments:[u.from(e).toString()]}}),o=nr(i[1]),s=nr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Ss(n){let{aptosConfig:t,sender:e,name:r,options:i}=n,o=Ee(t);if(!r)return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=Oe(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function xs(n){let{aptosConfig:t,name:e}=n,r=Ee(t),{domainName:i,subdomainName:o}=Oe(e),s=await Be({aptosConfig:t,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=nr(s[0]);return a?u.from(a):void 0}async function _s(n){let{aptosConfig:t,sender:e,name:r,address:i,options:o}=n,s=Ee(t),{domainName:a,subdomainName:c}=Oe(r);return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function vs(n){let{aptosConfig:t,name:e}=n,{domainName:r,subdomainName:i=""}=Oe(e),a=(await f({aptosConfig:t,query:{query:Ct,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i},is_active:{_eq:!0}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=dn(a)),a}async function Ps(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await ei({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountNames",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _151 => _151.limit]),offset:_optionalChain([e, 'optionalAccess', _152 => _152.offset]),order_by:_optionalChain([e, 'optionalAccess', _153 => _153.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _154 => _154.options, 'optionalAccess', _155 => _155.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(dn)}async function Cs(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await ei({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountDomains",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _156 => _156.limit]),offset:_optionalChain([e, 'optionalAccess', _157 => _157.offset]),order_by:_optionalChain([e, 'optionalAccess', _158 => _158.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _159 => _159.options, 'optionalAccess', _160 => _160.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(dn)}async function Es(n){let{aptosConfig:t,options:e,accountAddress:r}=n,i=await ei({aptosConfig:t});return(await f({aptosConfig:t,originMethod:"getAccountSubdomains",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _161 => _161.limit]),offset:_optionalChain([e, 'optionalAccess', _162 => _162.offset]),order_by:_optionalChain([e, 'optionalAccess', _163 => _163.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _164 => _164.options, 'optionalAccess', _165 => _165.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(dn)}async function Is(n){let{aptosConfig:t,options:e,domain:r}=n;return(await f({aptosConfig:t,originMethod:"getDomainSubdomains",query:{query:Ct,variables:{limit:_optionalChain([e, 'optionalAccess', _166 => _166.limit]),offset:_optionalChain([e, 'optionalAccess', _167 => _167.offset]),order_by:_optionalChain([e, 'optionalAccess', _168 => _168.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _169 => _169.options, 'optionalAccess', _170 => _170.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""},is_active:{_eq:!0}}}}})).current_aptos_names.map(dn)}async function ei(n){let{aptosConfig:t}=n,e=Ee(t),[r]=await Be({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 Us(n){let{aptosConfig:t,sender:e,name:r,years:i=1,options:o}=n,s=Ee(t),a=i*31536e3,{domainName:c,subdomainName:p}=Oe(r);if(p)throw new Error("Subdomains cannot be renewed");if(i!==1)throw new Error("Currently, only 1 year renewals are supported");return await h({aptosConfig:t,sender:e.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function dn(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var ln=class{constructor(t){this.config=t}async getOwnerAddress(t){return Ts({aptosConfig:this.config,...t})}async getExpiration(t){return Jr({aptosConfig:this.config,...t})}async getTargetAddress(t){return xs({aptosConfig:this.config,...t})}async setTargetAddress(t){return _s({aptosConfig:this.config,...t})}async getPrimaryName(t){return ws({aptosConfig:this.config,...t})}async setPrimaryName(t){return Ss({aptosConfig:this.config,...t})}async registerName(t){return bs({aptosConfig:this.config,...t})}async renewDomain(t){return Us({aptosConfig:this.config,...t})}async getName(t){return vs({aptosConfig:this.config,...t})}async getAccountNames(t){return Ps({aptosConfig:this.config,...t})}async getAccountDomains(t){return Cs({aptosConfig:this.config,...t})}async getAccountSubdomains(t){return Es({aptosConfig:this.config,...t})}async getDomainSubdomains(t){return Is({aptosConfig:this.config,...t})}};async function Rs(n){let{aptosConfig:t,poolAddress:e}=n,r=u.from(e).toStringLong(),o=await f({aptosConfig:t,query:{query:Er,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 zs(n){let{aptosConfig:t,options:e}=n,r={query:Er,variables:{order_by:_optionalChain([e, 'optionalAccess', _171 => _171.orderBy])}};return(await f({aptosConfig:t,query:r})).num_active_delegator_per_pool}async function Ks(n){let{aptosConfig:t,delegatorAddress:e,poolAddress:r}=n,i={query:Xi,variables:{delegatorAddress:u.from(e).toStringLong(),poolAddress:u.from(r).toStringLong()}};return(await f({aptosConfig:t,query:i})).delegated_staking_activities}var gn=class{constructor(t){this.config=t}async getNumberOfDelegators(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _172 => _172.minimumLedgerVersion]),processorType:"stake_processor"}),Rs({aptosConfig:this.config,...t})}async getNumberOfDelegatorsForAllPools(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _173 => _173.minimumLedgerVersion]),processorType:"stake_processor"}),zs({aptosConfig:this.config,...t})}async getDelegatedStakingActivities(t){return await b({config:this.config,minimumLedgerVersion:_optionalChain([t, 'optionalAccess', _174 => _174.minimumLedgerVersion]),processorType:"stake_processor"}),Ks({aptosConfig:this.config,...t})}};var rr=class{constructor(t){this.config=t}async simple(t){return h({aptosConfig:this.config,...t})}async multiAgent(t){return h({aptosConfig:this.config,...t})}};function ti(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 ni(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 zt=class{constructor(t){this.config=t}async simple(t){return jr({aptosConfig:this.config,...t})}async multiAgent(t){return jr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [ni],zt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [ni],zt.prototype,"multiAgent",1);var Kt=class{constructor(t){this.config=t}async simple(t){return tr({aptosConfig:this.config,...t})}async multiAgent(t){return tr({aptosConfig:this.config,...t})}};_chunkKSEUZTKYjs.a.call(void 0, [ti],Kt.prototype,"simple",1),_chunkKSEUZTKYjs.a.call(void 0, [ti],Kt.prototype,"multiAgent",1);var ir=()=>Math.floor(Date.now()/1e3),or= exports.AccountSequenceNumber =class{constructor(t,e,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=t,this.account=e,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;let t=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let e=ir();for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),ir()-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}t=this.currentNumber,this.currentNumber+=BigInt(1)}catch(e){console.error("error in getting next sequence number for this account",e)}finally{this.lock=!1}return t}async initialize(){let{sequence_number:t}=await we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(t),this.lastUncommintedNumber=BigInt(t)}async update(){let{sequence_number:t}=await we({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(t),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let t=ir();for(;this.lastUncommintedNumber!==this.currentNumber;)ir()-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, resyncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunkKSEUZTKYjs.b.call(void 0, this.sleepTime),await this.update())}catch(t){console.error("error in synchronizing this account sequence number with the one on chain",t)}finally{this.lock=!1}}}};var kt=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(t){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _175 => _175.pendingDequeue, 'access', _176 => _176.shift, 'call', _177 => _177(), 'optionalAccess', _178 => _178.resolve, 'call', _179 => _179(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 Dt("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},Dt=class extends Error{};var ks="fulfilled",Ds= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Ds||{}),sr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(e,r,i=30,o=100,s=10){super();this.taskQueue=new kt;this.transactionsQueue=new kt;this.outstandingTransactions=new kt;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=e,this.account=r,this.started=!1,this.accountSequnceNumber=new or(e,r,i,o,s)}async submitNextTransaction(){try{for(;;){let e=await this.accountSequnceNumber.nextSequenceNumber();if(e===null)return;let r=await this.generateNextTransaction(this.account,e);if(!r)return;let i=nn({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,e])}}catch(e){if(e instanceof Dt)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===ks?(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 Dt)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${e}`)}}async checkTransaction(e,r){try{let i=[];i.push(It({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===ks?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:e.value.hash})):(this.executedTransactions.push([a.status,r,a.reason]),this.emit("transactionExecutionFailed",{message:`failed to execute transaction ${this.executedTransactions.length} with error ${a.reason}`,error:a.reason}))}}catch(i){throw new Error(`Check transaction failed for ${this.account.accountAddress.toString()} with error ${i}`)}}async push(e,r){this.transactionsQueue.enqueue([e,r])}async generateNextTransaction(e,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return h({aptosConfig:this.aptosConfig,sender:e.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(e){throw new Error(`Unable to start transaction batching: ${e}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var ar=class extends _eventemitter32.default{constructor(e){super();this.config=e}start(e){let{sender:r}=e;this.account=r,this.transactionWorker=new sr(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 mn=class{constructor(t){this.config=t,this.build=new rr(this.config),this.simulate=new zt(this.config),this.submit=new Kt(this.config),this.batch=new ar(this.config)}async getTransactions(t){return bo({aptosConfig:this.config,...t})}async getTransactionByVersion(t){return wo({aptosConfig:this.config,...t})}async getTransactionByHash(t){return Jt({aptosConfig:this.config,...t})}async isPendingTransaction(t){return So({aptosConfig:this.config,...t})}async waitForTransaction(t){return It({aptosConfig:this.config,...t})}async getGasPriceEstimation(){return Vn({aptosConfig:this.config})}getSigningMessage(t){return Bo(t)}async publishPackageTransaction(t){return Oo({aptosConfig:this.config,...t})}async rotateAuthKey(t){return Fo({aptosConfig:this.config,...t})}sign(t){return er({...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,er({signer:e,transaction:r})}async batchTransactionsForSingleAccount(t){try{let{sender:e,data:r,options:i}=t;this.batch.forSingleAccount({sender:e,data:r,options:i})}catch(e){throw new Error(`failed to submit transactions with error: ${e}`)}}async signAndSubmitTransaction(t){let{signer:e,transaction:r}=t;return nn({aptosConfig:this.config,signer:e,transaction:r})}};async function ri(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,uidKey:i,derivationPath:o}=n,s={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Oi({aptosConfig:t,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return g.fromHexInput(a.pepper).toUint8Array()}async function Kc(n){let{aptosConfig:t,jwt:e,ephemeralKeyPair:r,pepper:i,uidKey:o,extraFieldKey:s}=n,a={jwt_b64:e,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:g.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:Number(r.expiryDateSecs),exp_horizon_secs:Mt,pepper:g.fromHexInput(i).toStringWithoutPrefix(),extra_field:s,uid_key:o||"sub"},{data:c}=await Fi({aptosConfig:t,path:"prove",body:a,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),p=c.proof,m=new Gt({a:p.a,b:p.b,c:p.c}),x;if(s){let ae=_jwtdecode.jwtDecode.call(void 0, e)[s];x=`"${s}":"${ae}",`}return new Ke({proof:new pt(m,0),extraField:x,trainingWheelsSignature:le.fromHex(c.training_wheels_signature)})}async function Ns(n){let{proofFetchCallback:t}=n,{pepper:e}=n;if(e===void 0)e=await ri(n);else if(g.fromHexInput(e).toUint8Array().length!==be.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${be.PEPPER_LENGTH} bytes`);let r=Kc({...n,pepper:e}),i=t?r:await r;return be.fromJWTAndProof({...n,proof:i,pepper:e,proofFetchCallback:t})}var yn=class{constructor(t){this.config=t}async getPepper(t){return ri({aptosConfig:this.config,...t})}async deriveKeylessAccount(t){return Ns({aptosConfig:this.config,...t})}};var J=class{constructor(t){this.config=new Qn(t),this.account=new en(this.config),this.ans=new ln(this.config),this.coin=new rn(this.config),this.digitalAsset=new on(this.config),this.event=new an(this.config),this.faucet=new cn(this.config),this.fungibleAsset=new un(this.config),this.general=new pn(this.config),this.staking=new gn(this.config),this.transaction=new mn(this.config),this.keyless=new yn(this.config)}};function ye(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))})}ye(J,en,"account");ye(J,ln,"ans");ye(J,rn,"coin");ye(J,on,"digitalAsset");ye(J,an,"event");ye(J,cn,"faucet");ye(J,un,"fungibleAsset");ye(J,pn,"general");ye(J,gn,"staking");ye(J,mn,"transaction");ye(J,yn,"keyless");exports.APTOS_BIP44_REGEX = Ys; exports.APTOS_COIN = En; exports.APTOS_HARDENED_REGEX = Xs; exports.Account = ke; exports.AccountAddress = u; exports.AccountAuthenticator = q; exports.AccountAuthenticatorEd25519 = me; exports.AccountAuthenticatorMultiEd25519 = Pn; exports.AccountAuthenticatorMultiKey = Xe; exports.AccountAuthenticatorSingleKey = $; exports.AccountAuthenticatorVariant = ci; exports.AccountPublicKey = te; exports.AccountSequenceNumber = or; exports.AddressInvalidReason = Ls; exports.AnyPublicKey = k; exports.AnyPublicKeyVariant = pr; exports.AnySignature = N; exports.AnySignatureVariant = ui; exports.Aptos = J; exports.AptosApiError = oe; exports.AptosApiType = qt; exports.AptosConfig = Qn; exports.AuthenticationKey = F; exports.Bool = R; exports.CKDPriv = Ai; exports.ChainId = gt; exports.DEFAULT_MAX_GAS_AMOUNT = vi; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = Pi; exports.DEFAULT_TXN_TIMEOUT_SEC = Cn; exports.DeriveScheme = Hs; exports.Deserializer = ee; exports.EPK_HORIZON_SECS = Mt; exports.Ed25519Account = xt; exports.Ed25519PrivateKey = M; exports.Ed25519PublicKey = P; exports.Ed25519Signature = _; exports.EntryFunction = Je; exports.EntryFunctionBytes = Tn; exports.EphemeralCertificate = ut; exports.EphemeralCertificateVariant = lr; exports.EphemeralKeyPair = Xt; exports.EphemeralPublicKey = Qe; exports.EphemeralPublicKeyVariant = dr; exports.EphemeralSignature = le; exports.EphemeralSignatureVariant = pi; exports.FeePayerRawTransaction = tt; exports.FixedBytes = Me; exports.Groth16Zkp = Gt; exports.HARDENED_OFFSET = mi; exports.Hex = g; exports.HexInvalidReason = Gs; exports.Identifier = U; exports.IssuerToJwkEndpoint = Ba; exports.KeyType = Zs; exports.KeylessAccount = be; exports.KeylessError = Yt; exports.KeylessErrorType = Oa; exports.KeylessPublicKey = ge; exports.KeylessSignature = We; exports.MAX_AUD_VAL_BYTES = _a; exports.MAX_COMMITED_EPK_BYTES = Ad; exports.MAX_EXTRA_FIELD_BYTES = yd; exports.MAX_ISS_VAL_BYTES = md; exports.MAX_JWT_HEADER_B64_BYTES = fd; exports.MAX_UID_KEY_BYTES = va; exports.MAX_UID_VAL_BYTES = Pa; exports.MimeType = bn; exports.ModuleId = $t; exports.MoveAbility = di; exports.MoveFunctionVisibility = qs; exports.MoveOption = Re; exports.MoveString = w; exports.MoveVector = T; exports.MultiAgentRawTransaction = et; exports.MultiAgentTransaction = Kn; exports.MultiEd25519PublicKey = at; exports.MultiEd25519Signature = He; exports.MultiKey = dt; exports.MultiKeyAccount = Nn; exports.MultiKeySignature = je; exports.MultiSig = Wt; exports.MultiSigTransactionPayload = jt; exports.Network = _r; exports.NetworkToChainId = vr; exports.NetworkToFaucetAPI = Ki; exports.NetworkToIndexerAPI = Ri; exports.NetworkToNetworkName = uy; exports.NetworkToNodeAPI = zi; exports.NetworkToPepperAPI = Sr; exports.NetworkToProverAPI = xr; exports.ParsingError = V; exports.ProcessorType = lt; exports.PublicKey = qe; exports.RAW_TRANSACTION_SALT = Ci; exports.RAW_TRANSACTION_WITH_DATA_SALT = hr; exports.RawTransaction = ie; exports.RawTransactionWithData = Un; exports.RoleType = $s; exports.RotationProofChallenge = Rn; exports.Script = Qt; exports.ScriptTransactionArgumentVariants = Bt; exports.Secp256k1PrivateKey = Le; exports.Secp256k1PublicKey = he; exports.Secp256k1Signature = xe; exports.Serializable = d; exports.Serializer = L; exports.Signature = D; exports.SignedTransaction = nt; exports.SigningScheme = fe; exports.SigningSchemeInput = yr; exports.SimpleTransaction = zn; exports.SingleKeyAccount = _t; exports.StructTag = ve; exports.TransactionAndProof = wr; exports.TransactionAuthenticator = Pe; exports.TransactionAuthenticatorEd25519 = ht; exports.TransactionAuthenticatorFeePayer = bt; exports.TransactionAuthenticatorMultiAgent = Tt; exports.TransactionAuthenticatorMultiEd25519 = Tr; exports.TransactionAuthenticatorSingleSender = wt; exports.TransactionAuthenticatorVariant = ai; exports.TransactionPayload = Ze; exports.TransactionPayloadEntryFunction = Vt; exports.TransactionPayloadMultiSig = Lt; exports.TransactionPayloadScript = Ht; exports.TransactionPayloadVariants = oi; exports.TransactionResponseType = mr; exports.TransactionVariants = si; exports.TransactionWorker = sr; exports.TransactionWorkerEventsEnum = Ds; exports.TypeTag = z; exports.TypeTagAddress = X; exports.TypeTagBool = G; exports.TypeTagGeneric = K; exports.TypeTagParserError = E; exports.TypeTagParserErrorType = Wa; exports.TypeTagReference = In; exports.TypeTagSigner = Ye; exports.TypeTagStruct = y; exports.TypeTagU128 = ft; exports.TypeTagU16 = mt; exports.TypeTagU256 = At; exports.TypeTagU32 = yt; exports.TypeTagU64 = Q; exports.TypeTagU8 = Te; exports.TypeTagVariants = ii; exports.TypeTagVector = C; exports.U128 = pe; exports.U16 = ce; exports.U256 = de; exports.U32 = ue; exports.U64 = B; exports.U8 = O; exports.ZeroKnowledgeSig = Ke; exports.ZkProof = pt; exports.ZkpVariant = gr; exports.aptosCoinStructTag = Cl; exports.aptosRequest = Bn; exports.buildTransaction = Qr; exports.checkOrConvertArgument = Rt; exports.convertArgument = Lr; exports.deriveKey = fr; exports.deriveTransactionType = br; exports.deserializeFromScriptArgument = Ea; exports.ensureBoolean = ur; exports.fetchEntryFunctionAbi = Ro; exports.fetchFunctionAbi = Uo; exports.fetchViewFunctionAbi = zo; exports.findFirstNonSignerArg = Io; exports.generateRawTransaction = nc; exports.generateSignedTransaction = Wr; exports.generateSignedTransactionForSimulation = ko; exports.generateSigningMessage = kn; exports.generateSigningMessageForBcsCryptoHashable = Ei; exports.generateSigningMessageForTransaction = St; exports.generateTransactionPayload = Jn; exports.generateTransactionPayloadWithABI = Ja; exports.generateUserTransactionHash = pA; exports.generateViewFunctionPayload = Ko; exports.generateViewFunctionPayloadWithABI = ec; exports.get = Pr; exports.getAptosFullNode = Z; exports.getAptosPepperService = Ry; exports.getAuthenticatorForSimulation = Zn; exports.getFunctionParts = tn; exports.hashValues = Do; exports.isBcsAddress = Yn; exports.isBcsBool = Nr; exports.isBcsFixedBytes = ja; exports.isBcsString = Br; exports.isBcsU128 = qr; exports.isBcsU16 = Fr; exports.isBcsU256 = $r; exports.isBcsU32 = Gr; exports.isBcsU64 = Mr; exports.isBcsU8 = Or; exports.isBlockMetadataTransactionResponse = ou; exports.isBool = vo; exports.isEd25519Signature = cu; exports.isEncodedEntryFunctionArgument = Co; exports.isFeePayerSignature = du; exports.isGenesisTransactionResponse = iu; exports.isLargeNumber = Xn; exports.isMultiAgentSignature = pu; exports.isMultiEd25519Signature = lu; exports.isNull = Po; exports.isNumber = jn; exports.isPendingTransactionResponse = nu; exports.isScriptDataInput = Eo; exports.isSecp256k1Signature = uu; exports.isStateCheckpointTransactionResponse = su; exports.isString = Ut; exports.isUserTransactionResponse = ru; exports.isValidBIP44Path = yi; exports.isValidHardenedPath = fi; exports.isValidatorTransactionResponse = au; exports.mnemonicToSeed = wn; exports.normalizeBundle = ki; exports.objectStructTag = Y; exports.optionStructTag = El; exports.outOfRangeErrorMessage = Ms; exports.paginateWithCursor = Pt; exports.parseTypeTag = Ce; exports.post = Zt; exports.postAptosFaucet = Bi; exports.postAptosFullNode = rt; exports.postAptosIndexer = Ni; exports.postAptosPepperService = Oi; exports.postAptosProvingService = Fi; exports.promiseFulfilledStatus = ks; exports.request = Ga; exports.splitPath = hi; exports.standardizeTypeTags = Vr; exports.stringStructTag = v; exports.throwTypeMismatch = I; exports.validateNumberInRange = Ue;
|
|
429
429
|
//# sourceMappingURL=index.js.map
|