@aptos-labs/ts-sdk 1.38.0 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/{accountAddress-5ltp27oM.d.ts → accountAddress-D0xKX-UM.d.ts} +1 -1
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/index.d.ts +55 -5
- package/dist/common/index.js +8 -8
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-D2MdV8Av.d.mts → Ed25519Account-D9XrCLfE.d.mts} +2 -2
- package/dist/esm/account/AbstractKeylessAccount.d.mts +2 -2
- package/dist/esm/account/AbstractKeylessAccount.mjs +1 -1
- package/dist/esm/account/AbstractedAccount.d.mts +1 -1
- package/dist/esm/account/AbstractedAccount.mjs +1 -1
- package/dist/esm/account/Account.d.mts +1 -1
- package/dist/esm/account/Account.mjs +1 -1
- package/dist/esm/account/AccountUtils.d.mts +2 -2
- package/dist/esm/account/AccountUtils.mjs +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.d.mts +1 -1
- package/dist/esm/account/DerivableAbstractedAccount.mjs +1 -1
- package/dist/esm/account/Ed25519Account.d.mts +1 -1
- package/dist/esm/account/Ed25519Account.mjs +1 -1
- package/dist/esm/account/EphemeralKeyPair.mjs +1 -1
- package/dist/esm/account/FederatedKeylessAccount.d.mts +2 -2
- package/dist/esm/account/FederatedKeylessAccount.mjs +1 -1
- package/dist/esm/account/KeylessAccount.d.mts +2 -2
- package/dist/esm/account/KeylessAccount.mjs +1 -1
- package/dist/esm/account/MultiEd25519Account.d.mts +1 -1
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +2 -2
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +1 -1
- package/dist/esm/account/SingleKeyAccount.mjs +1 -1
- package/dist/esm/account/index.d.mts +2 -2
- package/dist/esm/account/index.mjs +1 -1
- package/dist/esm/account/utils.mjs +1 -1
- package/dist/esm/api/account/abstraction.mjs +1 -1
- package/dist/esm/api/account.d.mts +2 -1
- package/dist/esm/api/account.mjs +1 -1
- package/dist/esm/api/ans.d.mts +1 -1
- package/dist/esm/api/ans.mjs +1 -1
- package/dist/esm/api/aptos.d.mts +2 -2
- package/dist/esm/api/aptos.mjs +1 -1
- package/dist/esm/api/coin.mjs +1 -1
- package/dist/esm/api/digitalAsset.d.mts +1 -1
- package/dist/esm/api/digitalAsset.mjs +1 -1
- package/dist/esm/api/event.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +51 -2
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.mjs +1 -1
- package/dist/esm/api/index.d.mts +2 -2
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/keyless.d.mts +2 -2
- package/dist/esm/api/keyless.mjs +1 -1
- package/dist/esm/api/object.mjs +1 -1
- package/dist/esm/api/staking.mjs +1 -1
- package/dist/esm/api/table.mjs +1 -1
- package/dist/esm/api/transaction.d.mts +1 -1
- package/dist/esm/api/transaction.mjs +1 -1
- package/dist/esm/api/transactionSubmission/build.mjs +1 -1
- package/dist/esm/api/transactionSubmission/management.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/management.mjs +1 -1
- package/dist/esm/api/transactionSubmission/sign.d.mts +1 -1
- package/dist/esm/api/transactionSubmission/sign.mjs +1 -1
- package/dist/esm/api/transactionSubmission/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/deserializer.mjs +1 -1
- package/dist/esm/bcs/index.mjs +1 -1
- package/dist/esm/bcs/serializable/entryFunctionBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/fixedBytes.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.d.mts +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/bcs/serializer.mjs +1 -1
- package/dist/esm/{chunk-KBHJPL6Y.mjs → chunk-25O4L7YR.mjs} +2 -2
- package/dist/esm/{chunk-CDGBM4JY.mjs → chunk-3IHKQH5O.mjs} +2 -2
- package/dist/esm/{chunk-FGFLPH5K.mjs → chunk-6PKBXYG3.mjs} +2 -2
- package/dist/esm/{chunk-6WDVDEQZ.mjs → chunk-6Y6ZO7TS.mjs} +2 -2
- package/dist/esm/{chunk-NKHYIVN3.mjs → chunk-ARNW34PP.mjs} +2 -2
- package/dist/esm/{chunk-HNBVYE3N.mjs → chunk-BUUV6B4P.mjs} +2 -2
- package/dist/esm/{chunk-QQDTCQQV.mjs → chunk-BXRBOMHW.mjs} +2 -2
- package/dist/esm/{chunk-WSR5EBJM.mjs → chunk-BYINW7I2.mjs} +2 -2
- package/dist/esm/{chunk-ORMOQWWH.mjs → chunk-C6JRJNK3.mjs} +2 -2
- package/dist/esm/{chunk-RQX6JOEN.mjs → chunk-FBCXUC7J.mjs} +2 -2
- package/dist/esm/{chunk-WIBQJBBB.mjs → chunk-GJ7STZEW.mjs} +2 -2
- package/dist/esm/{chunk-GSXNMAK2.mjs → chunk-GLFZJNF3.mjs} +2 -2
- package/dist/esm/{chunk-NAWRVBU4.mjs → chunk-GQ557FEA.mjs} +2 -2
- package/dist/esm/{chunk-RGKRCZ36.mjs → chunk-GYVSI3TS.mjs} +2 -2
- package/dist/esm/{chunk-TOBQ5UE6.mjs → chunk-IXYGZ57N.mjs} +2 -2
- package/dist/esm/{chunk-XTOIL6MB.mjs → chunk-JGFKIUG5.mjs} +2 -2
- package/dist/esm/{chunk-XTOIL6MB.mjs.map → chunk-JGFKIUG5.mjs.map} +1 -1
- package/dist/esm/{chunk-IRYH7OV4.mjs → chunk-KAYKTT4S.mjs} +2 -2
- package/dist/esm/chunk-L33JDCWL.mjs +2 -0
- package/dist/esm/{chunk-4AU6DSUL.mjs.map → chunk-L33JDCWL.mjs.map} +1 -1
- package/dist/esm/{chunk-EBMEXURY.mjs → chunk-NJN3EAOM.mjs} +2 -2
- package/dist/esm/{chunk-XKUIMGKU.mjs → chunk-OYH2T6V5.mjs} +2 -2
- package/dist/esm/chunk-OYUW6ZN2.mjs +2 -0
- package/dist/esm/{chunk-P23N7FX6.mjs → chunk-P237G6YB.mjs} +2 -2
- package/dist/esm/{chunk-N6YTF76Q.mjs → chunk-PRUQZNAP.mjs} +2 -2
- package/dist/esm/{chunk-N4VVDQA5.mjs → chunk-SOJ3OG6X.mjs} +2 -2
- package/dist/esm/chunk-TAEOFYOF.mjs +4 -0
- package/dist/esm/chunk-TAEOFYOF.mjs.map +1 -0
- package/dist/esm/chunk-TUZHLTDU.mjs +2 -0
- package/dist/esm/{chunk-PUYYROVD.mjs → chunk-V7U5Y4AU.mjs} +2 -2
- package/dist/esm/{chunk-MT2RJ7H3.mjs → chunk-WLUXOUZH.mjs} +2 -2
- package/dist/esm/{chunk-XZGEJMIL.mjs → chunk-WTLQD6MR.mjs} +2 -2
- package/dist/esm/{chunk-3BUKTQDX.mjs → chunk-XF6BISPI.mjs} +2 -2
- package/dist/esm/{chunk-7DQDJ2SA.mjs → chunk-YFFDF22R.mjs} +2 -2
- package/dist/esm/{chunk-4CVPCQ56.mjs → chunk-YQIAWAPY.mjs} +2 -2
- package/dist/esm/{chunk-WCMW2L3P.mjs → chunk-Z6KQX6VX.mjs} +2 -2
- package/dist/esm/{chunk-B563XRSZ.mjs → chunk-ZMT2M6YT.mjs} +2 -2
- package/dist/esm/cli/index.mjs +1 -1
- package/dist/esm/cli/localNode.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/account/index.mjs +1 -1
- package/dist/esm/core/account/utils/address.mjs +1 -1
- package/dist/esm/core/account/utils/index.mjs +1 -1
- package/dist/esm/core/accountAddress.mjs +1 -1
- package/dist/esm/core/authenticationKey.mjs +1 -1
- package/dist/esm/core/crypto/abstraction.mjs +1 -1
- package/dist/esm/core/crypto/ed25519.d.mts +1 -1
- package/dist/esm/core/crypto/ed25519.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +1 -1
- package/dist/esm/core/crypto/federatedKeyless.mjs +1 -1
- package/dist/esm/core/crypto/index.d.mts +1 -1
- package/dist/esm/core/crypto/index.mjs +1 -1
- package/dist/esm/core/crypto/keyless.d.mts +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/privateKey.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.d.mts +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.d.mts +2 -2
- package/dist/esm/core/crypto/singleKey.mjs +1 -1
- package/dist/esm/core/index.d.mts +1 -1
- package/dist/esm/core/index.mjs +1 -1
- package/dist/esm/errors/index.mjs +1 -1
- package/dist/esm/{federatedKeyless-BelAZrlM.d.mts → federatedKeyless-DAYXjY2Y.d.mts} +2 -2
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +2 -1
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +2 -2
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +2 -2
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +25 -2
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/keyless.d.mts +2 -2
- package/dist/esm/internal/keyless.mjs +1 -1
- package/dist/esm/internal/object.mjs +1 -1
- package/dist/esm/internal/staking.mjs +1 -1
- package/dist/esm/internal/table.mjs +1 -1
- package/dist/esm/internal/transaction.mjs +1 -1
- package/dist/esm/internal/transactionSubmission.d.mts +1 -1
- package/dist/esm/internal/transactionSubmission.mjs +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.mjs +1 -1
- package/dist/esm/internal/view.mjs +1 -1
- package/dist/esm/transactions/authenticator/account.mjs +1 -1
- package/dist/esm/transactions/authenticator/index.mjs +1 -1
- package/dist/esm/transactions/authenticator/transaction.mjs +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/transactions/instances/chainId.mjs +1 -1
- package/dist/esm/transactions/instances/identifier.mjs +1 -1
- package/dist/esm/transactions/instances/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.d.mts +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.d.mts +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.mjs +1 -1
- package/dist/esm/transactions/management/index.d.mts +1 -1
- package/dist/esm/transactions/management/index.mjs +1 -1
- package/dist/esm/transactions/management/transactionWorker.d.mts +1 -1
- package/dist/esm/transactions/management/transactionWorker.mjs +1 -1
- package/dist/esm/transactions/scriptComposer/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/helpers.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/index.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/remoteAbi.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/signingMessage.mjs +1 -1
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.d.mts +2 -2
- package/dist/esm/transactions/transactionBuilder/transactionBuilder.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/transactions/types.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/indexer.d.mts +1 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils/normalizeBundle.mjs +1 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +3 -3
- package/src/api/account.ts +1 -0
- package/src/api/fungibleAsset.ts +54 -1
- package/src/core/crypto/singleKey.ts +2 -2
- package/src/internal/account.ts +10 -9
- package/src/internal/fungibleAsset.ts +37 -0
- package/src/version.ts +1 -1
- package/dist/esm/chunk-4AU6DSUL.mjs +0 -2
- package/dist/esm/chunk-4N2JPV7H.mjs +0 -4
- package/dist/esm/chunk-4N2JPV7H.mjs.map +0 -1
- package/dist/esm/chunk-4YLUM62M.mjs +0 -2
- package/dist/esm/chunk-XJJVJOX5.mjs +0 -2
- /package/dist/esm/{chunk-KBHJPL6Y.mjs.map → chunk-25O4L7YR.mjs.map} +0 -0
- /package/dist/esm/{chunk-CDGBM4JY.mjs.map → chunk-3IHKQH5O.mjs.map} +0 -0
- /package/dist/esm/{chunk-FGFLPH5K.mjs.map → chunk-6PKBXYG3.mjs.map} +0 -0
- /package/dist/esm/{chunk-6WDVDEQZ.mjs.map → chunk-6Y6ZO7TS.mjs.map} +0 -0
- /package/dist/esm/{chunk-NKHYIVN3.mjs.map → chunk-ARNW34PP.mjs.map} +0 -0
- /package/dist/esm/{chunk-HNBVYE3N.mjs.map → chunk-BUUV6B4P.mjs.map} +0 -0
- /package/dist/esm/{chunk-QQDTCQQV.mjs.map → chunk-BXRBOMHW.mjs.map} +0 -0
- /package/dist/esm/{chunk-WSR5EBJM.mjs.map → chunk-BYINW7I2.mjs.map} +0 -0
- /package/dist/esm/{chunk-ORMOQWWH.mjs.map → chunk-C6JRJNK3.mjs.map} +0 -0
- /package/dist/esm/{chunk-RQX6JOEN.mjs.map → chunk-FBCXUC7J.mjs.map} +0 -0
- /package/dist/esm/{chunk-WIBQJBBB.mjs.map → chunk-GJ7STZEW.mjs.map} +0 -0
- /package/dist/esm/{chunk-GSXNMAK2.mjs.map → chunk-GLFZJNF3.mjs.map} +0 -0
- /package/dist/esm/{chunk-NAWRVBU4.mjs.map → chunk-GQ557FEA.mjs.map} +0 -0
- /package/dist/esm/{chunk-RGKRCZ36.mjs.map → chunk-GYVSI3TS.mjs.map} +0 -0
- /package/dist/esm/{chunk-TOBQ5UE6.mjs.map → chunk-IXYGZ57N.mjs.map} +0 -0
- /package/dist/esm/{chunk-IRYH7OV4.mjs.map → chunk-KAYKTT4S.mjs.map} +0 -0
- /package/dist/esm/{chunk-EBMEXURY.mjs.map → chunk-NJN3EAOM.mjs.map} +0 -0
- /package/dist/esm/{chunk-XKUIMGKU.mjs.map → chunk-OYH2T6V5.mjs.map} +0 -0
- /package/dist/esm/{chunk-XJJVJOX5.mjs.map → chunk-OYUW6ZN2.mjs.map} +0 -0
- /package/dist/esm/{chunk-P23N7FX6.mjs.map → chunk-P237G6YB.mjs.map} +0 -0
- /package/dist/esm/{chunk-N6YTF76Q.mjs.map → chunk-PRUQZNAP.mjs.map} +0 -0
- /package/dist/esm/{chunk-N4VVDQA5.mjs.map → chunk-SOJ3OG6X.mjs.map} +0 -0
- /package/dist/esm/{chunk-4YLUM62M.mjs.map → chunk-TUZHLTDU.mjs.map} +0 -0
- /package/dist/esm/{chunk-PUYYROVD.mjs.map → chunk-V7U5Y4AU.mjs.map} +0 -0
- /package/dist/esm/{chunk-MT2RJ7H3.mjs.map → chunk-WLUXOUZH.mjs.map} +0 -0
- /package/dist/esm/{chunk-XZGEJMIL.mjs.map → chunk-WTLQD6MR.mjs.map} +0 -0
- /package/dist/esm/{chunk-3BUKTQDX.mjs.map → chunk-XF6BISPI.mjs.map} +0 -0
- /package/dist/esm/{chunk-7DQDJ2SA.mjs.map → chunk-YFFDF22R.mjs.map} +0 -0
- /package/dist/esm/{chunk-4CVPCQ56.mjs.map → chunk-YQIAWAPY.mjs.map} +0 -0
- /package/dist/esm/{chunk-WCMW2L3P.mjs.map → chunk-Z6KQX6VX.mjs.map} +0 -0
- /package/dist/esm/{chunk-B563XRSZ.mjs.map → chunk-ZMT2M6YT.mjs.map} +0 -0
package/dist/common/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 _chunk66TIRJFDjs = require('./chunk-66TIRJFD.js');var R=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunk66TIRJFDjs.j.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===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 e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunk66TIRJFDjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>_chunk66TIRJFDjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var Ee=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var nr=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=new Ee(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ee.deserialize(e,t);return new n(r.value)}};var z=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.n.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new ye(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},X= exports.U8 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},Pe= exports.U16 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},_e= exports.U32 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},Q= exports.U64 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},xe= exports.U128 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},ye= exports.U256 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var S=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof X)){new hn(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunk66TIRJFDjs.j.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new X(r)))}static U16(e){return new n(e.map(t=>new Pe(t)))}static U32(e){return new n(e.map(t=>new _e(t)))}static U64(e){return new n(e.map(t=>new Q(t)))}static U128(e){return new n(e.map(t=>new xe(t)))}static U256(e){return new n(e.map(t=>new ye(t)))}static Bool(e){return new n(e.map(t=>new z(t)))}static MoveString(e){return new n(e.map(t=>new x(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},hn= exports.Serialized =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new R(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new S(r)}},x= exports.MoveString =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);S.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Y= exports.MoveOption =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}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 X(e):void 0)}static U16(e){return new n(e!=null?new Pe(e):void 0)}static U32(e){return new n(e!=null?new _e(e):void 0)}static U64(e){return new n(e!=null?new Q(e):void 0)}static U128(e){return new n(e!=null?new xe(e):void 0)}static U256(e){return new n(e!=null?new ye(e):void 0)}static Bool(e){return new n(e!=null?new z(e):void 0)}static MoveString(e){return new n(e!=null?new x(e):void 0)}static deserialize(e,t){let r=S.deserialize(e,t);return new n(r.values[0])}};var _sha3 = require('@noble/hashes/sha3');var ut=class ut extends _chunk66TIRJFDjs.l{constructor(e){super();let{data:t}=e,r=_chunk66TIRJFDjs.j.fromHexInput(t);if(r.toUint8Array().length!==ut.LENGTH)throw new Error(`Authentication Key length should be ${ut.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(ut.LENGTH);return new ut({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunk66TIRJFDjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new ut({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunk66TIRJFDjs.Z)(this.data.toUint8Array())}};ut.LENGTH=32;var B=ut;var St=class extends _chunk66TIRJFDjs.l{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk66TIRJFDjs.j.fromHexInput(e).toString()}},ie= exports.AccountPublicKey =class extends St{};var M=class extends _chunk66TIRJFDjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk66TIRJFDjs.j.fromHexInput(e).toString()}};var Tn=class n extends M{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},rr= exports.AbstractPublicKey =class extends ie{constructor(e){super(),this.accountAddress=e}authKey(){return new B({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var _ed25519 = require('@noble/curves/ed25519');var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var go = _interopRequireWildcard(_bip39);var mc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,yc= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,fc= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(fc||{}),mo= exports.HARDENED_OFFSET =2147483648;function yo(n){return yc.test(n)}function fo(n){return mc.test(n)}var Zr=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Ao= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return Zr(e,s)},Ac=n=>n.replace(/'/g,""),ho= exports.splitPath =n=>n.split("/").slice(1).map(Ac),ir= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return go.mnemonicToSeedSync(e)};var bn=class bn{static formatPrivateKey(e,t){let r=bn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk66TIRJFDjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=bn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk66TIRJFDjs.j.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunk66TIRJFDjs.j.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunk66TIRJFDjs.j.fromHexInput(e);return i}};bn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var pt=bn;var Wt=n=>typeof n=="string"?_chunk66TIRJFDjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var ei=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function hc(n){let e=n.toUint8Array().slice(32);for(let t=ei.length-1;t>=0;t-=1){if(e[t]<ei[t])return!0;if(e[t]>ei[t])return!1}return!1}var dt=class dt extends ie{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==dt.LENGTH)throw new Error(`PublicKey length should be ${dt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!hc(r))return!1;let i=Wt(t),o=_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return B.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new dt(t)}static isPublicKey(e){return e instanceof dt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _2 => _2.key, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.length])===dt.LENGTH}};dt.LENGTH=32;var I=dt,fe=class fe extends _chunk66TIRJFDjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==fe.LENGTH)throw new Error(`PrivateKey length should be ${fe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new fe(e,!1)}static fromDerivationPath(e,t){if(!fo(e))throw new Error(`Invalid derivation path ${e}`);return fe.fromDerivationPathInner(e,ir(t))}static fromDerivationPathInner(e,t,r=mo){let{key:i,chainCode:o}=Zr(fe.SLIP_0010_SEED,t),s=ho(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Ao(c,p+r),{key:i,chainCode:o});return new fe(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new I(e)}sign(e){let t=Wt(e),r=_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new K(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return pt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new fe(t,!1)}static isPrivateKey(e){return e instanceof fe}};fe.LENGTH=32,fe.SLIP_0010_SEED="ed25519 seed";var q=fe,Qt=class Qt extends M{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==Qt.LENGTH)throw new Error(`Signature length should be ${Qt.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Qt(t)}};Qt.LENGTH=64;var K=Qt;var lt=class n extends St{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof I)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Ue= exports.EphemeralSignature =class n extends M{constructor(e){super();let t=e.constructor.name;switch(t){case K.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunk66TIRJFDjs.j.fromHexInput(e),r=new R(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof K)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(K.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _jwtdecode = require('jwt-decode');var _poseidonlite = require('poseidon-lite');var ti=[_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],bo=31,zc=16,To=(zc-1)*bo;function ke(n,e){let r=new TextEncoder().encode(n);return Nc(r,e)}function Nc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=wn(n,e);return Pt(t)}function Oc(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Bc(n,e);return Fc(t)}function wn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Oc(n,e).concat([BigInt(n.length)])}function Fc(n){if(n.length>To)throw new Error(`Can't pack more than ${To}. Was given ${n.length} bytes`);return Gc(n,bo).map(e=>Et(e))}function Gc(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function Et(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function ni(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Bc(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Pt(n){if(n.length>ti.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${ti.length}`);return ti[n.length-1](n)}var sr=class extends _chunk66TIRJFDjs.l{};var wo="1.38.0";var So={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"},Eo= 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"},Po= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},ri= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},ii= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},oi= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(oi||{}),si= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},xl= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var _t=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(_t||{}),_o= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,xo= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,ar= exports.DEFAULT_TXN_TIMEOUT_SEC =20,xt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Io= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Co= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",ai= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",He= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(He||{}),vo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Ko(n,e){let t=e.bcsToBytes(),r=new R(t);return n.deserialize(r)}var Mc=(s=>(s[s.API_ERROR=0]="API_ERROR",s[s.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",s[s.SESSION_EXPIRED=2]="SESSION_EXPIRED",s[s.INVALID_STATE=3]="INVALID_STATE",s[s.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",s[s.UNKNOWN=5]="UNKNOWN",s))(Mc||{}),Vc= exports.KeylessErrorResolutionTip =(p=>(p.REAUTHENTICATE="Re-authentiate to continue using your keyless account",p.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",p.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",p.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",p.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",p.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",p.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p))(Vc||{}),cr= exports.KeylessErrorType =(y=>(y[y.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",y[y.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",y[y.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",y[y.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",y[y.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",y[y.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",y[y.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",y[y.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",y[y.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",y[y.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",y[y.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",y[y.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",y[y.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",y[y.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",y[y.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",y[y.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",y[y.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",y[y.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",y[y.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",y[y.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",y[y.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",y[y.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",y[y.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",y[y.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",y[y.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",y[y.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",y[y.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",y[y.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",y[y.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",y[y.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",y[y.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",y[y.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",y[y.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",y[y.UNKNOWN=33]="UNKNOWN",y))(cr||{}),Ro={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},P= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=Ro[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
|
|
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 _chunk66TIRJFDjs = require('./chunk-66TIRJFD.js');var R=class n{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let t=_chunk66TIRJFDjs.j.hexInputToUint8Array(e);return new n(t)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,t){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(t===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(t)}return this.deserialize(e)}}deserializeBytes(){let e=this.deserializeUleb128AsU32();return new Uint8Array(this.read(e))}deserializeFixedBytes(e){return new Uint8Array(this.read(e))}deserializeBool(){let e=new Uint8Array(this.read(1))[0];if(e!==1&&e!==0)throw new Error("Invalid boolean value");return e===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 e=this.deserializeU32(),t=this.deserializeU32();return BigInt(BigInt(t)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),t=this.deserializeU64();return BigInt(t<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),t=this.deserializeU128();return BigInt(t<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),t=0;for(;e<_chunk66TIRJFDjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),(r&128)===0)break;t+=7}if(e>_chunk66TIRJFDjs.d)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let t=this.deserializeUleb128AsU32(),r=new Array;for(let i=0;i<t;i+=1)r.push(this.deserialize(e));return r}};var Ee=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeFixedBytes(this.value)}serializeForEntryFunction(e){e.serialize(this)}serializeForScriptFunction(e){e.serialize(this)}static deserialize(e,t){let r=e.deserializeFixedBytes(t);return new n(r)}};var nr=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=new Ee(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Ee.deserialize(e,t);return new n(r.value)}};var z=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.n.call(void 0, e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new ye(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},X= exports.U8 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.b),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new n(e.deserializeU8())}},Pe= exports.U16 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.c),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new n(e.deserializeU16())}},_e= exports.U32 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,0,_chunk66TIRJFDjs.d),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new n(e.deserializeU32())}},Q= exports.U64 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.e),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new n(e.deserializeU64())}},xe= exports.U128 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.f),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new n(e.deserializeU128())}},ye= exports.U256 =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),_chunk66TIRJFDjs.p.call(void 0, e,BigInt(0),_chunk66TIRJFDjs.g),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new n(e.deserializeU256())}};var S=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof X)){new hn(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let t;if(Array.isArray(e)&&e.length===0)t=[];else if(Array.isArray(e)&&typeof e[0]=="number")t=e;else if(typeof e=="string"){let r=_chunk66TIRJFDjs.j.fromHexInput(e);t=Array.from(r.toUint8Array())}else if(e instanceof Uint8Array)t=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new n(t.map(r=>new X(r)))}static U16(e){return new n(e.map(t=>new Pe(t)))}static U32(e){return new n(e.map(t=>new _e(t)))}static U64(e){return new n(e.map(t=>new Q(t)))}static U128(e){return new n(e.map(t=>new xe(t)))}static U256(e){return new n(e.map(t=>new ye(t)))}static Bool(e){return new n(e.map(t=>new z(t)))}static MoveString(e){return new n(e.map(t=>new x(t)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,t){let r=e.deserializeUleb128AsU32(),i=new Array;for(let o=0;o<r;o+=1)i.push(t.deserialize(e));return new n(i)}},hn= exports.Serialized =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}serializeForEntryFunction(e){this.serialize(e)}serializeForScriptFunction(e){e.serializeU32AsUleb128(9),this.serialize(e)}static deserialize(e){return new n(e.deserializeBytes())}toMoveVector(e){let t=new R(this.bcsToBytes());t.deserializeUleb128AsU32();let r=t.deserializeVector(e);return new S(r)}},x= exports.MoveString =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);S.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new n(e.deserializeStr())}},Y= exports.MoveOption =class n extends _chunk66TIRJFDjs.l{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new S([e]):this.vec=new S([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let t=this.bcsToBytes();e.serializeBytes(t)}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 X(e):void 0)}static U16(e){return new n(e!=null?new Pe(e):void 0)}static U32(e){return new n(e!=null?new _e(e):void 0)}static U64(e){return new n(e!=null?new Q(e):void 0)}static U128(e){return new n(e!=null?new xe(e):void 0)}static U256(e){return new n(e!=null?new ye(e):void 0)}static Bool(e){return new n(e!=null?new z(e):void 0)}static MoveString(e){return new n(e!=null?new x(e):void 0)}static deserialize(e,t){let r=S.deserialize(e,t);return new n(r.values[0])}};var _sha3 = require('@noble/hashes/sha3');var ut=class ut extends _chunk66TIRJFDjs.l{constructor(e){super();let{data:t}=e,r=_chunk66TIRJFDjs.j.fromHexInput(t);if(r.toUint8Array().length!==ut.LENGTH)throw new Error(`Authentication Key length should be ${ut.LENGTH}`);this.data=r}serialize(e){e.serializeFixedBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeFixedBytes(ut.LENGTH);return new ut({data:t})}toUint8Array(){return this.data.toUint8Array()}static fromSchemeAndBytes(e){let{scheme:t,input:r}=e,i=_chunk66TIRJFDjs.j.fromHexInput(r).toUint8Array(),o=new Uint8Array([...i,t]),s=_sha3.sha3_256.create();s.update(o);let a=s.digest();return new ut({data:a})}static fromPublicKeyAndScheme(e){let{publicKey:t}=e;return t.authKey()}static fromPublicKey(e){let{publicKey:t}=e;return t.authKey()}derivedAddress(){return new (0, _chunk66TIRJFDjs.Z)(this.data.toUint8Array())}};ut.LENGTH=32;var B=ut;var St=class extends _chunk66TIRJFDjs.l{async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk66TIRJFDjs.j.fromHexInput(e).toString()}},ie= exports.AccountPublicKey =class extends St{};var M=class extends _chunk66TIRJFDjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk66TIRJFDjs.j.fromHexInput(e).toString()}};var Tn=class n extends M{constructor(e){super(),this.value=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array()}serialize(e){e.serializeBytes(this.value)}static deserialize(e){return new n(e.deserializeBytes())}},rr= exports.AbstractPublicKey =class extends ie{constructor(e){super(),this.accountAddress=e}authKey(){return new B({data:this.accountAddress.toUint8Array()})}verifySignature(e){throw new Error("This function is not implemented for AbstractPublicKey.")}async verifySignatureAsync(e){throw new Error("This function is not implemented for AbstractPublicKey.")}serialize(e){throw new Error("This function is not implemented for AbstractPublicKey.")}};var _ed25519 = require('@noble/curves/ed25519');var _hmac = require('@noble/hashes/hmac');var _sha512 = require('@noble/hashes/sha512');var _bip39 = require('@scure/bip39'); var go = _interopRequireWildcard(_bip39);var fc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,Ac= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,hc= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(hc||{}),mo= exports.HARDENED_OFFSET =2147483648;function yo(n){return Ac.test(n)}function fo(n){return fc.test(n)}var Zr=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},Ao= exports.CKDPriv =({key:n,chainCode:e},t)=>{let r=new ArrayBuffer(4);new DataView(r).setUint32(0,t);let i=new Uint8Array(r),o=new Uint8Array([0]),s=new Uint8Array([...o,...n,...i]);return Zr(e,s)},Tc=n=>n.replace(/'/g,""),ho= exports.splitPath =n=>n.split("/").slice(1).map(Tc),ir= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return go.mnemonicToSeedSync(e)};var bn=class bn{static formatPrivateKey(e,t){let r=bn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk66TIRJFDjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=bn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk66TIRJFDjs.j.fromHexInput(e),r!==!1&&console.warn("[Aptos SDK] It is recommended that private keys are AIP-80 compliant (https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-80.md). You can fix the private key by formatting it with `PrivateKey.formatPrivateKey(privateKey: string, type: 'ed25519' | 'secp256k1'): string`.");else if(e.startsWith(o))i=_chunk66TIRJFDjs.j.fromHexString(e.split("-")[2]);else throw r?new Error("Invalid HexString input while parsing private key. Must AIP-80 compliant string."):new Error("Invalid HexString input while parsing private key.");else i=_chunk66TIRJFDjs.j.fromHexInput(e);return i}};bn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var pt=bn;var Wt=n=>typeof n=="string"?_chunk66TIRJFDjs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var ei=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function bc(n){let e=n.toUint8Array().slice(32);for(let t=ei.length-1;t>=0;t-=1){if(e[t]<ei[t])return!0;if(e[t]>ei[t])return!1}return!1}var dt=class dt extends ie{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==dt.LENGTH)throw new Error(`PublicKey length should be ${dt.LENGTH}`);this.key=t}verifySignature(e){let{message:t,signature:r}=e;if(!bc(r))return!1;let i=Wt(t),o=_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array(),s=r.toUint8Array(),a=this.key.toUint8Array();return _ed25519.ed25519.verify(s,o,a)}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return B.fromSchemeAndBytes({scheme:0,input:this.toUint8Array()})}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new dt(t)}static isPublicKey(e){return e instanceof dt}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _2 => _2.key, 'optionalAccess', _3 => _3.data, 'optionalAccess', _4 => _4.length])===dt.LENGTH}};dt.LENGTH=32;var I=dt,fe=class fe extends _chunk66TIRJFDjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==fe.LENGTH)throw new Error(`PrivateKey length should be ${fe.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new fe(e,!1)}static fromDerivationPath(e,t){if(!fo(e))throw new Error(`Invalid derivation path ${e}`);return fe.fromDerivationPathInner(e,ir(t))}static fromDerivationPathInner(e,t,r=mo){let{key:i,chainCode:o}=Zr(fe.SLIP_0010_SEED,t),s=ho(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>Ao(c,p+r),{key:i,chainCode:o});return new fe(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new I(e)}sign(e){let t=Wt(e),r=_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array(),i=_ed25519.ed25519.sign(r,this.signingKey.toUint8Array());return new K(i)}toUint8Array(){return this.signingKey.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.signingKey.toString()}toAIP80String(){return pt.formatPrivateKey(this.signingKey.toString(),"ed25519")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new fe(t,!1)}static isPrivateKey(e){return e instanceof fe}};fe.LENGTH=32,fe.SLIP_0010_SEED="ed25519 seed";var q=fe,Qt=class Qt extends M{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==Qt.LENGTH)throw new Error(`Signature length should be ${Qt.LENGTH}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Qt(t)}};Qt.LENGTH=64;var K=Qt;var lt=class n extends St{constructor(e){super();let t=e.constructor.name;switch(t){case I.name:this.publicKey=e,this.variant=0;break;default:throw new Error(`Unsupported key for EphemeralPublicKey - ${t}`)}}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){return this.verifySignature(e)}serialize(e){if(this.publicKey instanceof I)e.serializeU32AsUleb128(0),this.publicKey.serialize(e);else throw new Error("Unknown public key type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(I.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}}static isPublicKey(e){return e instanceof n}},Ue= exports.EphemeralSignature =class n extends M{constructor(e){super();let t=e.constructor.name;switch(t){case K.name:this.signature=e;break;default:throw new Error(`Unsupported signature for EphemeralSignature - ${t}`)}}static fromHex(e){let t=_chunk66TIRJFDjs.j.fromHexInput(e),r=new R(t.toUint8Array());return n.deserialize(r)}serialize(e){if(this.signature instanceof K)e.serializeU32AsUleb128(0),this.signature.serialize(e);else throw new Error("Unknown signature type")}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(K.deserialize(e));default:throw new Error(`Unknown variant index for EphemeralSignature: ${t}`)}}};var _jwtdecode = require('jwt-decode');var _poseidonlite = require('poseidon-lite');var ti=[_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],bo=31,Fc=16,To=(Fc-1)*bo;function ke(n,e){let r=new TextEncoder().encode(n);return Oc(r,e)}function Oc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=wn(n,e);return Pt(t)}function Gc(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);let t=Vc(n,e);return Bc(t)}function wn(n,e){if(n.length>e)throw new Error(`Input bytes of length ${n} is longer than ${e}`);return Gc(n,e).concat([BigInt(n.length)])}function Bc(n){if(n.length>To)throw new Error(`Can't pack more than ${To}. Was given ${n.length} bytes`);return Mc(n,bo).map(e=>Et(e))}function Mc(n,e){let t=[];for(let r=0;r<n.length;r+=e)t.push(n.subarray(r,r+e));return t}function Et(n){let e=BigInt(0);for(let t=n.length-1;t>=0;t-=1)e=e<<BigInt(8)|BigInt(n[t]);return e}function ni(n,e){let t=BigInt(n),r=new Uint8Array(e);for(let i=0;i<e;i+=1)r[i]=Number(t&BigInt(255)),t>>=BigInt(8);return r}function Vc(n,e){if(e<n.length)throw new Error("Padded size must be greater than or equal to the input array size.");let t=new Uint8Array(e);t.set(n);for(let r=n.length;r<e;r+=1)t[r]=0;return t}function Pt(n){if(n.length>ti.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${ti.length}`);return ti[n.length-1](n)}var sr=class extends _chunk66TIRJFDjs.l{};var wo="1.39.0";var So={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"},Eo= 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"},Po= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},ri= exports.NetworkToPepperAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/pepper/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/pepper/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/pepper/v0",local:"https://api.devnet.aptoslabs.com/keyless/pepper/v0"},ii= exports.NetworkToProverAPI ={mainnet:"https://api.mainnet.aptoslabs.com/keyless/prover/v0",testnet:"https://api.testnet.aptoslabs.com/keyless/prover/v0",devnet:"https://api.devnet.aptoslabs.com/keyless/prover/v0",local:"https://api.devnet.aptoslabs.com/keyless/prover/v0"},oi= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(oi||{}),si= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Il= exports.NetworkToNetworkName ={mainnet:"mainnet",testnet:"testnet",devnet:"devnet",local:"local",custom:"custom"};var _t=(o=>(o.FULLNODE="Fullnode",o.INDEXER="Indexer",o.FAUCET="Faucet",o.PEPPER="Pepper",o.PROVER="Prover",o))(_t||{}),_o= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,xo= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,ar= exports.DEFAULT_TXN_TIMEOUT_SEC =20,xt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",Io= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Co= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",ai= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",He= exports.ProcessorType =(c=>(c.ACCOUNT_TRANSACTION_PROCESSOR="account_transactions_processor",c.DEFAULT="default_processor",c.EVENTS_PROCESSOR="events_processor",c.FUNGIBLE_ASSET_PROCESSOR="fungible_asset_processor",c.STAKE_PROCESSOR="stake_processor",c.TOKEN_V2_PROCESSOR="token_v2_processor",c.USER_TRANSACTION_PROCESSOR="user_transaction_processor",c.OBJECT_PROCESSOR="objects_processor",c))(He||{}),vo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Ko(n,e){let t=e.bcsToBytes(),r=new R(t);return n.deserialize(r)}var Hc=(s=>(s[s.API_ERROR=0]="API_ERROR",s[s.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",s[s.SESSION_EXPIRED=2]="SESSION_EXPIRED",s[s.INVALID_STATE=3]="INVALID_STATE",s[s.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",s[s.UNKNOWN=5]="UNKNOWN",s))(Hc||{}),Lc= exports.KeylessErrorResolutionTip =(p=>(p.REAUTHENTICATE="Re-authentiate to continue using your keyless account",p.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",p.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",p.RATE_LIMIT_EXCEEDED="Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest.",p.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",p.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",p.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",p))(Lc||{}),cr= exports.KeylessErrorType =(y=>(y[y.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",y[y.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",y[y.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",y[y.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",y[y.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",y[y.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",y[y.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",y[y.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",y[y.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",y[y.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",y[y.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",y[y.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",y[y.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",y[y.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",y[y.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",y[y.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",y[y.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",y[y.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",y[y.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",y[y.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",y[y.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",y[y.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",y[y.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",y[y.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",y[y.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",y[y.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",y[y.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",y[y.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",y[y.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",y[y.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",y[y.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",y[y.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",y[y.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",y[y.UNKNOWN=33]="UNKNOWN",y))(cr||{}),Ro={0:["The ephemeral keypair has expired.",2,"Re-authentiate to continue using your keyless account"],1:["The required proof could not be found.",3,"Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing."],2:["The required proof failed to fetch.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],3:["The provided proof is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],4:["The verification key used to authenticate was updated.",2,"Re-authentiate to continue using your keyless account"],5:["The JWK was found, but JWT failed verification",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],6:["The JWK required to verify the JWT could not be found. The JWK may have been rotated out.",2,"Re-authentiate to continue using your keyless account"],7:["The JWT issuer is not recognized.",3,"Update the invalid request parameters and reauthenticate."],8:["The JWT issuer is not supported by the Federated Keyless ",0,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],9:["The training wheels signature is invalid.",3,"Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support"],10:["The public key used to verify the training wheels signature was not found.",2,"Re-authentiate to continue using your keyless account"],11:["The expiry horizon is invalid.",2,"Re-authentiate to continue using your keyless account"],13:["Failed to fetch JWKS.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],14:["Failed to fetch JWKS for Federated Keyless provider.",1,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],15:["Rate limit exceeded. Too many requests in a short period.",0,"Cache the keyless account and reuse it to avoid making too many requests. Keyless accounts are valid until either the EphemeralKeyPair expires, when the JWK is rotated, or when the proof verifying key is changed, whichever comes soonest."],16:["Internal error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],17:["Bad request sent to Pepper service.",0,"Update the invalid request parameters and reauthenticate."],18:["Unknown error from Pepper service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],19:["Internal error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],20:["Bad request sent to Prover service.",0,"Update the invalid request parameters and reauthenticate."],21:["Unknown error from Prover service.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],12:["Error when parsing JWT. This should never happen. Join https://t.me/+h5CN-W35yUFiYzkx for support",3,"Try instantiating the account again. Avoid manipulating the account object directly"],22:["Error when looking up on-chain keyless configuration.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],23:["Error when looking up on-chain verification key.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],24:["Error when looking up on-chain JWKS.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],25:["Unknown error from full node.",0,"Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],26:["The signature is not a valid Keyless signature.",4,"For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"],27:["The ephemeral key pair used to sign the message has expired.",4,"Re-authentiate to continue using your keyless account"],28:["The expiry horizon on the signature exceeds the maximum allowed value.",4,"Re-authentiate to continue using your keyless account"],29:["Failed to verify the ephemeral signature with the ephemeral public key.",4,"Re-authentiate to continue using your keyless account"],30:["The training wheels signature is missing but is required by the Keyless configuration.",4,"Re-authentiate to continue using your keyless account"],31:["Failed to verify the training wheels signature with the training wheels public key.",4,"Re-authentiate to continue using your keyless account"],32:["The proof verification failed.",4,"Re-authentiate to continue using your keyless account"],33:["An unknown error has occurred.",5,"Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx"]},P= exports.KeylessError =class n extends Error{constructor(e){let{innerError:t,category:r,resolutionTip:i,type:o,message:s=Ro[o][0],details:a}=e;super(s),this.name="KeylessError",this.innerError=t,this.category=r,this.resolutionTip=i,this.type=o,this.details=a,this.message=n.constructMessage(s,i,t,a)}static constructMessage(e,t,r,i){let o=`
|
|
2
2
|
Message: ${e}`;return i&&(o+=`
|
|
3
3
|
Details: ${i}`),r instanceof Ae?o+=`
|
|
4
4
|
AptosApiError: ${r.message}`:r!==void 0&&(o+=`
|
|
5
5
|
Error: ${_chunk66TIRJFDjs.ca.call(void 0, r)}`),o+=`
|
|
6
|
-
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Ro[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Ae= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(Hc({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function Hc({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _5 => _5.headers, 'optionalAccess', _6 => _6.traceparent, 'optionalAccess', _7 => _7.split, 'call', _8 => _8("-"), 'access', _9 => _9[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _10 => _10.data, 'optionalAccess', _11 => _11.errors, 'optionalAccess', _12 => _12[0], 'optionalAccess', _13 => _13.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _14 => _14.data, 'optionalAccess', _15 => _15.message])!=null&&_optionalChain([t, 'access', _16 => _16.data, 'optionalAccess', _17 => _17.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${Lc(t.data)}`}var ci=400;function Lc(n){let e=JSON.stringify(n);return e.length<=ci?e:`truncated(original_size:${e.length}): ${e.slice(0,ci/2)}...${e.slice(-ci/2)}`}async function qc(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _18 => _18.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${wo}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _19 => _19.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _20 => _20.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _21 => _21.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _22 => _22.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:p,overrides:a})}async function ur(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await qc({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a})}async function pr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return ur({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function V(n){let{aptosConfig:e}=n;return pr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _23 => _23.clientConfig, 'optionalAccess', _24 => _24.HEADERS]),..._optionalChain([e, 'access', _25 => _25.fullnodeConfig, 'optionalAccess', _26 => _26.HEADERS])}}})}async function Zl(n){return pr({...n,type:"Pepper"})}async function dr(n){let e=new Array(0),t,r=n.params;do{let i=await pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function ui(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await lr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _27 => _27.params])&&(n.params.start=t),i!==void 0){let a=i-e.length;if(a<=0)break;r.limit=a}}while(t!=null);return e}async function lr(n){let e,t={};typeof _optionalChain([n, 'access', _28 => _28.params, 'optionalAccess', _29 => _29.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _30 => _30.params, 'optionalAccess', _31 => _31.limit])=="number"&&(t.limit=n.params.limit);let r=await pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:t,overrides:n.overrides});return e=r.headers["x-aptos-cursor"],{response:r,cursor:e}}async function Sn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,l=c.getRequestUrl(e);return ur({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function gt(n){let{aptosConfig:e}=n;return Sn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function Uo(n){let{aptosConfig:e}=n;return Sn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.indexerConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function ko(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _40 => _40.clientConfig, 'optionalAccess', _41 => delete _41.API_KEY]),Sn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _42 => _42.clientConfig, 'optionalAccess', _43 => _43.HEADERS]),..._optionalChain([t, 'access', _44 => _44.faucetConfig, 'optionalAccess', _45 => _45.HEADERS])}}})}async function Do(n){return Sn({...n,type:"Pepper"})}async function zo(n){return Sn({...n,type:"Prover"})}var pi=new Map;function De(n,e,t){return async(...r)=>{if(pi.has(e)){let{value:o,timestamp:s}=pi.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return pi.set(e,{value:i,timestamp:Date.now()}),i}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var jc=1e7,di= exports.MAX_AUD_VAL_BYTES =120,Jc= exports.MAX_UID_KEY_BYTES =30,Xc= exports.MAX_UID_VAL_BYTES =330,Yc= exports.MAX_ISS_VAL_BYTES =120,Zc= exports.MAX_EXTRA_FIELD_BYTES =350,eu= exports.MAX_JWT_HEADER_B64_BYTES =300,tu= exports.MAX_COMMITED_EPK_BYTES =93,ze=class ze extends ie{constructor(e,t){super();let r=_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array();if(r.length!==ze.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${ze.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunk66TIRJFDjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return gr({...e,publicKey:this}),!0}catch(t){if(t instanceof P)return!1;throw t}}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new ze(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new ze(t,r)}static isPublicKey(e){return e instanceof ze}static create(e){return No(e),new ze(e.iss,No(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return ze.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};ze.ID_COMMITMENT_LENGTH=32;var U=ze;async function Ai(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});return gr({message:r,publicKey:t,signature:i,jwk:o||await hi({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _46 => _46.throwErrorWithReason]))throw c;return!1}}function gr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ue))throw P.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let p=r.ephemeralCertificate.signature;if(!(p.proof.proof instanceof mt))throw P.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=p.proof.proof;if(r.expiryDateSecs<_chunk66TIRJFDjs.da.call(void 0, ))throw P.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(p.expHorizonSecs>a)throw P.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw P.fromErrorType({type:29});let h=nu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:h,groth16Proof:l}))throw P.fromErrorType({type:32});if(c){if(!p.trainingWheelsSignature)throw P.fromErrorType({type:30});let d=new gi(l,h);if(!c.verifySignature({message:d.hash(),signature:p.trainingWheelsSignature}))throw P.fromErrorType({type:31})}}function nu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof U?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ue))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...wn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Et(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(ke(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(ke(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(ke(" ",i.maxExtraFieldBytes))),a.push(ke(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(ke(s.overrideAudVal,di)),a.push(1n)):(a.push(ke("",di)),a.push(0n)),Pt(a)}async function hi(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof U?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof Z?t.jwkAddress:void 0;try{s=await ou({aptosConfig:e,jwkAddr:a})}catch(l){throw P.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw P.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let p=c.find(l=>l.kid===r);if(p===void 0)throw P.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return p}function No(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Et(_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array()),ke(r,di),ke(t,Xc),ke(e,Jc)];return ni(Pt(o),U.ID_COMMITMENT_LENGTH)}var he=class n extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return au(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=jt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=lt.deserialize(e),s=Ue.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new jt(new ue({proof:new Jt(new mt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new lt(new I(new Uint8Array(32))),ephemeralSignature:new Ue(new K(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},jt= exports.EphemeralCertificate =class n extends M{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ue.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},En=class En extends _chunk66TIRJFDjs.l{constructor(e){if(super(),this.data=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new En(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=_bn254.bn254.fields,i=r.create(li(e)),o=r.sqrt(r.add(r.pow(i,3n),En.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};En.B=_bn254.bn254.fields.Fp.create(3n);var Le=En;function li(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,_utils.bytesToNumberBE.call(void 0, e)}var Pn=class Pn extends _chunk66TIRJFDjs.l{constructor(e){if(super(),this.data=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new Pn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=_bn254.bn254.fields,s=o.fromBigTuple([li(t),li(r)]),a=o.sqrt(o.add(o.pow(s,3n),Pn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return _bn254.bn254.G2.ProjectivePoint.fromAffine({x:s,y:l})}};Pn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Pn,mt= exports.Groth16Zkp =class n extends sr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new Le(t),this.b=new It(r),this.c=new Le(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Le.deserialize(e).bcsToBytes(),r=It.deserialize(e).bcsToBytes(),i=Le.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},gi= exports.Groth16ProofAndStatement =class n extends _chunk66TIRJFDjs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ni(r,32):_chunk66TIRJFDjs.j.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(mt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return yt(this.bcsToBytes(),this.domainSeparator)}},Jt= exports.ZkProof =class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(mt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ue= exports.ZeroKnowledgeSig =class n extends M{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new R(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Jt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ue);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},mi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=jc,maxExtraFieldBytes:o=Zc,maxJwtHeaderB64Bytes:s=eu,maxIssValBytes:a=Yc,maxCommitedEpkBytes:c=tu}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new lt(new I(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new yi({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},yi= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Le(t),this.betaG2=new It(r),this.deltaG2=new It(i),this.gammaAbcG1=[new Le(o[0]),new Le(o[1])],this.gammaG2=new It(s)}hash(){let e=new _chunk66TIRJFDjs.m;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),p=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),h=this.gammaAbcG1.map(at=>at.toProjectivePoint()),{Fp12:d}=_bn254.bn254.fields,g=h[0].add(h[1].multiply(t)),b=_bn254.bn254.pairing(g,p),v=_bn254.bn254.pairing(i,o),W=_bn254.bn254.pairing(a,c),Me=_bn254.bn254.pairing(s,l),st=d.mul(W,d.mul(b,Me));return d.eql(v,st)}catch(i){throw P.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Xt(n){let{aptosConfig:e}=n;try{return await De(async()=>{let[t,r]=await Promise.all([ru(n),iu(n)]);return mi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof P?t:P.fromErrorType({type:25,error:t})}}function qe(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw P.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunk66TIRJFDjs.ca.call(void 0, o)}`})}if(typeof r.iss!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function ru(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk66TIRJFDjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _47 => _47.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function iu(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk66TIRJFDjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _48 => _48.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function ou(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _49 => _49.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _50 => _50.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:p}=c.variant,l=new R(_chunk66TIRJFDjs.j.fromHexInput(p).toUint8Array()),h=fi.deserialize(l);a.push(h)}o.set(_chunk66TIRJFDjs.k.call(void 0, s.issuer),a)}return o}var fi=class n extends _chunk66TIRJFDjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new R(_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw P.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunk66TIRJFDjs.ga.call(void 0, this.n),r=su(e.reverse()).map(i=>Et(i));return r.push(256n),Pt(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function su(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function au(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var Z=class n extends ie{constructor(e,t){super(),this.jwkAddress=_chunk66TIRJFDjs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk66TIRJFDjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return gr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=U.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,U.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,U.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk66TIRJFDjs.Z&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof U}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ce=class Ce extends St{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Ce.LENGTH)this.key=t;else if(r===Ce.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunk66TIRJFDjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ce.LENGTH} or ${Ce.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=Wt(t),o=_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new Ct(t)}static deserialize(e){let t=e.deserializeBytes();return new Ce(t)}static isPublicKey(e){return e instanceof Ce}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _51 => _51.key, 'optionalAccess', _52 => _52.data, 'optionalAccess', _53 => _53.length])===Ce.LENGTH}};Ce.LENGTH=65,Ce.COMPRESSED_LENGTH=33;var $e=Ce,Ne=class Ne extends _chunk66TIRJFDjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Ne.LENGTH)throw new Error(`PrivateKey length should be ${Ne.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ne(e,!1)}static fromDerivationPath(e,t){if(!yo(e))throw new Error(`Invalid derivation path ${e}`);return Ne.fromDerivationPathInner(e,ir(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Ne(r,!1)}sign(e){let t=Wt(e),r=_chunk66TIRJFDjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new Ct(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new $e(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return pt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ne(t,!1)}static isPrivateKey(e){return e instanceof Ne}};Ne.LENGTH=32;var We=Ne,Yt=class Yt extends M{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==Yt.LENGTH)throw new Error(`Signature length should be ${Yt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Yt(t)}};Yt.LENGTH=64;var Ct=Yt;var N=class n extends ie{constructor(e){if(super(),this.publicKey=e,e instanceof I)this.variant=0;else if(e instanceof $e)this.variant=1;else if(e instanceof U)this.variant=3;else if(e instanceof Z)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof U)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof H)){if(_optionalChain([e, 'access', _54 => _54.options, 'optionalAccess', _55 => _55.throwErrorWithReason]))throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return B.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=I.deserialize(e);break;case 1:r=$e.deserialize(e);break;case 3:r=U.deserialize(e);break;case 4:r=Z.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof I}isSecp256k1PublicKey(){return this.publicKey instanceof $e}static isInstance(e){return"publicKey"in e&&"variant"in e}},H= exports.AnySignature =class n extends M{constructor(e){if(super(),this.signature=e,e instanceof K)this.variant=0;else if(e instanceof Ct)this.variant=1;else if(e instanceof he)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=K.deserialize(e);break;case 1:r=Ct.deserialize(e);break;case 3:r=he.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function uu(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var xn=class extends ie{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),p=i[c];p|=r>>s%8,i[c]=p}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},Oe= exports.MultiKey =class n extends xn{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof N?i:new N(i)),this.signaturesRequired=r}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Fe))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.throwErrorWithReason]))throw r;return!1}}authKey(){return B.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(N),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof N?e:new N(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},pe=class pe extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${pe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof H?o:new H(o)),!(r instanceof Uint8Array))this.bitmap=pe.createBitmap({bits:r});else{if(r.length!==pe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${pe.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+uu(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${pe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)r&128>>i&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(H),r=e.deserializeBytes();return new pe({signatures:t,bitmap:r})}};pe.BITMAP_LEN=4,pe.MAX_SIGNATURES_SUPPORTED=pe.BITMAP_LEN*8;var Fe=pe;var Te=class Te extends xn{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>Te.MAX_KEYS||t.length<Te.MIN_KEYS)throw new Error(`Must have between ${Te.MIN_KEYS} and ${Te.MAX_KEYS} public keys, inclusive`);if(r<Te.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${Te.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Qe))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*I.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*I.LENGTH)}),e[this.publicKeys.length*I.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new Te({publicKeys:i,threshold:r})}getIndex(e){return super.getIndex(e)}};Te.MAX_KEYS=32,Te.MIN_KEYS=2,Te.MIN_THRESHOLD=1;var Zt=Te,de=class de extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>de.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${de.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=de.createBitmap({bits:r});else{if(r.length!==de.BITMAP_LEN)throw new Error(`"bitmap" length should be ${de.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*K.LENGTH+de.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*K.LENGTH)}),e.set(this.bitmap,this.signatures.length*K.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=K.LENGTH){let s=o;i.push(new K(t.subarray(s,s+K.LENGTH)))}return new de({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=de.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${de.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),p=i[c];p|=r>>s%8,i[c]=p}),i}};de.MAX_SIGNATURES_SUPPORTED=32,de.BITMAP_LEN=4;var Qe=de;var j=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ve.load(e);case 1:return je.load(e);case 2:return oe.load(e);case 3:return Ge.load(e);case 4:return en.load(e);case 5:return vt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof ve}isMultiEd25519(){return this instanceof je}isSingleKey(){return this instanceof oe}isMultiKey(){return this instanceof Ge}},ve= exports.AccountAuthenticatorEd25519 =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=I.deserialize(e),r=K.deserialize(e);return new n(t,r)}},je= exports.AccountAuthenticatorMultiEd25519 =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Zt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},oe= exports.AccountAuthenticatorSingleKey =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=N.deserialize(e),r=H.deserialize(e);return new n(t,r)}},Ge= exports.AccountAuthenticatorMultiKey =class n extends j{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Oe.deserialize(e),r=Fe.deserialize(e);return new n(t,r)}},en= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends j{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},vt= exports.AccountAuthenticatorAbstraction =class n extends j{constructor(e,t,r,i){if(super(),!_chunk66TIRJFDjs.ma.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=r,this.signingMessageDigest=_chunk66TIRJFDjs.j.fromHexInput(_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, this.functionInfo);_chunk66TIRJFDjs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.authenticator):e.serializeFixedBytes(this.authenticator),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let s=e.deserializeBytes(),a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var tn=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var k=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var In=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(_chunk66TIRJFDjs.Z.fromString(t[0]),new k(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e);return new n(t,r)}};var F=class n extends _chunk66TIRJFDjs.l{deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(n);return new Be(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return L.load(e);case 1:return le.load(e);case 2:return J.load(e);case 3:return Ye.load(e);case 4:return O.load(e);case 5:return Kt.load(e);case 6:return C.load(e);case 7:return A.load(e);case 8:return Je.load(e);case 9:return Xe.load(e);case 10:return Ze.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof L}isAddress(){return this instanceof O}isGeneric(){return this instanceof G}isSigner(){return this instanceof Kt}isVector(){return this instanceof C}isStruct(){return this instanceof A}isU8(){return this instanceof le}isU16(){return this instanceof Je}isU32(){return this instanceof Xe}isU64(){return this instanceof J}isU128(){return this instanceof Ye}isU256(){return this instanceof Ze}isPrimitive(){return this instanceof Kt||this instanceof O||this instanceof L||this instanceof le||this instanceof Je||this instanceof Xe||this instanceof J||this instanceof Ye||this instanceof Ze}},L= exports.TypeTagBool =class n extends F{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},le= exports.TypeTagU8 =class n extends F{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Je= exports.TypeTagU16 =class n extends F{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Xe= exports.TypeTagU32 =class n extends F{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},J= exports.TypeTagU64 =class n extends F{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Ye= exports.TypeTagU128 =class n extends F{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Ze= exports.TypeTagU256 =class n extends F{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},O= exports.TypeTagAddress =class n extends F{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Kt= exports.TypeTagSigner =class n extends F{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},mr= exports.TypeTagReference =class n extends F{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=F.deserialize(t);return new n(r)}},G= exports.TypeTagGeneric =class n extends F{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends F{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new le)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=F.deserialize(t);return new n(r)}},A= exports.TypeTagStruct =class n extends F{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=Be.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"rate_limiter","RateLimiter")}},Be= exports.StructTag =class n extends _chunk66TIRJFDjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(F);return new n(t,r,i,o)}};function $y(){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("aptos_coin"),new k("AptosCoin"),[])}function _(){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("string"),new k("String"),[])}function Wy(n){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("option"),new k("Option"),[n])}function ge(n){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("object"),new k("Object"),[n])}function pu(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return X.deserialize(n);case 1:return Q.deserialize(n);case 2:return xe.deserialize(n);case 3:return _chunk66TIRJFDjs.Z.deserialize(n);case 4:return S.deserialize(n,X);case 5:return z.deserialize(n);case 6:return Pe.deserialize(n);case 7:return _e.deserialize(n);case 8:return ye.deserialize(n);case 9:return hn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Rt=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ut.load(e);case 2:return Cn.load(e);case 3:return vn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Ut= exports.TransactionPayloadScript =class n extends Rt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Kn.deserialize(e);return new n(t)}},Cn= exports.TransactionPayloadEntryFunction =class n extends Rt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=kt.deserialize(e);return new n(t)}},vn= exports.TransactionPayloadMultiSig =class n extends Rt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Rn.deserialize(e);return new n(t)}},kt= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(In.fromStr(e),new k(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=In.deserialize(e),r=k.deserialize(e),i=e.deserializeVector(F),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=nr.deserialize(e,c);s.push(p)}return new n(t,r,i,s)}},Kn= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(F),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=pu(e);o.push(a)}return new n(t,r,o)}},Rn= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Un.deserialize(e)),new n(t,i)}},Un= exports.MultiSigTransactionPayload =class n extends _chunk66TIRJFDjs.l{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(kt.deserialize(e))}};var be=class n extends _chunk66TIRJFDjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeU64(),i=Rt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=tn.deserialize(e);return new n(t,r,i,o,s,a,c)}},yr= exports.RawTransactionWithData =class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Dt.load(e);case 1:return zt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Dt= exports.MultiAgentRawTransaction =class n extends yr{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z);return new n(t,r)}},zt= exports.FeePayerRawTransaction =class n extends yr{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=_chunk66TIRJFDjs.Z.deserialize(e);return new n(t,r,i)}};var fr=class extends _chunk66TIRJFDjs.l{constructor(t){super();this.accountAddress=_chunk66TIRJFDjs.Z.ONE;this.moduleName=new x("account");this.structName=new x("RotationProofChallenge");this.sequenceNumber=new Q(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var et=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Nt.load(e);case 1:return nn.load(e);case 2:return Ot.load(e);case 3:return Ft.load(e);case 4:return ft.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Nt}isMultiEd25519(){return this instanceof nn}isMultiAgent(){return this instanceof Ot}isFeePayer(){return this instanceof Ft}isSingleSender(){return this instanceof ft}},Nt= exports.TransactionAuthenticatorEd25519 =class n extends et{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=I.deserialize(e),r=K.deserialize(e);return new n(t,r)}},nn= exports.TransactionAuthenticatorMultiEd25519 =class n extends et{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Zt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},Ot= exports.TransactionAuthenticatorMultiAgent =class n extends et{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=j.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeVector(j);return new n(t,r,i)}},Ft= exports.TransactionAuthenticatorFeePayer =class n extends et{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=j.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeVector(j),o=_chunk66TIRJFDjs.Z.deserialize(e),s=j.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ft= exports.TransactionAuthenticatorSingleSender =class n extends et{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=j.deserialize(e);return new n(t)}};var tt=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=be.deserialize(e),r=et.deserialize(e);return new n(t,r)}};var rn=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=be.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk66TIRJFDjs.Z.deserialize(e)),new n(t,i)}};var Ar=class n extends _chunk66TIRJFDjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeBool(),o;return i&&(o=_chunk66TIRJFDjs.Z.deserialize(e)),new n(t,r,o)}};function hr(n){return n.feePayerAddress?new zt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Dt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function yt(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function oA(n){return yt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ke(n){let e=hr(n);return n.feePayerAddress?yt(e.bcsToBytes(),ai):n.secondarySignerAddresses?yt(e.bcsToBytes(),ai):yt(e.bcsToBytes(),Co)}var se=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=q.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=q.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ve(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new ve(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ke(e))}};function Ti(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var we=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new N(t.publicKey()),this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=q.generate();break;case 2:r=We.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=We.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new oe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new oe(this.publicKey,this.signTransaction(e))}sign(e){return new H(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ke(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var nt=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?se.generate():we.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new se({privateKey:t,address:r}):new we({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?se.fromDerivationPath({mnemonic:r,path:i}):we.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};var _utils3 = require('@noble/hashes/utils');var gu=1209600,on=class on extends _chunk66TIRJFDjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new lt(t.publicKey()),this.expiryDateSecs=r||_chunk66TIRJFDjs.ea.call(void 0, _chunk66TIRJFDjs.da.call(void 0, )+gu),this.blinder=i!==void 0?_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array():mu();let o=wn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Et(this.blinder));let s=Pt(o);this.nonce=s.toString()}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 t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new on({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return on.deserialize(new R(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _58 => _58.scheme])){case 0:default:t=q.generate()}return new on({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _59 => _59.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ue(this.privateKey.sign(e))}};on.BLINDER_LENGTH=31;var Gt=on;function mu(){return _utils3.randomBytes.call(void 0, Gt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function br(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var sn=class sn extends _chunk66TIRJFDjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:p,proof:l,proofFetchCallback:h,jwt:d,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=d,this.emitter=new _eventemitter32.default,this.proofOrPromise=l,l instanceof ue)this.proof=l;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async v=>{await h(v),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunk66TIRJFDjs.j.fromHexInput(p).toUint8Array();if(b.length!==sn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${sn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunk66TIRJFDjs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk66TIRJFDjs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new N(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=_chunk66TIRJFDjs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Gt.deserialize(t),c=ue.deserialize(t),p=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:p}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new H(this.sign(t)),i=new N(this.publicKey);return new oe(i,r)}signTransactionWithAuthenticator(t){let r=new H(this.signTransaction(t)),i=new N(this.publicKey);return new oe(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw P.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw P.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw P.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Xt({aptosConfig:t});if(_chunk66TIRJFDjs.j.hexInputToString(i.hash())!==_chunk66TIRJFDjs.j.hexInputToString(this.verificationKeyHash))throw P.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await sn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw P.fromErrorType({type:0});if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new he({jwtHeader:_chunk66TIRJFDjs.fa.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new jt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=hr(t),o=new Tr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=hr(t);return new Tr(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return hi(t)}};sn.PEPPER_LENGTH=31;var me=sn,Tr= exports.TransactionAndProof =class extends _chunk66TIRJFDjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return yt(this.bcsToBytes(),this.domainSeparator)}};var rt=class n extends me{constructor(e){let t=U.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),{iss:p,aud:l,uidVal:h}=qe({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:h,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new R(_chunk66TIRJFDjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:p}=e,{iss:l,aud:h,uidVal:d}=qe({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:d,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var Bt=class n extends me{constructor(e){let t=Z.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),p=_chunk66TIRJFDjs.Z.deserialize(e),{iss:l,aud:h,uidVal:d}=qe({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:d,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return n.deserialize(R.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:l}=e,{iss:h,aud:d,uidVal:g}=qe({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:g,aud:d,pepper:s,jwkAddress:_chunk66TIRJFDjs.Z.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var kn=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof se?we.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new Oe({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Ge(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ge(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof me).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof me).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Fe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Fe({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var wr=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk66TIRJFDjs.Z.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new je(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new je(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Qe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Ke(e))}};function Go(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk66TIRJFDjs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk66TIRJFDjs.Z.deserialize(n),signingScheme:e}}function Bo(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Mo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Gt.deserialize(n),o=ue.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Vo;(h=>{function n(d){let g=new _chunk66TIRJFDjs.m;switch(g.serializeU32AsUleb128(d.signingScheme),d.accountAddress.serialize(g),d.signingScheme){case 0:return d.privateKey.serialize(g),g.toUint8Array();case 2:{if(!Ti(d))throw new Error("Account is not a SingleKeySigner");let b=d.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return Bo(d,g),g.toUint8Array();case 4:{let v=d;return Bo(v,g),v.publicKey.jwkAddress.serialize(g),g.serializeBool(v.audless),g.toUint8Array()}case 1:case 0:return d.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=d;return b.publicKey.serialize(g),g.serializeU32AsUleb128(b.signers.length),b.signers.forEach(v=>{g.serializeFixedBytes(n(v))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${d.signingScheme}`)}}h.toBytes=n;function e(d){return _chunk66TIRJFDjs.j.hexInputToStringWithoutPrefix(n(d))}h.toHexStringWithoutPrefix=e;function t(d){return _chunk66TIRJFDjs.j.hexInputToString(n(d))}h.toHexString=t;function r(d){let{address:g,signingScheme:b}=Go(d);switch(b){case 0:{let v=q.deserialize(d);return new se({privateKey:v,address:g})}case 2:{let v=d.deserializeUleb128AsU32();switch(v){case 0:{let W=q.deserialize(d);return new we({privateKey:W,address:g})}case 1:{let W=We.deserialize(d);return new we({privateKey:W,address:g})}case 3:{let W=Mo(d),Me=qe(W);return new rt({...W,...Me})}case 4:{let W=Mo(d),Me=_chunk66TIRJFDjs.Z.deserialize(d),st=d.deserializeBool(),at=qe(W);return new Bt({...W,...at,jwkAddress:Me,audless:st})}default:throw new Error(`Unsupported public key variant ${v}`)}}case 3:{let v=Oe.deserialize(d),W=d.deserializeUleb128AsU32(),Me=new Array;for(let st=0;st<W;st+=1){let at=r(d);if(!Ti(at)&&!(at instanceof se))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Me.push(at)}return new kn({multiKey:v,signers:Me,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=r;function i(d){let g=p(d);if(!(g instanceof rt))throw new Error("Deserialization of KeylessAccount failed");return g}h.keylessAccountFromHex=i;function o(d){let g=p(d);if(!(g instanceof Bt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}h.federatedKeylessAccountFromHex=o;function s(d){let g=p(d);if(!(g instanceof kn))throw new Error("Deserialization of MultiKeyAccount failed");return g}h.multiKeyAccountFromHex=s;function a(d){let g=p(d);if(!(g instanceof we))throw new Error("Deserialization of SingleKeyAccount failed");return g}h.singleKeyAccountFromHex=a;function c(d){let g=p(d);if(!(g instanceof se))throw new Error("Deserialization of Ed25519Account failed");return g}h.ed25519AccountFromHex=c;function p(d){return r(R.fromHex(d))}h.fromHex=p;function l(d){return p(d)}h.fromBytes=l})(Vo||(Vo= exports.AccountUtils ={}));var Sr=class n extends nt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk66TIRJFDjs.ma.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new rr(this.accountAddress),this.sign=o=>new Tn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk66TIRJFDjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new vt(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(Ke(t))}signTransaction(t){return this.sign(Ke(t))}setSigner(t){this.sign=r=>new Tn(t(r))}};var Dn=class Dn extends Sr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunk66TIRJFDjs.Z)(Dn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunk66TIRJFDjs.ma.call(void 0, e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=_sha3.sha3_256.create(),a=new _chunk66TIRJFDjs.m;_chunk66TIRJFDjs.Z.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunk66TIRJFDjs.m;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([Dn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new vt(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};Dn.ADDRESS_DOMAIN_SEPERATOR=5;var Lo=Dn;var Au=`
|
|
6
|
+
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Ro[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},Ae= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(qc({apiType:e,aptosRequest:t,aptosResponse:r})),this.name="AptosApiError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.data=r.data,this.request=t}};function qc({apiType:n,aptosRequest:e,aptosResponse:t}){let r=_optionalChain([t, 'access', _5 => _5.headers, 'optionalAccess', _6 => _6.traceparent, 'optionalAccess', _7 => _7.split, 'call', _8 => _8("-"), 'access', _9 => _9[1]]),i=r?`(trace_id:${r}) `:"",o=`Request to [${n}]: ${e.method} ${_nullishCoalesce(t.url, () => (e.url))} ${i}failed with`;return n==="Indexer"&&_optionalChain([t, 'access', _10 => _10.data, 'optionalAccess', _11 => _11.errors, 'optionalAccess', _12 => _12[0], 'optionalAccess', _13 => _13.message])!=null?`${o}: ${t.data.errors[0].message}`:_optionalChain([t, 'access', _14 => _14.data, 'optionalAccess', _15 => _15.message])!=null&&_optionalChain([t, 'access', _16 => _16.data, 'optionalAccess', _17 => _17.error_code])!=null?`${o}: ${JSON.stringify(t.data)}`:`${o} status: ${t.statusText}(code:${t.status}) and response body: ${$c(t.data)}`}var ci=400;function $c(n){let e=JSON.stringify(n);return e.length<=ci?e:`truncated(original_size:${e.length}): ${e.slice(0,ci/2)}...${e.slice(-ci/2)}`}async function Wc(n,e){let{url:t,method:r,body:i,contentType:o,params:s,overrides:a,originMethod:c}=n,p={..._optionalChain([a, 'optionalAccess', _18 => _18.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${wo}`,"content-type":_nullishCoalesce(o, () => ("application/json")),"x-aptos-typescript-sdk-origin-method":c};return _optionalChain([a, 'optionalAccess', _19 => _19.AUTH_TOKEN])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _20 => _20.AUTH_TOKEN])}`),_optionalChain([a, 'optionalAccess', _21 => _21.API_KEY])&&(p.Authorization=`Bearer ${_optionalChain([a, 'optionalAccess', _22 => _22.API_KEY])}`),e.provider({url:t,method:r,body:i,params:s,headers:p,overrides:a})}async function ur(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await Wc({...n,url:o},e.client),a={status:s.status,statusText:_nullishCoalesce(s.statusText, () => ("No status text provided")),data:s.data,headers:s.headers,config:s.config,request:s.request,url:o};if(a.status===401)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new Ae({apiType:t,aptosRequest:n,aptosResponse:a})}async function pr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return ur({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function V(n){let{aptosConfig:e}=n;return pr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _23 => _23.clientConfig, 'optionalAccess', _24 => _24.HEADERS]),..._optionalChain([e, 'access', _25 => _25.fullnodeConfig, 'optionalAccess', _26 => _26.HEADERS])}}})}async function eg(n){return pr({...n,type:"Pepper"})}async function dr(n){let e=new Array(0),t,r=n.params;do{let i=await pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});t=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),r.start=t}while(t!=null);return e}async function ui(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await lr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _27 => _27.params])&&(n.params.start=t),i!==void 0){let a=i-e.length;if(a<=0)break;r.limit=a}}while(t!=null);return e}async function lr(n){let e,t={};typeof _optionalChain([n, 'access', _28 => _28.params, 'optionalAccess', _29 => _29.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _30 => _30.params, 'optionalAccess', _31 => _31.limit])=="number"&&(t.limit=n.params.limit);let r=await pr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:t,overrides:n.overrides});return e=r.headers["x-aptos-cursor"],{response:r,cursor:e}}async function Sn(n){let{type:e,originMethod:t,path:r,body:i,acceptType:o,contentType:s,params:a,aptosConfig:c,overrides:p}=n,l=c.getRequestUrl(e);return ur({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function gt(n){let{aptosConfig:e}=n;return Sn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _32 => _32.clientConfig, 'optionalAccess', _33 => _33.HEADERS]),..._optionalChain([e, 'access', _34 => _34.fullnodeConfig, 'optionalAccess', _35 => _35.HEADERS])}}})}async function Uo(n){let{aptosConfig:e}=n;return Sn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.indexerConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function ko(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _40 => _40.clientConfig, 'optionalAccess', _41 => delete _41.API_KEY]),Sn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _42 => _42.clientConfig, 'optionalAccess', _43 => _43.HEADERS]),..._optionalChain([t, 'access', _44 => _44.faucetConfig, 'optionalAccess', _45 => _45.HEADERS])}}})}async function Do(n){return Sn({...n,type:"Pepper"})}async function zo(n){return Sn({...n,type:"Prover"})}var pi=new Map;function De(n,e,t){return async(...r)=>{if(pi.has(e)){let{value:o,timestamp:s}=pi.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return pi.set(e,{value:i,timestamp:Date.now()}),i}}var _bn254 = require('@noble/curves/bn254');var _utils = require('@noble/curves/abstract/utils');var _jsbase64 = require('js-base64');var Xc=1e7,di= exports.MAX_AUD_VAL_BYTES =120,Yc= exports.MAX_UID_KEY_BYTES =30,Zc= exports.MAX_UID_VAL_BYTES =330,eu= exports.MAX_ISS_VAL_BYTES =120,tu= exports.MAX_EXTRA_FIELD_BYTES =350,nu= exports.MAX_JWT_HEADER_B64_BYTES =300,ru= exports.MAX_COMMITED_EPK_BYTES =93,ze=class ze extends ie{constructor(e,t){super();let r=_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array();if(r.length!==ze.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${ze.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunk66TIRJFDjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return gr({...e,publicKey:this}),!0}catch(t){if(t instanceof P)return!1;throw t}}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new ze(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new ze(t,r)}static isPublicKey(e){return e instanceof ze}static create(e){return No(e),new ze(e.iss,No(e))}static fromJwtAndPepper(e){let{jwt:t,pepper:r,uidKey:i="sub"}=e,o=_jwtdecode.jwtDecode.call(void 0, t);if(typeof o.iss!="string")throw new Error("iss was not found");if(typeof o.aud!="string")throw new Error("aud was not found or an array of values");let s=o[i];return ze.create({iss:o.iss,uidKey:i,uidVal:s,aud:o.aud,pepper:r})}static isInstance(e){return"iss"in e&&typeof e.iss=="string"&&"idCommitment"in e&&e.idCommitment instanceof Uint8Array}};ze.ID_COMMITMENT_LENGTH=32;var U=ze;async function Ai(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await Xt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});return gr({message:r,publicKey:t,signature:i,jwk:o||await hi({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _46 => _46.throwErrorWithReason]))throw c;return!1}}function gr(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});if(!(r.ephemeralCertificate.signature instanceof ue))throw P.fromErrorType({type:26,details:"Unsupported ephemeral certificate variant"});let p=r.ephemeralCertificate.signature;if(!(p.proof.proof instanceof mt))throw P.fromErrorType({type:26,details:"Unsupported proof variant for ZeroKnowledgeSig"});let l=p.proof.proof;if(r.expiryDateSecs<_chunk66TIRJFDjs.da.call(void 0, ))throw P.fromErrorType({type:27,details:"The expiryDateSecs is in the past"});if(p.expHorizonSecs>a)throw P.fromErrorType({type:28});if(!r.ephemeralPublicKey.verifySignature({message:t,signature:r.ephemeralSignature}))throw P.fromErrorType({type:29});let h=iu({publicKey:e,signature:r,jwk:o,keylessConfig:i});if(!s.verifyProof({publicInputsHash:h,groth16Proof:l}))throw P.fromErrorType({type:32});if(c){if(!p.trainingWheelsSignature)throw P.fromErrorType({type:30});let d=new gi(l,h);if(!c.verifySignature({message:d.hash(),signature:p.trainingWheelsSignature}))throw P.fromErrorType({type:31})}}function iu(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof U?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof ue))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...wn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Et(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(ke(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(ke(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(ke(" ",i.maxExtraFieldBytes))),a.push(ke(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(ke(s.overrideAudVal,di)),a.push(1n)):(a.push(ke("",di)),a.push(0n)),Pt(a)}async function hi(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof U?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof Z?t.jwkAddress:void 0;try{s=await au({aptosConfig:e,jwkAddr:a})}catch(l){throw P.fromErrorType({type:24,error:l,details:`Failed to fetch ${a?"Federated":"Patched"}JWKs ${a?`for address ${a}`:"0x1"}`})}let c=s.get(o);if(c===void 0)throw P.fromErrorType({type:7,details:`JWKs for issuer ${o} not found.`});let p=c.find(l=>l.kid===r);if(p===void 0)throw P.fromErrorType({type:6,details:`JWK with kid '${r}' for issuer '${o}' not found.`});return p}function No(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Et(_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array()),ke(r,di),ke(t,Zc),ke(e,Yc)];return ni(Pt(o),U.ID_COMMITMENT_LENGTH)}var he=class n extends M{constructor(e){super();let{jwtHeader:t,ephemeralCertificate:r,expiryDateSecs:i,ephemeralPublicKey:o,ephemeralSignature:s}=e;this.jwtHeader=t,this.ephemeralCertificate=r,this.expiryDateSecs=i,this.ephemeralPublicKey=o,this.ephemeralSignature=s}getJwkKid(){return uu(this.jwtHeader).kid}serialize(e){this.ephemeralCertificate.serialize(e),e.serializeStr(this.jwtHeader),e.serializeU64(this.expiryDateSecs),this.ephemeralPublicKey.serialize(e),this.ephemeralSignature.serialize(e)}static deserialize(e){let t=jt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=lt.deserialize(e),s=Ue.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new jt(new ue({proof:new Jt(new mt({a:new Uint8Array(32),b:new Uint8Array(64),c:new Uint8Array(32)}),0),expHorizonSecs:0}),0),expiryDateSecs:0,ephemeralPublicKey:new lt(new I(new Uint8Array(32))),ephemeralSignature:new Ue(new K(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},jt= exports.EphemeralCertificate =class n extends M{constructor(e,t){super(),this.signature=e,this.variant=t}toUint8Array(){return this.signature.toUint8Array()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(ue.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},En=class En extends _chunk66TIRJFDjs.l{constructor(e){if(super(),this.data=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array(),this.data.length!==32)throw new Error("Input needs to be 32 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(32);return new En(t)}toArray(){let e=this.toProjectivePoint();return[e.x.toString(),e.y.toString(),e.pz.toString()]}toProjectivePoint(){let e=new Uint8Array(this.data);e.reverse();let t=(e[0]&128)>>7,{Fp:r}=_bn254.bn254.fields,i=r.create(li(e)),o=r.sqrt(r.add(r.pow(i,3n),En.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};En.B=_bn254.bn254.fields.Fp.create(3n);var Le=En;function li(n){if(n.length!==32)throw new Error("Input should be 32 bytes");let e=new Uint8Array(n);return e[0]=e[0]&63,_utils.bytesToNumberBE.call(void 0, e)}var Pn=class Pn extends _chunk66TIRJFDjs.l{constructor(e){if(super(),this.data=_chunk66TIRJFDjs.j.fromHexInput(e).toUint8Array(),this.data.length!==64)throw new Error("Input needs to be 64 bytes")}serialize(e){e.serializeFixedBytes(this.data)}static deserialize(e){let t=e.deserializeFixedBytes(64);return new Pn(t)}toArray(){let e=this.toProjectivePoint();return[[e.x.c0.toString(),e.x.c1.toString()],[e.y.c0.toString(),e.y.c1.toString()],[e.pz.c0.toString(),e.pz.c1.toString()]]}toProjectivePoint(){let e=new Uint8Array(this.data),t=e.slice(0,32).reverse(),r=e.slice(32,64).reverse(),i=(r[0]&128)>>7,{Fp2:o}=_bn254.bn254.fields,s=o.fromBigTuple([li(t),li(r)]),a=o.sqrt(o.add(o.pow(s,3n),Pn.B)),c=o.neg(a),l=(a.c1>c.c1||a.c1===c.c1&&a.c0>c.c0)===(i===1)?a:c;return _bn254.bn254.G2.ProjectivePoint.fromAffine({x:s,y:l})}};Pn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Pn,mt= exports.Groth16Zkp =class n extends sr{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new Le(t),this.b=new It(r),this.c=new Le(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=Le.deserialize(e).bcsToBytes(),r=It.deserialize(e).bcsToBytes(),i=Le.deserialize(e).bcsToBytes();return new n({a:t,b:r,c:i})}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",pi_a:this.a.toArray(),pi_b:this.b.toArray(),pi_c:this.c.toArray()}}},gi= exports.Groth16ProofAndStatement =class n extends _chunk66TIRJFDjs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ni(r,32):_chunk66TIRJFDjs.j.fromHexInput(r).toUint8Array(),this.publicInputsHash.length!==32)throw new Error("Invalid public inputs hash")}serialize(t){this.proof.serialize(t),t.serializeFixedBytes(this.publicInputsHash)}static deserialize(t){return new n(mt.deserialize(t),t.deserializeFixedBytes(32))}hash(){return yt(this.bcsToBytes(),this.domainSeparator)}},Jt= exports.ZkProof =class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.proof=e,this.variant=t}serialize(e){e.serializeU32AsUleb128(this.variant),this.proof.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return new n(mt.deserialize(e),t);default:throw new Error(`Unknown variant index for ZkProof: ${t}`)}}},ue= exports.ZeroKnowledgeSig =class n extends M{constructor(e){super();let{proof:t,expHorizonSecs:r,trainingWheelsSignature:i,extraField:o,overrideAudVal:s}=e;this.proof=t,this.expHorizonSecs=r,this.trainingWheelsSignature=i,this.extraField=o,this.overrideAudVal=s}static fromBytes(e){return n.deserialize(new R(e))}serialize(e){this.proof.serialize(e),e.serializeU64(this.expHorizonSecs),e.serializeOption(this.extraField),e.serializeOption(this.overrideAudVal),e.serializeOption(this.trainingWheelsSignature)}static deserialize(e){let t=Jt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Ue);return new n({proof:t,expHorizonSecs:r,trainingWheelsSignature:s,extraField:i,overrideAudVal:o})}},mi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Xc,maxExtraFieldBytes:o=tu,maxJwtHeaderB64Bytes:s=nu,maxIssValBytes:a=eu,maxCommitedEpkBytes:c=ru}=e;this.verificationKey=t,this.maxExpHorizonSecs=i,r&&(this.trainingWheelsPubkey=new lt(new I(r))),this.maxExtraFieldBytes=o,this.maxJwtHeaderB64Bytes=s,this.maxIssValBytes=a,this.maxCommitedEpkBytes=c}static create(e,t){return new n({verificationKey:new yi({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2}),maxExpHorizonSecs:Number(t.max_exp_horizon_secs),trainingWheelsPubkey:t.training_wheels_pubkey.vec[0],maxExtraFieldBytes:t.max_extra_field_bytes,maxJwtHeaderB64Bytes:t.max_jwt_header_b64_bytes,maxIssValBytes:t.max_iss_val_bytes,maxCommitedEpkBytes:t.max_commited_epk_bytes})}},yi= exports.Groth16VerificationKey =class n{constructor(e){let{alphaG1:t,betaG2:r,deltaG2:i,gammaAbcG1:o,gammaG2:s}=e;this.alphaG1=new Le(t),this.betaG2=new It(r),this.deltaG2=new It(i),this.gammaAbcG1=[new Le(o[0]),new Le(o[1])],this.gammaG2=new It(s)}hash(){let e=new _chunk66TIRJFDjs.m;return this.serialize(e),_sha3.sha3_256.create().update(e.toUint8Array()).digest()}serialize(e){this.alphaG1.serialize(e),this.betaG2.serialize(e),this.deltaG2.serialize(e),this.gammaAbcG1[0].serialize(e),this.gammaAbcG1[1].serialize(e),this.gammaG2.serialize(e)}static fromGroth16VerificationKeyResponse(e){return new n({alphaG1:e.alpha_g1,betaG2:e.beta_g2,deltaG2:e.delta_g2,gammaAbcG1:e.gamma_abc_g1,gammaG2:e.gamma_g2})}verifyProof(e){let{publicInputsHash:t,groth16Proof:r}=e;try{let i=r.a.toProjectivePoint(),o=r.b.toProjectivePoint(),s=r.c.toProjectivePoint(),a=this.alphaG1.toProjectivePoint(),c=this.betaG2.toProjectivePoint(),p=this.gammaG2.toProjectivePoint(),l=this.deltaG2.toProjectivePoint(),h=this.gammaAbcG1.map(at=>at.toProjectivePoint()),{Fp12:d}=_bn254.bn254.fields,g=h[0].add(h[1].multiply(t)),b=_bn254.bn254.pairing(g,p),v=_bn254.bn254.pairing(i,o),W=_bn254.bn254.pairing(a,c),Me=_bn254.bn254.pairing(s,l),st=d.mul(W,d.mul(b,Me));return d.eql(v,st)}catch(i){throw P.fromErrorType({type:32,error:i,details:"Error encountered when checking zero knowledge relation"})}}toSnarkJsJson(){return{protocol:"groth16",curve:"bn128",nPublic:1,vk_alpha_1:this.alphaG1.toArray(),vk_beta_2:this.betaG2.toArray(),vk_gamma_2:this.gammaG2.toArray(),vk_delta_2:this.deltaG2.toArray(),IC:this.gammaAbcG1.map(e=>e.toArray())}}};async function Xt(n){let{aptosConfig:e}=n;try{return await De(async()=>{let[t,r]=await Promise.all([ou(n),su(n)]);return mi.create(r,t)},`keyless-configuration-${e.network}`,1e3*60*5)()}catch(t){throw t instanceof P?t:P.fromErrorType({type:25,error:t})}}function qe(n){let{jwt:e,uidKey:t="sub"}=n,r;try{r=_jwtdecode.jwtDecode.call(void 0, e)}catch(o){throw P.fromErrorType({type:12,details:`Failed to parse JWT - ${_chunk66TIRJFDjs.ca.call(void 0, o)}`})}if(typeof r.iss!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'iss' in the payload. This should never happen."});if(typeof r.aud!="string")throw P.fromErrorType({type:12,details:"JWT is missing 'aud' in the payload or 'aud' is an array of values."});let i=r[t];return{iss:r.iss,aud:r.aud,uidVal:i}}async function ou(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk66TIRJFDjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _47 => _47.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function su(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk66TIRJFDjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _48 => _48.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function au(n){let{aptosConfig:e,jwkAddr:t,options:r}=n,i;if(t){let s="0x1::jwks::FederatedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _49 => _49.ledgerVersion])}});i=a}else{let s="0x1::jwks::PatchedJWKs",{data:a}=await V({aptosConfig:e,originMethod:"getKeylessJWKs",path:`accounts/0x1/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _50 => _50.ledgerVersion])}});i=a}let o=new Map;for(let s of i.data.jwks.entries){let a=[];for(let c of s.jwks){let{data:p}=c.variant,l=new R(_chunk66TIRJFDjs.j.fromHexInput(p).toUint8Array()),h=fi.deserialize(l);a.push(h)}o.set(_chunk66TIRJFDjs.k.call(void 0, s.issuer),a)}return o}var fi=class n extends _chunk66TIRJFDjs.l{constructor(e){super();let{kid:t,kty:r,alg:i,e:o,n:s}=e;this.kid=t,this.kty=r,this.alg=i,this.e=o,this.n=s}serialize(e){e.serializeStr(this.kid),e.serializeStr(this.kty),e.serializeStr(this.alg),e.serializeStr(this.e),e.serializeStr(this.n)}static fromMoveStruct(e){let{data:t}=e.variant,r=new R(_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array());return n.deserialize(r)}toScalar(){if(this.alg!=="RS256")throw P.fromErrorType({type:32,details:"Failed to convert JWK to scalar when calculating the public inputs hash. Only RSA 256 is supported currently"});let e=_chunk66TIRJFDjs.ga.call(void 0, this.n),r=cu(e.reverse()).map(i=>Et(i));return r.push(256n),Pt(r)}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeStr(),s=e.deserializeStr();return new n({kid:t,kty:r,alg:i,n:s,e:o})}};function cu(n){let e=[];for(let t=0;t<n.length;t+=24){let r=n.slice(t,Math.min(t+24,n.length));if(r.length<24){let i=new Uint8Array(24);i.set(r),e.push(i)}else e.push(r)}return e}function uu(n){try{let e=JSON.parse(n);if(e.kid===void 0)throw new Error("JWT header missing kid");return e}catch (e2){throw new Error("Failed to parse JWT header.")}}var Z=class n extends ie{constructor(e,t){super(),this.jwkAddress=_chunk66TIRJFDjs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk66TIRJFDjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return gr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=U.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}static create(e){return new n(e.jwkAddress,U.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,U.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk66TIRJFDjs.Z&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof U}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ce=class Ce extends St{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Ce.LENGTH)this.key=t;else if(r===Ce.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunk66TIRJFDjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ce.LENGTH} or ${Ce.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=Wt(t),o=_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array(),s=_sha3.sha3_256.call(void 0, o),a=r.toUint8Array();return _secp256k1.secp256k1.verify(a,s,this.key.toUint8Array(),{lowS:!0})}async verifySignatureAsync(e){return this.verifySignature(e)}toUint8Array(){return this.key.toUint8Array()}serialize(e){e.serializeBytes(this.key.toUint8Array())}deserialize(e){let t=e.deserializeBytes();return new Ct(t)}static deserialize(e){let t=e.deserializeBytes();return new Ce(t)}static isPublicKey(e){return e instanceof Ce}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _51 => _51.key, 'optionalAccess', _52 => _52.data, 'optionalAccess', _53 => _53.length])===Ce.LENGTH}};Ce.LENGTH=65,Ce.COMPRESSED_LENGTH=33;var $e=Ce,Ne=class Ne extends _chunk66TIRJFDjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==Ne.LENGTH)throw new Error(`PrivateKey length should be ${Ne.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new Ne(e,!1)}static fromDerivationPath(e,t){if(!yo(e))throw new Error(`Invalid derivation path ${e}`);return Ne.fromDerivationPathInner(e,ir(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new Ne(r,!1)}sign(e){let t=Wt(e),r=_chunk66TIRJFDjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new Ct(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new $e(e)}toUint8Array(){return this.key.toUint8Array()}toString(){return this.toHexString()}toHexString(){return this.key.toString()}toAIP80String(){return pt.formatPrivateKey(this.key.toString(),"secp256k1")}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Ne(t,!1)}static isPrivateKey(e){return e instanceof Ne}};Ne.LENGTH=32;var We=Ne,Yt=class Yt extends M{constructor(e){super();let t=_chunk66TIRJFDjs.j.fromHexInput(e);if(t.toUint8Array().length!==Yt.LENGTH)throw new Error(`Signature length should be ${Yt.LENGTH}, received ${t.toUint8Array().length}`);this.data=t}toUint8Array(){return this.data.toUint8Array()}serialize(e){e.serializeBytes(this.data.toUint8Array())}static deserialize(e){let t=e.deserializeBytes();return new Yt(t)}};Yt.LENGTH=64;var Ct=Yt;var N=class n extends ie{constructor(e){if(super(),this.publicKey=e,e instanceof I)this.variant=0;else if(e instanceof $e)this.variant=1;else if(e instanceof U)this.variant=3;else if(e instanceof Z)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;if(this.publicKey instanceof U)throw new Error("Use verifySignatureAsync to verify Keyless signatures");return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){if(!(e.signature instanceof H)){if(_optionalChain([e, 'access', _54 => _54.options, 'optionalAccess', _55 => _55.throwErrorWithReason]))throw new Error("Signature must be an instance of AnySignature");return!1}return await this.publicKey.verifySignatureAsync({...e,signature:e.signature.signature})}authKey(){return B.fromSchemeAndBytes({scheme:2,input:this.toUint8Array()})}toUint8Array(){return this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.publicKey.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=I.deserialize(e);break;case 1:r=$e.deserialize(e);break;case 3:r=U.deserialize(e);break;case 4:r=Z.deserialize(e);break;default:throw new Error(`Unknown variant index for AnyPublicKey: ${t}`)}return new n(r)}static isPublicKey(e){return e instanceof n}isEd25519(){return this.publicKey instanceof I}isSecp256k1PublicKey(){return this.publicKey instanceof $e}static isInstance(e){return"publicKey"in e&&"variant"in e}},H= exports.AnySignature =class n extends M{constructor(e){if(super(),this.signature=e,e instanceof K)this.variant=0;else if(e instanceof Ct)this.variant=1;else if(e instanceof he)this.variant=3;else throw new Error("Unsupported signature type")}toUint8Array(){return console.warn("[Aptos SDK] Calls to AnySignature.toUint8Array() will soon return the underlying signature bytes. Use AnySignature.bcsToBytes() instead."),this.bcsToBytes()}serialize(e){e.serializeU32AsUleb128(this.variant),this.signature.serialize(e)}static deserialize(e){let t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=K.deserialize(e);break;case 1:r=Ct.deserialize(e);break;case 3:r=he.deserialize(e);break;default:throw new Error(`Unknown variant index for AnySignature: ${t}`)}return new n(r)}static isInstance(e){return"signature"in e&&typeof e.signature=="object"&&e.signature!==null&&"toUint8Array"in e.signature}};function du(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var xn=class extends ie{constructor(e){super(),this.publicKeys=e.publicKeys}createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(a+1>this.publicKeys.length)throw new Error(`Signature index ${a+1} is out of public keys range, ${this.publicKeys.length}.`);if(o.has(s))throw new Error(`Duplicate bit ${s} detected.`);o.add(s);let c=Math.floor(s/8),p=i[c];p|=r>>s%8,i[c]=p}),i}getIndex(e){let t=this.publicKeys.findIndex(r=>r.toString()===e.toString());if(t!==-1)return t;throw new Error(`Public key ${e} not found in multi key set ${this.publicKeys}`)}},Fe= exports.MultiKey =class n extends xn{constructor(e){let{publicKeys:t,signaturesRequired:r}=e;if(super({publicKeys:t}),r<1)throw new Error("The number of required signatures needs to be greater than 0");if(t.length<r)throw new Error(`Provided ${t.length} public keys is smaller than the ${r} required signatures`);this.publicKeys=t.map(i=>i instanceof N?i:new N(i)),this.signaturesRequired=r}verifySignature(e){let{message:t,signature:r}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let i=r.bitMapToSignerIndices();for(let o=0;o<r.signatures.length;o+=1){let s=r.signatures[o];if(!this.publicKeys[i[o]].verifySignature({message:t,signature:s}))return!1}return!0}async verifySignatureAsync(e){let{signature:t}=e;try{if(!(t instanceof Oe))throw new Error("Signature is not a MultiKeySignature");if(t.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let r=t.bitMapToSignerIndices();for(let i=0;i<t.signatures.length;i+=1){let o=t.signatures[i];if(!await this.publicKeys[r[i]].verifySignatureAsync({...e,signature:o}))return!1}return!0}catch(r){if(_optionalChain([e, 'access', _56 => _56.options, 'optionalAccess', _57 => _57.throwErrorWithReason]))throw r;return!1}}authKey(){return B.fromSchemeAndBytes({scheme:3,input:this.toUint8Array()})}serialize(e){e.serializeVector(this.publicKeys),e.serializeU8(this.signaturesRequired)}static deserialize(e){let t=e.deserializeVector(N),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof N?e:new N(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},pe=class pe extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${pe.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t.map(o=>o instanceof H?o:new H(o)),!(r instanceof Uint8Array))this.bitmap=pe.createBitmap({bits:r});else{if(r.length!==pe.BITMAP_LEN)throw new Error(`"bitmap" length should be ${pe.BITMAP_LEN}`);this.bitmap=r}let i=this.bitmap.reduce((o,s)=>o+du(s),0);if(i!==this.signatures.length)throw new Error(`Expecting ${i} signatures from the bitmap, but got ${this.signatures.length}`)}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach(s=>{if(s>=pe.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${pe.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");o.add(s);let a=Math.floor(s/8),c=i[a];c|=r>>s%8,i[a]=c}),i}bitMapToSignerIndices(){let e=[];for(let t=0;t<this.bitmap.length;t+=1){let r=this.bitmap[t];for(let i=0;i<8;i+=1)(r&128>>i)!==0&&e.push(t*8+i)}return e}serialize(e){e.serializeVector(this.signatures),e.serializeBytes(this.bitmap)}static deserialize(e){let t=e.deserializeVector(H),r=e.deserializeBytes();return new pe({signatures:t,bitmap:r})}};pe.BITMAP_LEN=4,pe.MAX_SIGNATURES_SUPPORTED=pe.BITMAP_LEN*8;var Oe=pe;var Te=class Te extends xn{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>Te.MAX_KEYS||t.length<Te.MIN_KEYS)throw new Error(`Must have between ${Te.MIN_KEYS} and ${Te.MAX_KEYS} public keys, inclusive`);if(r<Te.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${Te.MIN_THRESHOLD} and ${t.length}, inclusive`);this.publicKeys=t,this.threshold=r}verifySignature(e){let{message:t,signature:r}=e;if(!(r instanceof Qe))return!1;let i=[];for(let o=0;o<4;o+=1)for(let s=0;s<8;s+=1)if((r.bitmap[o]&1<<7-s)!==0){let c=o*8+s;i.push(c)}if(i.length!==r.signatures.length)throw new Error("Bitmap and signatures length mismatch");if(i.length<this.threshold)throw new Error("Not enough signatures");for(let o=0;o<i.length;o+=1)if(!this.publicKeys[i[o]].verifySignature({message:t,signature:r.signatures[o]}))return!1;return!0}async verifySignatureAsync(e){return this.verifySignature(e)}authKey(){return B.fromSchemeAndBytes({scheme:1,input:this.toUint8Array()})}toUint8Array(){let e=new Uint8Array(this.publicKeys.length*I.LENGTH+1);return this.publicKeys.forEach((t,r)=>{e.set(t.toUint8Array(),r*I.LENGTH)}),e[this.publicKeys.length*I.LENGTH]=this.threshold,e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t[t.length-1],i=[];for(let o=0;o<t.length-1;o+=I.LENGTH){let s=o;i.push(new I(t.subarray(s,s+I.LENGTH)))}return new Te({publicKeys:i,threshold:r})}getIndex(e){return super.getIndex(e)}};Te.MAX_KEYS=32,Te.MIN_KEYS=2,Te.MIN_THRESHOLD=1;var Zt=Te,de=class de extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>de.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${de.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=de.createBitmap({bits:r});else{if(r.length!==de.BITMAP_LEN)throw new Error(`"bitmap" length should be ${de.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*K.LENGTH+de.BITMAP_LEN);return this.signatures.forEach((t,r)=>{e.set(t.toUint8Array(),r*K.LENGTH)}),e.set(this.bitmap,this.signatures.length*K.LENGTH),e}serialize(e){e.serializeBytes(this.toUint8Array())}static deserialize(e){let t=e.deserializeBytes(),r=t.subarray(t.length-4),i=[];for(let o=0;o<t.length-r.length;o+=K.LENGTH){let s=o;i.push(new K(t.subarray(s,s+K.LENGTH)))}return new de({signatures:i,bitmap:r})}static createBitmap(e){let{bits:t}=e,r=128,i=new Uint8Array([0,0,0,0]),o=new Set;return t.forEach((s,a)=>{if(s>=de.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${de.MAX_SIGNATURES_SUPPORTED-1}.`);if(o.has(s))throw new Error("Duplicate bits detected.");if(a>0&&s<=t[a-1])throw new Error("The bits need to be sorted in ascending order.");o.add(s);let c=Math.floor(s/8),p=i[c];p|=r>>s%8,i[c]=p}),i}};de.MAX_SIGNATURES_SUPPORTED=32,de.BITMAP_LEN=4;var Qe=de;var j=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return ve.load(e);case 1:return je.load(e);case 2:return oe.load(e);case 3:return Ge.load(e);case 4:return en.load(e);case 5:return vt.load(e);default:throw new Error(`Unknown variant index for AccountAuthenticator: ${t}`)}}isEd25519(){return this instanceof ve}isMultiEd25519(){return this instanceof je}isSingleKey(){return this instanceof oe}isMultiKey(){return this instanceof Ge}},ve= exports.AccountAuthenticatorEd25519 =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=I.deserialize(e),r=K.deserialize(e);return new n(t,r)}},je= exports.AccountAuthenticatorMultiEd25519 =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Zt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},oe= exports.AccountAuthenticatorSingleKey =class n extends j{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(2),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=N.deserialize(e),r=H.deserialize(e);return new n(t,r)}},Ge= exports.AccountAuthenticatorMultiKey =class n extends j{constructor(e,t){super(),this.public_keys=e,this.signatures=t}serialize(e){e.serializeU32AsUleb128(3),this.public_keys.serialize(e),this.signatures.serialize(e)}static load(e){let t=Fe.deserialize(e),r=Oe.deserialize(e);return new n(t,r)}},en= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends j{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},vt= exports.AccountAuthenticatorAbstraction =class n extends j{constructor(e,t,r,i){if(super(),!_chunk66TIRJFDjs.ma.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=r,this.signingMessageDigest=_chunk66TIRJFDjs.j.fromHexInput(_chunk66TIRJFDjs.j.fromHexInput(t).toUint8Array()),this.accountIdentity=i}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, this.functionInfo);_chunk66TIRJFDjs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),this.accountIdentity?e.serializeU32AsUleb128(1):e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),this.accountIdentity?e.serializeBytes(this.authenticator):e.serializeFixedBytes(this.authenticator),this.accountIdentity&&e.serializeBytes(this.accountIdentity)}static load(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeStr(),i=e.deserializeStr(),o=e.deserializeUleb128AsU32();if(o===0){let s=e.deserializeBytes(),a=e.deserializeFixedBytes(e.remaining());return new n(`${t}::${r}::${i}`,s,a)}if(o===1){let s=e.deserializeBytes(),a=e.deserializeBytes(),c=e.deserializeBytes();return new n(`${t}::${r}::${i}`,s,a,c)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var tn=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let t=e.deserializeU8();return new n(t)}};var k=class n extends _chunk66TIRJFDjs.l{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let t=e.deserializeStr();return new n(t)}};var In=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.address=e,this.name=t}static fromStr(e){let t=e.split("::");if(t.length!==2)throw new Error("Invalid module id.");return new n(_chunk66TIRJFDjs.Z.fromString(t[0]),new k(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e);return new n(t,r)}};var O=class n extends _chunk66TIRJFDjs.l{deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(n);return new Be(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return L.load(e);case 1:return le.load(e);case 2:return J.load(e);case 3:return Ye.load(e);case 4:return F.load(e);case 5:return Kt.load(e);case 6:return C.load(e);case 7:return A.load(e);case 8:return Je.load(e);case 9:return Xe.load(e);case 10:return Ze.load(e);case 255:return G.load(e);default:throw new Error(`Unknown variant index for TypeTag: ${t}`)}}isBool(){return this instanceof L}isAddress(){return this instanceof F}isGeneric(){return this instanceof G}isSigner(){return this instanceof Kt}isVector(){return this instanceof C}isStruct(){return this instanceof A}isU8(){return this instanceof le}isU16(){return this instanceof Je}isU32(){return this instanceof Xe}isU64(){return this instanceof J}isU128(){return this instanceof Ye}isU256(){return this instanceof Ze}isPrimitive(){return this instanceof Kt||this instanceof F||this instanceof L||this instanceof le||this instanceof Je||this instanceof Xe||this instanceof J||this instanceof Ye||this instanceof Ze}},L= exports.TypeTagBool =class n extends O{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},le= exports.TypeTagU8 =class n extends O{toString(){return"u8"}serialize(e){e.serializeU32AsUleb128(1)}static load(e){return new n}},Je= exports.TypeTagU16 =class n extends O{toString(){return"u16"}serialize(e){e.serializeU32AsUleb128(8)}static load(e){return new n}},Xe= exports.TypeTagU32 =class n extends O{toString(){return"u32"}serialize(e){e.serializeU32AsUleb128(9)}static load(e){return new n}},J= exports.TypeTagU64 =class n extends O{toString(){return"u64"}serialize(e){e.serializeU32AsUleb128(2)}static load(e){return new n}},Ye= exports.TypeTagU128 =class n extends O{toString(){return"u128"}serialize(e){e.serializeU32AsUleb128(3)}static load(e){return new n}},Ze= exports.TypeTagU256 =class n extends O{toString(){return"u256"}serialize(e){e.serializeU32AsUleb128(10)}static load(e){return new n}},F= exports.TypeTagAddress =class n extends O{toString(){return"address"}serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},Kt= exports.TypeTagSigner =class n extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},mr= exports.TypeTagReference =class n extends O{constructor(t){super();this.value=t}toString(){return`&${this.value.toString()}`}serialize(t){t.serializeU32AsUleb128(254)}static load(t){let r=O.deserialize(t);return new n(r)}},G= exports.TypeTagGeneric =class n extends O{constructor(t){super();this.value=t;if(t<0)throw new Error("Generic type parameter index cannot be negative")}toString(){return`T${this.value}`}serialize(t){t.serializeU32AsUleb128(255),t.serializeU32(this.value)}static load(t){let r=t.deserializeU32();return new n(r)}},C= exports.TypeTagVector =class n extends O{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new le)}serialize(t){t.serializeU32AsUleb128(6),this.value.serialize(t)}static load(t){let r=O.deserialize(t);return new n(r)}},A= exports.TypeTagStruct =class n extends O{constructor(t){super();this.value=t}toString(){let t="";return this.value.typeArgs.length>0&&(t=`<${this.value.typeArgs.map(r=>r.toString()).join(", ")}>`),`${this.value.address.toString()}::${this.value.moduleName.identifier}::${this.value.name.identifier}${t}`}serialize(t){t.serializeU32AsUleb128(7),this.value.serialize(t)}static load(t){let r=Be.deserialize(t);return new n(r)}isTypeTag(t,r,i){return this.value.moduleName.identifier===r&&this.value.name.identifier===i&&this.value.address.equals(t)}isString(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk66TIRJFDjs.Z.ONE,"rate_limiter","RateLimiter")}},Be= exports.StructTag =class n extends _chunk66TIRJFDjs.l{constructor(e,t,r,i){super(),this.address=e,this.moduleName=t,this.name=r,this.typeArgs=i}serialize(e){e.serialize(this.address),e.serialize(this.moduleName),e.serialize(this.name),e.serializeVector(this.typeArgs)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(O);return new n(t,r,i,o)}};function Wy(){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("aptos_coin"),new k("AptosCoin"),[])}function _(){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("string"),new k("String"),[])}function Qy(n){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("option"),new k("Option"),[n])}function ge(n){return new Be(_chunk66TIRJFDjs.Z.ONE,new k("object"),new k("Object"),[n])}function lu(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return X.deserialize(n);case 1:return Q.deserialize(n);case 2:return xe.deserialize(n);case 3:return _chunk66TIRJFDjs.Z.deserialize(n);case 4:return S.deserialize(n,X);case 5:return z.deserialize(n);case 6:return Pe.deserialize(n);case 7:return _e.deserialize(n);case 8:return ye.deserialize(n);case 9:return hn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Rt=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Ut.load(e);case 2:return Cn.load(e);case 3:return vn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Ut= exports.TransactionPayloadScript =class n extends Rt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Kn.deserialize(e);return new n(t)}},Cn= exports.TransactionPayloadEntryFunction =class n extends Rt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=kt.deserialize(e);return new n(t)}},vn= exports.TransactionPayloadMultiSig =class n extends Rt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Rn.deserialize(e);return new n(t)}},kt= exports.EntryFunction =class n{constructor(e,t,r,i){this.module_name=e,this.function_name=t,this.type_args=r,this.args=i}static build(e,t,r,i){return new n(In.fromStr(e),new k(t),r,i)}serialize(e){this.module_name.serialize(e),this.function_name.serialize(e),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForEntryFunction(e)})}static deserialize(e){let t=In.deserialize(e),r=k.deserialize(e),i=e.deserializeVector(O),o=e.deserializeUleb128AsU32(),s=new Array;for(let a=0;a<o;a+=1){let c=e.deserializeUleb128AsU32(),p=nr.deserialize(e,c);s.push(p)}return new n(t,r,i,s)}},Kn= exports.Script =class n{constructor(e,t,r){this.bytecode=e,this.type_args=t,this.args=r}serialize(e){e.serializeBytes(this.bytecode),e.serializeVector(this.type_args),e.serializeU32AsUleb128(this.args.length),this.args.forEach(t=>{t.serializeForScriptFunction(e)})}static deserialize(e){let t=e.deserializeBytes(),r=e.deserializeVector(O),i=e.deserializeUleb128AsU32(),o=new Array;for(let s=0;s<i;s+=1){let a=lu(e);o.push(a)}return new n(t,r,o)}},Rn= exports.MultiSig =class n{constructor(e,t){this.multisig_address=e,this.transaction_payload=t}serialize(e){this.multisig_address.serialize(e),this.transaction_payload===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.transaction_payload.serialize(e))}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Un.deserialize(e)),new n(t,i)}},Un= exports.MultiSigTransactionPayload =class n extends _chunk66TIRJFDjs.l{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(kt.deserialize(e))}};var be=class n extends _chunk66TIRJFDjs.l{constructor(e,t,r,i,o,s,a){super(),this.sender=e,this.sequence_number=t,this.payload=r,this.max_gas_amount=i,this.gas_unit_price=o,this.expiration_timestamp_secs=s,this.chain_id=a}serialize(e){this.sender.serialize(e),e.serializeU64(this.sequence_number),this.payload.serialize(e),e.serializeU64(this.max_gas_amount),e.serializeU64(this.gas_unit_price),e.serializeU64(this.expiration_timestamp_secs),this.chain_id.serialize(e)}static deserialize(e){let t=_chunk66TIRJFDjs.Z.deserialize(e),r=e.deserializeU64(),i=Rt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=tn.deserialize(e);return new n(t,r,i,o,s,a,c)}},yr= exports.RawTransactionWithData =class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Dt.load(e);case 1:return zt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},Dt= exports.MultiAgentRawTransaction =class n extends yr{constructor(e,t){super(),this.raw_txn=e,this.secondary_signer_addresses=t}serialize(e){e.serializeU32AsUleb128(0),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses)}static load(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z);return new n(t,r)}},zt= exports.FeePayerRawTransaction =class n extends yr{constructor(e,t,r){super(),this.raw_txn=e,this.secondary_signer_addresses=t,this.fee_payer_address=r}serialize(e){e.serializeU32AsUleb128(1),this.raw_txn.serialize(e),e.serializeVector(this.secondary_signer_addresses),this.fee_payer_address.serialize(e)}static load(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=_chunk66TIRJFDjs.Z.deserialize(e);return new n(t,r,i)}};var fr=class extends _chunk66TIRJFDjs.l{constructor(t){super();this.accountAddress=_chunk66TIRJFDjs.Z.ONE;this.moduleName=new x("account");this.structName=new x("RotationProofChallenge");this.sequenceNumber=new Q(t.sequenceNumber),this.originator=t.originator,this.currentAuthKey=t.currentAuthKey,this.newPublicKey=S.U8(t.newPublicKey.toUint8Array())}serialize(t){t.serialize(this.accountAddress),t.serialize(this.moduleName),t.serialize(this.structName),t.serialize(this.sequenceNumber),t.serialize(this.originator),t.serialize(this.currentAuthKey),t.serialize(this.newPublicKey)}};var et=class extends _chunk66TIRJFDjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Nt.load(e);case 1:return nn.load(e);case 2:return Ft.load(e);case 3:return Ot.load(e);case 4:return ft.load(e);default:throw new Error(`Unknown variant index for TransactionAuthenticator: ${t}`)}}isEd25519(){return this instanceof Nt}isMultiEd25519(){return this instanceof nn}isMultiAgent(){return this instanceof Ft}isFeePayer(){return this instanceof Ot}isSingleSender(){return this instanceof ft}},Nt= exports.TransactionAuthenticatorEd25519 =class n extends et{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(0),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=I.deserialize(e),r=K.deserialize(e);return new n(t,r)}},nn= exports.TransactionAuthenticatorMultiEd25519 =class n extends et{constructor(e,t){super(),this.public_key=e,this.signature=t}serialize(e){e.serializeU32AsUleb128(1),this.public_key.serialize(e),this.signature.serialize(e)}static load(e){let t=Zt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},Ft= exports.TransactionAuthenticatorMultiAgent =class n extends et{constructor(e,t,r){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r}serialize(e){e.serializeU32AsUleb128(2),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers)}static load(e){let t=j.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeVector(j);return new n(t,r,i)}},Ot= exports.TransactionAuthenticatorFeePayer =class n extends et{constructor(e,t,r,i){super(),this.sender=e,this.secondary_signer_addresses=t,this.secondary_signers=r,this.fee_payer=i}serialize(e){e.serializeU32AsUleb128(3),this.sender.serialize(e),e.serializeVector(this.secondary_signer_addresses),e.serializeVector(this.secondary_signers),this.fee_payer.address.serialize(e),this.fee_payer.authenticator.serialize(e)}static load(e){let t=j.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeVector(j),o=_chunk66TIRJFDjs.Z.deserialize(e),s=j.deserialize(e),a={address:o,authenticator:s};return new n(t,r,i,a)}},ft= exports.TransactionAuthenticatorSingleSender =class n extends et{constructor(e){super(),this.sender=e}serialize(e){e.serializeU32AsUleb128(4),this.sender.serialize(e)}static load(e){let t=j.deserialize(e);return new n(t)}};var tt=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.raw_txn=e,this.authenticator=t}serialize(e){this.raw_txn.serialize(e),this.authenticator.serialize(e)}static deserialize(e){let t=be.deserialize(e),r=et.deserialize(e);return new n(t,r)}};var rn=class n extends _chunk66TIRJFDjs.l{constructor(e,t){super(),this.rawTransaction=e,this.feePayerAddress=t}serialize(e){this.rawTransaction.serialize(e),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=be.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk66TIRJFDjs.Z.deserialize(e)),new n(t,i)}};var Ar=class n extends _chunk66TIRJFDjs.l{constructor(e,t,r){super(),this.rawTransaction=e,this.feePayerAddress=r,this.secondarySignerAddresses=t}serialize(e){this.rawTransaction.serialize(e),e.serializeVector(this.secondarySignerAddresses),this.feePayerAddress===void 0?e.serializeBool(!1):(e.serializeBool(!0),this.feePayerAddress.serialize(e))}static deserialize(e){let t=be.deserialize(e),r=e.deserializeVector(_chunk66TIRJFDjs.Z),i=e.deserializeBool(),o;return i&&(o=_chunk66TIRJFDjs.Z.deserialize(e)),new n(t,r,o)}};function hr(n){return n.feePayerAddress?new zt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new Dt(n.rawTransaction,n.secondarySignerAddresses):n.rawTransaction}function yt(n,e){let t=_sha3.sha3_256.create();if(!e.startsWith("APTOS::"))throw new Error(`Domain separator needs to start with 'APTOS::'. Provided - ${e}`);t.update(e);let r=t.digest(),i=n,o=new Uint8Array(r.length+i.length);return o.set(r),o.set(i,r.length),o}function sA(n){return yt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ke(n){let e=hr(n);return n.feePayerAddress?yt(e.bcsToBytes(),ai):n.secondarySignerAddresses?yt(e.bcsToBytes(),ai):yt(e.bcsToBytes(),Co)}var se=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=q.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=q.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new ve(this.publicKey,this.privateKey.sign(e))}signTransactionWithAuthenticator(e){return new ve(this.publicKey,this.signTransaction(e))}sign(e){return this.privateKey.sign(e)}signTransaction(e){return this.sign(Ke(e))}};function Ti(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var we=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new N(t.publicKey()),this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress()}getAnyPublicKey(){return this.publicKey}static generate(e={}){let{scheme:t=0}=e,r;switch(t){case 0:r=q.generate();break;case 2:r=We.generate();break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:r})}static fromDerivationPath(e){let{scheme:t=0,path:r,mnemonic:i}=e,o;switch(t){case 0:o=q.fromDerivationPath(r,i);break;case 2:o=We.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new oe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new oe(this.publicKey,this.signTransaction(e))}sign(e){return new H(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ke(e))}static fromEd25519Account(e){return new n({privateKey:e.privateKey,address:e.accountAddress})}};var nt=class{static generate(e={}){let{scheme:t=0,legacy:r=!0}=e;return t===0&&r?se.generate():we.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new se({privateKey:t,address:r}):new we({privateKey:t,address:r})}static fromPrivateKeyAndAddress(e){return this.fromPrivateKey(e)}static fromDerivationPath(e){let{scheme:t=0,mnemonic:r,path:i,legacy:o=!0}=e;return t===0&&o?se.fromDerivationPath({mnemonic:r,path:i}):we.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync(e)}};var _utils3 = require('@noble/hashes/utils');var yu=1209600,on=class on extends _chunk66TIRJFDjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new lt(t.publicKey()),this.expiryDateSecs=r||_chunk66TIRJFDjs.ea.call(void 0, _chunk66TIRJFDjs.da.call(void 0, )+yu),this.blinder=i!==void 0?_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array():fu();let o=wn(this.publicKey.bcsToBytes(),93);o.push(BigInt(this.expiryDateSecs)),o.push(Et(this.blinder));let s=Pt(o);this.nonce=s.toString()}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 t=e.deserializeUleb128AsU32(),r;switch(t){case 0:r=q.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new on({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return on.deserialize(new R(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _58 => _58.scheme])){case 0:default:t=q.generate()}return new on({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _59 => _59.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ue(this.privateKey.sign(e))}};on.BLINDER_LENGTH=31;var Gt=on;function fu(){return _utils3.randomBytes.call(void 0, Gt.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function br(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var sn=class sn extends _chunk66TIRJFDjs.l{constructor(t){super();this.signingScheme=2;let{address:r,ephemeralKeyPair:i,publicKey:o,uidKey:s,uidVal:a,aud:c,pepper:p,proof:l,proofFetchCallback:h,jwt:d,verificationKeyHash:g}=t;if(this.ephemeralKeyPair=i,this.publicKey=o,this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress(),this.uidKey=s,this.uidVal=a,this.aud=c,this.jwt=d,this.emitter=new _eventemitter32.default,this.proofOrPromise=l,l instanceof ue)this.proof=l;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async v=>{await h(v),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunk66TIRJFDjs.j.fromHexInput(p).toUint8Array();if(b.length!==sn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${sn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunk66TIRJFDjs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk66TIRJFDjs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new N(this.publicKey)}async init(t){try{this.proof=await t,this.emitter.emit("proofFetchFinish",{status:"Success"})}catch(r){r instanceof Error?this.emitter.emit("proofFetchFinish",{status:"Failed",error:r.toString()}):this.emitter.emit("proofFetchFinish",{status:"Failed",error:"Unknown"})}}serialize(t){if(this.accountAddress.serialize(t),t.serializeStr(this.jwt),t.serializeStr(this.uidKey),t.serializeFixedBytes(this.pepper),this.ephemeralKeyPair.serialize(t),this.proof===void 0)throw new Error("Cannot serialize - proof undefined");this.proof.serialize(t),t.serializeOption(this.verificationKeyHash,32)}static partialDeserialize(t){let r=_chunk66TIRJFDjs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Gt.deserialize(t),c=ue.deserialize(t),p=t.deserializeOption("fixedBytes",32);return{address:r,jwt:i,uidKey:o,pepper:s,ephemeralKeyPair:a,proof:c,verificationKeyHash:p}}isExpired(){return this.ephemeralKeyPair.isExpired()}signWithAuthenticator(t){let r=new H(this.sign(t)),i=new N(this.publicKey);return new oe(i,r)}signTransactionWithAuthenticator(t){let r=new H(this.signTransaction(t)),i=new N(this.publicKey);return new oe(i,r)}async waitForProofFetch(){this.proofOrPromise instanceof Promise&&await this.proofOrPromise}async checkKeylessAccountValidity(t){if(this.isExpired())throw P.fromErrorType({type:0});if(await this.waitForProofFetch(),this.proof===void 0)throw P.fromErrorType({type:2});let r=_jwtdecode.jwtDecode.call(void 0, this.jwt,{header:!0});if(r.kid===void 0)throw P.fromErrorType({type:12,details:"checkKeylessAccountValidity failed. JWT is missing 'kid' in header. This should never happen."});if(this.verificationKeyHash!==void 0){let{verificationKey:i}=await Xt({aptosConfig:t});if(_chunk66TIRJFDjs.j.hexInputToString(i.hash())!==_chunk66TIRJFDjs.j.hexInputToString(this.verificationKeyHash))throw P.fromErrorType({type:4})}else console.warn("[Aptos SDK] The verification key hash was not set. Proof may be invalid if the verification key has rotated.");await sn.fetchJWK({aptosConfig:t,publicKey:this.publicKey,kid:r.kid})}sign(t){let{expiryDateSecs:r}=this.ephemeralKeyPair;if(this.isExpired())throw P.fromErrorType({type:0});if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let i=this.ephemeralKeyPair.getPublicKey(),o=this.ephemeralKeyPair.sign(t);return new he({jwtHeader:_chunk66TIRJFDjs.fa.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new jt(this.proof,0),expiryDateSecs:r,ephemeralPublicKey:i,ephemeralSignature:o})}signTransaction(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=hr(t),o=new Tr(r,this.proof.proof).hash();return this.sign(o)}getSigningMessage(t){if(this.proof===void 0)throw P.fromErrorType({type:1,details:"Proof not found - make sure to call `await account.checkKeylessAccountValidity()` before signing."});let r=hr(t);return new Tr(r,this.proof.proof).hash()}verifySignature(t){return this.publicKey.verifySignature(t)}async verifySignatureAsync(t){return this.publicKey.verifySignatureAsync({...t})}static async fetchJWK(t){return hi(t)}};sn.PEPPER_LENGTH=31;var me=sn,Tr= exports.TransactionAndProof =class extends _chunk66TIRJFDjs.l{constructor(t,r){super();this.domainSeparator="APTOS::TransactionAndProof";this.transaction=t,this.proof=r}serialize(t){t.serializeFixedBytes(this.transaction.bcsToBytes()),t.serializeOption(this.proof)}hash(){return yt(this.bcsToBytes(),this.domainSeparator)}};var rt=class n extends me{constructor(e){let t=U.create(e);super({publicKey:t,...e}),this.publicKey=t}serialize(e){super.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),{iss:p,aud:l,uidVal:h}=qe({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:p,uidKey:s,uidVal:h,aud:l,pepper:a,jwt:o,verificationKeyHash:c})}static fromBytes(e){return n.deserialize(new R(_chunk66TIRJFDjs.j.hexInputToUint8Array(e)))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,uidKey:a="sub",proofFetchCallback:c,verificationKey:p}=e,{iss:l,aud:h,uidVal:d}=qe({jwt:i,uidKey:a});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:l,uidKey:a,uidVal:d,aud:h,pepper:s,jwt:i,proofFetchCallback:c,verificationKeyHash:p?p.hash():void 0})}};var Bt=class n extends me{constructor(e){let t=Z.create(e);super({publicKey:t,...e}),this.publicKey=t,this.audless=_nullishCoalesce(e.audless, () => (!1))}serialize(e){super.serialize(e),this.publicKey.jwkAddress.serialize(e)}static deserialize(e){let{address:t,proof:r,ephemeralKeyPair:i,jwt:o,uidKey:s,pepper:a,verificationKeyHash:c}=me.partialDeserialize(e),p=_chunk66TIRJFDjs.Z.deserialize(e),{iss:l,aud:h,uidVal:d}=qe({jwt:o,uidKey:s});return new n({address:t,proof:r,ephemeralKeyPair:i,iss:l,uidKey:s,uidVal:d,aud:h,pepper:a,jwt:o,verificationKeyHash:c,jwkAddress:p})}static fromBytes(e){return n.deserialize(R.fromHex(e))}static create(e){let{address:t,proof:r,jwt:i,ephemeralKeyPair:o,pepper:s,jwkAddress:a,uidKey:c="sub",proofFetchCallback:p,verificationKey:l}=e,{iss:h,aud:d,uidVal:g}=qe({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:g,aud:d,pepper:s,jwkAddress:_chunk66TIRJFDjs.Z.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var kn=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof se?we.fromEd25519Account(a):a);if(t.signaturesRequired>i.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${t.signaturesRequired} signers, but only ${i.length} provided`);if(t.signaturesRequired<i.length)throw new Error(`More signers provided than required. Need ${t.signaturesRequired} signers, but ${i.length} provided`);this.publicKey=t,this.accountAddress=r?_chunk66TIRJFDjs.Z.from(r):this.publicKey.authKey().derivedAddress();let o=[];for(let a of i)o.push(this.publicKey.getIndex(a.getAnyPublicKey()));let s=i.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndicies=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}static fromPublicKeysAndSigners(e){let{address:t,publicKeys:r,signaturesRequired:i,signers:o}=e,s=new Fe({publicKeys:r,signaturesRequired:i});return new n({multiKey:s,signers:o,address:t})}static isMultiKeySigner(e){return e instanceof n}signWithAuthenticator(e){return new Ge(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Ge(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof me).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof me).map(i=>i.checkKeylessAccountValidity(e));await Promise.all(r)}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Oe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new Oe({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var wr=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk66TIRJFDjs.Z.from(i):this.publicKey.authKey().derivedAddress(),r.threshold>t.length)throw new Error(`Not enough signers provided to satisfy the required signatures. Need ${r.threshold} signers, but only ${t.length} provided`);if(r.threshold<t.length)throw new Error(`More signers provided than required. Need ${r.threshold} signers, but ${t.length} provided`);let o=[];for(let a of t)o.push(this.publicKey.getIndex(a.publicKey()));let s=t.map((a,c)=>[a,o[c]]);s.sort((a,c)=>a[1]-c[1]),this.signers=s.map(a=>a[0]),this.signerIndices=s.map(a=>a[1]),this.signaturesBitmap=this.publicKey.createBitmap({bits:o})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return this.publicKey.verifySignatureAsync({...e,signature:e.signature})}signWithAuthenticator(e){return new je(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new je(this.publicKey,this.signTransaction(e))}sign(e){let t=[];for(let r of this.signers)t.push(r.sign(e));return new Qe({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){return this.sign(Ke(e))}};function Go(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk66TIRJFDjs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk66TIRJFDjs.Z.deserialize(n),signingScheme:e}}function Bo(n,e){if(e.serializeStr(n.jwt),e.serializeStr(n.uidKey),e.serializeFixedBytes(n.pepper),n.ephemeralKeyPair.serialize(e),n.proof===void 0)throw new Error("Cannot serialize - proof undefined");n.proof.serialize(e),e.serializeOption(n.verificationKeyHash,32)}function Mo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Gt.deserialize(n),o=ue.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Vo;(h=>{function n(d){let g=new _chunk66TIRJFDjs.m;switch(g.serializeU32AsUleb128(d.signingScheme),d.accountAddress.serialize(g),d.signingScheme){case 0:return d.privateKey.serialize(g),g.toUint8Array();case 2:{if(!Ti(d))throw new Error("Account is not a SingleKeySigner");let b=d.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return Bo(d,g),g.toUint8Array();case 4:{let v=d;return Bo(v,g),v.publicKey.jwkAddress.serialize(g),g.serializeBool(v.audless),g.toUint8Array()}case 1:case 0:return d.privateKey.serialize(g),g.toUint8Array();default:throw new Error(`Invalid public key variant: ${b.variant}`)}}case 3:{let b=d;return b.publicKey.serialize(g),g.serializeU32AsUleb128(b.signers.length),b.signers.forEach(v=>{g.serializeFixedBytes(n(v))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${d.signingScheme}`)}}h.toBytes=n;function e(d){return _chunk66TIRJFDjs.j.hexInputToStringWithoutPrefix(n(d))}h.toHexStringWithoutPrefix=e;function t(d){return _chunk66TIRJFDjs.j.hexInputToString(n(d))}h.toHexString=t;function r(d){let{address:g,signingScheme:b}=Go(d);switch(b){case 0:{let v=q.deserialize(d);return new se({privateKey:v,address:g})}case 2:{let v=d.deserializeUleb128AsU32();switch(v){case 0:{let W=q.deserialize(d);return new we({privateKey:W,address:g})}case 1:{let W=We.deserialize(d);return new we({privateKey:W,address:g})}case 3:{let W=Mo(d),Me=qe(W);return new rt({...W,...Me})}case 4:{let W=Mo(d),Me=_chunk66TIRJFDjs.Z.deserialize(d),st=d.deserializeBool(),at=qe(W);return new Bt({...W,...at,jwkAddress:Me,audless:st})}default:throw new Error(`Unsupported public key variant ${v}`)}}case 3:{let v=Fe.deserialize(d),W=d.deserializeUleb128AsU32(),Me=new Array;for(let st=0;st<W;st+=1){let at=r(d);if(!Ti(at)&&!(at instanceof se))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Me.push(at)}return new kn({multiKey:v,signers:Me,address:g})}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${b}`)}}h.deserialize=r;function i(d){let g=p(d);if(!(g instanceof rt))throw new Error("Deserialization of KeylessAccount failed");return g}h.keylessAccountFromHex=i;function o(d){let g=p(d);if(!(g instanceof Bt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}h.federatedKeylessAccountFromHex=o;function s(d){let g=p(d);if(!(g instanceof kn))throw new Error("Deserialization of MultiKeyAccount failed");return g}h.multiKeyAccountFromHex=s;function a(d){let g=p(d);if(!(g instanceof we))throw new Error("Deserialization of SingleKeyAccount failed");return g}h.singleKeyAccountFromHex=a;function c(d){let g=p(d);if(!(g instanceof se))throw new Error("Deserialization of Ed25519Account failed");return g}h.ed25519AccountFromHex=c;function p(d){return r(R.fromHex(d))}h.fromHex=p;function l(d){return p(d)}h.fromBytes=l})(Vo||(Vo= exports.AccountUtils ={}));var Sr=class n extends nt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk66TIRJFDjs.ma.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new rr(this.accountAddress),this.sign=o=>new Tn(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk66TIRJFDjs.m;return t.publicKey.serialize(o),t.sign(i).serialize(o),o.toUint8Array()},accountAddress:_nullishCoalesce(r, () => (t.accountAddress)),authenticationFunction:"0x1::permissioned_delegation::authenticate"})}signWithAuthenticator(t){return new vt(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(Ke(t))}signTransaction(t){return this.sign(Ke(t))}setSigner(t){this.sign=r=>new Tn(t(r))}};var Dn=class Dn extends Sr{constructor({signer:e,authenticationFunction:t,abstractPublicKey:r}){let i=new (0, _chunk66TIRJFDjs.Z)(Dn.computeAccountAddress(t,r));super({accountAddress:i,signer:e,authenticationFunction:t}),this.abstractPublicKey=r}static computeAccountAddress(e,t){if(!_chunk66TIRJFDjs.ma.call(void 0, e))throw new Error(`Invalid authentication function ${e} passed into DerivableAbstractedAccount`);let[r,i,o]=e.split("::"),s=_sha3.sha3_256.create(),a=new _chunk66TIRJFDjs.m;_chunk66TIRJFDjs.Z.fromString(r).serialize(a),a.serializeStr(i),a.serializeStr(o),s.update(a.toUint8Array());let c=new _chunk66TIRJFDjs.m;return c.serializeBytes(t),s.update(c.toUint8Array()),s.update(new Uint8Array([Dn.ADDRESS_DOMAIN_SEPERATOR])),s.digest()}signWithAuthenticator(e){return new vt(this.authenticationFunction,_sha3.sha3_256.call(void 0, e),this.sign(_sha3.sha3_256.call(void 0, e)).value,this.abstractPublicKey)}};Dn.ADDRESS_DOMAIN_SEPERATOR=5;var Lo=Dn;var Tu=`
|
|
7
7
|
fragment TokenActivitiesFields on token_activities_v2 {
|
|
8
8
|
after_value
|
|
9
9
|
before_value
|
|
@@ -21,7 +21,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
21
21
|
transaction_version
|
|
22
22
|
type
|
|
23
23
|
}
|
|
24
|
-
`,
|
|
24
|
+
`,bu=`
|
|
25
25
|
fragment AnsTokenFragment on current_aptos_names {
|
|
26
26
|
domain
|
|
27
27
|
expiration_timestamp
|
|
@@ -168,7 +168,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
168
168
|
...CurrentTokenOwnershipFields
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
${Er}`,
|
|
171
|
+
${Er}`,XT=`
|
|
172
172
|
query getAccountOwnedTokensByTokenData($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
173
173
|
current_token_ownerships_v2(
|
|
174
174
|
where: $where_condition
|
|
@@ -351,7 +351,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
351
351
|
...AnsTokenFragment
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
${
|
|
354
|
+
${bu}`,wi=`
|
|
355
355
|
query getNumberOfDelegators($where_condition: num_active_delegator_per_pool_bool_exp, $order_by: [num_active_delegator_per_pool_order_by!]) {
|
|
356
356
|
num_active_delegator_per_pool(where: $where_condition, order_by: $order_by) {
|
|
357
357
|
num_active_delegator
|
|
@@ -423,7 +423,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
423
423
|
...TokenActivitiesFields
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
${
|
|
426
|
+
${Tu}`,Ei=`
|
|
427
427
|
query getCurrentTokenOwnership($where_condition: current_token_ownerships_v2_bool_exp!, $offset: Int, $limit: Int, $order_by: [current_token_ownerships_v2_order_by!]) {
|
|
428
428
|
current_token_ownerships_v2(
|
|
429
429
|
where: $where_condition
|
|
@@ -474,7 +474,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
474
474
|
}
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
`;async function _r(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function us(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Yo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Uo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Tu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Si},originMethod:"getProcessorStatuses"})).processor_status}async function xr(n){let e=await Tu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Ir(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Si,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Cr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}`});return r}async function ds(n){return _optionalChain([n, 'access', _60 => _60.options, 'optionalAccess', _61 => _61.ledgerVersion])!==void 0?ps(n):De(async()=>ps(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ps(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _62 => _62.ledgerVersion])}});return o}async function vr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await gt({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _63 => _63.ledgerVersion])},body:r})).data}async function ls(n){let{aptosConfig:e,options:t}=n,r={query:os,variables:{where_condition:_optionalChain([t, 'optionalAccess', _64 => _64.where]),offset:_optionalChain([t, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([t, 'optionalAccess', _66 => _66.limit]),order_by:_optionalChain([t, 'optionalAccess', _67 => _67.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function gs(n){let{aptosConfig:e,options:t}=n,r={query:ss,variables:{where_condition:_optionalChain([t, 'optionalAccess', _68 => _68.where]),offset:_optionalChain([t, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([t, 'optionalAccess', _70 => _70.limit]),order_by:_optionalChain([t, 'optionalAccess', _71 => _71.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function _i(n){let{aptosConfig:e,options:t}=n;return dr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([t, 'optionalAccess', _73 => _73.limit])}})}async function Rr(n){let{aptosConfig:e}=n;return De(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function ms(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function zn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function ys(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await zn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _74 => _74.status])===404)return!0;throw r}}async function bu(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function At(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _75 => _75.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _76 => _76.checkSuccess]), () => (!0)),s=!0,a=0,c,p,l=200,h=1.5;function d(g){if(!(g instanceof Ae)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await zn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){d(g)}if(s){let g=Date.now();try{c=await bu({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){d(b)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await zn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){d(g)}await _chunk66TIRJFDjs.ba.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new Kr(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Kr(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Pi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Ur(n){let{aptosConfig:e,processorType:t}=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(t===void 0?s=await xr({aptosConfig:e}):s=(await Ir({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk66TIRJFDjs.ba.call(void 0, 200)}}var Kr=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Pi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function fs(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _77 => _77.withTransactions])}});return hs({block:i,...n})}async function As(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _78 => _78.withTransactions])}});return hs({block:i,...n})}async function hs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _79 => _79.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _80 => _80.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let p=[],l=100n;for(let d=c+1n;d<s;d+=BigInt(100))p.push(_i({aptosConfig:e,options:{offset:d,limit:Math.min(Number(l),Number(s-d+1n))}}));let h=await Promise.all(p);for(let d of h)t.transactions.push(...d)}return t}function Ts(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function bs(n){return!!n.match(/\s/)}function wu(n){return!!n.match(/^T[0-9]+$/)}function Su(n){return!!n.match(/^&.+$/)}function Eu(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function Pu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!bs(r))break}return t}var _u=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(_u||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Re(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _81 => _81.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 b=Nn(a,i,t);o.push(b)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:d,savedExpectedTypes:g}=l;i=o,o=d,a=h,c=g}else if(p===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=Nn(a,i,t);i=[],o.push(l),a="",c+=1}else if(bs(p)){let l=!1;if(a.length!==0){let d=Nn(a,i,t);i=[],o.push(d),a="",l=!0}s=Pu(n,s);let h=n[s];if(s<n.length&&l&&h!==","&&h!==">")throw new $(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return Nn(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function Nn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Eu(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Kt;case"bool":return new L;case"address":return new O;case"u8":return new le;case"u16":return new Je;case"u32":return new Xe;case"u64":return new J;case"u128":return new Ye;case"u256":return new Ze;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(Su(r)){let a=r.substring(1);return new mr(Nn(a,e,t))}if(wu(r)){if(t)return new G(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunk66TIRJFDjs.Z.fromString(o[0])}catch (e4){throw new $(n,"struct address must be valid")}if(!Ts(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!Ts(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new A(new Be(s,new k(o[1]),new k(o[2]),e))}}function ws(n){return typeof n=="boolean"}function it(n){return typeof n=="string"}function xu(n){return typeof n=="number"}function kr(n){if(xu(n))return n;if(it(n)&&n!=="")return Number.parseInt(n,10)}function Dr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ss(n){return n==null}function Es(n){return xi(n)||Ci(n)||vi(n)||Ki(n)||Ri(n)||Ui(n)||ki(n)||zr(n)||Ii(n)||Iu(n)||n instanceof S||n instanceof Y}function xi(n){return n instanceof z}function zr(n){return n instanceof _chunk66TIRJFDjs.Z}function Ii(n){return n instanceof x}function Iu(n){return n instanceof Ee}function Ci(n){return n instanceof X}function vi(n){return n instanceof Pe}function Ki(n){return n instanceof _e}function Ri(n){return n instanceof Q}function Ui(n){return n instanceof xe}function ki(n){return n instanceof ye}function Ps(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function _s(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Cu=new TextEncoder;function cn(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _82 => _82.map, 'call', _83 => _83(e=>it(e)?Re(e):e)]), () => ([]))}async function zi(n,e,t){return(await Nr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Ni(n,e,t,r){let i=await zi(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function Vb(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(Re(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function xs(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=_s(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Re(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Is(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Re(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Re(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Hb(n,e,t,r,i){return n instanceof _chunk66TIRJFDjs.X?n:_chunk66TIRJFDjs.X.newBytes(un(e,t,n,r,i).bcsToBytes())}function un(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=Re(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return Mt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Mt(n,e,t,r,i,o){return Es(n)?(Di(e,n,t),n):vu(n,e,t,r,i,o)}function vu(n,e,t,r,i,o){if(e.isBool()){if(ws(n))return new z(n);if(it(n)){if(n==="true")return new z(!0);if(n==="false")return new z(!1)}D("boolean",t)}if(e.isAddress()){if(it(n))return _chunk66TIRJFDjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let s=kr(n);if(s!==void 0)return new X(s);D("number | string",t)}if(e.isU16()){let s=kr(n);if(s!==void 0)return new Pe(s);D("number | string",t)}if(e.isU32()){let s=kr(n);if(s!==void 0)return new _e(s);D("number | string",t)}if(e.isU64()){if(Dr(n))return new Q(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(Dr(n))return new xe(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(Dr(n))return new ye(BigInt(n));D("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Mt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(it(n))return S.U8(Cu.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(it(n)&&n.startsWith("["))return Mt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Mt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(it(n))return new x(n);D("string",t)}if(e.isObject()){if(it(n))return _chunk66TIRJFDjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Ee(n);D("Uint8Array",t)}if(e.isOption()){if(Ss(n)){let a=e.value.typeArgs[0];return a instanceof L?new Y(null):a instanceof O?new Y(null):a instanceof le?new Y(null):a instanceof Je?new Y(null):a instanceof Xe?new Y(null):a instanceof J?new Y(null):a instanceof Ye?new Y(null):a instanceof Ze?new Y(null):new Y(null)}return new Y(Mt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _84 => _84.structs, 'access', _85 => _85.find, 'call', _86 => _86(a=>a.name===e.value.name.identifier), 'optionalAccess', _87 => _87.fields, 'access', _88 => _88.length])===0&&n instanceof Uint8Array)return new Ee(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _89 => _89.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Ee(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Di(n,e,t){if(n.isBool()){if(xi(e))return;D("Bool",t)}if(n.isAddress()){if(zr(e))return;D("AccountAddress",t)}if(n.isU8()){if(Ci(e))return;D("U8",t)}if(n.isU16()){if(vi(e))return;D("U16",t)}if(n.isU32()){if(Ki(e))return;D("U32",t)}if(n.isU64()){if(Ri(e))return;D("U64",t)}if(n.isU128()){if(Ui(e))return;D("U128",t)}if(n.isU256()){if(ki(e))return;D("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Di(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof A){if(n.isString()){if(Ii(e))return;D("MoveString",t)}if(n.isObject()){if(zr(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof Y){e.value!==void 0&&Di(n.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Or(n){if(Ps(n))return ku(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk66TIRJFDjs.la.call(void 0, n.function),i=await Rs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:xs});return Ru({...n,abi:i})}function Ru(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, n.function),o=cn(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>un(n.function,e,c,p,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=kt.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunk66TIRJFDjs.Z.from(n.multisigAddress);return new vn(new Rn(c,new Un(a)))}return new Cn(a)}async function Cs(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk66TIRJFDjs.la.call(void 0, n.function),i=await Rs({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Is});return Uu({abi:i,...n})}function Uu(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, n.function),o=cn(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _90 => _90.functionArguments, 'optionalAccess', _91 => _91.map, 'call', _92 => _92((a,c)=>un(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return kt.build(`${t}::${r}`,i,o,s)}function ku(n){return new Ut(new Kn(_chunk66TIRJFDjs.j.fromHexInput(n.bytecode).toUint8Array(),cn(n.typeArguments),n.functionArguments))}async function Oi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>si[e.network]?{chainId:si[e.network]}:{chainId:(await _r({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _93 => _93.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Rr({aptosConfig:e})).gas_estimate},c=async()=>{let v=async()=>_optionalChain([i, 'optionalAccess', _94 => _94.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Cr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk66TIRJFDjs.Z.from(o).equals(_chunk66TIRJFDjs.Z.ZERO))try{return await v()}catch (e5){return 0}else return v()},[{chainId:p},{gasEstimate:l},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:d,gasUnitPrice:g,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _95 => _95.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _96 => _96.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _97 => _97.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new be(_chunk66TIRJFDjs.Z.from(t),BigInt(h),r,BigInt(d),BigInt(g),BigInt(b),new tn(p))}async function Fi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Oi({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.secondarySignerAddresses, 'optionalAccess', _99 => _99.map, 'call', _100 => _100(c=>_chunk66TIRJFDjs.Z.from(c))]), () => ([]));return new Ar(s,a,n.feePayerAddress?_chunk66TIRJFDjs.Z.from(n.feePayerAddress):void 0)}return new rn(s,n.feePayerAddress?_chunk66TIRJFDjs.Z.from(n.feePayerAddress):void 0)}function vs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=pn(e);if(t.feePayerAddress){let a=new zt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>pn(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>pn(void 0)));let p=pn(i),l=new Ft(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new tt(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Dt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>pn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>pn(void 0));let p=new Ot(o,t.secondarySignerAddresses,c);return new tt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof ve)s=new Nt(o.public_key,o.signature);else if(o instanceof oe||o instanceof Ge)s=new ft(o);else if(o instanceof en)s=new ft(o);else throw new Error("Invalid public key");return new tt(t.rawTransaction,s).bcsToBytes()}function pn(n){if(!n)return new en;let t=U.isInstance(n)||Z.isInstance(n)||$e.isInstance(n)?new N(n):n,r=new K(new Uint8Array(64));if(I.isInstance(t))return new ve(t,r);if(N.isInstance(t))return U.isInstance(t.publicKey)?new oe(t,new H(he.getSimulationSignature())):new oe(t,new H(r));if(Oe.isInstance(t))return new Ge(t,new Fe({signatures:t.publicKeys.map(i=>U.isInstance(i.publicKey)||Z.isInstance(i.publicKey)?new H(he.getSimulationSignature()):new H(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Gi(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Ko(j,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Ft(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Ot(i,e.secondarySignerAddresses,r)}else i instanceof ve?o=new Nt(i.public_key,i.signature):i instanceof je?o=new nn(i.public_key,i.signature):o=new ft(i);return new tt(e.rawTransaction,o).bcsToBytes()}function Ks(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Du=Ks(["APTOS::Transaction"]);function mw(n){let e=Gi(n);return new (0, _chunk66TIRJFDjs.j)(Ks([Du,new Uint8Array([0]),e])).toString()}async function Rs({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:De(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var Fr=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await Promise.resolve().then(() => _interopRequireWildcard(require("@aptos-labs/script-composer-pack"))),{TransactionComposer:t,initSync:r}=e;_scriptcomposerpack.ScriptComposerWasm.isInitialized||_scriptcomposerpack.ScriptComposerWasm.init(),r({module:_scriptcomposerpack.ScriptComposerWasm.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, e.function),o=this.config.getRequestUrl("Fullnode");if(await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0)for(let l of e.typeArguments)await this.builder.load_type_tag(o,l.toString());let s=cn(e.typeArguments),a=await zi(t,r,this.config);if(!a)throw new Error(`Could not find module ABI for '${t}::${r}'`);let c=_optionalChain([a, 'optionalAccess', _101 => _101.exposed_functions, 'access', _102 => _102.find, 'call', _103 => _103(l=>l.name===i)]);if(!c)throw new Error(`Could not find function ABI for '${t}::${r}::${i}'`);if(s.length!==c.generic_type_params.length)throw new Error(`Type argument count mismatch, expected ${_optionalChain([c, 'optionalAccess', _104 => _104.generic_type_params, 'access', _105 => _105.length])}, received ${s.length}`);let p=e.functionArguments.map((l,h)=>l instanceof _chunk66TIRJFDjs.X?l:_chunk66TIRJFDjs.X.newBytes(un(i,a,l,h,s,{allowUnknownStructs:!0}).bcsToBytes()));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(l=>l.toString()),p)}build(){return this.builder.generate_batched_calls(!0)}};async function T(n){let e=await zu(n);return Nu(n,e)}async function zu(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Or(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Or(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Or(r)),i}async function Nu(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Ou(n)&&(o=_chunk66TIRJFDjs.Z.ZERO.toString()),Fu(n)){let{secondarySignerAddresses:s}=n;return Fi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Fi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function Ou(n){return n.withFeePayer===!0}function Fu(n){return"secondarySignerAddresses"in n}function Us(n){let{transaction:e}=n;return Ke(e)}function Gr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Br(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Gr({signer:e,transaction:t})}async function Mi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=vs({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await gt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _106 => _106.options, 'optionalAccess', _107 => _107.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _108 => _108.options, 'optionalAccess', _109 => _109.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _110 => _110.options, 'optionalAccess', _111 => _111.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function On(n){let{aptosConfig:e}=n,t=Gi({...n});try{let{data:r}=await gt({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=tt.deserialize(new R(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof U||i.authenticator.sender.public_key.publicKey instanceof Z)&&await me.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function ht(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;br(t)&&await t.checkKeylessAccountValidity(e),br(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Br({signer:r,transaction:i}),s=Gr({signer:t,transaction:i});return On({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ks(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;br(r)&&await r.checkKeylessAccountValidity(e);let o=Br({signer:r,transaction:i});return On({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Gu={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Ds(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>S.U8(a));return T({aptosConfig:e,sender:_chunk66TIRJFDjs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Gu},options:o})}async function Vt(n){return Cr(n)}async function Ns(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ui({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _112 => _112.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _113 => _113.limit]), () => (1e3))}})}async function Os(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await lr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _114 => _114.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _115 => _115.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _116 => _116.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Nr(n){return ds(n)}async function Fs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return dr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _117 => _117.offset]),limit:_optionalChain([r, 'optionalAccess', _118 => _118.limit])}})}async function Gs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ui({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _119 => _119.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.limit]), () => (999))}})}async function Bs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await lr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _121 => _121.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _122 => _122.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _123 => _123.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function Hi(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _124 => _124.ledgerVersion])}});return o.data}async function dn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Hi({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunk66TIRJFDjs.Z.from(t);try{let a=await vr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk66TIRJFDjs.Z.from(a)}catch(a){if(a instanceof Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ms(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Jo,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 Vs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _125 => _125.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _126 => _126.tokenStandard])});let s={query:Qo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _127 => _127.offset]),limit:_optionalChain([r, 'optionalAccess', _128 => _128.limit]),order_by:_optionalChain([r, 'optionalAccess', _129 => _129.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Hs(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk66TIRJFDjs.Z.from(t).toStringLong(),s=_chunk66TIRJFDjs.Z.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _130 => _130.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _131 => _131.tokenStandard])});let c={query:jo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _132 => _132.offset]),limit:_optionalChain([i, 'optionalAccess', _133 => _133.limit]),order_by:_optionalChain([i, 'optionalAccess', _134 => _134.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Ls(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _135 => _135.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _136 => _136.tokenStandard])}});let s={query:Wo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _137 => _137.offset]),limit:_optionalChain([r, 'optionalAccess', _138 => _138.limit]),order_by:_optionalChain([r, 'optionalAccess', _139 => _139.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function qs(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Xo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function $s(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _140 => _140.where]),owner_address:{_eq:i}},s={query:$o,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([r, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([r, 'optionalAccess', _143 => _143.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Ws(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:qo,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 Qs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}},s={query:Pr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _144 => _144.offset]),limit:_optionalChain([r, 'optionalAccess', _145 => _145.limit]),order_by:_optionalChain([r, 'optionalAccess', _146 => _146.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function js(n){let{aptosConfig:e,privateKey:t}=n,r=new N(t.publicKey());if(t instanceof We){let o=B.fromPublicKey({publicKey:r}).derivedAddress();return nt.fromPrivateKey({privateKey:t,address:o})}if(t instanceof q){let i=B.fromPublicKey({publicKey:r});if(await zs({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return nt.fromPrivateKey({privateKey:t,address:c,legacy:!1})}let s=B.fromPublicKey({publicKey:r.publicKey});if(await zs({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return nt.fromPrivateKey({privateKey:t,address:c,legacy:!0})}}throw new Error(`Can't derive account from private key ${t}`)}async function zs(n){let{aptosConfig:e,authKey:t}=n,r=await dn({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Vt({aptosConfig:e,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}var Bu={typeParameters:[],parameters:[new le,C.u8(),new le,C.u8(),C.u8(),C.u8()]};async function Js(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r}=n;if("toNewPrivateKey"in n)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey});let i;if("toAccount"in n){if(n.toAccount instanceof se)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof wr)return Vi({aptosConfig:e,fromAccount:t,toAccount:n.toAccount});i=n.toAccount.publicKey.authKey()}else if("toAuthKey"in n)i=n.toAuthKey;else throw new Error("Invalid arguments");let o=await Vu({aptosConfig:e,fromAccount:t,toAuthKey:i});if(r===!0)return o;let s=await At({aptosConfig:e,transactionHash:o.hash});if(!s.success)throw new Error(`Failed to rotate authentication key - ${s}`);let a=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return ht({aptosConfig:e,signer:n.toAccount,transaction:a})}async function Vi(n){let{aptosConfig:e,fromAccount:t}=n,r=await Vt({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=nt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new fr({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk66TIRJFDjs.Z.from(r.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),a=t.sign(s),c=i.sign(s),p=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new X(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new X(i.signingScheme),S.U8(i.publicKey.toUint8Array()),S.U8(a.toUint8Array()),S.U8(c.toUint8Array())],abi:Bu}});return ht({aptosConfig:e,signer:t,transaction:p})}var Mu={typeParameters:[],parameters:[C.u8()]};async function Vu(n){let{aptosConfig:e,fromAccount:t,toAuthKey:r}=n,i=r,o=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[S.U8(i.toUint8Array())],abi:Mu}});return ht({aptosConfig:e,signer:t,transaction:o})}async function E(n){n.minimumLedgerVersion!==void 0&&await Ur({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function ae(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Cs({...t,aptosConfig:e}),o=new _chunk66TIRJFDjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await gt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _147 => _147.ledgerVersion])},body:s});return a}async function Xs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await gt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _148 => _148.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function Ys(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk66TIRJFDjs.la.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new O,new A(_()),new A(_())]}},options:i})}async function Zs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk66TIRJFDjs.la.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new O,new A(_()),new A(_())]}},options:i})}async function ea(n){let{aptosConfig:e,sender:t,options:r}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Ht=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk66TIRJFDjs.la.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.some, 'call', _150 => _150(s=>_chunk66TIRJFDjs.Z.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)]), () => (!1))};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ys({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Zs({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return ea({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ae({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk66TIRJFDjs.Z.from(t)],abi:{typeParameters:[],parameters:[new O],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk66TIRJFDjs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var Fn=class{constructor(e){this.config=e;this.abstraction=new Ht(e)}async getAccountInfo(e){return Vt({aptosConfig:this.config,...e})}async getAccountModules(e){return Ns({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Os({aptosConfig:this.config,...e})}async getAccountModule(e){return Nr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Fs({aptosConfig:this.config,...e})}async getAccountResources(e){return Gs({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Bs({aptosConfig:this.config,...e})}async getAccountResource(e){return Hi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return dn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ms({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),qs({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$s({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ws({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:xt,faMetadataAddress:Io,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
|
|
477
|
+
`;async function _r(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function us(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Yo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await Uo({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function wu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Si},originMethod:"getProcessorStatuses"})).processor_status}async function xr(n){let e=await wu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Ir(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Si,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function Cr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}`});return r}async function ds(n){return _optionalChain([n, 'access', _60 => _60.options, 'optionalAccess', _61 => _61.ledgerVersion])!==void 0?ps(n):De(async()=>ps(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ps(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _62 => _62.ledgerVersion])}});return o}async function vr(n){let{aptosConfig:e,handle:t,data:r,options:i}=n;return(await gt({aptosConfig:e,originMethod:"getTableItem",path:`tables/${t}/item`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _63 => _63.ledgerVersion])},body:r})).data}async function ls(n){let{aptosConfig:e,options:t}=n,r={query:os,variables:{where_condition:_optionalChain([t, 'optionalAccess', _64 => _64.where]),offset:_optionalChain([t, 'optionalAccess', _65 => _65.offset]),limit:_optionalChain([t, 'optionalAccess', _66 => _66.limit]),order_by:_optionalChain([t, 'optionalAccess', _67 => _67.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function gs(n){let{aptosConfig:e,options:t}=n,r={query:ss,variables:{where_condition:_optionalChain([t, 'optionalAccess', _68 => _68.where]),offset:_optionalChain([t, 'optionalAccess', _69 => _69.offset]),limit:_optionalChain([t, 'optionalAccess', _70 => _70.limit]),order_by:_optionalChain([t, 'optionalAccess', _71 => _71.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function _i(n){let{aptosConfig:e,options:t}=n;return dr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([t, 'optionalAccess', _73 => _73.limit])}})}async function Rr(n){let{aptosConfig:e}=n;return De(async()=>{let{data:t}=await V({aptosConfig:e,originMethod:"getGasPriceEstimation",path:"estimate_gas_price"});return t},`gas-price-${e.network}`,1e3*60*5)()}async function ms(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function zn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function ys(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await zn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _74 => _74.status])===404)return!0;throw r}}async function Su(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/wait_by_hash/${t}`,originMethod:"longWaitForTransaction"});return r}async function At(n){let{aptosConfig:e,transactionHash:t,options:r}=n,i=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _75 => _75.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _76 => _76.checkSuccess]), () => (!0)),s=!0,a=0,c,p,l=200,h=1.5;function d(g){if(!(g instanceof Ae)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await zn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){d(g)}if(s){let g=Date.now();try{c=await Su({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(b){d(b)}a=(Date.now()-g)/1e3}for(;s&&!(a>=i);){try{if(c=await zn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){d(g)}await _chunk66TIRJFDjs.ba.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new Kr(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Kr(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new Pi(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function Ur(n){let{aptosConfig:e,processorType:t}=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(t===void 0?s=await xr({aptosConfig:e}):s=(await Ir({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk66TIRJFDjs.ba.call(void 0, 200)}}var Kr=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},Pi=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function fs(n){let{aptosConfig:e,ledgerVersion:t,options:r}=n,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByVersion",path:`blocks/by_version/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _77 => _77.withTransactions])}});return hs({block:i,...n})}async function As(n){let{aptosConfig:e,blockHeight:t,options:r}=n,{data:i}=await V({aptosConfig:e,originMethod:"getBlockByHeight",path:`blocks/by_height/${t}`,params:{with_transactions:_optionalChain([r, 'optionalAccess', _78 => _78.withTransactions])}});return hs({block:i,...n})}async function hs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _79 => _79.withTransactions])){t.transactions=_nullishCoalesce(t.transactions, () => ([]));let i=t.transactions[t.transactions.length-1],o=BigInt(t.first_version),s=BigInt(t.last_version),a=_optionalChain([i, 'optionalAccess', _80 => _80.version]),c;if(a===void 0?c=o-1n:c=BigInt(a),c===s)return t;let p=[],l=100n;for(let d=c+1n;d<s;d+=BigInt(100))p.push(_i({aptosConfig:e,options:{offset:d,limit:Math.min(Number(l),Number(s-d+1n))}}));let h=await Promise.all(p);for(let d of h)t.transactions.push(...d)}return t}function Ts(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function bs(n){return!!n.match(/\s/)}function Eu(n){return!!n.match(/^T[0-9]+$/)}function Pu(n){return!!n.match(/^&.+$/)}function _u(n){switch(n){case"signer":case"address":case"bool":case"u8":case"u16":case"u32":case"u64":case"u128":case"u256":return!0;default:return!1}}function xu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!bs(r))break}return t}var Iu=(b=>(b.InvalidTypeTag="unknown type",b.UnexpectedGenericType="unexpected generic type",b.UnexpectedTypeArgumentClose="unexpected '>'",b.UnexpectedWhitespaceCharacter="unexpected whitespace character",b.UnexpectedComma="unexpected ','",b.TypeArgumentCountMismatch="type argument count doesn't match expected amount",b.MissingTypeArgumentClose="no matching '>' for '<'",b.MissingTypeArgument="no type argument before ','",b.UnexpectedPrimitiveTypeArguments="primitive types not expected to have type arguments",b.UnexpectedVectorTypeArgumentCount="vector type expected to have exactly one type argument",b.UnexpectedStructFormat="unexpected struct format, must be of the form 0xaddress::module_name::struct_name",b.InvalidModuleNameCharacter="module name must only contain alphanumeric or '_' characters",b.InvalidStructNameCharacter="struct name must only contain alphanumeric or '_' characters",b.InvalidAddress="struct address must be valid",b))(Iu||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Re(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _81 => _81.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 b=Nn(a,i,t);o.push(b)}let l=r.pop();if(l===void 0)throw new $(n,"unexpected '>'");if(c!==o.length)throw new $(n,"type argument count doesn't match expected amount");let{savedStr:h,savedTypes:d,savedExpectedTypes:g}=l;i=o,o=d,a=h,c=g}else if(p===","){if(r.length===0)throw new $(n,"unexpected ','");if(a.length===0)throw new $(n,"no type argument before ','");let l=Nn(a,i,t);i=[],o.push(l),a="",c+=1}else if(bs(p)){let l=!1;if(a.length!==0){let d=Nn(a,i,t);i=[],o.push(d),a="",l=!0}s=xu(n,s);let h=n[s];if(s<n.length&&l&&h!==","&&h!==">")throw new $(n,"unexpected whitespace character");continue}else a+=p;s+=1}if(r.length>0)throw new $(n,"no matching '>' for '<'");switch(o.length){case 0:return Nn(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function Nn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(_u(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Kt;case"bool":return new L;case"address":return new F;case"u8":return new le;case"u16":return new Je;case"u32":return new Xe;case"u64":return new J;case"u128":return new Ye;case"u256":return new Ze;case"vector":if(e.length!==1)throw new $(n,"vector type expected to have exactly one type argument");return new C(e[0]);default:if(Pu(r)){let a=r.substring(1);return new mr(Nn(a,e,t))}if(Eu(r)){if(t)return new G(Number(r.split("T")[1]));throw new $(n,"unexpected generic type")}if(!r.match(/:/))throw new $(n,"unknown type");let o=r.split("::");if(o.length!==3)throw new $(n,"unexpected struct format, must be of the form 0xaddress::module_name::struct_name");let s;try{s=_chunk66TIRJFDjs.Z.fromString(o[0])}catch (e4){throw new $(n,"struct address must be valid")}if(!Ts(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!Ts(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new A(new Be(s,new k(o[1]),new k(o[2]),e))}}function ws(n){return typeof n=="boolean"}function it(n){return typeof n=="string"}function Cu(n){return typeof n=="number"}function kr(n){if(Cu(n))return n;if(it(n)&&n!=="")return Number.parseInt(n,10)}function Dr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ss(n){return n==null}function Es(n){return xi(n)||Ci(n)||vi(n)||Ki(n)||Ri(n)||Ui(n)||ki(n)||zr(n)||Ii(n)||vu(n)||n instanceof S||n instanceof Y}function xi(n){return n instanceof z}function zr(n){return n instanceof _chunk66TIRJFDjs.Z}function Ii(n){return n instanceof x}function vu(n){return n instanceof Ee}function Ci(n){return n instanceof X}function vi(n){return n instanceof Pe}function Ki(n){return n instanceof _e}function Ri(n){return n instanceof Q}function Ui(n){return n instanceof xe}function ki(n){return n instanceof ye}function Ps(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function _s(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Ku=new TextEncoder;function cn(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _82 => _82.map, 'call', _83 => _83(e=>it(e)?Re(e):e)]), () => ([]))}async function zi(n,e,t){return(await Nr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Ni(n,e,t,r){let i=await zi(n,e,r);if(!i)throw new Error(`Could not find module ABI for '${n}::${e}'`);return i.exposed_functions.find(o=>o.name===t)}async function Hb(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find function ABI for '${n}::${e}::${t}'`);let o=[];for(let s=0;s<i.params.length;s+=1)o.push(Re(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function xs(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find entry function ABI for '${n}::${e}::${t}'`);if(!i.is_entry)throw new Error(`'${n}::${e}::${t}' is not an entry function`);let o=_s(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Re(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Is(n,e,t,r){let i=await Ni(n,e,t,r);if(!i)throw new Error(`Could not find view function ABI for '${n}::${e}::${t}'`);if(!i.is_view)throw new Error(`'${n}::${e}::${t}' is not an view function`);let o=[];for(let a=0;a<i.params.length;a+=1)o.push(Re(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Re(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Lb(n,e,t,r,i){return n instanceof _chunk66TIRJFDjs.X?n:_chunk66TIRJFDjs.X.newBytes(un(e,t,n,r,i).bcsToBytes())}function un(n,e,t,r,i,o){let s;if("exposed_functions"in e){let a=e.exposed_functions.find(c=>c.name===n);if(!a)throw new Error(`Could not find function ABI for '${e.address}::${e.name}::${n}'`);if(r>=a.params.length)throw new Error(`Too many arguments for '${n}', expected ${a.params.length}`);s=Re(a.params[r],{allowGenerics:!0})}else{if(r>=e.parameters.length)throw new Error(`Too many arguments for '${n}', expected ${e.parameters.length}`);s=e.parameters[r]}return Mt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Mt(n,e,t,r,i,o){return Es(n)?(Di(e,n,t),n):Ru(n,e,t,r,i,o)}function Ru(n,e,t,r,i,o){if(e.isBool()){if(ws(n))return new z(n);if(it(n)){if(n==="true")return new z(!0);if(n==="false")return new z(!1)}D("boolean",t)}if(e.isAddress()){if(it(n))return _chunk66TIRJFDjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let s=kr(n);if(s!==void 0)return new X(s);D("number | string",t)}if(e.isU16()){let s=kr(n);if(s!==void 0)return new Pe(s);D("number | string",t)}if(e.isU32()){let s=kr(n);if(s!==void 0)return new _e(s);D("number | string",t)}if(e.isU64()){if(Dr(n))return new Q(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(Dr(n))return new xe(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(Dr(n))return new ye(BigInt(n));D("bigint | number | string",t)}if(e.isGeneric()){let s=e.value;if(s<0||s>=r.length)throw new Error(`Generic argument ${e.toString()} is invalid for argument ${t}`);return Mt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(it(n))return S.U8(Ku.encode(n));if(n instanceof Uint8Array)return S.U8(n);if(n instanceof ArrayBuffer)return S.U8(new Uint8Array(n))}if(it(n)&&n.startsWith("["))return Mt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Mt(s,e.value,t,r,i)));throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}if(e.isStruct()){if(e.isString()){if(it(n))return new x(n);D("string",t)}if(e.isObject()){if(it(n))return _chunk66TIRJFDjs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Ee(n);D("Uint8Array",t)}if(e.isOption()){if(Ss(n)){let a=e.value.typeArgs[0];return a instanceof L?new Y(null):a instanceof F?new Y(null):a instanceof le?new Y(null):a instanceof Je?new Y(null):a instanceof Xe?new Y(null):a instanceof J?new Y(null):a instanceof Ye?new Y(null):a instanceof Ze?new Y(null):new Y(null)}return new Y(Mt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _84 => _84.structs, 'access', _85 => _85.find, 'call', _86 => _86(a=>a.name===e.value.name.identifier), 'optionalAccess', _87 => _87.fields, 'access', _88 => _88.length])===0&&n instanceof Uint8Array)return new Ee(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _89 => _89.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Ee(n);throw new Error(`Unsupported struct input type for argument ${t}, type '${e.toString()}'`)}throw new Error(`Type mismatch for argument ${t}, type '${e.toString()}'`)}function Di(n,e,t){if(n.isBool()){if(xi(e))return;D("Bool",t)}if(n.isAddress()){if(zr(e))return;D("AccountAddress",t)}if(n.isU8()){if(Ci(e))return;D("U8",t)}if(n.isU16()){if(vi(e))return;D("U16",t)}if(n.isU32()){if(Ki(e))return;D("U32",t)}if(n.isU64()){if(Ri(e))return;D("U64",t)}if(n.isU128()){if(Ui(e))return;D("U128",t)}if(n.isU256()){if(ki(e))return;D("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Di(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof A){if(n.isString()){if(Ii(e))return;D("MoveString",t)}if(n.isObject()){if(zr(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof Y){e.value!==void 0&&Di(n.value.typeArgs[0],e.value,t);return}D("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Fr(n){if(Ps(n))return zu(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk66TIRJFDjs.la.call(void 0, n.function),i=await Rs({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:xs});return ku({...n,abi:i})}function ku(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, n.function),o=cn(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=n.functionArguments.map((c,p)=>un(n.function,e,c,p,o));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);let a=kt.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunk66TIRJFDjs.Z.from(n.multisigAddress);return new vn(new Rn(c,new Un(a)))}return new Cn(a)}async function Cs(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk66TIRJFDjs.la.call(void 0, n.function),i=await Rs({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Is});return Du({abi:i,...n})}function Du(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, n.function),o=cn(n.typeArguments);if(o.length!==e.typeParameters.length)throw new Error(`Type argument count mismatch, expected ${e.typeParameters.length}, received ${o.length}`);let s=_nullishCoalesce(_optionalChain([n, 'optionalAccess', _90 => _90.functionArguments, 'optionalAccess', _91 => _91.map, 'call', _92 => _92((a,c)=>un(n.function,e,a,c,o))]), () => ([]));if(s.length!==e.parameters.length)throw new Error(`Too few arguments for '${t}::${r}::${i}', expected ${e.parameters.length} but got ${s.length}`);return kt.build(`${t}::${r}`,i,o,s)}function zu(n){return new Ut(new Kn(_chunk66TIRJFDjs.j.fromHexInput(n.bytecode).toUint8Array(),cn(n.typeArguments),n.functionArguments))}async function Fi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>si[e.network]?{chainId:si[e.network]}:{chainId:(await _r({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _93 => _93.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Rr({aptosConfig:e})).gas_estimate},c=async()=>{let v=async()=>_optionalChain([i, 'optionalAccess', _94 => _94.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Cr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk66TIRJFDjs.Z.from(o).equals(_chunk66TIRJFDjs.Z.ZERO))try{return await v()}catch (e5){return 0}else return v()},[{chainId:p},{gasEstimate:l},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:d,gasUnitPrice:g,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _95 => _95.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _96 => _96.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _97 => _97.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new be(_chunk66TIRJFDjs.Z.from(t),BigInt(h),r,BigInt(d),BigInt(g),BigInt(b),new tn(p))}async function Oi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=await Fi({aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o});if("secondarySignerAddresses"in n){let a=_nullishCoalesce(_optionalChain([n, 'access', _98 => _98.secondarySignerAddresses, 'optionalAccess', _99 => _99.map, 'call', _100 => _100(c=>_chunk66TIRJFDjs.Z.from(c))]), () => ([]));return new Ar(s,a,n.feePayerAddress?_chunk66TIRJFDjs.Z.from(n.feePayerAddress):void 0)}return new rn(s,n.feePayerAddress?_chunk66TIRJFDjs.Z.from(n.feePayerAddress):void 0)}function vs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=pn(e);if(t.feePayerAddress){let a=new zt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>pn(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>pn(void 0)));let p=pn(i),l=new Ot(o,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),c,{address:t.feePayerAddress,authenticator:p});return new tt(a.raw_txn,l).bcsToBytes()}if(t.secondarySignerAddresses){let a=new Dt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>pn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>pn(void 0));let p=new Ft(o,t.secondarySignerAddresses,c);return new tt(a.raw_txn,p).bcsToBytes()}let s;if(o instanceof ve)s=new Nt(o.public_key,o.signature);else if(o instanceof oe||o instanceof Ge)s=new ft(o);else if(o instanceof en)s=new ft(o);else throw new Error("Invalid public key");return new tt(t.rawTransaction,s).bcsToBytes()}function pn(n){if(!n)return new en;let t=U.isInstance(n)||Z.isInstance(n)||$e.isInstance(n)?new N(n):n,r=new K(new Uint8Array(64));if(I.isInstance(t))return new ve(t,r);if(N.isInstance(t))return U.isInstance(t.publicKey)?new oe(t,new H(he.getSimulationSignature())):new oe(t,new H(r));if(Fe.isInstance(t))return new Ge(t,new Oe({signatures:t.publicKeys.map(i=>U.isInstance(i.publicKey)||Z.isInstance(i.publicKey)?new H(he.getSimulationSignature()):new H(r)),bitmap:t.createBitmap({bits:Array(t.publicKeys.length).fill(0).map((i,o)=>o)})}));throw new Error("Unsupported PublicKey used for simulations")}function Gi(n){let{transaction:e,feePayerAuthenticator:t,additionalSignersAuthenticators:r}=n,i=Ko(j,n.senderAuthenticator),o;if(e.feePayerAddress){if(!t)throw new Error("Must provide a feePayerAuthenticator argument to generate a signed fee payer transaction");o=new Ot(i,_nullishCoalesce(e.secondarySignerAddresses, () => ([])),_nullishCoalesce(r, () => ([])),{address:e.feePayerAddress,authenticator:t})}else if(e.secondarySignerAddresses){if(!r)throw new Error("Must provide a additionalSignersAuthenticators argument to generate a signed multi agent transaction");o=new Ft(i,e.secondarySignerAddresses,r)}else i instanceof ve?o=new Nt(i.public_key,i.signature):i instanceof je?o=new nn(i.public_key,i.signature):o=new ft(i);return new tt(e.rawTransaction,o).bcsToBytes()}function Ks(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Nu=Ks(["APTOS::Transaction"]);function yw(n){let e=Gi(n);return new (0, _chunk66TIRJFDjs.j)(Ks([Nu,new Uint8Array([0]),e])).toString()}async function Rs({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:De(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var Or=class n{constructor(e){this.config=e,this.builder=void 0}async init(){if(!n.transactionComposer){let e=await Promise.resolve().then(() => _interopRequireWildcard(require("@aptos-labs/script-composer-pack"))),{TransactionComposer:t,initSync:r}=e;_scriptcomposerpack.ScriptComposerWasm.isInitialized||_scriptcomposerpack.ScriptComposerWasm.init(),r({module:_scriptcomposerpack.ScriptComposerWasm.wasm}),n.transactionComposer=t}this.builder=n.transactionComposer.single_signer()}async addBatchedCalls(e){let{moduleAddress:t,moduleName:r,functionName:i}=_chunk66TIRJFDjs.la.call(void 0, e.function),o=this.config.getRequestUrl("Fullnode");if(await this.builder.load_module(o,`${t}::${r}`),e.typeArguments!==void 0)for(let l of e.typeArguments)await this.builder.load_type_tag(o,l.toString());let s=cn(e.typeArguments),a=await zi(t,r,this.config);if(!a)throw new Error(`Could not find module ABI for '${t}::${r}'`);let c=_optionalChain([a, 'optionalAccess', _101 => _101.exposed_functions, 'access', _102 => _102.find, 'call', _103 => _103(l=>l.name===i)]);if(!c)throw new Error(`Could not find function ABI for '${t}::${r}::${i}'`);if(s.length!==c.generic_type_params.length)throw new Error(`Type argument count mismatch, expected ${_optionalChain([c, 'optionalAccess', _104 => _104.generic_type_params, 'access', _105 => _105.length])}, received ${s.length}`);let p=e.functionArguments.map((l,h)=>l instanceof _chunk66TIRJFDjs.X?l:_chunk66TIRJFDjs.X.newBytes(un(i,a,l,h,s,{allowUnknownStructs:!0}).bcsToBytes()));return this.builder.add_batched_call(`${t}::${r}`,i,s.map(l=>l.toString()),p)}build(){return this.builder.generate_batched_calls(!0)}};async function T(n){let e=await Fu(n);return Ou(n,e)}async function Fu(n){let{aptosConfig:e,data:t}=n,r,i;return"bytecode"in t?i=await Fr(t):"multisigAddress"in t?(r={aptosConfig:e,multisigAddress:t.multisigAddress,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Fr(r)):(r={aptosConfig:e,function:t.function,functionArguments:t.functionArguments,typeArguments:t.typeArguments,abi:t.abi},i=await Fr(r)),i}async function Ou(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Gu(n)&&(o=_chunk66TIRJFDjs.Z.ZERO.toString()),Bu(n)){let{secondarySignerAddresses:s}=n;return Oi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Oi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function Gu(n){return n.withFeePayer===!0}function Bu(n){return"secondarySignerAddresses"in n}function Us(n){let{transaction:e}=n;return Ke(e)}function Gr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Br(n){let{signer:e,transaction:t}=n;if(!t.feePayerAddress)throw new Error(`Transaction ${t} is not a Fee Payer transaction`);return t.feePayerAddress=e.accountAddress,Gr({signer:e,transaction:t})}async function Mi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=vs({transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}),{data:c}=await gt({aptosConfig:e,body:a,path:"transactions/simulate",params:{estimate_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _106 => _106.options, 'optionalAccess', _107 => _107.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _108 => _108.options, 'optionalAccess', _109 => _109.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _110 => _110.options, 'optionalAccess', _111 => _111.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Fn(n){let{aptosConfig:e}=n,t=Gi({...n});try{let{data:r}=await gt({aptosConfig:e,body:t,path:"transactions",originMethod:"submitTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return r}catch(r){let i=tt.deserialize(new R(t));throw i.authenticator.isSingleSender()&&i.authenticator.sender.isSingleKey()&&(i.authenticator.sender.public_key.publicKey instanceof U||i.authenticator.sender.public_key.publicKey instanceof Z)&&await me.fetchJWK({aptosConfig:e,publicKey:i.authenticator.sender.public_key.publicKey,kid:i.authenticator.sender.signature.signature.getJwkKid()}),r}}async function ht(n){let{aptosConfig:e,signer:t,feePayer:r,transaction:i}=n;br(t)&&await t.checkKeylessAccountValidity(e),br(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Br({signer:r,transaction:i}),s=Gr({signer:t,transaction:i});return Fn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ks(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;br(r)&&await r.checkKeylessAccountValidity(e);let o=Br({signer:r,transaction:i});return Fn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Mu={typeParameters:[],parameters:[C.u8(),new C(C.u8())]};async function Ds(n){let{aptosConfig:e,account:t,metadataBytes:r,moduleBytecode:i,options:o}=n,s=i.map(a=>S.U8(a));return T({aptosConfig:e,sender:_chunk66TIRJFDjs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Mu},options:o})}async function Vt(n){return Cr(n)}async function Ns(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ui({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _112 => _112.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _113 => _113.limit]), () => (1e3))}})}async function Fs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await lr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _114 => _114.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _115 => _115.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _116 => _116.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Nr(n){return ds(n)}async function Os(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return dr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _117 => _117.offset]),limit:_optionalChain([r, 'optionalAccess', _118 => _118.limit])}})}async function Gs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return ui({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _119 => _119.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _120 => _120.limit]), () => (999))}})}async function Bs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await lr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _121 => _121.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _122 => _122.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _123 => _123.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function Hi(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk66TIRJFDjs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _124 => _124.ledgerVersion])}});return o.data}async function dn(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Hi({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunk66TIRJFDjs.Z.from(t);try{let a=await vr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk66TIRJFDjs.Z.from(a)}catch(a){if(a instanceof Ae&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Ms(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Jo,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 Vs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _125 => _125.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _126 => _126.tokenStandard])});let s={query:Qo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _127 => _127.offset]),limit:_optionalChain([r, 'optionalAccess', _128 => _128.limit]),order_by:_optionalChain([r, 'optionalAccess', _129 => _129.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedTokens"})).current_token_ownerships_v2}async function Hs(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk66TIRJFDjs.Z.from(t).toStringLong(),s=_chunk66TIRJFDjs.Z.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _130 => _130.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _131 => _131.tokenStandard])});let c={query:jo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _132 => _132.offset]),limit:_optionalChain([i, 'optionalAccess', _133 => _133.limit]),order_by:_optionalChain([i, 'optionalAccess', _134 => _134.orderBy])}};return(await w({aptosConfig:e,query:c,originMethod:"getAccountOwnedTokensFromCollectionAddress"})).current_token_ownerships_v2}async function Ls(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _135 => _135.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _136 => _136.tokenStandard])}});let s={query:Wo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _137 => _137.offset]),limit:_optionalChain([r, 'optionalAccess', _138 => _138.limit]),order_by:_optionalChain([r, 'optionalAccess', _139 => _139.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCollectionsWithOwnedTokens"})).current_collection_ownership_v2_view}async function qs(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Xo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function $s(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _140 => _140.where]),owner_address:{_eq:i}},s={query:$o,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _141 => _141.offset]),limit:_optionalChain([r, 'optionalAccess', _142 => _142.limit]),order_by:_optionalChain([r, 'optionalAccess', _143 => _143.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountCoinsData"})).current_fungible_asset_balances}async function Ws(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:qo,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 Qs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}},s={query:Pr,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _144 => _144.offset]),limit:_optionalChain([r, 'optionalAccess', _145 => _145.limit]),order_by:_optionalChain([r, 'optionalAccess', _146 => _146.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function js(n){let{aptosConfig:e,privateKey:t}=n,r=new N(t.publicKey());if(t instanceof We){let o=B.fromPublicKey({publicKey:r}).derivedAddress();return nt.fromPrivateKey({privateKey:t,address:o})}if(t instanceof q){let i=B.fromPublicKey({publicKey:r.publicKey});if(await zs({authKey:i,aptosConfig:e})){let c=i.derivedAddress();return nt.fromPrivateKey({privateKey:t,address:c,legacy:!0})}let s=B.fromPublicKey({publicKey:r});if(await zs({authKey:s,aptosConfig:e})){let c=s.derivedAddress();return nt.fromPrivateKey({privateKey:t,address:c,legacy:!1})}}throw new Error(`Can't derive account from private key ${t}`)}async function zs(n){let{aptosConfig:e,authKey:t}=n,r=await dn({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Vt({aptosConfig:e,accountAddress:r}),!0}catch(i){if(i.status===404)return!1;throw new Error(`Error while looking for an account info ${r.toString()}`)}}var Vu={typeParameters:[],parameters:[new le,C.u8(),new le,C.u8(),C.u8(),C.u8()]};async function Js(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r}=n;if("toNewPrivateKey"in n)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey});let i;if("toAccount"in n){if(n.toAccount instanceof se)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof wr)return Vi({aptosConfig:e,fromAccount:t,toAccount:n.toAccount});i=n.toAccount.publicKey.authKey()}else if("toAuthKey"in n)i=n.toAuthKey;else throw new Error("Invalid arguments");let o=await Lu({aptosConfig:e,fromAccount:t,toAuthKey:i});if(r===!0)return o;let s=await At({aptosConfig:e,transactionHash:o.hash});if(!s.success)throw new Error(`Failed to rotate authentication key - ${s}`);let a=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::set_originating_address",functionArguments:[]}});return ht({aptosConfig:e,signer:n.toAccount,transaction:a})}async function Vi(n){let{aptosConfig:e,fromAccount:t}=n,r=await Vt({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=nt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new fr({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk66TIRJFDjs.Z.from(r.authentication_key),newPublicKey:i.publicKey}).bcsToBytes(),a=t.sign(s),c=i.sign(s),p=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key",functionArguments:[new X(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new X(i.signingScheme),S.U8(i.publicKey.toUint8Array()),S.U8(a.toUint8Array()),S.U8(c.toUint8Array())],abi:Vu}});return ht({aptosConfig:e,signer:t,transaction:p})}var Hu={typeParameters:[],parameters:[C.u8()]};async function Lu(n){let{aptosConfig:e,fromAccount:t,toAuthKey:r}=n,i=r,o=await T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::account::rotate_authentication_key_call",functionArguments:[S.U8(i.toUint8Array())],abi:Hu}});return ht({aptosConfig:e,signer:t,transaction:o})}async function E(n){n.minimumLedgerVersion!==void 0&&await Ur({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function ae(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Cs({...t,aptosConfig:e}),o=new _chunk66TIRJFDjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await gt({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _147 => _147.ledgerVersion])},body:s});return a}async function Xs(n){let{aptosConfig:e,payload:t,options:r}=n,{data:i}=await gt({aptosConfig:e,originMethod:"viewJson",path:"view",params:{ledger_version:_optionalChain([r, 'optionalAccess', _148 => _148.ledgerVersion])},body:{function:t.function,type_arguments:_nullishCoalesce(t.typeArguments, () => ([])),arguments:_nullishCoalesce(t.functionArguments, () => ([]))}});return i}async function Ys(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk66TIRJFDjs.la.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::add_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(_()),new A(_())]}},options:i})}async function Zs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk66TIRJFDjs.la.call(void 0, r);return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authentication_function",typeArguments:[],functionArguments:[o,s,a],abi:{typeParameters:[],parameters:[new F,new A(_()),new A(_())]}},options:i})}async function ea(n){let{aptosConfig:e,sender:t,options:r}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::account_abstraction::remove_authenticator",typeArguments:[],functionArguments:[],abi:{typeParameters:[],parameters:[]}},options:r})}var Ht=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk66TIRJFDjs.la.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.some, 'call', _150 => _150(s=>_chunk66TIRJFDjs.Z.fromString(r).equals(s.moduleAddress)&&i===s.moduleName&&o===s.functionName)]), () => (!1))};this.enableAccountAbstractionTransaction=this.addAuthenticationFunctionTransaction;this.disableAccountAbstractionTransaction=async e=>{let{accountAddress:t,authenticationFunction:r,options:i}=e;return r?this.removeAuthenticationFunctionTransaction({accountAddress:t,authenticationFunction:r,options:i}):this.removeDispatchableAuthenticatorTransaction({accountAddress:t,options:i})}}async addAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ys({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Zs({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return ea({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ae({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk66TIRJFDjs.Z.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk66TIRJFDjs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var On=class{constructor(e){this.config=e;this.abstraction=new Ht(e)}async getAccountInfo(e){return Vt({aptosConfig:this.config,...e})}async getAccountModules(e){return Ns({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Fs({aptosConfig:this.config,...e})}async getAccountModule(e){return Nr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Os({aptosConfig:this.config,...e})}async getAccountResources(e){return Gs({aptosConfig:this.config,...e})}async getAccountResourcesPage(e){return Bs({aptosConfig:this.config,...e})}async getAccountResource(e){return Hi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return dn({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ms({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ls({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),qs({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$s({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),Ws({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:xt,faMetadataAddress:Io,...e})}async getAccountCoinAmount(e){let{accountAddress:t,coinType:r,faMetadataAddress:i,minimumLedgerVersion:o}=e;o&&console.warn(`minimumLedgerVersion is not used anymore, here for backward
|
|
478
478
|
compatibility see https://github.com/aptos-labs/aptos-ts-sdk/pull/519,
|
|
479
|
-
will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await De(async()=>{try{let p=(await ae({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunk66TIRJFDjs.ka.call(void 0, p.vec[0]))return _chunk66TIRJFDjs.ja.call(void 0, p.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunk66TIRJFDjs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===xt?a=_chunk66TIRJFDjs.Z.A.toStringLong():a=_chunk66TIRJFDjs._.call(void 0, _chunk66TIRJFDjs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let p=_chunk66TIRJFDjs.Z.from(i);a=p.toStringLong(),p===_chunk66TIRJFDjs.Z.A&&(s=xt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await ae({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await ae({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Qs({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return js({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Mr=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _151 => _151.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _152 => _152.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _153 => _153.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _154 => _154.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _155 => _155.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _156 => _156.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _157 => _157.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _158 => _158.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _159 => _159.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _160 => _160.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _161 => _161.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){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 Eo[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Po[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 So[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 ri[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 ii[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return ri[this.network]===e}isProverServiceRequest(e){return ii[this.network]===e}};var Lu={typeParameters:[{constraints:[]}],parameters:[new O,new J]};async function ta(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (xt))],functionArguments:[r,i],abi:Lu},options:s})}var Gn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return ta({aptosConfig:this.config,...e})}};var Tt={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 na(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:cs,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ra(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Ei,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ia(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}},o={query:Ei,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _162 => _162.offset]),limit:_optionalChain([r, 'optionalAccess', _163 => _163.limit]),order_by:_optionalChain([r, 'optionalAccess', _164 => _164.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function oa(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}},o={query:as,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _165 => _165.offset]),limit:_optionalChain([r, 'optionalAccess', _166 => _166.limit]),order_by:_optionalChain([r, 'optionalAccess', _167 => _167.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var qu={typeParameters:[],parameters:[new A(_()),new J,new A(_()),new A(_()),new L,new L,new L,new L,new L,new L,new L,new L,new L,new J,new J]};async function sa(n){let{aptosConfig:e,options:t,creator:r}=n;return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new x(n.description),new Q(_nullishCoalesce(n.maxSupply, () => (_chunk66TIRJFDjs.e))),new x(n.name),new x(n.uri),new z(_nullishCoalesce(n.mutableDescription, () => (!0))),new z(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new z(_nullishCoalesce(n.mutableURI, () => (!0))),new z(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new z(_nullishCoalesce(n.mutableTokenName, () => (!0))),new z(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new z(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new z(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new z(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(n.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:qu},options:t})}async function ln(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _168 => _168.where]);_optionalChain([t, 'optionalAccess', _169 => _169.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _170 => _170.tokenStandard]), () => ("v2"))});let i={query:Zo,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _171 => _171.offset]),limit:_optionalChain([t, 'optionalAccess', _172 => _172.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function aa(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk66TIRJFDjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _173 => _173.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _174 => _174.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...i,where:s}})}async function ca(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _175 => _175.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _176 => _176.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...r,where:o}})}async function ua(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _177 => _177.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _178 => _178.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...r,where:o}})}async function pa(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk66TIRJFDjs.Z.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _179 => _179.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _180 => _180.tokenStandard]), () => ("v2"))}),(await ln({aptosConfig:i,options:{where:s}})).collection_id}var $u={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new C(new A(_())),new C(new A(_())),new C(C.u8())]};async function da(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:l}=n,h=_optionalChain([p, 'optionalAccess', _181 => _181.map, 'call', _182 => _182(d=>Tt[d])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new x(i),new x(o),new x(s),new x(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(h, () => ([]))),_a(_nullishCoalesce(l, () => ([])),_nullishCoalesce(h, () => ([])))],abi:$u},options:t})}var Wu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new O]};async function la(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(r),_chunk66TIRJFDjs.Z.from(i)],abi:Wu},options:s})}var Qu={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new C(new A(_())),new C(new A(_())),new C(C.u8()),new O]};async function ga(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:l,options:h}=n;if(_optionalChain([c, 'optionalAccess', _183 => _183.length])!==_optionalChain([l, 'optionalAccess', _184 => _184.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _185 => _185.length])!==_optionalChain([l, 'optionalAccess', _186 => _186.length]))throw new Error("Property types and property values counts do not match");let d=_optionalChain([p, 'optionalAccess', _187 => _187.map, 'call', _188 => _188(g=>Tt[g])]);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(d, () => ([]))),_a(_nullishCoalesce(l, () => ([])),_nullishCoalesce(d, () => ([]))),a],abi:Qu},options:h})}var ju={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function ma(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(r)],abi:ju},options:o})}var Ju={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function ya(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[r],abi:Ju},options:o})}var Xu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function fa(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[r],abi:Xu},options:o})}var Yu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function Aa(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:Yu},options:s})}var Zu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function ha(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:Zu},options:s})}var ep={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function Ta(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:ep},options:s})}var tp={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_()),new A(_()),C.u8()]};async function ba(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),new x(Tt[i]),S.U8(Li(o,Tt[i]))],abi:tp},options:c})}var np={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function wa(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:np},options:s})}var rp={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_()),new A(_()),C.u8()]};async function Sa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),new x(Tt[i]),Li(o,Tt[i])],abi:rp},options:c})}var ip={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(ge(new G(0))),new A(_()),new G(1)]};async function Ea(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),Tt[i]],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),o],abi:ip},options:c})}var op={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(ge(new G(0))),new A(_()),new G(1)]};async function Pa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),Tt[i]],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),o],abi:op},options:c})}function _a(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Li(n[i],r))}),t}function Li(n,e){let t=Re(e);return Mt(n,t,0,[]).bcsToBytes()}var Bn=class{constructor(e){this.config=e}async getCollectionData(e){await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunk66TIRJFDjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _189 => _189.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _190 => _190.tokenStandard]), () => ("v2"))}),ln({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),aa({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ca({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ua({aptosConfig:this.config,...e})}async getCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),pa({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),na({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ra({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ia({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),oa({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return sa({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return da({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return la({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return ga({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ma({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ya({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return fa({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Aa({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ha({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Ta({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return ba({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return wa({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Sa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Ea({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Pa({aptosConfig:this.config,...e})}};var xa=300,sp=n=>{if(n&&n.length>xa)throw new Error(`Event type length exceeds the maximum length of ${xa}`)};async function Ia(n){let{aptosConfig:e,eventType:t,options:r}=n,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return Mn({aptosConfig:e,options:{...r,where:i}})}async function Ca(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunk66TIRJFDjs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Mn({aptosConfig:t,options:{...i,where:s}})}async function va(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunk66TIRJFDjs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Mn({aptosConfig:t,options:{...i,where:s}})}async function Mn(n){let{aptosConfig:e,options:t}=n;sp(_optionalChain([t, 'optionalAccess', _191 => _191.where, 'optionalAccess', _192 => _192.indexed_type, 'optionalAccess', _193 => _193._eq]));let r={query:ns,variables:{where_condition:_optionalChain([t, 'optionalAccess', _194 => _194.where]),offset:_optionalChain([t, 'optionalAccess', _195 => _195.offset]),limit:_optionalChain([t, 'optionalAccess', _196 => _196.limit]),order_by:_optionalChain([t, 'optionalAccess', _197 => _197.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Vn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ia({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ca({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),va({aptosConfig:this.config,...e})}async getEvents(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _198 => _198.minimumLedgerVersion]),processorType:"events_processor"}),Mn({aptosConfig:this.config,...e})}};async function Ka(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _199 => _199.timeoutSecs])||20,{data:s}=await ko({aptosConfig:e,path:"fund",body:{address:_chunk66TIRJFDjs.Z.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await At({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _200 => _200.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Hn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ka({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.waitForIndexer])===void 0||_optionalChain([e, 'access', _203 => _203.options, 'optionalAccess', _204 => _204.waitForIndexer]))&&await Ur({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Vr(n){let{aptosConfig:e,options:t}=n,r={query:is,variables:{where_condition:_optionalChain([t, 'optionalAccess', _205 => _205.where]),limit:_optionalChain([t, 'optionalAccess', _206 => _206.limit]),offset:_optionalChain([t, 'optionalAccess', _207 => _207.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Ra(n){let{aptosConfig:e,options:t}=n,r={query:rs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _208 => _208.where]),limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),offset:_optionalChain([t, 'optionalAccess', _210 => _210.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ua(n){let{aptosConfig:e,options:t}=n,r={query:es,variables:{where_condition:_optionalChain([t, 'optionalAccess', _211 => _211.where]),limit:_optionalChain([t, 'optionalAccess', _212 => _212.limit]),offset:_optionalChain([t, 'optionalAccess', _213 => _213.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ap={typeParameters:[{constraints:[]}],parameters:[Re("0x1::object::Object"),new O,new J]};async function ka(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ap},options:s})}var Ln=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _214 => _214.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Vr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _215 => _215.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Vr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _216 => _216.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Vr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk66TIRJFDjs.Z.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ra({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _218 => _218.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ua({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ka({aptosConfig:this.config,...e})}};var qn=class{constructor(e){this.config=e}async getLedgerInfo(){return _r({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return fs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return As({aptosConfig:this.config,...e})}async view(e){return ae({aptosConfig:this.config,...e})}async viewJson(e){return Xs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return us({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return xr({aptosConfig:this.config})}async getProcessorStatus(e){return Ir({aptosConfig:this.config,processorType:e})}};var Da=["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 za(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function bt(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!za(e))throw new Error(`${e} is not valid. ${Da}`);if(t&&!za(t))throw new Error(`${t} is not valid. ${Da}`);return{domainName:t||e,subdomainName:t?e:void 0}}function Na(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var cp="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",up={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:cp,custom:null,devnet:null};function ot(n){let e=up[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Hr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Oa(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Hr(s[0]);return a?_chunk66TIRJFDjs.Z.from(a):void 0}async function Fa(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=ot(e),{domainName:l,subdomainName:h}=bt(r),d=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!d)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(d&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let W=_nullishCoalesce(t.years, () => (1));if(W!==1)throw new Error("For now, names can only be registered for 1 year at a time");let st=W*31536e3;return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[l,st,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await qi({aptosConfig:e,name:l});if(!g)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:g;if(b>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[l,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function qi(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t);try{let s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Ga(n){let{aptosConfig:e,address:t}=n,r=ot(e),i=await ae({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk66TIRJFDjs.Z.from(t).toString()]}}),o=Hr(i[1]),s=Hr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Ba(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=ot(e);if(!r)return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=bt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ma(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Hr(s[0]);return a?_chunk66TIRJFDjs.Z.from(a):void 0}async function Va(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=ot(e),{domainName:a,subdomainName:c}=bt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function Ha(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=bt(t),a=(await w({aptosConfig:e,query:{query:an,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=$n(a)),Na(a)?a:void 0}async function La(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _219 => _219.limit]),offset:_optionalChain([t, 'optionalAccess', _220 => _220.offset]),order_by:_optionalChain([t, 'optionalAccess', _221 => _221.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _222 => _222.options, 'optionalAccess', _223 => _223.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map($n)}async function qa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _224 => _224.limit]),offset:_optionalChain([t, 'optionalAccess', _225 => _225.offset]),order_by:_optionalChain([t, 'optionalAccess', _226 => _226.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map($n)}async function $a(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),offset:_optionalChain([t, 'optionalAccess', _230 => _230.offset]),order_by:_optionalChain([t, 'optionalAccess', _231 => _231.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _232 => _232.options, 'optionalAccess', _233 => _233.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map($n)}async function Wa(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _234 => _234.limit]),offset:_optionalChain([t, 'optionalAccess', _235 => _235.offset]),order_by:_optionalChain([t, 'optionalAccess', _236 => _236.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _237 => _237.options, 'optionalAccess', _238 => _238.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map($n).filter(Na)}async function $i(n){let{aptosConfig:e}=n,t=ot(e),[r]=await ae({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Qa(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=ot(e),a=i*31536e3,{domainName:c,subdomainName:p}=bt(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 T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function $n(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var Wn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Oa({aptosConfig:this.config,...e})}async getExpiration(e){return qi({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ma({aptosConfig:this.config,...e})}async setTargetAddress(e){return Va({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ga({aptosConfig:this.config,...e})}async setPrimaryName(e){return Ba({aptosConfig:this.config,...e})}async registerName(e){return Fa({aptosConfig:this.config,...e})}async renewDomain(e){return Qa({aptosConfig:this.config,...e})}async getName(e){return Ha({aptosConfig:this.config,...e})}async getAccountNames(e){return La({aptosConfig:this.config,...e})}async getAccountDomains(e){return qa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return $a({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return Wa({aptosConfig:this.config,...e})}};async function ja(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:wi,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 Ja(n){let{aptosConfig:e,options:t}=n,r={query:wi,variables:{order_by:_optionalChain([t, 'optionalAccess', _239 => _239.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Xa(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:ts,variables:{delegatorAddress:_chunk66TIRJFDjs.Z.from(t).toStringLong(),poolAddress:_chunk66TIRJFDjs.Z.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var Qn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _240 => _240.minimumLedgerVersion]),processorType:"stake_processor"}),ja({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _241 => _241.minimumLedgerVersion]),processorType:"stake_processor"}),Ja({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _242 => _242.minimumLedgerVersion]),processorType:"stake_processor"}),Xa({aptosConfig:this.config,...e})}};var Lr=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Fr(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Oi({aptosConfig:this.config,payload:Ut.load(new R(i)),...e});return new rn(o,e.withFeePayer===!0?_chunk66TIRJFDjs.Z.ZERO:void 0)}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function Wi(n,e,t){let r=t.value;return t.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)},t}function Qi(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var gn=class{constructor(e){this.config=e}async simple(e){return Mi({aptosConfig:this.config,...e})}async multiAgent(e){return Mi({aptosConfig:this.config,...e})}};_chunk66TIRJFDjs.a.call(void 0, [Qi],gn.prototype,"simple",1),_chunk66TIRJFDjs.a.call(void 0, [Qi],gn.prototype,"multiAgent",1);var mn=class{constructor(e){this.config=e}async simple(e){return On({aptosConfig:this.config,...e})}async multiAgent(e){return On({aptosConfig:this.config,...e})}};_chunk66TIRJFDjs.a.call(void 0, [Wi],mn.prototype,"simple",1),_chunk66TIRJFDjs.a.call(void 0, [Wi],mn.prototype,"multiAgent",1);var qr=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunk66TIRJFDjs.da.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime),_chunk66TIRJFDjs.da.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await Vt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Vt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk66TIRJFDjs.da.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk66TIRJFDjs.da.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var yn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _243 => _243.pendingDequeue, 'access', _244 => _244.shift, 'call', _245 => _245(), 'optionalAccess', _246 => _246.resolve, 'call', _247 => _247(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new fn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},fn=class extends Error{};var Ya="fulfilled",Za= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Za||{}),$r= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new yn;this.transactionsQueue=new yn;this.outstandingTransactions=new yn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new qr(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=ht({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof fn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===Ya?(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(t){if(t instanceof fn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(At({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===Ya?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.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(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return T({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Wr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new $r(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var jn=class{constructor(e){this.config=e,this.build=new Lr(this.config),this.simulate=new gn(this.config),this.submit=new mn(this.config),this.batch=new Wr(this.config)}async getTransactions(e){return _i({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ms({aptosConfig:this.config,...e})}async getTransactionByHash(e){return zn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ys({aptosConfig:this.config,...e})}async waitForTransaction(e){return At({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Rr({aptosConfig:this.config})}getSigningMessage(e){return Us(e)}async publishPackageTransaction(e){return Ds({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Js({aptosConfig:this.config,...e})}sign(e){return Gr({...e})}signAsFeePayer(e){return Br({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return ht({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ks({aptosConfig:this.config,...e})}};var Jn=class{constructor(e){this.config=e}async getTableItem(e){return vr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ls({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),gs({aptosConfig:this.config,...e})}};async function Qr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:_chunk66TIRJFDjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Do({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunk66TIRJFDjs.j.fromHexInput(a.pepper).toUint8Array()}async function ji(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Qr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array().length!==rt.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${rt.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunk66TIRJFDjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk66TIRJFDjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await zo({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=p.proof,h=new mt({a:l.a,b:l.b,c:l.c});return new ue({proof:new Jt(h,0),trainingWheelsSignature:Ue.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function ec(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Qr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),p=ji({...n,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(r!==void 0){let g=Z.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await dn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Bt.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let h=U.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),d=await dn({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return rt.create({...n,address:d,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function tc(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(vo.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let p;throw c instanceof Error?p=`${c.message}`:p=`error unknown - ${c}`,P.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${p}`})}let a=await s.json();return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var Xn=class{constructor(e){this.config=e}async getPepper(e){return Qr({aptosConfig:this.config,...e})}async getProof(e){return ji({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return ec({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return tc({aptosConfig:this.config,...e})}};async function gp(n){let{aptosConfig:e,options:t}=n,r={query:Pr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _248 => _248.where]),offset:_optionalChain([t, 'optionalAccess', _249 => _249.offset]),limit:_optionalChain([t, 'optionalAccess', _250 => _250.limit]),order_by:_optionalChain([t, 'optionalAccess', _251 => _251.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function nc(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return(await gp({aptosConfig:e,options:{...r,where:o}}))[0]}var Yn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),nc({aptosConfig:this.config,...e})}};var ee=class{constructor(e){this.config=new Mr(e),this.account=new Fn(this.config),this.abstraction=new Ht(this.config),this.ans=new Wn(this.config),this.coin=new Gn(this.config),this.digitalAsset=new Bn(this.config),this.event=new Vn(this.config),this.faucet=new Hn(this.config),this.fungibleAsset=new Ln(this.config),this.general=new qn(this.config),this.staking=new Qn(this.config),this.transaction=new jn(this.config),this.table=new Jn(this.config),this.keyless=new Xn(this.config),this.object=new Yn(this.config)}};function ce(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}ce(ee,Fn,"account");ce(ee,Ht,"abstraction");ce(ee,Wn,"ans");ce(ee,Gn,"coin");ce(ee,Bn,"digitalAsset");ce(ee,Vn,"event");ce(ee,Hn,"faucet");ce(ee,Ln,"fungibleAsset");ce(ee,qn,"general");ce(ee,Qn,"staking");ce(ee,jn,"transaction");ce(ee,Jn,"table");ce(ee,Xn,"keyless");ce(ee,Yn,"object");exports.APTOS_BIP44_REGEX = yc; exports.APTOS_COIN = xt; exports.APTOS_FA = Io; exports.APTOS_HARDENED_REGEX = mc; exports.AbstractKeylessAccount = me; exports.AbstractMultiKey = xn; exports.AbstractPublicKey = rr; exports.AbstractSignature = Tn; exports.AbstractedAccount = Sr; exports.Account = nt; exports.AccountAddress = _chunk66TIRJFDjs.Z; exports.AccountAuthenticator = j; exports.AccountAuthenticatorAbstraction = vt; exports.AccountAuthenticatorEd25519 = ve; exports.AccountAuthenticatorMultiEd25519 = je; exports.AccountAuthenticatorMultiKey = Ge; exports.AccountAuthenticatorNoAccountAuthenticator = en; exports.AccountAuthenticatorSingleKey = oe; exports.AccountAuthenticatorVariant = _chunk66TIRJFDjs.w; exports.AccountPublicKey = ie; exports.AccountSequenceNumber = qr; exports.AccountUtils = Vo; exports.AddressInvalidReason = _chunk66TIRJFDjs.Y; exports.AnyPublicKey = N; exports.AnyPublicKeyVariant = _chunk66TIRJFDjs.y; exports.AnySignature = H; exports.AnySignatureVariant = _chunk66TIRJFDjs.z; exports.Aptos = ee; exports.AptosApiError = Ae; exports.AptosApiType = _t; exports.AptosConfig = Mr; exports.AptosScriptComposer = Fr; exports.AuthenticationKey = B; exports.Bool = z; exports.CKDPriv = Ao; exports.CallArgument = _chunk66TIRJFDjs.X; exports.ChainId = tn; exports.DEFAULT_MAX_GAS_AMOUNT = _o; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = xo; exports.DEFAULT_TXN_TIMEOUT_SEC = ar; exports.DerivableAbstractedAccount = Lo; exports.DeriveScheme = _chunk66TIRJFDjs.W; exports.Deserializer = R; exports.EPK_HORIZON_SECS = jc; exports.Ed25519Account = se; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = I; exports.Ed25519Signature = K; exports.EntryFunction = kt; exports.EntryFunctionBytes = nr; exports.EphemeralCertificate = jt; exports.EphemeralCertificateVariant = _chunk66TIRJFDjs.C; exports.EphemeralKeyPair = Gt; exports.EphemeralPublicKey = lt; exports.EphemeralPublicKeyVariant = _chunk66TIRJFDjs.A; exports.EphemeralSignature = Ue; exports.EphemeralSignatureVariant = _chunk66TIRJFDjs.B; exports.FIREBASE_AUTH_ISS_PATTERN = vo; exports.FederatedKeylessAccount = Bt; exports.FederatedKeylessPublicKey = Z; exports.FeePayerRawTransaction = zt; exports.FixedBytes = Ee; exports.Groth16ProofAndStatement = gi; exports.Groth16VerificationKey = yi; exports.Groth16Zkp = mt; exports.HARDENED_OFFSET = mo; exports.Hex = _chunk66TIRJFDjs.j; exports.HexInvalidReason = _chunk66TIRJFDjs.i; exports.Identifier = k; exports.KeyType = fc; exports.KeylessAccount = rt; exports.KeylessConfiguration = mi; exports.KeylessError = P; exports.KeylessErrorCategory = Mc; exports.KeylessErrorResolutionTip = Vc; exports.KeylessErrorType = cr; exports.KeylessPublicKey = U; exports.KeylessSignature = he; exports.MAX_AUD_VAL_BYTES = di; exports.MAX_COMMITED_EPK_BYTES = tu; exports.MAX_EXTRA_FIELD_BYTES = Zc; exports.MAX_ISS_VAL_BYTES = Yc; exports.MAX_JWT_HEADER_B64_BYTES = eu; exports.MAX_UID_KEY_BYTES = Jc; exports.MAX_UID_VAL_BYTES = Xc; exports.MimeType = _chunk66TIRJFDjs.q; exports.ModuleId = In; exports.MoveAbility = _chunk66TIRJFDjs.S; exports.MoveFunctionVisibility = _chunk66TIRJFDjs.R; exports.MoveJWK = fi; exports.MoveOption = Y; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = Dt; exports.MultiAgentTransaction = Ar; exports.MultiEd25519Account = wr; exports.MultiEd25519PublicKey = Zt; exports.MultiEd25519Signature = Qe; exports.MultiKey = Oe; exports.MultiKeyAccount = kn; exports.MultiKeySignature = Fe; exports.MultiSig = Rn; exports.MultiSigTransactionPayload = Un; exports.Network = oi; exports.NetworkToChainId = si; exports.NetworkToFaucetAPI = Po; exports.NetworkToIndexerAPI = So; exports.NetworkToNetworkName = xl; exports.NetworkToNodeAPI = Eo; exports.NetworkToPepperAPI = ri; exports.NetworkToProverAPI = ii; exports.ParsingError = _chunk66TIRJFDjs.h; exports.PrivateKey = pt; exports.PrivateKeyVariants = _chunk66TIRJFDjs.x; exports.ProcessorType = He; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Co; exports.RAW_TRANSACTION_WITH_DATA_SALT = ai; exports.RawTransaction = be; exports.RawTransactionWithData = yr; exports.RoleType = _chunk66TIRJFDjs.T; exports.RotationProofChallenge = fr; exports.Script = Kn; exports.ScriptTransactionArgumentVariants = _chunk66TIRJFDjs.s; exports.Secp256k1PrivateKey = We; exports.Secp256k1PublicKey = $e; exports.Secp256k1Signature = Ct; exports.Serializable = _chunk66TIRJFDjs.l; exports.Serialized = hn; exports.Serializer = _chunk66TIRJFDjs.m; exports.Signature = M; exports.SignedTransaction = tt; exports.SigningScheme = _chunk66TIRJFDjs.U; exports.SigningSchemeInput = _chunk66TIRJFDjs.V; exports.SimpleTransaction = rn; exports.SingleKeyAccount = we; exports.StructTag = Be; exports.TransactionAndProof = Tr; exports.TransactionAuthenticator = et; exports.TransactionAuthenticatorEd25519 = Nt; exports.TransactionAuthenticatorFeePayer = Ft; exports.TransactionAuthenticatorMultiAgent = Ot; exports.TransactionAuthenticatorMultiEd25519 = nn; exports.TransactionAuthenticatorSingleSender = ft; exports.TransactionAuthenticatorVariant = _chunk66TIRJFDjs.v; exports.TransactionPayload = Rt; exports.TransactionPayloadEntryFunction = Cn; exports.TransactionPayloadMultiSig = vn; exports.TransactionPayloadScript = Ut; exports.TransactionPayloadVariants = _chunk66TIRJFDjs.t; exports.TransactionResponseType = _chunk66TIRJFDjs.E; exports.TransactionVariants = _chunk66TIRJFDjs.u; exports.TransactionWorker = $r; exports.TransactionWorkerEventsEnum = Za; exports.TypeTag = F; exports.TypeTagAddress = O; exports.TypeTagBool = L; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = _u; exports.TypeTagReference = mr; exports.TypeTagSigner = Kt; exports.TypeTagStruct = A; exports.TypeTagU128 = Ye; exports.TypeTagU16 = Je; exports.TypeTagU256 = Ze; exports.TypeTagU32 = Xe; exports.TypeTagU64 = J; exports.TypeTagU8 = le; exports.TypeTagVariants = _chunk66TIRJFDjs.r; exports.TypeTagVector = C; exports.U128 = xe; exports.U16 = Pe; exports.U256 = ye; exports.U32 = _e; exports.U64 = Q; exports.U8 = X; exports.ZeroKnowledgeSig = ue; exports.ZkProof = Jt; exports.ZkpVariant = _chunk66TIRJFDjs.D; exports.aptosCoinStructTag = $y; exports.aptosRequest = ur; exports.base64UrlDecode = _chunk66TIRJFDjs.fa; exports.base64UrlToBytes = _chunk66TIRJFDjs.ga; exports.bigIntToBytesLE = ni; exports.buildTransaction = Fi; exports.bytesToBigIntLE = Et; exports.checkOrConvertArgument = Mt; exports.convertAmountFromHumanReadableToOnChain = _chunk66TIRJFDjs.ha; exports.convertAmountFromOnChainToHumanReadable = _chunk66TIRJFDjs.ia; exports.convertArgument = un; exports.convertCallArgument = Hb; exports.convertNumber = kr; exports.createObjectAddress = _chunk66TIRJFDjs._; exports.createResourceAddress = _chunk66TIRJFDjs.$; exports.createTokenAddress = _chunk66TIRJFDjs.aa; exports.deriveKey = Zr; exports.deriveTransactionType = hr; exports.deserializeFromScriptArgument = pu; exports.ensureBoolean = _chunk66TIRJFDjs.n; exports.fetchEntryFunctionAbi = xs; exports.fetchFunctionAbi = Ni; exports.fetchJWK = hi; exports.fetchModuleAbi = zi; exports.fetchMoveFunctionAbi = Vb; exports.fetchViewFunctionAbi = Is; exports.findFirstNonSignerArg = _s; exports.floorToWholeHour = _chunk66TIRJFDjs.ea; exports.generateRawTransaction = Oi; exports.generateSignedTransaction = Gi; exports.generateSignedTransactionForSimulation = vs; exports.generateSigningMessage = yt; exports.generateSigningMessageForSerializable = oA; exports.generateSigningMessageForTransaction = Ke; exports.generateTransactionPayload = Or; exports.generateTransactionPayloadWithABI = Ru; exports.generateUserTransactionHash = mw; exports.generateViewFunctionPayload = Cs; exports.generateViewFunctionPayloadWithABI = Uu; exports.get = pr; exports.getAptosFullNode = V; exports.getAptosPepperService = Zl; exports.getAuthenticatorForSimulation = pn; exports.getErrorMessage = _chunk66TIRJFDjs.ca; exports.getFunctionParts = _chunk66TIRJFDjs.la; exports.getIssAudAndUidVal = qe; exports.getKeylessConfig = Xt; exports.getKeylessJWKs = ou; exports.getPageWithObfuscatedCursor = lr; exports.hashStrToField = ke; exports.hashValues = Ks; exports.hexToAsciiString = _chunk66TIRJFDjs.k; exports.isBcsAddress = zr; exports.isBcsBool = xi; exports.isBcsFixedBytes = Iu; exports.isBcsString = Ii; exports.isBcsU128 = Ui; exports.isBcsU16 = vi; exports.isBcsU256 = ki; exports.isBcsU32 = Ki; exports.isBcsU64 = Ri; exports.isBcsU8 = Ci; exports.isBlockEpilogueTransactionResponse = _chunk66TIRJFDjs.L; exports.isBlockMetadataTransactionResponse = _chunk66TIRJFDjs.I; exports.isBool = ws; exports.isCanonicalEd25519Signature = hc; exports.isEd25519Signature = _chunk66TIRJFDjs.M; exports.isEmptyOption = Ss; exports.isEncodedEntryFunctionArgument = Es; exports.isEncodedStruct = _chunk66TIRJFDjs.ka; exports.isFeePayerSignature = _chunk66TIRJFDjs.P; exports.isGenesisTransactionResponse = _chunk66TIRJFDjs.H; exports.isKeylessSigner = br; exports.isLargeNumber = Dr; exports.isMultiAgentSignature = _chunk66TIRJFDjs.O; exports.isMultiEd25519Signature = _chunk66TIRJFDjs.Q; exports.isNumber = xu; exports.isPendingTransactionResponse = _chunk66TIRJFDjs.F; exports.isScriptDataInput = Ps; exports.isSecp256k1Signature = _chunk66TIRJFDjs.N; exports.isSingleKeySigner = Ti; exports.isStateCheckpointTransactionResponse = _chunk66TIRJFDjs.J; exports.isString = it; exports.isUserTransactionResponse = _chunk66TIRJFDjs.G; exports.isValidBIP44Path = yo; exports.isValidFunctionInfo = _chunk66TIRJFDjs.ma; exports.isValidHardenedPath = fo; exports.isValidatorTransactionResponse = _chunk66TIRJFDjs.K; exports.mnemonicToSeed = ir; exports.normalizeBundle = Ko; exports.nowInSeconds = _chunk66TIRJFDjs.da; exports.objectStructTag = ge; exports.optionStructTag = Wy; exports.outOfRangeErrorMessage = _chunk66TIRJFDjs.o; exports.padAndPackBytesWithLen = wn; exports.paginateWithCursor = dr; exports.paginateWithObfuscatedCursor = ui; exports.pairedFaMetadataAddress = _chunk66TIRJFDjs.oa; exports.parseEncodedStruct = _chunk66TIRJFDjs.ja; exports.parseJwtHeader = au; exports.parseTypeTag = Re; exports.poseidonHash = Pt; exports.post = Sn; exports.postAptosFaucet = ko; exports.postAptosFullNode = gt; exports.postAptosIndexer = Uo; exports.postAptosPepperService = Do; exports.postAptosProvingService = zo; exports.promiseFulfilledStatus = Ya; exports.request = qc; exports.sleep = _chunk66TIRJFDjs.ba; exports.splitPath = ho; exports.standardizeTypeTags = cn; exports.stringStructTag = _; exports.throwTypeMismatch = D; exports.truncateAddress = _chunk66TIRJFDjs.na; exports.validateNumberInRange = _chunk66TIRJFDjs.p; exports.verifyKeylessSignature = Ai; exports.verifyKeylessSignatureWithJwkAndConfig = gr;
|
|
479
|
+
will be removed in the near future`);let s=r;r===void 0&&i!==void 0&&(s=await De(async()=>{try{let p=(await ae({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunk66TIRJFDjs.ka.call(void 0, p.vec[0]))return _chunk66TIRJFDjs.ja.call(void 0, p.vec[0])}catch (e6){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunk66TIRJFDjs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===xt?a=_chunk66TIRJFDjs.Z.A.toStringLong():a=_chunk66TIRJFDjs._.call(void 0, _chunk66TIRJFDjs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let p=_chunk66TIRJFDjs.Z.from(i);a=p.toStringLong(),p===_chunk66TIRJFDjs.Z.A&&(s=xt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await ae({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await ae({aptosConfig:this.config,payload:{function:"0x1::primary_fungible_store::balance",typeArguments:["0x1::object::ObjectCore"],functionArguments:[t,a]}});return parseInt(c,10)}async getAccountOwnedObjects(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),Qs({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return js({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Mr=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _151 => _151.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _152 => _152.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _153 => _153.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _154 => _154.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _155 => _155.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _156 => _156.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _157 => _157.client]), () => ({provider:_aptosclient2.default})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _158 => _158.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _159 => _159.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _160 => _160.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _161 => _161.faucetConfig]), () => ({}))}getRequestUrl(e){switch(e){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 Eo[this.network];case"Faucet":if(this.faucet!==void 0)return this.faucet;if(this.network==="testnet")throw new Error("There is no way to programmatically mint testnet APT, you must use the minting site at https://aptos.dev/network/faucet");if(this.network==="mainnet")throw new Error("There is no mainnet faucet");if(this.network==="custom")throw new Error("Please provide a custom faucet url");return Po[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 So[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 ri[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 ii[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return ri[this.network]===e}isProverServiceRequest(e){return ii[this.network]===e}};var $u={typeParameters:[{constraints:[]}],parameters:[new F,new J]};async function ta(n){let{aptosConfig:e,sender:t,recipient:r,amount:i,coinType:o,options:s}=n;return T({aptosConfig:e,sender:t,data:{function:"0x1::aptos_account::transfer_coins",typeArguments:[_nullishCoalesce(o, () => (xt))],functionArguments:[r,i],abi:$u},options:s})}var Gn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return ta({aptosConfig:this.config,...e})}};var Tt={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 na(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:cs,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function ra(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Ei,variables:{where_condition:r}},originMethod:"getCurrentDigitalAssetOwnership"})).current_token_ownerships_v2[0]}async function ia(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()},amount:{_gt:0}},o={query:Ei,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _162 => _162.offset]),limit:_optionalChain([r, 'optionalAccess', _163 => _163.limit]),order_by:_optionalChain([r, 'optionalAccess', _164 => _164.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getOwnedDigitalAssets"})).current_token_ownerships_v2}async function oa(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}},o={query:as,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _165 => _165.offset]),limit:_optionalChain([r, 'optionalAccess', _166 => _166.limit]),order_by:_optionalChain([r, 'optionalAccess', _167 => _167.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Wu={typeParameters:[],parameters:[new A(_()),new J,new A(_()),new A(_()),new L,new L,new L,new L,new L,new L,new L,new L,new L,new J,new J]};async function sa(n){let{aptosConfig:e,options:t,creator:r}=n;return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::create_collection",functionArguments:[new x(n.description),new Q(_nullishCoalesce(n.maxSupply, () => (_chunk66TIRJFDjs.e))),new x(n.name),new x(n.uri),new z(_nullishCoalesce(n.mutableDescription, () => (!0))),new z(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new z(_nullishCoalesce(n.mutableURI, () => (!0))),new z(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new z(_nullishCoalesce(n.mutableTokenName, () => (!0))),new z(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new z(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new z(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new z(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(n.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Wu},options:t})}async function ln(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _168 => _168.where]);_optionalChain([t, 'optionalAccess', _169 => _169.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _170 => _170.tokenStandard]), () => ("v2"))});let i={query:Zo,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _171 => _171.offset]),limit:_optionalChain([t, 'optionalAccess', _172 => _172.limit])}};return(await w({aptosConfig:e,query:i,originMethod:"getCollectionData"})).current_collections_v2[0]}async function aa(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk66TIRJFDjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _173 => _173.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _174 => _174.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...i,where:s}})}async function ca(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _175 => _175.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _176 => _176.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...r,where:o}})}async function ua(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _177 => _177.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _178 => _178.tokenStandard]), () => ("v2"))}),ln({aptosConfig:e,options:{...r,where:o}})}async function pa(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk66TIRJFDjs.Z.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _179 => _179.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _180 => _180.tokenStandard]), () => ("v2"))}),(await ln({aptosConfig:i,options:{where:s}})).collection_id}var Qu={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new C(new A(_())),new C(new A(_())),new C(C.u8())]};async function da(n){let{aptosConfig:e,options:t,creator:r,collection:i,description:o,name:s,uri:a,propertyKeys:c,propertyTypes:p,propertyValues:l}=n,h=_optionalChain([p, 'optionalAccess', _181 => _181.map, 'call', _182 => _182(d=>Tt[d])]);return T({aptosConfig:e,sender:r.accountAddress,data:{function:"0x4::aptos_token::mint",functionArguments:[new x(i),new x(o),new x(s),new x(a),S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(h, () => ([]))),_a(_nullishCoalesce(l, () => ([])),_nullishCoalesce(h, () => ([])))],abi:Qu},options:t})}var ju={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new F]};async function la(n){let{aptosConfig:e,sender:t,digitalAssetAddress:r,recipient:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::object::transfer",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(r),_chunk66TIRJFDjs.Z.from(i)],abi:ju},options:s})}var Ju={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new C(new A(_())),new C(new A(_())),new C(C.u8()),new F]};async function ga(n){let{aptosConfig:e,account:t,collection:r,description:i,name:o,uri:s,recipient:a,propertyKeys:c,propertyTypes:p,propertyValues:l,options:h}=n;if(_optionalChain([c, 'optionalAccess', _183 => _183.length])!==_optionalChain([l, 'optionalAccess', _184 => _184.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _185 => _185.length])!==_optionalChain([l, 'optionalAccess', _186 => _186.length]))throw new Error("Property types and property values counts do not match");let d=_optionalChain([p, 'optionalAccess', _187 => _187.map, 'call', _188 => _188(g=>Tt[g])]);return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::mint_soul_bound",functionArguments:[r,i,o,s,S.MoveString(_nullishCoalesce(c, () => ([]))),S.MoveString(_nullishCoalesce(d, () => ([]))),_a(_nullishCoalesce(l, () => ([])),_nullishCoalesce(d, () => ([]))),a],abi:Ju},options:h})}var Xu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function ma(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::burn",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(r)],abi:Xu},options:o})}var Yu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function ya(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[r],abi:Yu},options:o})}var Zu={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0)))]};async function fa(n){let{aptosConfig:e,creator:t,digitalAssetAddress:r,digitalAssetType:i,options:o}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (Se))],functionArguments:[r],abi:Zu},options:o})}var ep={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function Aa(n){let{aptosConfig:e,creator:t,description:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_description",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:ep},options:s})}var tp={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function ha(n){let{aptosConfig:e,creator:t,name:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_name",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:tp},options:s})}var np={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function Ta(n){let{aptosConfig:e,creator:t,uri:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::set_uri",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:np},options:s})}var rp={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_()),new A(_()),C.u8()]};async function ba(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),new x(Tt[i]),S.U8(Li(o,Tt[i]))],abi:rp},options:c})}var ip={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_())]};async function wa(n){let{aptosConfig:e,creator:t,propertyKey:r,digitalAssetAddress:i,digitalAssetType:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::remove_property",typeArguments:[_nullishCoalesce(o, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(i),new x(r)],abi:ip},options:s})}var op={typeParameters:[{constraints:["key"]}],parameters:[new A(ge(new G(0))),new A(_()),new A(_()),C.u8()]};async function Sa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_property",typeArguments:[_nullishCoalesce(a, () => (Se))],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),new x(Tt[i]),Li(o,Tt[i])],abi:op},options:c})}var sp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(ge(new G(0))),new A(_()),new G(1)]};async function Ea(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),Tt[i]],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),o],abi:sp},options:c})}var ap={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(ge(new G(0))),new A(_()),new G(1)]};async function Pa(n){let{aptosConfig:e,creator:t,propertyKey:r,propertyType:i,propertyValue:o,digitalAssetAddress:s,digitalAssetType:a,options:c}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x4::aptos_token::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (Se)),Tt[i]],functionArguments:[_chunk66TIRJFDjs.Z.from(s),new x(r),o],abi:ap},options:c})}function _a(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Li(n[i],r))}),t}function Li(n,e){let t=Re(e);return Mt(n,t,0,[]).bcsToBytes()}var Bn=class{constructor(e){this.config=e}async getCollectionData(e){await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"});let{creatorAddress:t,collectionName:r,options:i}=e,o=_chunk66TIRJFDjs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _189 => _189.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _190 => _190.tokenStandard]), () => ("v2"))}),ln({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),aa({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ca({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ua({aptosConfig:this.config,...e})}async getCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),pa({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),na({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ra({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ia({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),oa({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return sa({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return da({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return la({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return ga({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ma({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ya({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return fa({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return Aa({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return ha({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return Ta({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return ba({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return wa({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return Sa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Ea({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Pa({aptosConfig:this.config,...e})}};var xa=300,cp=n=>{if(n&&n.length>xa)throw new Error(`Event type length exceeds the maximum length of ${xa}`)};async function Ia(n){let{aptosConfig:e,eventType:t,options:r}=n,i={_or:[{account_address:{_eq:t.split("::")[0]}},{account_address:{_eq:"0x0000000000000000000000000000000000000000000000000000000000000000"},sequence_number:{_eq:0},creation_number:{_eq:0}}],indexed_type:{_eq:t}};return Mn({aptosConfig:e,options:{...r,where:i}})}async function Ca(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunk66TIRJFDjs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Mn({aptosConfig:t,options:{...i,where:s}})}async function va(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunk66TIRJFDjs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Mn({aptosConfig:t,options:{...i,where:s}})}async function Mn(n){let{aptosConfig:e,options:t}=n;cp(_optionalChain([t, 'optionalAccess', _191 => _191.where, 'optionalAccess', _192 => _192.indexed_type, 'optionalAccess', _193 => _193._eq]));let r={query:ns,variables:{where_condition:_optionalChain([t, 'optionalAccess', _194 => _194.where]),offset:_optionalChain([t, 'optionalAccess', _195 => _195.offset]),limit:_optionalChain([t, 'optionalAccess', _196 => _196.limit]),order_by:_optionalChain([t, 'optionalAccess', _197 => _197.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Vn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ia({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ca({aptosConfig:this.config,...e})}async getAccountEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),va({aptosConfig:this.config,...e})}async getEvents(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _198 => _198.minimumLedgerVersion]),processorType:"events_processor"}),Mn({aptosConfig:this.config,...e})}};async function Ka(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _199 => _199.timeoutSecs])||20,{data:s}=await ko({aptosConfig:e,path:"fund",body:{address:_chunk66TIRJFDjs.Z.from(t).toString(),amount:r},originMethod:"fundAccount"}),a=s.txn_hashes[0],c=await At({aptosConfig:e,transactionHash:a,options:{timeoutSecs:o,checkSuccess:_optionalChain([i, 'optionalAccess', _200 => _200.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Hn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ka({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.waitForIndexer])===void 0||_optionalChain([e, 'access', _203 => _203.options, 'optionalAccess', _204 => _204.waitForIndexer]))&&await Ur({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Vr(n){let{aptosConfig:e,options:t}=n,r={query:is,variables:{where_condition:_optionalChain([t, 'optionalAccess', _205 => _205.where]),limit:_optionalChain([t, 'optionalAccess', _206 => _206.limit]),offset:_optionalChain([t, 'optionalAccess', _207 => _207.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetMetadata"})).fungible_asset_metadata}async function Ra(n){let{aptosConfig:e,options:t}=n,r={query:rs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _208 => _208.where]),limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),offset:_optionalChain([t, 'optionalAccess', _210 => _210.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getFungibleAssetActivities"})).fungible_asset_activities}async function Ua(n){let{aptosConfig:e,options:t}=n,r={query:es,variables:{where_condition:_optionalChain([t, 'optionalAccess', _211 => _211.where]),limit:_optionalChain([t, 'optionalAccess', _212 => _212.limit]),offset:_optionalChain([t, 'optionalAccess', _213 => _213.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var ka={typeParameters:[{constraints:[]}],parameters:[Re("0x1::object::Object"),new F,new J]};async function Da(n){let{aptosConfig:e,sender:t,fungibleAssetMetadataAddress:r,recipient:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::primary_fungible_store::transfer",typeArguments:["0x1::fungible_asset::Metadata"],functionArguments:[r,i,o],abi:ka},options:s})}async function za(n){let{aptosConfig:e,sender:t,fromStore:r,toStore:i,amount:o,options:s}=n;return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::dispatchable_fungible_asset::transfer",typeArguments:["0x1::fungible_asset::FungibleStore"],functionArguments:[r,i,o],abi:ka},options:s})}var Ln=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _214 => _214.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Vr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _215 => _215.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Vr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _216 => _216.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Vr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk66TIRJFDjs.Z.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _217 => _217.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ra({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _218 => _218.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ua({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Da({aptosConfig:this.config,...e})}async transferFungibleAssetBetweenStores(e){return za({aptosConfig:this.config,...e})}};var qn=class{constructor(e){this.config=e}async getLedgerInfo(){return _r({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return fs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return As({aptosConfig:this.config,...e})}async view(e){return ae({aptosConfig:this.config,...e})}async viewJson(e){return Xs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return us({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return xr({aptosConfig:this.config})}async getProcessorStatus(e){return Ir({aptosConfig:this.config,processorType:e})}};var Na=["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 Fa(n){return!(!n||n.length<3||n.length>63||!/^[a-z\d][a-z\d-]{1,61}[a-z\d]$/.test(n))}function bt(n){let[e,t,...r]=n.replace(/\.apt$/,"").split(".");if(r.length>0)throw new Error(`${n} is invalid. A name can only have two parts, a domain and a subdomain separated by a "."`);if(!Fa(e))throw new Error(`${e} is not valid. ${Na}`);if(t&&!Fa(t))throw new Error(`${t} is not valid. ${Na}`);return{domainName:t||e,subdomainName:t?e:void 0}}function Oa(n){if(!n)return!1;let e=new Date(n.domain_expiration_timestamp).getTime()<Date.now(),t=new Date(n.expiration_timestamp).getTime()<Date.now();return n.subdomain&&e?!1:n.subdomain&&n.subdomain_expiration_policy===1?!0:!t}var up="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",pp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:up,custom:null,devnet:null};function ot(n){let e=pp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var Hr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Ga(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=Hr(s[0]);return a?_chunk66TIRJFDjs.Z.from(a):void 0}async function Ba(n){let{aptosConfig:e,expiration:t,name:r,sender:i,targetAddress:o,toAddress:s,options:a,transferable:c}=n,p=ot(e),{domainName:l,subdomainName:h}=bt(r),d=t.policy==="subdomain:independent"||t.policy==="subdomain:follow-domain";if(h&&!d)throw new Error("Subdomains must have an expiration policy of either 'subdomain:independent' or 'subdomain:follow-domain'");if(d&&!h)throw new Error(`Policy is set to ${t.policy} but no subdomain was provided`);if(t.policy==="domain"){let W=_nullishCoalesce(t.years, () => (1));if(W!==1)throw new Error("For now, names can only be registered for 1 year at a time");let st=W*31536e3;return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_domain`,functionArguments:[l,st,o,s]},options:a})}if(!h)throw new Error(`${t.policy} requires a subdomain to be provided.`);let g=await qi({aptosConfig:e,name:l});if(!g)throw new Error("The domain does not exist");let b=t.policy==="subdomain:independent"?t.expirationDate:g;if(b>g)throw new Error("The subdomain expiration time cannot be greater than the domain expiration time");return await T({aptosConfig:e,sender:i.accountAddress.toString(),data:{function:`${p}::router::register_subdomain`,functionArguments:[l,h,Math.round(b/1e3),t.policy==="subdomain:follow-domain"?1:0,!!c,o,s]},options:a})}async function qi(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t);try{let s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e7){return}}async function Ma(n){let{aptosConfig:e,address:t}=n,r=ot(e),i=await ae({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk66TIRJFDjs.Z.from(t).toString()]}}),o=Hr(i[1]),s=Hr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Va(n){let{aptosConfig:e,sender:t,name:r,options:i}=n,o=ot(e);if(!r)return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::clear_primary_name`,functionArguments:[]},options:i});let{domainName:s,subdomainName:a}=bt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${o}::router::set_primary_name`,functionArguments:[s,a]},options:i})}async function Ha(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ae({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=Hr(s[0]);return a?_chunk66TIRJFDjs.Z.from(a):void 0}async function La(n){let{aptosConfig:e,sender:t,name:r,address:i,options:o}=n,s=ot(e),{domainName:a,subdomainName:c}=bt(r);return await T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::set_target_addr`,functionArguments:[a,c,i]},options:o})}async function qa(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=bt(t),a=(await w({aptosConfig:e,query:{query:an,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=$n(a)),Oa(a)?a:void 0}async function $a(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _219 => _219.limit]),offset:_optionalChain([t, 'optionalAccess', _220 => _220.offset]),order_by:_optionalChain([t, 'optionalAccess', _221 => _221.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _222 => _222.options, 'optionalAccess', _223 => _223.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map($n)}async function Wa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _224 => _224.limit]),offset:_optionalChain([t, 'optionalAccess', _225 => _225.offset]),order_by:_optionalChain([t, 'optionalAccess', _226 => _226.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map($n)}async function Qa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _229 => _229.limit]),offset:_optionalChain([t, 'optionalAccess', _230 => _230.offset]),order_by:_optionalChain([t, 'optionalAccess', _231 => _231.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _232 => _232.options, 'optionalAccess', _233 => _233.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map($n)}async function ja(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:an,variables:{limit:_optionalChain([t, 'optionalAccess', _234 => _234.limit]),offset:_optionalChain([t, 'optionalAccess', _235 => _235.offset]),order_by:_optionalChain([t, 'optionalAccess', _236 => _236.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _237 => _237.options, 'optionalAccess', _238 => _238.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map($n).filter(Oa)}async function $i(n){let{aptosConfig:e}=n,t=ot(e),[r]=await ae({aptosConfig:e,payload:{function:`${t}::config::reregistration_grace_sec`,functionArguments:[]}}),i=r/60/60/24,o=()=>new Date;return new Date(o().setDate(o().getDate()-i)).toISOString()}async function Ja(n){let{aptosConfig:e,sender:t,name:r,years:i=1,options:o}=n,s=ot(e),a=i*31536e3,{domainName:c,subdomainName:p}=bt(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 T({aptosConfig:e,sender:t.accountAddress.toString(),data:{function:`${s}::router::renew_domain`,functionArguments:[c,a]},options:o})}function $n(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var Wn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Ga({aptosConfig:this.config,...e})}async getExpiration(e){return qi({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ha({aptosConfig:this.config,...e})}async setTargetAddress(e){return La({aptosConfig:this.config,...e})}async getPrimaryName(e){return Ma({aptosConfig:this.config,...e})}async setPrimaryName(e){return Va({aptosConfig:this.config,...e})}async registerName(e){return Ba({aptosConfig:this.config,...e})}async renewDomain(e){return Ja({aptosConfig:this.config,...e})}async getName(e){return qa({aptosConfig:this.config,...e})}async getAccountNames(e){return $a({aptosConfig:this.config,...e})}async getAccountDomains(e){return Wa({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return Qa({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return ja({aptosConfig:this.config,...e})}};async function Xa(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk66TIRJFDjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:wi,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 Ya(n){let{aptosConfig:e,options:t}=n,r={query:wi,variables:{order_by:_optionalChain([t, 'optionalAccess', _239 => _239.orderBy])}};return(await w({aptosConfig:e,query:r})).num_active_delegator_per_pool}async function Za(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:ts,variables:{delegatorAddress:_chunk66TIRJFDjs.Z.from(t).toStringLong(),poolAddress:_chunk66TIRJFDjs.Z.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var Qn=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _240 => _240.minimumLedgerVersion]),processorType:"stake_processor"}),Xa({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _241 => _241.minimumLedgerVersion]),processorType:"stake_processor"}),Ya({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _242 => _242.minimumLedgerVersion]),processorType:"stake_processor"}),Za({aptosConfig:this.config,...e})}};var Lr=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Or(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Fi({aptosConfig:this.config,payload:Ut.load(new R(i)),...e});return new rn(o,e.withFeePayer===!0?_chunk66TIRJFDjs.Z.ZERO:void 0)}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function Wi(n,e,t){let r=t.value;return t.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)},t}function Qi(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var gn=class{constructor(e){this.config=e}async simple(e){return Mi({aptosConfig:this.config,...e})}async multiAgent(e){return Mi({aptosConfig:this.config,...e})}};_chunk66TIRJFDjs.a.call(void 0, [Qi],gn.prototype,"simple",1),_chunk66TIRJFDjs.a.call(void 0, [Qi],gn.prototype,"multiAgent",1);var mn=class{constructor(e){this.config=e}async simple(e){return Fn({aptosConfig:this.config,...e})}async multiAgent(e){return Fn({aptosConfig:this.config,...e})}};_chunk66TIRJFDjs.a.call(void 0, [Wi],mn.prototype,"simple",1),_chunk66TIRJFDjs.a.call(void 0, [Wi],mn.prototype,"multiAgent",1);var qr=class{constructor(e,t,r,i,o){this.lastUncommintedNumber=null;this.currentNumber=null;this.lock=!1;this.aptosConfig=e,this.account=t,this.maxWaitTime=r,this.maximumInFlight=i,this.sleepTime=o}async nextSequenceNumber(){for(;this.lock;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime);this.lock=!0;let e=BigInt(0);try{if((this.lastUncommintedNumber===null||this.currentNumber===null)&&await this.initialize(),this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight){await this.update();let t=_chunk66TIRJFDjs.da.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime),_chunk66TIRJFDjs.da.call(void 0, )-t>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):await this.update()}e=this.currentNumber,this.currentNumber+=BigInt(1)}catch(t){console.error("error in getting next sequence number for this account",t)}finally{this.lock=!1}return e}async initialize(){let{sequence_number:e}=await Vt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Vt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});return this.lastUncommintedNumber=BigInt(e),this.lastUncommintedNumber}async synchronize(){if(this.lastUncommintedNumber!==this.currentNumber){for(;this.lock;)await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk66TIRJFDjs.da.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk66TIRJFDjs.da.call(void 0, )-e>this.maxWaitTime?(console.warn(`Waited over 30 seconds for a transaction to commit, re-syncing ${this.account.accountAddress.toString()}`),await this.initialize()):(await _chunk66TIRJFDjs.ba.call(void 0, this.sleepTime),await this.update())}catch(e){console.error("error in synchronizing this account sequence number with the one on chain",e)}finally{this.lock=!1}}}};var yn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _243 => _243.pendingDequeue, 'access', _244 => _244.shift, 'call', _245 => _245(), 'optionalAccess', _246 => _246.resolve, 'call', _247 => _247(e)]);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,t)=>{this.pendingDequeue.push({resolve:e,reject:t})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new fn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},fn=class extends Error{};var ec="fulfilled",tc= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(tc||{}),$r= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new yn;this.transactionsQueue=new yn;this.outstandingTransactions=new yn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new qr(t,r,i,o,s)}async submitNextTransaction(){try{for(;;){let t=await this.accountSequnceNumber.nextSequenceNumber();if(t===null)return;let r=await this.generateNextTransaction(this.account,t);if(!r)return;let i=ht({aptosConfig:this.aptosConfig,transaction:r,signer:this.account});await this.outstandingTransactions.enqueue([i,t])}}catch(t){if(t instanceof fn)return;throw new Error(`Submit transaction failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async processTransactions(){try{for(;;){let t=[],r=[],[i,o]=await this.outstandingTransactions.dequeue();for(t.push(i),r.push(o);!this.outstandingTransactions.isEmpty();)[i,o]=await this.outstandingTransactions.dequeue(),t.push(i),r.push(o);let s=await Promise.allSettled(t);for(let a=0;a<s.length&&a<r.length;a+=1){let c=s[a];o=r[a],c.status===ec?(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(t){if(t instanceof fn)return;throw new Error(`Process execution failed for ${this.account.accountAddress.toString()} with error ${t}`)}}async checkTransaction(t,r){try{let i=[];i.push(At({aptosConfig:this.aptosConfig,transactionHash:t.value.hash}));let o=await Promise.allSettled(i);for(let s=0;s<o.length;s+=1){let a=o[s];a.status===ec?(this.executedTransactions.push([a.value.hash,r,null]),this.emit("transactionExecuted",{message:`transaction hash ${a.value.hash} has been executed on chain`,transactionHash:t.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(t,r){this.transactionsQueue.enqueue([t,r])}async generateNextTransaction(t,r){if(this.transactionsQueue.isEmpty())return;let[i,o]=await this.transactionsQueue.dequeue();return T({aptosConfig:this.aptosConfig,sender:t.accountAddress,data:i,options:{...o,accountSequenceNumber:r}})}async run(){try{for(;!this.taskQueue.isCancelled();)await(await this.taskQueue.dequeue())()}catch(t){throw new Error(`Unable to start transaction batching: ${t}`)}}start(){if(this.started)throw new Error("worker has already started");this.started=!0,this.taskQueue.enqueue(()=>this.submitNextTransaction()),this.taskQueue.enqueue(()=>this.processTransactions()),this.run()}stop(){if(this.taskQueue.isCancelled())throw new Error("worker has already stopped");this.started=!1,this.taskQueue.cancel()}};var Wr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new $r(this.config,t),this.transactionWorker.start(),this.registerToEvents()}push(e){let{data:t,options:r}=e;for(let i of t)this.transactionWorker.push(i,r)}registerToEvents(){this.transactionWorker.on("transactionSent",async e=>{this.emit("transactionSent",e)}),this.transactionWorker.on("transactionSendFailed",async e=>{this.emit("transactionSendFailed",e)}),this.transactionWorker.on("transactionExecuted",async e=>{this.emit("transactionExecuted",e)}),this.transactionWorker.on("transactionExecutionFailed",async e=>{this.emit("transactionExecutionFailed",e)}),this.transactionWorker.on("executionFinish",async e=>{this.emit("executionFinish",e)})}forSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.start({sender:t}),this.push({data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}};var jn=class{constructor(e){this.config=e,this.build=new Lr(this.config),this.simulate=new gn(this.config),this.submit=new mn(this.config),this.batch=new Wr(this.config)}async getTransactions(e){return _i({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ms({aptosConfig:this.config,...e})}async getTransactionByHash(e){return zn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return ys({aptosConfig:this.config,...e})}async waitForTransaction(e){return At({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Rr({aptosConfig:this.config})}getSigningMessage(e){return Us(e)}async publishPackageTransaction(e){return Ds({aptosConfig:this.config,...e})}async rotateAuthKey(e){return Js({aptosConfig:this.config,...e})}sign(e){return Gr({...e})}signAsFeePayer(e){return Br({...e})}async batchTransactionsForSingleAccount(e){try{let{sender:t,data:r,options:i}=e;this.batch.forSingleAccount({sender:t,data:r,options:i})}catch(t){throw new Error(`failed to submit transactions with error: ${t}`)}}async signAndSubmitTransaction(e){return ht({aptosConfig:this.config,...e})}async signAndSubmitAsFeePayer(e){return ks({aptosConfig:this.config,...e})}};var Jn=class{constructor(e){this.config=e}async getTableItem(e){return vr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ls({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),gs({aptosConfig:this.config,...e})}};async function Qr(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,uidKey:i="sub",derivationPath:o}=n,s={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,epk_blinder:_chunk66TIRJFDjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await Do({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunk66TIRJFDjs.j.fromHexInput(a.pepper).toUint8Array()}async function ji(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Qr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await Xt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk66TIRJFDjs.j.fromHexInput(i).toUint8Array().length!==rt.PEPPER_LENGTH)throw new Error(`Pepper needs to be ${rt.PEPPER_LENGTH} bytes`);let a=_jwtdecode.jwtDecode.call(void 0, t);if(typeof a.iat!="number")throw new Error("iat was not found");if(s<r.expiryDateSecs-a.iat)throw Error(`The EphemeralKeyPair is too long lived. It's lifespan must be less than ${s}`);let c={jwt_b64:t,epk:r.getPublicKey().bcsToHex().toStringWithoutPrefix(),epk_blinder:_chunk66TIRJFDjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk66TIRJFDjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await zo({aptosConfig:e,path:"prove",body:c,originMethod:"getProof",overrides:{WITH_CREDENTIALS:!1}}),l=p.proof,h=new mt({a:l.a,b:l.b,c:l.c});return new ue({proof:new Jt(h,0),trainingWheelsSignature:Ue.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function nc(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Qr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await Xt({aptosConfig:e}),p=ji({...n,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(r!==void 0){let g=Z.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await dn({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Bt.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let h=U.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),d=await dn({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return rt.create({...n,address:d,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function rc(n){let{aptosConfig:e,sender:t,iss:r,options:i}=n,{jwksUrl:o}=n;o===void 0&&(vo.test(r)?o="https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com":o=r.endsWith("/")?`${r}.well-known/jwks.json`:`${r}/.well-known/jwks.json`);let s;try{if(s=await fetch(o),!s.ok)throw new Error(`${s.status} ${s.statusText}`)}catch(c){let p;throw c instanceof Error?p=`${c.message}`:p=`error unknown - ${c}`,P.fromErrorType({type:14,details:`Failed to fetch JWKS at ${o}: ${p}`})}let a=await s.json();return T({aptosConfig:e,sender:t.accountAddress,data:{function:"0x1::jwks::update_federated_jwk_set",functionArguments:[r,S.MoveString(a.keys.map(c=>c.kid)),S.MoveString(a.keys.map(c=>c.alg)),S.MoveString(a.keys.map(c=>c.e)),S.MoveString(a.keys.map(c=>c.n))]},options:i})}var Xn=class{constructor(e){this.config=e}async getPepper(e){return Qr({aptosConfig:this.config,...e})}async getProof(e){return ji({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return nc({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return rc({aptosConfig:this.config,...e})}};async function mp(n){let{aptosConfig:e,options:t}=n,r={query:Pr,variables:{where_condition:_optionalChain([t, 'optionalAccess', _248 => _248.where]),offset:_optionalChain([t, 'optionalAccess', _249 => _249.offset]),limit:_optionalChain([t, 'optionalAccess', _250 => _250.limit]),order_by:_optionalChain([t, 'optionalAccess', _251 => _251.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getObjectData"})).current_objects}async function ic(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk66TIRJFDjs.Z.from(t).toStringLong()}};return(await mp({aptosConfig:e,options:{...r,where:o}}))[0]}var Yn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),ic({aptosConfig:this.config,...e})}};var ee=class{constructor(e){this.config=new Mr(e),this.account=new On(this.config),this.abstraction=new Ht(this.config),this.ans=new Wn(this.config),this.coin=new Gn(this.config),this.digitalAsset=new Bn(this.config),this.event=new Vn(this.config),this.faucet=new Hn(this.config),this.fungibleAsset=new Ln(this.config),this.general=new qn(this.config),this.staking=new Qn(this.config),this.transaction=new jn(this.config),this.table=new Jn(this.config),this.keyless=new Xn(this.config),this.object=new Yn(this.config)}};function ce(n,e,t){Object.getOwnPropertyNames(e.prototype).forEach(r=>{let i=Object.getOwnPropertyDescriptor(e.prototype,r);i&&(i.value=function(...o){return this[t][r](...o)},Object.defineProperty(n.prototype,r,i))})}ce(ee,On,"account");ce(ee,Ht,"abstraction");ce(ee,Wn,"ans");ce(ee,Gn,"coin");ce(ee,Bn,"digitalAsset");ce(ee,Vn,"event");ce(ee,Hn,"faucet");ce(ee,Ln,"fungibleAsset");ce(ee,qn,"general");ce(ee,Qn,"staking");ce(ee,jn,"transaction");ce(ee,Jn,"table");ce(ee,Xn,"keyless");ce(ee,Yn,"object");exports.APTOS_BIP44_REGEX = Ac; exports.APTOS_COIN = xt; exports.APTOS_FA = Io; exports.APTOS_HARDENED_REGEX = fc; exports.AbstractKeylessAccount = me; exports.AbstractMultiKey = xn; exports.AbstractPublicKey = rr; exports.AbstractSignature = Tn; exports.AbstractedAccount = Sr; exports.Account = nt; exports.AccountAddress = _chunk66TIRJFDjs.Z; exports.AccountAuthenticator = j; exports.AccountAuthenticatorAbstraction = vt; exports.AccountAuthenticatorEd25519 = ve; exports.AccountAuthenticatorMultiEd25519 = je; exports.AccountAuthenticatorMultiKey = Ge; exports.AccountAuthenticatorNoAccountAuthenticator = en; exports.AccountAuthenticatorSingleKey = oe; exports.AccountAuthenticatorVariant = _chunk66TIRJFDjs.w; exports.AccountPublicKey = ie; exports.AccountSequenceNumber = qr; exports.AccountUtils = Vo; exports.AddressInvalidReason = _chunk66TIRJFDjs.Y; exports.AnyPublicKey = N; exports.AnyPublicKeyVariant = _chunk66TIRJFDjs.y; exports.AnySignature = H; exports.AnySignatureVariant = _chunk66TIRJFDjs.z; exports.Aptos = ee; exports.AptosApiError = Ae; exports.AptosApiType = _t; exports.AptosConfig = Mr; exports.AptosScriptComposer = Or; exports.AuthenticationKey = B; exports.Bool = z; exports.CKDPriv = Ao; exports.CallArgument = _chunk66TIRJFDjs.X; exports.ChainId = tn; exports.DEFAULT_MAX_GAS_AMOUNT = _o; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = xo; exports.DEFAULT_TXN_TIMEOUT_SEC = ar; exports.DerivableAbstractedAccount = Lo; exports.DeriveScheme = _chunk66TIRJFDjs.W; exports.Deserializer = R; exports.EPK_HORIZON_SECS = Xc; exports.Ed25519Account = se; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = I; exports.Ed25519Signature = K; exports.EntryFunction = kt; exports.EntryFunctionBytes = nr; exports.EphemeralCertificate = jt; exports.EphemeralCertificateVariant = _chunk66TIRJFDjs.C; exports.EphemeralKeyPair = Gt; exports.EphemeralPublicKey = lt; exports.EphemeralPublicKeyVariant = _chunk66TIRJFDjs.A; exports.EphemeralSignature = Ue; exports.EphemeralSignatureVariant = _chunk66TIRJFDjs.B; exports.FIREBASE_AUTH_ISS_PATTERN = vo; exports.FederatedKeylessAccount = Bt; exports.FederatedKeylessPublicKey = Z; exports.FeePayerRawTransaction = zt; exports.FixedBytes = Ee; exports.Groth16ProofAndStatement = gi; exports.Groth16VerificationKey = yi; exports.Groth16Zkp = mt; exports.HARDENED_OFFSET = mo; exports.Hex = _chunk66TIRJFDjs.j; exports.HexInvalidReason = _chunk66TIRJFDjs.i; exports.Identifier = k; exports.KeyType = hc; exports.KeylessAccount = rt; exports.KeylessConfiguration = mi; exports.KeylessError = P; exports.KeylessErrorCategory = Hc; exports.KeylessErrorResolutionTip = Lc; exports.KeylessErrorType = cr; exports.KeylessPublicKey = U; exports.KeylessSignature = he; exports.MAX_AUD_VAL_BYTES = di; exports.MAX_COMMITED_EPK_BYTES = ru; exports.MAX_EXTRA_FIELD_BYTES = tu; exports.MAX_ISS_VAL_BYTES = eu; exports.MAX_JWT_HEADER_B64_BYTES = nu; exports.MAX_UID_KEY_BYTES = Yc; exports.MAX_UID_VAL_BYTES = Zc; exports.MimeType = _chunk66TIRJFDjs.q; exports.ModuleId = In; exports.MoveAbility = _chunk66TIRJFDjs.S; exports.MoveFunctionVisibility = _chunk66TIRJFDjs.R; exports.MoveJWK = fi; exports.MoveOption = Y; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = Dt; exports.MultiAgentTransaction = Ar; exports.MultiEd25519Account = wr; exports.MultiEd25519PublicKey = Zt; exports.MultiEd25519Signature = Qe; exports.MultiKey = Fe; exports.MultiKeyAccount = kn; exports.MultiKeySignature = Oe; exports.MultiSig = Rn; exports.MultiSigTransactionPayload = Un; exports.Network = oi; exports.NetworkToChainId = si; exports.NetworkToFaucetAPI = Po; exports.NetworkToIndexerAPI = So; exports.NetworkToNetworkName = Il; exports.NetworkToNodeAPI = Eo; exports.NetworkToPepperAPI = ri; exports.NetworkToProverAPI = ii; exports.ParsingError = _chunk66TIRJFDjs.h; exports.PrivateKey = pt; exports.PrivateKeyVariants = _chunk66TIRJFDjs.x; exports.ProcessorType = He; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Co; exports.RAW_TRANSACTION_WITH_DATA_SALT = ai; exports.RawTransaction = be; exports.RawTransactionWithData = yr; exports.RoleType = _chunk66TIRJFDjs.T; exports.RotationProofChallenge = fr; exports.Script = Kn; exports.ScriptTransactionArgumentVariants = _chunk66TIRJFDjs.s; exports.Secp256k1PrivateKey = We; exports.Secp256k1PublicKey = $e; exports.Secp256k1Signature = Ct; exports.Serializable = _chunk66TIRJFDjs.l; exports.Serialized = hn; exports.Serializer = _chunk66TIRJFDjs.m; exports.Signature = M; exports.SignedTransaction = tt; exports.SigningScheme = _chunk66TIRJFDjs.U; exports.SigningSchemeInput = _chunk66TIRJFDjs.V; exports.SimpleTransaction = rn; exports.SingleKeyAccount = we; exports.StructTag = Be; exports.TransactionAndProof = Tr; exports.TransactionAuthenticator = et; exports.TransactionAuthenticatorEd25519 = Nt; exports.TransactionAuthenticatorFeePayer = Ot; exports.TransactionAuthenticatorMultiAgent = Ft; exports.TransactionAuthenticatorMultiEd25519 = nn; exports.TransactionAuthenticatorSingleSender = ft; exports.TransactionAuthenticatorVariant = _chunk66TIRJFDjs.v; exports.TransactionPayload = Rt; exports.TransactionPayloadEntryFunction = Cn; exports.TransactionPayloadMultiSig = vn; exports.TransactionPayloadScript = Ut; exports.TransactionPayloadVariants = _chunk66TIRJFDjs.t; exports.TransactionResponseType = _chunk66TIRJFDjs.E; exports.TransactionVariants = _chunk66TIRJFDjs.u; exports.TransactionWorker = $r; exports.TransactionWorkerEventsEnum = tc; exports.TypeTag = O; exports.TypeTagAddress = F; exports.TypeTagBool = L; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = Iu; exports.TypeTagReference = mr; exports.TypeTagSigner = Kt; exports.TypeTagStruct = A; exports.TypeTagU128 = Ye; exports.TypeTagU16 = Je; exports.TypeTagU256 = Ze; exports.TypeTagU32 = Xe; exports.TypeTagU64 = J; exports.TypeTagU8 = le; exports.TypeTagVariants = _chunk66TIRJFDjs.r; exports.TypeTagVector = C; exports.U128 = xe; exports.U16 = Pe; exports.U256 = ye; exports.U32 = _e; exports.U64 = Q; exports.U8 = X; exports.ZeroKnowledgeSig = ue; exports.ZkProof = Jt; exports.ZkpVariant = _chunk66TIRJFDjs.D; exports.aptosCoinStructTag = Wy; exports.aptosRequest = ur; exports.base64UrlDecode = _chunk66TIRJFDjs.fa; exports.base64UrlToBytes = _chunk66TIRJFDjs.ga; exports.bigIntToBytesLE = ni; exports.buildTransaction = Oi; exports.bytesToBigIntLE = Et; exports.checkOrConvertArgument = Mt; exports.convertAmountFromHumanReadableToOnChain = _chunk66TIRJFDjs.ha; exports.convertAmountFromOnChainToHumanReadable = _chunk66TIRJFDjs.ia; exports.convertArgument = un; exports.convertCallArgument = Lb; exports.convertNumber = kr; exports.createObjectAddress = _chunk66TIRJFDjs._; exports.createResourceAddress = _chunk66TIRJFDjs.$; exports.createTokenAddress = _chunk66TIRJFDjs.aa; exports.deriveKey = Zr; exports.deriveTransactionType = hr; exports.deserializeFromScriptArgument = lu; exports.ensureBoolean = _chunk66TIRJFDjs.n; exports.fetchEntryFunctionAbi = xs; exports.fetchFunctionAbi = Ni; exports.fetchJWK = hi; exports.fetchModuleAbi = zi; exports.fetchMoveFunctionAbi = Hb; exports.fetchViewFunctionAbi = Is; exports.findFirstNonSignerArg = _s; exports.floorToWholeHour = _chunk66TIRJFDjs.ea; exports.generateRawTransaction = Fi; exports.generateSignedTransaction = Gi; exports.generateSignedTransactionForSimulation = vs; exports.generateSigningMessage = yt; exports.generateSigningMessageForSerializable = sA; exports.generateSigningMessageForTransaction = Ke; exports.generateTransactionPayload = Fr; exports.generateTransactionPayloadWithABI = ku; exports.generateUserTransactionHash = yw; exports.generateViewFunctionPayload = Cs; exports.generateViewFunctionPayloadWithABI = Du; exports.get = pr; exports.getAptosFullNode = V; exports.getAptosPepperService = eg; exports.getAuthenticatorForSimulation = pn; exports.getErrorMessage = _chunk66TIRJFDjs.ca; exports.getFunctionParts = _chunk66TIRJFDjs.la; exports.getIssAudAndUidVal = qe; exports.getKeylessConfig = Xt; exports.getKeylessJWKs = au; exports.getPageWithObfuscatedCursor = lr; exports.hashStrToField = ke; exports.hashValues = Ks; exports.hexToAsciiString = _chunk66TIRJFDjs.k; exports.isBcsAddress = zr; exports.isBcsBool = xi; exports.isBcsFixedBytes = vu; exports.isBcsString = Ii; exports.isBcsU128 = Ui; exports.isBcsU16 = vi; exports.isBcsU256 = ki; exports.isBcsU32 = Ki; exports.isBcsU64 = Ri; exports.isBcsU8 = Ci; exports.isBlockEpilogueTransactionResponse = _chunk66TIRJFDjs.L; exports.isBlockMetadataTransactionResponse = _chunk66TIRJFDjs.I; exports.isBool = ws; exports.isCanonicalEd25519Signature = bc; exports.isEd25519Signature = _chunk66TIRJFDjs.M; exports.isEmptyOption = Ss; exports.isEncodedEntryFunctionArgument = Es; exports.isEncodedStruct = _chunk66TIRJFDjs.ka; exports.isFeePayerSignature = _chunk66TIRJFDjs.P; exports.isGenesisTransactionResponse = _chunk66TIRJFDjs.H; exports.isKeylessSigner = br; exports.isLargeNumber = Dr; exports.isMultiAgentSignature = _chunk66TIRJFDjs.O; exports.isMultiEd25519Signature = _chunk66TIRJFDjs.Q; exports.isNumber = Cu; exports.isPendingTransactionResponse = _chunk66TIRJFDjs.F; exports.isScriptDataInput = Ps; exports.isSecp256k1Signature = _chunk66TIRJFDjs.N; exports.isSingleKeySigner = Ti; exports.isStateCheckpointTransactionResponse = _chunk66TIRJFDjs.J; exports.isString = it; exports.isUserTransactionResponse = _chunk66TIRJFDjs.G; exports.isValidBIP44Path = yo; exports.isValidFunctionInfo = _chunk66TIRJFDjs.ma; exports.isValidHardenedPath = fo; exports.isValidatorTransactionResponse = _chunk66TIRJFDjs.K; exports.mnemonicToSeed = ir; exports.normalizeBundle = Ko; exports.nowInSeconds = _chunk66TIRJFDjs.da; exports.objectStructTag = ge; exports.optionStructTag = Qy; exports.outOfRangeErrorMessage = _chunk66TIRJFDjs.o; exports.padAndPackBytesWithLen = wn; exports.paginateWithCursor = dr; exports.paginateWithObfuscatedCursor = ui; exports.pairedFaMetadataAddress = _chunk66TIRJFDjs.oa; exports.parseEncodedStruct = _chunk66TIRJFDjs.ja; exports.parseJwtHeader = uu; exports.parseTypeTag = Re; exports.poseidonHash = Pt; exports.post = Sn; exports.postAptosFaucet = ko; exports.postAptosFullNode = gt; exports.postAptosIndexer = Uo; exports.postAptosPepperService = Do; exports.postAptosProvingService = zo; exports.promiseFulfilledStatus = ec; exports.request = Wc; exports.sleep = _chunk66TIRJFDjs.ba; exports.splitPath = ho; exports.standardizeTypeTags = cn; exports.stringStructTag = _; exports.throwTypeMismatch = D; exports.truncateAddress = _chunk66TIRJFDjs.na; exports.validateNumberInRange = _chunk66TIRJFDjs.p; exports.verifyKeylessSignature = Ai; exports.verifyKeylessSignatureWithJwkAndConfig = gr;
|
|
480
480
|
//# sourceMappingURL=index.js.map
|