@aptos-labs/ts-sdk 1.36.0-zeta.0 → 1.37.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-C685VEzA.d.ts → accountAddress-DZH9Wn5l.d.ts} +28 -1
- package/dist/common/chunk-MVCKMP5U.js +4 -0
- package/dist/common/{chunk-5GUWOXQG.js.map → chunk-MVCKMP5U.js.map} +1 -1
- package/dist/common/cli/index.d.ts +1 -1
- package/dist/common/cli/index.js +1 -1
- package/dist/common/cli/index.js.map +1 -1
- package/dist/common/index.d.ts +221 -31
- package/dist/common/index.js +9 -9
- package/dist/common/index.js.map +1 -1
- package/dist/esm/{Ed25519Account-6KGApCPu.d.mts → Ed25519Account-CDURCT1q.d.mts} +56 -0
- 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 +3 -3
- 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/Ed25519Account.d.mts +4 -4
- 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 +35 -13
- package/dist/esm/account/MultiEd25519Account.mjs +1 -1
- package/dist/esm/account/MultiKeyAccount.d.mts +6 -2
- package/dist/esm/account/MultiKeyAccount.mjs +1 -1
- package/dist/esm/account/SingleKeyAccount.d.mts +4 -4
- 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 +85 -6
- 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/experimental.mjs +1 -1
- package/dist/esm/api/faucet.mjs +1 -1
- package/dist/esm/api/fungibleAsset.d.mts +1 -1
- package/dist/esm/api/fungibleAsset.mjs +1 -1
- package/dist/esm/api/general.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/index.mjs +1 -1
- package/dist/esm/bcs/serializable/movePrimitives.mjs +1 -1
- package/dist/esm/bcs/serializable/moveStructs.mjs +1 -1
- package/dist/esm/{chunk-AIPHJFJL.mjs → chunk-3IGJ2IMB.mjs} +2 -2
- package/dist/esm/{chunk-CWL7ZA3P.mjs → chunk-5MMTP427.mjs} +2 -2
- package/dist/esm/chunk-6374Q7AG.mjs +2 -0
- package/dist/esm/{chunk-3RVAGHAA.mjs.map → chunk-6374Q7AG.mjs.map} +1 -1
- package/dist/esm/{chunk-AEGA5N2W.mjs → chunk-6J64BOS7.mjs} +2 -2
- package/dist/esm/chunk-7H44HTYE.mjs +4 -0
- package/dist/esm/chunk-7H44HTYE.mjs.map +1 -0
- package/dist/esm/{chunk-6KE4JZD6.mjs → chunk-7VEWPUCH.mjs} +2 -2
- package/dist/esm/chunk-ANTUWHYB.mjs +2 -0
- package/dist/esm/chunk-ANTUWHYB.mjs.map +1 -0
- package/dist/esm/{chunk-R6QCPXQG.mjs → chunk-B373VRCY.mjs} +2 -2
- package/dist/esm/chunk-B373VRCY.mjs.map +1 -0
- package/dist/esm/{chunk-TTY5GFMN.mjs → chunk-BSH7B2QT.mjs} +2 -2
- package/dist/esm/chunk-EYLZD4JU.mjs +4 -0
- package/dist/esm/chunk-EYLZD4JU.mjs.map +1 -0
- package/dist/esm/chunk-GPG64UZT.mjs +2 -0
- package/dist/esm/{chunk-X5YB74NB.mjs.map → chunk-GPG64UZT.mjs.map} +1 -1
- package/dist/esm/{chunk-PSZYS4RG.mjs → chunk-HRHICHDX.mjs} +2 -2
- package/dist/esm/{chunk-XLDMPCLF.mjs → chunk-JG4T5BDZ.mjs} +2 -2
- package/dist/esm/{chunk-35CO4BP4.mjs → chunk-LBA4CTUV.mjs} +2 -2
- package/dist/esm/{chunk-RXMLONF7.mjs → chunk-NZXPT44W.mjs} +2 -2
- package/dist/esm/{chunk-KXVD52Y6.mjs → chunk-POELQOLD.mjs} +2 -2
- package/dist/esm/chunk-PR72YXRK.mjs +2 -0
- package/dist/esm/chunk-PR72YXRK.mjs.map +1 -0
- package/dist/esm/{chunk-3EUHEZND.mjs → chunk-PXG3WJIU.mjs} +2 -2
- package/dist/esm/{chunk-TBY3VMMV.mjs → chunk-TTFYJM6A.mjs} +2 -2
- package/dist/esm/{chunk-EODSU3YN.mjs → chunk-VNUNIQAY.mjs} +2 -2
- package/dist/esm/{chunk-WB26DWOY.mjs → chunk-YHJHXLYS.mjs} +2 -2
- package/dist/esm/{chunk-7YTGBTWH.mjs → chunk-YHKWV7NV.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.d.mts +5 -1
- package/dist/esm/client/get.mjs +1 -1
- package/dist/esm/client/index.d.mts +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.d.mts +18 -0
- 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.mjs +1 -1
- package/dist/esm/core/crypto/ephemeral.mjs +1 -1
- package/dist/esm/core/crypto/federatedKeyless.d.mts +2 -2
- 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.d.mts +2 -2
- package/dist/esm/core/crypto/multiEd25519.mjs +1 -1
- package/dist/esm/core/crypto/multiKey.d.mts +4 -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.mjs +1 -1
- package/dist/esm/core/crypto/signature.mjs +1 -1
- package/dist/esm/core/crypto/singleKey.d.mts +4 -1
- 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-Qe_j8OqV.d.mts → federatedKeyless-J5bdbbLQ.d.mts} +20 -20
- package/dist/esm/index.d.mts +5 -5
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/internal/abstraction.mjs +1 -1
- package/dist/esm/internal/account.d.mts +49 -6
- package/dist/esm/internal/account.mjs +1 -1
- package/dist/esm/internal/ans.d.mts +1 -1
- package/dist/esm/internal/ans.mjs +1 -1
- package/dist/esm/internal/coin.mjs +1 -1
- package/dist/esm/internal/digitalAsset.d.mts +1 -1
- package/dist/esm/internal/digitalAsset.mjs +1 -1
- package/dist/esm/internal/event.mjs +1 -1
- package/dist/esm/internal/experimental.mjs +1 -1
- package/dist/esm/internal/faucet.mjs +1 -1
- package/dist/esm/internal/fungibleAsset.d.mts +1 -1
- package/dist/esm/internal/fungibleAsset.mjs +1 -1
- package/dist/esm/internal/general.mjs +1 -1
- package/dist/esm/internal/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.d.mts +1 -1
- package/dist/esm/internal/utils/index.mjs +1 -1
- package/dist/esm/internal/utils/utils.d.mts +2 -19
- 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/index.mjs +1 -1
- package/dist/esm/transactions/instances/moduleId.mjs +1 -1
- package/dist/esm/transactions/instances/multiAgentTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rawTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/rotationProofChallenge.mjs +1 -1
- package/dist/esm/transactions/instances/signedTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/simpleTransaction.mjs +1 -1
- package/dist/esm/transactions/instances/transactionPayload.mjs +1 -1
- package/dist/esm/transactions/management/accountSequenceNumber.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.mjs +1 -1
- package/dist/esm/transactions/typeTag/index.mjs +1 -1
- package/dist/esm/transactions/typeTag/parser.mjs +1 -1
- package/dist/esm/types/index.d.mts +1 -1
- package/dist/esm/types/index.mjs +1 -1
- package/dist/esm/types/types.d.mts +10 -1
- package/dist/esm/types/types.mjs +1 -1
- package/dist/esm/utils/helpers.d.mts +27 -1
- package/dist/esm/utils/helpers.mjs +1 -1
- package/dist/esm/utils/index.d.mts +3 -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 +7 -1
- package/src/account/Account.ts +20 -0
- package/src/account/Ed25519Account.ts +26 -1
- package/src/account/MultiEd25519Account.ts +28 -1
- package/src/account/MultiKeyAccount.ts +2 -0
- package/src/account/SingleKeyAccount.ts +35 -1
- package/src/api/account.ts +84 -4
- package/src/client/get.ts +45 -18
- package/src/core/accountAddress.ts +25 -0
- package/src/core/crypto/federatedKeyless.ts +8 -2
- package/src/core/crypto/keyless.ts +93 -60
- package/src/core/crypto/multiEd25519.ts +2 -2
- package/src/core/crypto/multiKey.ts +24 -13
- package/src/core/crypto/singleKey.ts +12 -2
- package/src/internal/account.ts +84 -7
- package/src/internal/utils/utils.ts +2 -32
- package/src/types/types.ts +10 -0
- package/src/utils/helpers.ts +50 -0
- package/src/version.ts +1 -1
- package/dist/common/chunk-5GUWOXQG.js +0 -4
- package/dist/esm/chunk-3RVAGHAA.mjs +0 -2
- package/dist/esm/chunk-LQOSHBB7.mjs +0 -4
- package/dist/esm/chunk-LQOSHBB7.mjs.map +0 -1
- package/dist/esm/chunk-NFPNWY6Z.mjs +0 -4
- package/dist/esm/chunk-NFPNWY6Z.mjs.map +0 -1
- package/dist/esm/chunk-R6QCPXQG.mjs.map +0 -1
- package/dist/esm/chunk-TNWABITK.mjs +0 -2
- package/dist/esm/chunk-TNWABITK.mjs.map +0 -1
- package/dist/esm/chunk-X5YB74NB.mjs +0 -2
- package/dist/esm/chunk-ZELTLAUN.mjs +0 -2
- package/dist/esm/chunk-ZELTLAUN.mjs.map +0 -1
- /package/dist/esm/{chunk-AIPHJFJL.mjs.map → chunk-3IGJ2IMB.mjs.map} +0 -0
- /package/dist/esm/{chunk-CWL7ZA3P.mjs.map → chunk-5MMTP427.mjs.map} +0 -0
- /package/dist/esm/{chunk-AEGA5N2W.mjs.map → chunk-6J64BOS7.mjs.map} +0 -0
- /package/dist/esm/{chunk-6KE4JZD6.mjs.map → chunk-7VEWPUCH.mjs.map} +0 -0
- /package/dist/esm/{chunk-TTY5GFMN.mjs.map → chunk-BSH7B2QT.mjs.map} +0 -0
- /package/dist/esm/{chunk-PSZYS4RG.mjs.map → chunk-HRHICHDX.mjs.map} +0 -0
- /package/dist/esm/{chunk-XLDMPCLF.mjs.map → chunk-JG4T5BDZ.mjs.map} +0 -0
- /package/dist/esm/{chunk-35CO4BP4.mjs.map → chunk-LBA4CTUV.mjs.map} +0 -0
- /package/dist/esm/{chunk-RXMLONF7.mjs.map → chunk-NZXPT44W.mjs.map} +0 -0
- /package/dist/esm/{chunk-KXVD52Y6.mjs.map → chunk-POELQOLD.mjs.map} +0 -0
- /package/dist/esm/{chunk-3EUHEZND.mjs.map → chunk-PXG3WJIU.mjs.map} +0 -0
- /package/dist/esm/{chunk-TBY3VMMV.mjs.map → chunk-TTFYJM6A.mjs.map} +0 -0
- /package/dist/esm/{chunk-EODSU3YN.mjs.map → chunk-VNUNIQAY.mjs.map} +0 -0
- /package/dist/esm/{chunk-WB26DWOY.mjs.map → chunk-YHJHXLYS.mjs.map} +0 -0
- /package/dist/esm/{chunk-7YTGBTWH.mjs.map → chunk-YHKWV7NV.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 _chunk5GUWOXQGjs = require('./chunk-5GUWOXQG.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=_chunk5GUWOXQGjs.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<_chunk5GUWOXQGjs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>_chunk5GUWOXQGjs.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 Se=class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),this.value=_chunk5GUWOXQGjs.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 rr=class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),this.value=new Se(e)}serialize(e){e.serialize(this.value)}serializeForEntryFunction(e){e.serializeU32AsUleb128(this.value.value.length),e.serialize(this)}static deserialize(e,t){let r=Se.deserialize(e,t);return new n(r.value)}};var D=class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.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 fe(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},Y= exports.U8 =class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.p.call(void 0, e,0,_chunk5GUWOXQGjs.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())}},Ee= exports.U16 =class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.p.call(void 0, e,0,_chunk5GUWOXQGjs.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())}},Pe= exports.U32 =class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.p.call(void 0, e,0,_chunk5GUWOXQGjs.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 _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.p.call(void 0, e,BigInt(0),_chunk5GUWOXQGjs.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())}},_e= exports.U128 =class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.p.call(void 0, e,BigInt(0),_chunk5GUWOXQGjs.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())}},fe= exports.U256 =class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),_chunk5GUWOXQGjs.p.call(void 0, e,BigInt(0),_chunk5GUWOXQGjs.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 _chunk5GUWOXQGjs.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 Y)){new fn(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=_chunk5GUWOXQGjs.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 Y(r)))}static U16(e){return new n(e.map(t=>new Ee(t)))}static U32(e){return new n(e.map(t=>new Pe(t)))}static U64(e){return new n(e.map(t=>new Q(t)))}static U128(e){return new n(e.map(t=>new _e(t)))}static U256(e){return new n(e.map(t=>new fe(t)))}static Bool(e){return new n(e.map(t=>new D(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)}},fn= exports.Serialized =class n extends _chunk5GUWOXQGjs.l{constructor(e){super(),this.value=_chunk5GUWOXQGjs.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 _chunk5GUWOXQGjs.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())}},Z= exports.MoveOption =class n extends _chunk5GUWOXQGjs.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 Y(e):void 0)}static U16(e){return new n(e!=null?new Ee(e):void 0)}static U32(e){return new n(e!=null?new Pe(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 _e(e):void 0)}static U256(e){return new n(e!=null?new fe(e):void 0)}static Bool(e){return new n(e!=null?new D(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 _chunk5GUWOXQGjs.l{constructor(e){super();let{data:t}=e,r=_chunk5GUWOXQGjs.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=_chunk5GUWOXQGjs.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, _chunk5GUWOXQGjs.Z)(this.data.toUint8Array())}};ut.LENGTH=32;var B=ut;var St=class extends _chunk5GUWOXQGjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk5GUWOXQGjs.j.fromHexInput(e).toString()}},oe= exports.AccountPublicKey =class extends St{};var M=class extends _chunk5GUWOXQGjs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunk5GUWOXQGjs.j.fromHexInput(e).toString()}};var An=class n extends M{constructor(e){super(),this.value=_chunk5GUWOXQGjs.j.fromHexInput(e)}serialize(e){e.serializeBytes(this.value.toUint8Array())}static deserialize(e){return new n(e.deserializeBytes())}},ir= exports.AbstractPublicKey =class extends oe{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 yc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,fc= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Ac= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Ac||{}),mo= exports.HARDENED_OFFSET =2147483648;function yo(n){return fc.test(n)}function fo(n){return yc.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)},hc=n=>n.replace(/'/g,""),ho= exports.splitPath =n=>n.split("/").slice(1).map(hc),or= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return go.mnemonicToSeedSync(e)};var hn=class hn{static formatPrivateKey(e,t){let r=hn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunk5GUWOXQGjs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=hn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunk5GUWOXQGjs.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=_chunk5GUWOXQGjs.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=_chunk5GUWOXQGjs.j.fromHexInput(e);return i}};hn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var pt=hn;var qt=n=>typeof n=="string"?_chunk5GUWOXQGjs.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 Tc(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 oe{constructor(e){super();let t=_chunk5GUWOXQGjs.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(!Tc(r))return!1;let i=qt(t),o=_chunk5GUWOXQGjs.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,Ae=class Ae extends _chunk5GUWOXQGjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==Ae.LENGTH)throw new Error(`PrivateKey length should be ${Ae.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new Ae(e,!1)}static fromDerivationPath(e,t){if(!fo(e))throw new Error(`Invalid derivation path ${e}`);return Ae.fromDerivationPathInner(e,or(t))}static fromDerivationPathInner(e,t,r=mo){let{key:i,chainCode:o}=Zr(Ae.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 Ae(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new I(e)}sign(e){let t=qt(e),r=_chunk5GUWOXQGjs.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 Ae(t,!1)}static isPrivateKey(e){return e instanceof Ae}};Ae.LENGTH=32,Ae.SLIP_0010_SEED="ed25519 seed";var L=Ae,$t=class $t extends M{constructor(e){super();let t=_chunk5GUWOXQGjs.j.fromHexInput(e);if(t.toUint8Array().length!==$t.LENGTH)throw new Error(`Signature length should be ${$t.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 $t(t)}};$t.LENGTH=64;var K=$t;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}},Re= 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=_chunk5GUWOXQGjs.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 Ue(n,e){let r=new TextEncoder().encode(n);return Fc(r,e)}function Fc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=Tn(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=Mc(n,e);return Gc(t)}function Tn(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 Gc(n){if(n.length>To)throw new Error(`Can't pack more than ${To}. Was given ${n.length} bytes`);return Bc(n,bo).map(e=>Et(e))}function Bc(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 Mc(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 ar=class extends _chunk5GUWOXQGjs.l{};var ri="1.36.0";var wo={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"},So= 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"},Eo= exports.NetworkToFaucetAPI ={devnet:"https://faucet.devnet.aptoslabs.com",local:"http://127.0.0.1:8081"},ii= 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"},oi= 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"},si= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(si||{}),ai= 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||{}),Po= exports.DEFAULT_MAX_GAS_AMOUNT =2e5,_o= exports.DEFAULT_TXN_EXP_SEC_FROM_NOW =20,cr= exports.DEFAULT_TXN_TIMEOUT_SEC =20,xt= exports.APTOS_COIN ="0x1::aptos_coin::AptosCoin",xo= exports.APTOS_FA ="0x000000000000000000000000000000000000000000000000000000000000000a",Io= exports.RAW_TRANSACTION_SALT ="APTOS::RawTransaction",ci= exports.RAW_TRANSACTION_WITH_DATA_SALT ="APTOS::RawTransactionWithData",Ve= 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))(Ve||{}),vo= exports.FIREBASE_AUTH_ISS_PATTERN =/^https:\/\/securetoken\.google\.com\/[a-zA-Z0-9-_]+$/;function Co(n,e){let t=e.bcsToBytes(),r=new R(t);return n.deserialize(r)}var Vc=(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))(Vc||{}),Hc= 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))(Hc||{}),ur= 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))(ur||{}),Ko={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=Ko[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 _chunkMVCKMP5Ujs = require('./chunk-MVCKMP5U.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=_chunkMVCKMP5Ujs.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<_chunkMVCKMP5Ujs.d;){let r=this.deserializeU8();if(e|=BigInt(r&127)<<BigInt(t),!(r&128))break;t+=7}if(e>_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.l{constructor(e){super(),this.value=_chunkMVCKMP5Ujs.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 rr=class n extends _chunkMVCKMP5Ujs.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 N=class n extends _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.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 fe(e.deserializeU256())}static deserialize(e){return new n(e.deserializeBool())}},Y= exports.U8 =class n extends _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.p.call(void 0, e,0,_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.p.call(void 0, e,0,_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.p.call(void 0, e,0,_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.p.call(void 0, e,BigInt(0),_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.p.call(void 0, e,BigInt(0),_chunkMVCKMP5Ujs.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())}},fe= exports.U256 =class n extends _chunkMVCKMP5Ujs.l{constructor(e){super(),_chunkMVCKMP5Ujs.p.call(void 0, e,BigInt(0),_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.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 Y)){new fn(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=_chunkMVCKMP5Ujs.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 Y(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 fe(t)))}static Bool(e){return new n(e.map(t=>new N(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)}},fn= exports.Serialized =class n extends _chunkMVCKMP5Ujs.l{constructor(e){super(),this.value=_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.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())}},Z= exports.MoveOption =class n extends _chunkMVCKMP5Ujs.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 Y(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 fe(e):void 0)}static Bool(e){return new n(e!=null?new N(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 _chunkMVCKMP5Ujs.l{constructor(e){super();let{data:t}=e,r=_chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.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, _chunkMVCKMP5Ujs.Z)(this.data.toUint8Array())}};ut.LENGTH=32;var B=ut;var St=class extends _chunkMVCKMP5Ujs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkMVCKMP5Ujs.j.fromHexInput(e).toString()}},oe= exports.AccountPublicKey =class extends St{};var M=class extends _chunkMVCKMP5Ujs.l{toUint8Array(){return this.bcsToBytes()}toString(){let e=this.toUint8Array();return _chunkMVCKMP5Ujs.j.fromHexInput(e).toString()}};var An=class n extends M{constructor(e){super(),this.value=_chunkMVCKMP5Ujs.j.fromHexInput(e)}serialize(e){e.serializeBytes(this.value.toUint8Array())}static deserialize(e){return new n(e.deserializeBytes())}},ir= exports.AbstractPublicKey =class extends oe{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 mo = _interopRequireWildcard(_bip39);var yc=/^m\/44'\/637'\/[0-9]+'\/[0-9]+'\/[0-9]+'?$/,fc= exports.APTOS_BIP44_REGEX =/^m\/44'\/637'\/[0-9]+'\/[0-9]+\/[0-9]+$/,Ac= exports.KeyType =(e=>(e.ED25519="ed25519 seed",e))(Ac||{}),yo= exports.HARDENED_OFFSET =2147483648;function fo(n){return fc.test(n)}function Ao(n){return yc.test(n)}var ei=(n,e)=>{let t=_hmac.hmac.create(_sha512.sha512,n).update(e).digest();return{key:t.slice(0,32),chainCode:t.slice(32)}},ho= 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 ei(e,s)},hc=n=>n.replace(/'/g,""),To= exports.splitPath =n=>n.split("/").slice(1).map(hc),or= exports.mnemonicToSeed =n=>{let e=n.trim().split(/\s+/).map(t=>t.toLowerCase()).join(" ");return mo.mnemonicToSeedSync(e)};var hn=class hn{static formatPrivateKey(e,t){let r=hn.AIP80_PREFIXES[t],i=e;return typeof i=="string"&&i.startsWith(r)&&(i=i.split("-")[2]),`${r}${_chunkMVCKMP5Ujs.j.fromHexInput(i).toString()}`}static parseHexInput(e,t,r){let i,o=hn.AIP80_PREFIXES[t];if(typeof e=="string")if(!r&&!e.startsWith(o))i=_chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.j.fromHexInput(e);return i}};hn.AIP80_PREFIXES={ed25519:"ed25519-priv-",secp256k1:"secp256k1-priv-"};var pt=hn;var qt=n=>typeof n=="string"?_chunkMVCKMP5Ujs.j.isValid(n).valid?n:new TextEncoder().encode(n):n;var ti=[237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16];function Tc(n){let e=n.toUint8Array().slice(32);for(let t=ti.length-1;t>=0;t-=1){if(e[t]<ti[t])return!0;if(e[t]>ti[t])return!1}return!1}var dt=class dt extends oe{constructor(e){super();let t=_chunkMVCKMP5Ujs.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(!Tc(r))return!1;let i=qt(t),o=_chunkMVCKMP5Ujs.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,Ae=class Ae extends _chunkMVCKMP5Ujs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"ed25519",t);if(r.toUint8Array().length!==Ae.LENGTH)throw new Error(`PrivateKey length should be ${Ae.LENGTH}`);this.signingKey=r}static generate(){let e=_ed25519.ed25519.utils.randomPrivateKey();return new Ae(e,!1)}static fromDerivationPath(e,t){if(!Ao(e))throw new Error(`Invalid derivation path ${e}`);return Ae.fromDerivationPathInner(e,or(t))}static fromDerivationPathInner(e,t,r=yo){let{key:i,chainCode:o}=ei(Ae.SLIP_0010_SEED,t),s=To(e).map(c=>parseInt(c,10)),{key:a}=s.reduce((c,p)=>ho(c,p+r),{key:i,chainCode:o});return new Ae(a,!1)}publicKey(){let e=_ed25519.ed25519.getPublicKey(this.signingKey.toUint8Array());return new I(e)}sign(e){let t=qt(e),r=_chunkMVCKMP5Ujs.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 Ae(t,!1)}static isPrivateKey(e){return e instanceof Ae}};Ae.LENGTH=32,Ae.SLIP_0010_SEED="ed25519 seed";var q=Ae,$t=class $t extends M{constructor(e){super();let t=_chunkMVCKMP5Ujs.j.fromHexInput(e);if(t.toUint8Array().length!==$t.LENGTH)throw new Error(`Signature length should be ${$t.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 $t(t)}};$t.LENGTH=64;var K=$t;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=_chunkMVCKMP5Ujs.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 ni=[_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],wo=31,zc=16,bo=(zc-1)*wo;function ke(n,e){let r=new TextEncoder().encode(n);return Fc(r,e)}function Fc(n,e){if(n.length>e)throw new Error(`Inputted bytes of length ${n} is longer than ${e}`);let t=Tn(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=Mc(n,e);return Gc(t)}function Tn(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 Gc(n){if(n.length>bo)throw new Error(`Can't pack more than ${bo}. Was given ${n.length} bytes`);return Bc(n,wo).map(e=>Et(e))}function Bc(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 ri(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 Mc(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>ni.length)throw new Error(`Unable to hash input of length ${n.length}. Max input length is ${ni.length}`);return ni[n.length-1](n)}var ar=class extends _chunkMVCKMP5Ujs.l{};var ii="1.37.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"},oi= 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"},si= 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"},ai= exports.Network =(o=>(o.MAINNET="mainnet",o.TESTNET="testnet",o.DEVNET="devnet",o.LOCAL="local",o.CUSTOM="custom",o))(ai||{}),ci= exports.NetworkToChainId ={mainnet:1,testnet:2,local:4},Rl= 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,cr= 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",ui= 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 Vc=(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))(Vc||{}),Hc= 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))(Hc||{}),ur= 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))(ur||{}),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 ee?o+=`
|
|
4
4
|
AptosApiError: ${r.message}`:r!==void 0&&(o+=`
|
|
5
|
-
Error: ${
|
|
6
|
-
KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,details:i}=e,[o,s,a]=Ko[r];return new n({message:o,details:i,innerError:t,category:s,resolutionTip:a,type:r})}},ee= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(Lc({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 Lc({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: ${qc(t.data)}`}var ui=400;function qc(n){let e=JSON.stringify(n);return e.length<=ui?e:`truncated(original_size:${e.length}): ${e.slice(0,ui/2)}...${e.slice(-ui/2)}`}async function $c(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/${ri}`,"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 Wc(n,e){if(e.binaryProvider===void 0)throw new Error("Binary provider is not provided");let{url:t,method:r,body:i,contentType:o,acceptType:s,params:a,overrides:c,originMethod:p}=n,l={..._optionalChain([c, 'optionalAccess', _23 => _23.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${ri}`,"content-type":_nullishCoalesce(o, () => ("application/json")),accept:_nullishCoalesce(s, () => ("application/x-bcs")),"x-aptos-typescript-sdk-origin-method":p};return _optionalChain([c, 'optionalAccess', _24 => _24.AUTH_TOKEN])&&(l.Authorization=`Bearer ${_optionalChain([c, 'optionalAccess', _25 => _25.AUTH_TOKEN])}`),_optionalChain([c, 'optionalAccess', _26 => _26.API_KEY])&&(l.Authorization=`Bearer ${_optionalChain([c, 'optionalAccess', _27 => _27.API_KEY])}`),e.binaryProvider({acceptType:"application/x-bcs",url:t,method:r,body:i,params:a,headers:l,overrides:c})}async function pr(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await $c({...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 ee({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ee({apiType:t,aptosRequest:n,aptosResponse:a})}async function dr(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 ee({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ee({apiType:t,aptosRequest:n,aptosResponse:a})}async function lr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return pr({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function Qc(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return dr({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 lr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _28 => _28.clientConfig, 'optionalAccess', _29 => _29.HEADERS]),..._optionalChain([e, 'access', _30 => _30.fullnodeConfig, 'optionalAccess', _31 => _31.HEADERS])}}})}async function eg(n){let{aptosConfig:e}=n;return Qc({...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 tg(n){return lr({...n,type:"Pepper"})}async function gr(n){let e=[],t,r=n.params;do{let i=await lr({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 mr(n){let e=[],t,r=n.params,i=r.limit;do{let o=await lr({type:"Fullnode",aptosConfig:n.aptosConfig,originMethod:n.originMethod,path:n.path,params:r,overrides:n.overrides});if(t=o.headers["x-aptos-cursor"],delete o.headers,e.push(...o.data),r.offset=t,i!==void 0){let s=i-e.length;if(s<=0)break;r.limit=s}}while(t!=null);return e}async function bn(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 pr({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function jc(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 dr({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 bn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _36 => _36.clientConfig, 'optionalAccess', _37 => _37.HEADERS]),..._optionalChain([e, 'access', _38 => _38.fullnodeConfig, 'optionalAccess', _39 => _39.HEADERS])}}})}async function Ro(n){let{aptosConfig:e}=n;return jc({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _40 => _40.clientConfig, 'optionalAccess', _41 => _41.HEADERS]),..._optionalChain([e, 'access', _42 => _42.fullnodeConfig, 'optionalAccess', _43 => _43.HEADERS])}}})}async function Uo(n){let{aptosConfig:e}=n;return bn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _44 => _44.clientConfig, 'optionalAccess', _45 => _45.HEADERS]),..._optionalChain([e, 'access', _46 => _46.indexerConfig, 'optionalAccess', _47 => _47.HEADERS])}}})}async function ko(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _48 => _48.clientConfig, 'optionalAccess', _49 => delete _49.API_KEY]),bn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _50 => _50.clientConfig, 'optionalAccess', _51 => _51.HEADERS]),..._optionalChain([t, 'access', _52 => _52.faucetConfig, 'optionalAccess', _53 => _53.HEADERS])}}})}async function Do(n){return bn({...n,type:"Pepper"})}async function No(n){return bn({...n,type:"Prover"})}var pi=new Map;function ke(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 Zc=1e7,di= exports.MAX_AUD_VAL_BYTES =120,eu= exports.MAX_UID_KEY_BYTES =30,tu= exports.MAX_UID_VAL_BYTES =330,nu= exports.MAX_ISS_VAL_BYTES =120,ru= exports.MAX_EXTRA_FIELD_BYTES =350,iu= exports.MAX_JWT_HEADER_B64_BYTES =300,ou= exports.MAX_COMMITED_EPK_BYTES =93,De=class De extends oe{constructor(e,t){super();let r=_chunk5GUWOXQGjs.j.fromHexInput(t).toUint8Array();if(r.length!==De.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${De.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunk5GUWOXQGjs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){return hi({...e,publicKey:this})}serialize(e){e.serializeStr(this.iss),e.serializeBytes(this.idCommitment)}async verifySignatureAsync(e){return Ai({...e,publicKey:this})}static deserialize(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new De(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new De(t,r)}static isPublicKey(e){return e instanceof De}static create(e){return zo(e),new De(e.iss,zo(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 De.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}};De.ID_COMMITMENT_LENGTH=32;var N=De;async function Ai(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o=await Ti({aptosConfig:n.aptosConfig,publicKey:n.publicKey,kid:i.getJwkKid()}),keylessConfig:s=await jt({aptosConfig:e}),options:a}=n;try{return t.verifySignature({message:r,signature:i,jwk:o,keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _54 => _54.throwErrorWithReason]))throw c;return!1}}function hi(n){let{publicKey:e,message:t,signature:r,keylessConfig:i,jwk:o}=n,{verificationKey:s,maxExpHorizonSecs:a,trainingWheelsPubkey:c}=i;if(!(r.ephemeralCertificate.signature instanceof pe))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<_chunk5GUWOXQGjs.aa.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=su({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})}return!0}function su(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof N?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof pe))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Tn(t.ephemeralPublicKey.toUint8Array(),i.maxCommitedEpkBytes)),a.push(Et(o.idCommitment)),a.push(t.expiryDateSecs),a.push(s.expHorizonSecs),a.push(Ue(o.iss,i.maxIssValBytes)),s.extraField?(a.push(1n),a.push(Ue(s.extraField,i.maxExtraFieldBytes))):(a.push(0n),a.push(Ue(" ",i.maxExtraFieldBytes))),a.push(Ue(_jsbase64.encode.call(void 0, t.jwtHeader,!0)+".",i.maxJwtHeaderB64Bytes)),a.push(r.toScalar()),s.overrideAudVal?(a.push(Ue(s.overrideAudVal,di)),a.push(1n)):(a.push(Ue("",di)),a.push(0n)),Pt(a)}async function Ti(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof N?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof te?t.jwkAddress:void 0;try{s=await uu({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 zo(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Et(_chunk5GUWOXQGjs.j.fromHexInput(i).toUint8Array()),Ue(r,di),Ue(t,tu),Ue(e,eu)];return ni(Pt(o),N.ID_COMMITMENT_LENGTH)}var Ne=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 du(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=Wt.deserialize(e),r=e.deserializeStr(),i=e.deserializeU64(),o=lt.deserialize(e),s=Re.deserialize(e);return new n({jwtHeader:r,expiryDateSecs:Number(i),ephemeralCertificate:t,ephemeralPublicKey:o,ephemeralSignature:s})}static getSimulationSignature(){return new n({jwtHeader:"{}",ephemeralCertificate:new Wt(new pe({proof:new Qt(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 Re(new K(new Uint8Array(64)))})}static isSignature(e){return e instanceof n}},Wt= 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(pe.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},wn=class wn extends _chunk5GUWOXQGjs.l{constructor(e){if(super(),this.data=_chunk5GUWOXQGjs.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 wn(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),wn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};wn.B=_bn254.bn254.fields.Fp.create(3n);var He=wn;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 Sn=class Sn extends _chunk5GUWOXQGjs.l{constructor(e){if(super(),this.data=_chunk5GUWOXQGjs.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 Sn(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),Sn.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})}};Sn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Sn,mt= exports.Groth16Zkp =class n extends ar{constructor(e){super();let{a:t,b:r,c:i}=e;this.a=new He(t),this.b=new It(r),this.c=new He(i)}serialize(e){this.a.serialize(e),this.b.serialize(e),this.c.serialize(e)}static deserialize(e){let t=He.deserialize(e).bcsToBytes(),r=It.deserialize(e).bcsToBytes(),i=He.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 _chunk5GUWOXQGjs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ni(r,32):_chunk5GUWOXQGjs.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)}},Qt= exports.ZkProof =class n extends _chunk5GUWOXQGjs.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}`)}}},pe= 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=Qt.deserialize(e),r=Number(e.deserializeU64()),i=e.deserializeOption("string"),o=e.deserializeOption("string"),s=e.deserializeOption(Re);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=Zc,maxExtraFieldBytes:o=ru,maxJwtHeaderB64Bytes:s=iu,maxIssValBytes:a=nu,maxCommitedEpkBytes:c=ou}=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 He(t),this.betaG2=new It(r),this.deltaG2=new It(i),this.gammaAbcG1=[new He(o[0]),new He(o[1])],this.gammaG2=new It(s)}hash(){let e=new _chunk5GUWOXQGjs.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,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),C=_bn254.bn254.pairing(i,o),W=_bn254.bn254.pairing(a,c),Be=_bn254.bn254.pairing(s,l),st=d.mul(W,d.mul(b,Be));return d.eql(C,st)}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 jt(n){let{aptosConfig:e}=n;try{return await ke(async()=>{let[t,r]=await Promise.all([au(n),cu(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 Le(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 - ${_chunk5GUWOXQGjs.$.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 au(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunk5GUWOXQGjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _55 => _55.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function cu(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunk5GUWOXQGjs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _56 => _56.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function uu(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/${_chunk5GUWOXQGjs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _57 => _57.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', _58 => _58.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(_chunk5GUWOXQGjs.j.fromHexInput(p).toUint8Array()),h=fi.deserialize(l);a.push(h)}o.set(_chunk5GUWOXQGjs.k.call(void 0, s.issuer),a)}return o}var fi=class n extends _chunk5GUWOXQGjs.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(_chunk5GUWOXQGjs.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=_chunk5GUWOXQGjs.da.call(void 0, this.n),r=pu(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 pu(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 du(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 te=class n extends oe{constructor(e,t){super(),this.jwkAddress=_chunk5GUWOXQGjs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunk5GUWOXQGjs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){return hi({...e,publicKey:this})}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunk5GUWOXQGjs.Z.deserialize(e),r=N.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,N.create(e))}static fromJwtAndPepper(e){return new n(e.jwkAddress,N.fromJwtAndPepper(e))}static isInstance(e){return"jwkAddress"in e&&e.jwkAddress instanceof _chunk5GUWOXQGjs.Z&&"keylessPublicKey"in e&&e.keylessPublicKey instanceof N}};var _secp256k1 = require('@noble/curves/secp256k1');var _bip32 = require('@scure/bip32');var Ie=class Ie extends St{constructor(e){super();let t=_chunk5GUWOXQGjs.j.fromHexInput(e),{length:r}=t.toUint8Array();if(r===Ie.LENGTH)this.key=t;else if(r===Ie.COMPRESSED_LENGTH){let i=_secp256k1.secp256k1.ProjectivePoint.fromHex(t.toUint8Array());this.key=_chunk5GUWOXQGjs.j.fromHexInput(i.toRawBytes(!1))}else throw new Error(`PublicKey length should be ${Ie.LENGTH} or ${Ie.COMPRESSED_LENGTH}, received ${r}`)}verifySignature(e){let{message:t,signature:r}=e,i=qt(t),o=_chunk5GUWOXQGjs.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 vt(t)}static deserialize(e){let t=e.deserializeBytes();return new Ie(t)}static isPublicKey(e){return e instanceof Ie}static isInstance(e){return"key"in e&&_optionalChain([e, 'access', _59 => _59.key, 'optionalAccess', _60 => _60.data, 'optionalAccess', _61 => _61.length])===Ie.LENGTH}};Ie.LENGTH=65,Ie.COMPRESSED_LENGTH=33;var qe=Ie,ze=class ze extends _chunk5GUWOXQGjs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==ze.LENGTH)throw new Error(`PrivateKey length should be ${ze.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ze(e,!1)}static fromDerivationPath(e,t){if(!yo(e))throw new Error(`Invalid derivation path ${e}`);return ze.fromDerivationPathInner(e,or(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new ze(r,!1)}sign(e){let t=qt(e),r=_chunk5GUWOXQGjs.j.fromHexInput(t),i=_sha3.sha3_256.call(void 0, r.toUint8Array()),o=_secp256k1.secp256k1.sign(i,this.key.toUint8Array(),{lowS:!0});return new vt(o.toCompactRawBytes())}publicKey(){let e=_secp256k1.secp256k1.getPublicKey(this.key.toUint8Array(),!1);return new qe(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 ze(t,!1)}static isPrivateKey(e){return e instanceof ze}};ze.LENGTH=32;var $e=ze,Jt=class Jt extends M{constructor(e){super();let t=_chunk5GUWOXQGjs.j.fromHexInput(e);if(t.toUint8Array().length!==Jt.LENGTH)throw new Error(`Signature length should be ${Jt.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 Jt(t)}};Jt.LENGTH=64;var vt=Jt;var z=class n extends oe{constructor(e){if(super(),this.publicKey=e,e instanceof I)this.variant=0;else if(e instanceof qe)this.variant=1;else if(e instanceof N)this.variant=3;else if(e instanceof te)this.variant=4;else throw new Error("Unsupported public key type")}verifySignature(e){let{message:t,signature:r}=e;return this.publicKey.verifySignature({message:t,signature:r.signature})}async verifySignatureAsync(e){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=qe.deserialize(e);break;case 3:r=N.deserialize(e);break;case 4:r=te.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 qe}static isInstance(e){return"publicKey"in e&&"variant"in e}},q= exports.AnySignature =class n extends M{constructor(e){if(super(),this.signature=e,e instanceof K)this.variant=0;else if(e instanceof vt)this.variant=1;else if(e instanceof Ne)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=vt.deserialize(e);break;case 3:r=Ne.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 gu(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Pn=class extends oe{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 Pn{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 z?i:new z(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{message:t,signature:r,aptosConfig:i}=e;if(r.signatures.length!==this.signaturesRequired)throw new Error("The number of signatures does not match the number of required signatures");let o=r.bitMapToSignerIndices();for(let s=0;s<r.signatures.length;s+=1){let a=r.signatures[s];if(!await this.publicKeys[o[s]].verifySignatureAsync({aptosConfig:i,message:t,signature:a}))return!1}return!0}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(z),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof z?e:new z(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},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.map(o=>o instanceof q?o:new q(o)),!(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}let i=this.bitmap.reduce((o,s)=>o+gu(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>=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.");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(q),r=e.deserializeBytes();return new de({signatures:t,bitmap:r})}};de.BITMAP_LEN=4,de.MAX_SIGNATURES_SUPPORTED=de.BITMAP_LEN*8;var We=de;var he=class he extends Pn{constructor(e){let{publicKeys:t,threshold:r}=e;if(super({publicKeys:t}),t.length>he.MAX_KEYS||t.length<he.MIN_KEYS)throw new Error(`Must have between ${he.MIN_KEYS} and ${he.MAX_KEYS} public keys, inclusive`);if(r<he.MIN_THRESHOLD||r>t.length)throw new Error(`Threshold must be between ${he.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 he({publicKeys:i,threshold:r})}getIndex(e){return super.getIndex(e)}};he.MAX_KEYS=32,he.MIN_KEYS=2,he.MIN_THRESHOLD=1;var Xt=he,le=class le extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>le.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${le.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=le.createBitmap({bits:r});else{if(r.length!==le.BITMAP_LEN)throw new Error(`"bitmap" length should be ${le.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*K.LENGTH+le.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 le({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>=le.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${le.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}};le.MAX_SIGNATURES_SUPPORTED=32,le.BITMAP_LEN=4;var Qe=le;var yr=(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...r,254]);return new (0, _chunk5GUWOXQGjs.Z)(_sha3.sha3_256.call(void 0, i))},dy= exports.createResourceAddress =(n,e)=>{let t=n.bcsToBytes(),r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...t,...r,255]);return new (0, _chunk5GUWOXQGjs.Z)(_sha3.sha3_256.call(void 0, i))},ly= exports.createTokenAddress =(n,e,t)=>{let r=`${e}::${t}`;return yr(n,r)};var j=class extends _chunk5GUWOXQGjs.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 se.load(e);case 3:return Oe.load(e);case 4:return Yt.load(e);case 5:return _n.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 se}isMultiKey(){return this instanceof Oe}},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=Xt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},se= 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=z.deserialize(e),r=q.deserialize(e);return new n(t,r)}},Oe= 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=We.deserialize(e);return new n(t,r)}},Yt= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends j{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},_n= exports.AccountAuthenticatorAbstraction =class n extends j{constructor(e,t,r){if(super(),!_chunk5GUWOXQGjs.ja.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=_chunk5GUWOXQGjs.j.fromHexInput(r),this.signingMessageDigest=_chunk5GUWOXQGjs.j.fromHexInput(_chunk5GUWOXQGjs.j.fromHexInput(t).toUint8Array())}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunk5GUWOXQGjs.ia.call(void 0, this.functionInfo);_chunk5GUWOXQGjs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),e.serializeFixedBytes(this.authenticator.toUint8Array())}static load(e){let t=_chunk5GUWOXQGjs.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)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var Zt=class n extends _chunk5GUWOXQGjs.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 U=class n extends _chunk5GUWOXQGjs.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 xn=class n extends _chunk5GUWOXQGjs.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(_chunk5GUWOXQGjs.Z.fromString(t[0]),new U(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunk5GUWOXQGjs.Z.deserialize(e),r=U.deserialize(e);return new n(t,r)}};var O=class n extends _chunk5GUWOXQGjs.l{deserialize(e){let t=_chunk5GUWOXQGjs.Z.deserialize(e),r=U.deserialize(e),i=U.deserialize(e),o=e.deserializeVector(n);return new Ge(t,r,i,o)}static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return H.load(e);case 1:return ge.load(e);case 2:return J.load(e);case 3:return Ye.load(e);case 4:return F.load(e);case 5:return Ct.load(e);case 6:return v.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 H}isAddress(){return this instanceof F}isGeneric(){return this instanceof G}isSigner(){return this instanceof Ct}isVector(){return this instanceof v}isStruct(){return this instanceof A}isU8(){return this instanceof ge}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 Ct||this instanceof F||this instanceof H||this instanceof ge||this instanceof Je||this instanceof Xe||this instanceof J||this instanceof Ye||this instanceof Ze}},H= exports.TypeTagBool =class n extends O{toString(){return"bool"}serialize(e){e.serializeU32AsUleb128(0)}static load(e){return new n}},ge= 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}},Ct= exports.TypeTagSigner =class n extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},fr= 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)}},v= exports.TypeTagVector =class n extends O{constructor(t){super();this.value=t}toString(){return`vector<${this.value.toString()}>`}static u8(){return new n(new ge)}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=Ge.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(_chunk5GUWOXQGjs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunk5GUWOXQGjs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunk5GUWOXQGjs.Z.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunk5GUWOXQGjs.Z.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunk5GUWOXQGjs.Z.ONE,"rate_limiter","RateLimiter")}},Ge= exports.StructTag =class n extends _chunk5GUWOXQGjs.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=_chunk5GUWOXQGjs.Z.deserialize(e),r=U.deserialize(e),i=U.deserialize(e),o=e.deserializeVector(O);return new n(t,r,i,o)}};function nf(){return new Ge(_chunk5GUWOXQGjs.Z.ONE,new U("aptos_coin"),new U("AptosCoin"),[])}function _(){return new Ge(_chunk5GUWOXQGjs.Z.ONE,new U("string"),new U("String"),[])}function rf(n){return new Ge(_chunk5GUWOXQGjs.Z.ONE,new U("option"),new U("Option"),[n])}function me(n){return new Ge(_chunk5GUWOXQGjs.Z.ONE,new U("object"),new U("Object"),[n])}function mu(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Y.deserialize(n);case 1:return Q.deserialize(n);case 2:return _e.deserialize(n);case 3:return _chunk5GUWOXQGjs.Z.deserialize(n);case 4:return S.deserialize(n,Y);case 5:return D.deserialize(n);case 6:return Ee.deserialize(n);case 7:return Pe.deserialize(n);case 8:return fe.deserialize(n);case 9:return fn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Kt=class extends _chunk5GUWOXQGjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Rt.load(e);case 2:return In.load(e);case 3:return vn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Rt= exports.TransactionPayloadScript =class n extends Kt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=Cn.deserialize(e);return new n(t)}},In= exports.TransactionPayloadEntryFunction =class n extends Kt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Ut.deserialize(e);return new n(t)}},vn= exports.TransactionPayloadMultiSig =class n extends Kt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Kn.deserialize(e);return new n(t)}},Ut= 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(xn.fromStr(e),new U(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=xn.deserialize(e),r=U.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=rr.deserialize(e,c);s.push(p)}return new n(t,r,i,s)}},Cn= 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=mu(e);o.push(a)}return new n(t,r,o)}},Kn= 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=_chunk5GUWOXQGjs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Rn.deserialize(e)),new n(t,i)}},Rn= exports.MultiSigTransactionPayload =class n extends _chunk5GUWOXQGjs.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(Ut.deserialize(e))}};var Te=class n extends _chunk5GUWOXQGjs.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=_chunk5GUWOXQGjs.Z.deserialize(e),r=e.deserializeU64(),i=Kt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Zt.deserialize(e);return new n(t,r,i,o,s,a,c)}},Ar= exports.RawTransactionWithData =class extends _chunk5GUWOXQGjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return kt.load(e);case 1:return Dt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},kt= exports.MultiAgentRawTransaction =class n extends Ar{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=Te.deserialize(e),r=e.deserializeVector(_chunk5GUWOXQGjs.Z);return new n(t,r)}},Dt= exports.FeePayerRawTransaction =class n extends Ar{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=Te.deserialize(e),r=e.deserializeVector(_chunk5GUWOXQGjs.Z),i=_chunk5GUWOXQGjs.Z.deserialize(e);return new n(t,r,i)}};var hr=class extends _chunk5GUWOXQGjs.l{constructor(t){super();this.accountAddress=_chunk5GUWOXQGjs.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 _chunk5GUWOXQGjs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Nt.load(e);case 1:return en.load(e);case 2:return zt.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 en}isMultiAgent(){return this instanceof zt}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)}},en= 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=Xt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},zt= 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(_chunk5GUWOXQGjs.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(_chunk5GUWOXQGjs.Z),i=e.deserializeVector(j),o=_chunk5GUWOXQGjs.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 _chunk5GUWOXQGjs.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=Te.deserialize(e),r=et.deserialize(e);return new n(t,r)}};var tn=class n extends _chunk5GUWOXQGjs.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=Te.deserialize(e),r=e.deserializeBool(),i;return r&&(i=_chunk5GUWOXQGjs.Z.deserialize(e)),new n(t,i)}};var Tr=class n extends _chunk5GUWOXQGjs.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=Te.deserialize(e),r=e.deserializeVector(_chunk5GUWOXQGjs.Z),i=e.deserializeBool(),o;return i&&(o=_chunk5GUWOXQGjs.Z.deserialize(e)),new n(t,r,o)}};function br(n){return n.feePayerAddress?new Dt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new kt(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 yA(n){return yt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ce(n){let e=br(n);return n.feePayerAddress?yt(e.bcsToBytes(),ci):n.secondarySignerAddresses?yt(e.bcsToBytes(),ci):yt(e.bcsToBytes(),Io)}var ae=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunk5GUWOXQGjs.Z.from(r):this.publicKey.authKey().derivedAddress()}static generate(){let e=L.generate();return new n({privateKey:e})}static fromDerivationPath(e){let{path:t,mnemonic:r}=e,i=L.fromDerivationPath(t,r);return new n({privateKey:i})}verifySignature(e){return this.publicKey.verifySignature(e)}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(Ce(e))}};function bi(n){return typeof n=="object"&&n!==null&&"getAnyPublicKey"in n&&typeof n.getAnyPublicKey=="function"}var be=class n{constructor(e){this.signingScheme=2;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=new z(t.publicKey()),this.accountAddress=r?_chunk5GUWOXQGjs.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=L.generate();break;case 2:r=$e.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=L.fromDerivationPath(r,i);break;case 2:o=$e.fromDerivationPath(r,i);break;default:throw new Error(`Unsupported signature scheme ${t}`)}return new n({privateKey:o})}verifySignature(e){return this.publicKey.verifySignature(e)}signWithAuthenticator(e){return new se(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new se(this.publicKey,this.signTransaction(e))}sign(e){return new q(this.privateKey.sign(e))}signTransaction(e){return this.sign(Ce(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?ae.generate():be.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof L&&i?new ae({privateKey:t,address:r}):new be({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?ae.fromDerivationPath({mnemonic:r,path:i}):be.fromDerivationPath({scheme:t,mnemonic:r,path:i})}static authKey(e){let{publicKey:t}=e;return t.authKey()}verifySignature(e){return this.publicKey.verifySignature(e)}};var _utils3 = require('@noble/hashes/utils');var Au=1209600,nn=class nn extends _chunk5GUWOXQGjs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new lt(t.publicKey()),this.expiryDateSecs=r||_chunk5GUWOXQGjs.ba.call(void 0, _chunk5GUWOXQGjs.aa.call(void 0, )+Au),this.blinder=i!==void 0?_chunk5GUWOXQGjs.j.fromHexInput(i).toUint8Array():hu();let o=Tn(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=L.deserialize(e);break;default:throw new Error(`Unknown variant index for EphemeralPublicKey: ${t}`)}let i=e.deserializeU64(),o=e.deserializeFixedBytes(31);return new nn({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return nn.deserialize(new R(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _62 => _62.scheme])){case 0:default:t=L.generate()}return new nn({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _63 => _63.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Re(this.privateKey.sign(e))}};nn.BLINDER_LENGTH=31;var Ot=nn;function hu(){return _utils3.randomBytes.call(void 0, Ot.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function Sr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var rn=class rn extends _chunk5GUWOXQGjs.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?_chunk5GUWOXQGjs.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 pe)this.proof=l;else{if(h===void 0)throw new Error("Must provide callback for async proof fetch");this.emitter.on("proofFetchFinish",async C=>{await h(C),this.emitter.removeAllListeners()}),this.init(l)}let b=_chunk5GUWOXQGjs.j.fromHexInput(p).toUint8Array();if(b.length!==rn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${rn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunk5GUWOXQGjs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunk5GUWOXQGjs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new z(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=_chunk5GUWOXQGjs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Ot.deserialize(t),c=pe.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 q(this.sign(t)),i=new z(this.publicKey);return new se(i,r)}signTransactionWithAuthenticator(t){let r=new q(this.signTransaction(t)),i=new z(this.publicKey);return new se(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 jt({aptosConfig:t});if(_chunk5GUWOXQGjs.j.hexInputToString(i.hash())!==_chunk5GUWOXQGjs.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 rn.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 Ne({jwtHeader:_chunk5GUWOXQGjs.ca.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Wt(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=br(t),o=new wr(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=br(t);return new wr(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 Ti(t)}};rn.PEPPER_LENGTH=31;var ye=rn,wr= exports.TransactionAndProof =class extends _chunk5GUWOXQGjs.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 ye{constructor(e){let t=N.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}=ye.partialDeserialize(e),{iss:p,aud:l,uidVal:h}=Le({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(_chunk5GUWOXQGjs.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}=Le({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 Gt=class n extends ye{constructor(e){let t=te.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}=ye.partialDeserialize(e),p=_chunk5GUWOXQGjs.Z.deserialize(e),{iss:l,aud:h,uidVal:d}=Le({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}=Le({jwt:i,uidKey:c});return new n({address:t,proof:r,ephemeralKeyPair:o,iss:h,uidKey:c,uidVal:g,aud:d,pepper:s,jwkAddress:_chunk5GUWOXQGjs.Z.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var Un=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof ae?be.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?_chunk5GUWOXQGjs.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 Oe(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new Oe(this.publicKey,this.signTransaction(e))}async waitForProofFetch(){let t=this.signers.filter(r=>r instanceof ye).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof ye).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 We({signatures:t,bitmap:this.signaturesBitmap})}signTransaction(e){let t=[];for(let r of this.signers)t.push(r.signTransaction(e));return new We({signatures:t,bitmap:this.signaturesBitmap})}verifySignature(e){return this.publicKey.verifySignature(e)}async verifySignatureAsync(e){return await this.publicKey.verifySignatureAsync(e)}};var Er=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunk5GUWOXQGjs.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)}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(Ce(e))}};function Bo(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunk5GUWOXQGjs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunk5GUWOXQGjs.Z.deserialize(n),signingScheme:e}}function Mo(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 Vo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Ot.deserialize(n),o=pe.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Ho;(h=>{function n(d){let g=new _chunk5GUWOXQGjs.m;switch(g.serializeU32AsUleb128(d.signingScheme),d.accountAddress.serialize(g),d.signingScheme){case 0:return d.privateKey.serialize(g),g.toUint8Array();case 2:{if(!bi(d))throw new Error("Account is not a SingleKeySigner");let b=d.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return Mo(d,g),g.toUint8Array();case 4:{let C=d;return Mo(C,g),C.publicKey.jwkAddress.serialize(g),g.serializeBool(C.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(C=>{g.serializeFixedBytes(n(C))}),g.toUint8Array()}default:throw new Error(`Deserialization of Account failed: invalid signingScheme value ${d.signingScheme}`)}}h.toBytes=n;function e(d){return _chunk5GUWOXQGjs.j.hexInputToStringWithoutPrefix(n(d))}h.toHexStringWithoutPrefix=e;function t(d){return _chunk5GUWOXQGjs.j.hexInputToString(n(d))}h.toHexString=t;function r(d){let{address:g,signingScheme:b}=Bo(d);switch(b){case 0:{let C=L.deserialize(d);return new ae({privateKey:C,address:g})}case 2:{let C=d.deserializeUleb128AsU32();switch(C){case 0:{let W=L.deserialize(d);return new be({privateKey:W,address:g})}case 1:{let W=$e.deserialize(d);return new be({privateKey:W,address:g})}case 3:{let W=Vo(d),Be=Le(W);return new rt({...W,...Be})}case 4:{let W=Vo(d),Be=_chunk5GUWOXQGjs.Z.deserialize(d),st=d.deserializeBool(),at=Le(W);return new Gt({...W,...at,jwkAddress:Be,audless:st})}default:throw new Error(`Unsupported public key variant ${C}`)}}case 3:{let C=Fe.deserialize(d),W=d.deserializeUleb128AsU32(),Be=new Array;for(let st=0;st<W;st+=1){let at=r(d);if(!bi(at)&&!(at instanceof ae))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Be.push(at)}return new Un({multiKey:C,signers:Be,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 Gt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}h.federatedKeylessAccountFromHex=o;function s(d){let g=p(d);if(!(g instanceof Un))throw new Error("Deserialization of MultiKeyAccount failed");return g}h.multiKeyAccountFromHex=s;function a(d){let g=p(d);if(!(g instanceof be))throw new Error("Deserialization of SingleKeyAccount failed");return g}h.singleKeyAccountFromHex=a;function c(d){let g=p(d);if(!(g instanceof ae))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})(Ho||(Ho= exports.AccountUtils ={}));var qo=class n extends nt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunk5GUWOXQGjs.ja.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new ir(this.accountAddress),this.sign=o=>new An(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunk5GUWOXQGjs.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 _n(this.authenticationFunction,_sha3.sha3_256.call(void 0, t),this.sign(_sha3.sha3_256.call(void 0, t)).toUint8Array())}signTransactionWithAuthenticator(t){return this.signWithAuthenticator(Ce(t))}signTransaction(t){return this.sign(Ce(t))}setSigner(t){this.sign=r=>new An(t(r))}};var wu=`
|
|
5
|
+
Error: ${_chunkMVCKMP5Ujs.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})}},ee= exports.AptosApiError =class extends Error{constructor({apiType:e,aptosRequest:t,aptosResponse:r}){super(Lc({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 Lc({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: ${qc(t.data)}`}var pi=400;function qc(n){let e=JSON.stringify(n);return e.length<=pi?e:`truncated(original_size:${e.length}): ${e.slice(0,pi/2)}...${e.slice(-pi/2)}`}async function $c(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/${ii}`,"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 Wc(n,e){if(e.binaryProvider===void 0)throw new Error("Binary provider is not provided");let{url:t,method:r,body:i,contentType:o,acceptType:s,params:a,overrides:c,originMethod:p}=n,l={..._optionalChain([c, 'optionalAccess', _23 => _23.HEADERS]),"x-aptos-client":`aptos-typescript-sdk/${ii}`,"content-type":_nullishCoalesce(o, () => ("application/json")),accept:_nullishCoalesce(s, () => ("application/x-bcs")),"x-aptos-typescript-sdk-origin-method":p};return _optionalChain([c, 'optionalAccess', _24 => _24.AUTH_TOKEN])&&(l.Authorization=`Bearer ${_optionalChain([c, 'optionalAccess', _25 => _25.AUTH_TOKEN])}`),_optionalChain([c, 'optionalAccess', _26 => _26.API_KEY])&&(l.Authorization=`Bearer ${_optionalChain([c, 'optionalAccess', _27 => _27.API_KEY])}`),e.binaryProvider({acceptType:"application/x-bcs",url:t,method:r,body:i,params:a,headers:l,overrides:c})}async function pr(n,e,t){let{url:r,path:i}=n,o=i?`${r}/${i}`:r,s=await $c({...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 ee({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ee({apiType:t,aptosRequest:n,aptosResponse:a})}async function dr(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 ee({apiType:t,aptosRequest:n,aptosResponse:a});if(t==="Indexer"){let c=a.data;if(c.errors)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});a.data=c.data}else if((t==="Pepper"||t==="Prover")&&a.status>=400)throw new ee({apiType:t,aptosRequest:n,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new ee({apiType:t,aptosRequest:n,aptosResponse:a})}async function lr(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return pr({url:p,method:"GET",originMethod:a,path:s,contentType:i,acceptType:o,params:r,overrides:{...e.clientConfig,...t}},e,n.type)}async function Qc(n){let{aptosConfig:e,overrides:t,params:r,contentType:i,acceptType:o,path:s,originMethod:a,type:c}=n,p=e.getRequestUrl(c);return dr({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 lr({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _28 => _28.clientConfig, 'optionalAccess', _29 => _29.HEADERS]),..._optionalChain([e, 'access', _30 => _30.fullnodeConfig, 'optionalAccess', _31 => _31.HEADERS])}}})}async function ig(n){let{aptosConfig:e}=n;return Qc({...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 og(n){return lr({...n,type:"Pepper"})}async function gr(n){let e=new Array(0),t,r=n.params;do{let i=await lr({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 di(n){let e=new Array(0),t,r=n.params,i=r.limit;do{let{response:o,cursor:s}=await mr({...n});if(t=s,e.push(...o.data),_optionalChain([n, 'optionalAccess', _36 => _36.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 mr(n){let e,t={};typeof _optionalChain([n, 'access', _37 => _37.params, 'optionalAccess', _38 => _38.cursor])=="string"&&(t.start=n.params.cursor),typeof _optionalChain([n, 'access', _39 => _39.params, 'optionalAccess', _40 => _40.limit])=="number"&&(t.limit=n.params.limit);let r=await lr({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 bn(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 pr({url:l,method:"POST",originMethod:t,path:r,body:i,contentType:s,acceptType:o,params:a,overrides:p},c,n.type)}async function jc(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 dr({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 bn({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _41 => _41.clientConfig, 'optionalAccess', _42 => _42.HEADERS]),..._optionalChain([e, 'access', _43 => _43.fullnodeConfig, 'optionalAccess', _44 => _44.HEADERS])}}})}async function Uo(n){let{aptosConfig:e}=n;return jc({...n,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _45 => _45.clientConfig, 'optionalAccess', _46 => _46.HEADERS]),..._optionalChain([e, 'access', _47 => _47.fullnodeConfig, 'optionalAccess', _48 => _48.HEADERS])}}})}async function ko(n){let{aptosConfig:e}=n;return bn({...n,type:"Indexer",overrides:{...e.clientConfig,...e.indexerConfig,...n.overrides,HEADERS:{..._optionalChain([e, 'access', _49 => _49.clientConfig, 'optionalAccess', _50 => _50.HEADERS]),..._optionalChain([e, 'access', _51 => _51.indexerConfig, 'optionalAccess', _52 => _52.HEADERS])}}})}async function Do(n){let{aptosConfig:e}=n,t={...e,clientConfig:{...e.clientConfig}};return _optionalChainDelete([t, 'optionalAccess', _53 => _53.clientConfig, 'optionalAccess', _54 => delete _54.API_KEY]),bn({...n,type:"Faucet",overrides:{...t.clientConfig,...t.faucetConfig,...n.overrides,HEADERS:{..._optionalChain([t, 'access', _55 => _55.clientConfig, 'optionalAccess', _56 => _56.HEADERS]),..._optionalChain([t, 'access', _57 => _57.faucetConfig, 'optionalAccess', _58 => _58.HEADERS])}}})}async function No(n){return bn({...n,type:"Pepper"})}async function zo(n){return bn({...n,type:"Prover"})}var li=new Map;function De(n,e,t){return async(...r)=>{if(li.has(e)){let{value:o,timestamp:s}=li.get(e);if(t===void 0||Date.now()-s<=t)return o}let i=await n(...r);return li.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 Zc=1e7,gi= exports.MAX_AUD_VAL_BYTES =120,eu= exports.MAX_UID_KEY_BYTES =30,tu= exports.MAX_UID_VAL_BYTES =330,nu= exports.MAX_ISS_VAL_BYTES =120,ru= exports.MAX_EXTRA_FIELD_BYTES =350,iu= exports.MAX_JWT_HEADER_B64_BYTES =300,ou= exports.MAX_COMMITED_EPK_BYTES =93,Ne=class Ne extends oe{constructor(e,t){super();let r=_chunkMVCKMP5Ujs.j.fromHexInput(t).toUint8Array();if(r.length!==Ne.ID_COMMITMENT_LENGTH)throw new Error(`Id Commitment length in bytes should be ${Ne.ID_COMMITMENT_LENGTH}`);this.iss=e,this.idCommitment=r}authKey(){let e=new _chunkMVCKMP5Ujs.m;return e.serializeU32AsUleb128(3),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return yr({...e,publicKey:this}),!0}catch(t){if(t instanceof P)return!1;throw t}}async verifySignatureAsync(e){return Ti({...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 Ne(t,r)}static load(e){let t=e.deserializeStr(),r=e.deserializeBytes();return new Ne(t,r)}static isPublicKey(e){return e instanceof Ne}static create(e){return Fo(e),new Ne(e.iss,Fo(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 Ne.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}};Ne.ID_COMMITMENT_LENGTH=32;var U=Ne;async function Ti(n){let{aptosConfig:e,publicKey:t,message:r,signature:i,jwk:o,keylessConfig:s=await jt({aptosConfig:e}),options:a}=n;try{if(!(i instanceof he))throw P.fromErrorType({type:26,details:"Not a keyless signature"});return yr({message:r,publicKey:t,signature:i,jwk:o||await bi({aptosConfig:e,publicKey:t,kid:i.getJwkKid()}),keylessConfig:s}),!0}catch(c){if(_optionalChain([a, 'optionalAccess', _59 => _59.throwErrorWithReason]))throw c;return!1}}function yr(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 pe))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<_chunkMVCKMP5Ujs.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=su({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 yi(l,h);if(!c.verifySignature({message:d.hash(),signature:p.trainingWheelsSignature}))throw P.fromErrorType({type:31})}}function su(n){let{publicKey:e,signature:t,jwk:r,keylessConfig:i}=n,o=e instanceof U?e:e.keylessPublicKey;if(!(t.ephemeralCertificate.signature instanceof pe))throw new Error("Signature is not a ZeroKnowledgeSig");let s=t.ephemeralCertificate.signature,a=[];return a.push(...Tn(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,gi)),a.push(1n)):(a.push(ke("",gi)),a.push(0n)),Pt(a)}async function bi(n){let{aptosConfig:e,publicKey:t,kid:r}=n,i=t instanceof U?t:t.keylessPublicKey,{iss:o}=i,s,a=t instanceof te?t.jwkAddress:void 0;try{s=await uu({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 Fo(n){let{uidKey:e,uidVal:t,aud:r,pepper:i}=n,o=[Et(_chunkMVCKMP5Ujs.j.fromHexInput(i).toUint8Array()),ke(r,gi),ke(t,tu),ke(e,eu)];return ri(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 du(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=Wt.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 Wt(new pe({proof:new Qt(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}},Wt= 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(pe.deserialize(e),t);default:throw new Error(`Unknown variant index for EphemeralCertificate: ${t}`)}}},wn=class wn extends _chunkMVCKMP5Ujs.l{constructor(e){if(super(),this.data=_chunkMVCKMP5Ujs.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 wn(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(mi(e)),o=r.sqrt(r.add(r.pow(i,3n),wn.B)),s=r.neg(o),a=o>s==(t===1)?o:s;return _bn254.bn254.G1.ProjectivePoint.fromAffine({x:i,y:a})}};wn.B=_bn254.bn254.fields.Fp.create(3n);var Le=wn;function mi(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 Sn=class Sn extends _chunkMVCKMP5Ujs.l{constructor(e){if(super(),this.data=_chunkMVCKMP5Ujs.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 Sn(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([mi(t),mi(r)]),a=o.sqrt(o.add(o.pow(s,3n),Sn.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})}};Sn.B=_bn254.bn254.fields.Fp2.fromBigTuple([19485874751759354771024239261021720505790618469301721065564631296452457478373n,266929791119991161246907387137283842545076965332900288569378510910307636690n]);var It=Sn,mt= exports.Groth16Zkp =class n extends ar{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()}}},yi= exports.Groth16ProofAndStatement =class n extends _chunkMVCKMP5Ujs.l{constructor(t,r){super();this.domainSeparator="APTOS::Groth16ProofAndStatement";if(this.proof=t,this.publicInputsHash=typeof r=="bigint"?ri(r,32):_chunkMVCKMP5Ujs.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)}},Qt= exports.ZkProof =class n extends _chunkMVCKMP5Ujs.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}`)}}},pe= 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=Qt.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})}},fi= exports.KeylessConfiguration =class n{constructor(e){let{verificationKey:t,trainingWheelsPubkey:r,maxExpHorizonSecs:i=Zc,maxExtraFieldBytes:o=ru,maxJwtHeaderB64Bytes:s=iu,maxIssValBytes:a=nu,maxCommitedEpkBytes:c=ou}=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 Ai({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})}},Ai= 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 _chunkMVCKMP5Ujs.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 jt(n){let{aptosConfig:e}=n;try{return await De(async()=>{let[t,r]=await Promise.all([au(n),cu(n)]);return fi.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 - ${_chunkMVCKMP5Ujs.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 au(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Configuration";try{let{data:i}=await V({aptosConfig:e,originMethod:"getKeylessConfigurationResource",path:`accounts/${_chunkMVCKMP5Ujs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _60 => _60.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:22,error:i})}}async function cu(n){let{aptosConfig:e,options:t}=n,r="0x1::keyless_account::Groth16VerificationKey";try{let{data:i}=await V({aptosConfig:e,originMethod:"getGroth16VerificationKeyResource",path:`accounts/${_chunkMVCKMP5Ujs.Z.from("0x1").toString()}/resource/${r}`,params:{ledger_version:_optionalChain([t, 'optionalAccess', _61 => _61.ledgerVersion])}});return i.data}catch(i){throw P.fromErrorType({type:23,error:i})}}async function uu(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/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/resource/${s}`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _62 => _62.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', _63 => _63.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(_chunkMVCKMP5Ujs.j.fromHexInput(p).toUint8Array()),h=hi.deserialize(l);a.push(h)}o.set(_chunkMVCKMP5Ujs.k.call(void 0, s.issuer),a)}return o}var hi=class n extends _chunkMVCKMP5Ujs.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(_chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.ga.call(void 0, this.n),r=pu(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 pu(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 du(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 te=class n extends oe{constructor(e,t){super(),this.jwkAddress=_chunkMVCKMP5Ujs.Z.from(e),this.keylessPublicKey=t}authKey(){let e=new _chunkMVCKMP5Ujs.m;return e.serializeU32AsUleb128(4),e.serializeFixedBytes(this.bcsToBytes()),B.fromSchemeAndBytes({scheme:2,input:e.toUint8Array()})}verifySignature(e){try{return yr({...e,publicKey:this}),!0}catch (e3){return!1}}serialize(e){this.jwkAddress.serialize(e),this.keylessPublicKey.serialize(e)}static deserialize(e){let t=_chunkMVCKMP5Ujs.Z.deserialize(e),r=U.deserialize(e);return new n(t,r)}static isPublicKey(e){return e instanceof n}async verifySignatureAsync(e){return Ti({...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 _chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.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=qt(t),o=_chunkMVCKMP5Ujs.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', _64 => _64.key, 'optionalAccess', _65 => _65.data, 'optionalAccess', _66 => _66.length])===Ce.LENGTH}};Ce.LENGTH=65,Ce.COMPRESSED_LENGTH=33;var $e=Ce,ze=class ze extends _chunkMVCKMP5Ujs.l{constructor(e,t){super();let r=pt.parseHexInput(e,"secp256k1",t);if(r.toUint8Array().length!==ze.LENGTH)throw new Error(`PrivateKey length should be ${ze.LENGTH}`);this.key=r}static generate(){let e=_secp256k1.secp256k1.utils.randomPrivateKey();return new ze(e,!1)}static fromDerivationPath(e,t){if(!fo(e))throw new Error(`Invalid derivation path ${e}`);return ze.fromDerivationPathInner(e,or(t))}static fromDerivationPathInner(e,t){let{privateKey:r}=_bip32.HDKey.fromMasterSeed(t).derive(e);if(r===null)throw new Error("Invalid key");return new ze(r,!1)}sign(e){let t=qt(e),r=_chunkMVCKMP5Ujs.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 ze(t,!1)}static isPrivateKey(e){return e instanceof ze}};ze.LENGTH=32;var We=ze,Jt=class Jt extends M{constructor(e){super();let t=_chunkMVCKMP5Ujs.j.fromHexInput(e);if(t.toUint8Array().length!==Jt.LENGTH)throw new Error(`Signature length should be ${Jt.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 Jt(t)}};Jt.LENGTH=64;var Ct=Jt;var z=class n extends oe{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 te)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', _67 => _67.options, 'optionalAccess', _68 => _68.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=te.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 gu(n){let e=n;return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}var Pn=class extends oe{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 Pn{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 z?i:new z(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', _69 => _69.options, 'optionalAccess', _70 => _70.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(z),r=e.deserializeU8();return new n({publicKeys:t,signaturesRequired:r})}getIndex(e){let t=e instanceof z?e:new z(e);return super.getIndex(t)}static isInstance(e){return"publicKeys"in e&&"signaturesRequired"in e}},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.map(o=>o instanceof H?o:new H(o)),!(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}let i=this.bitmap.reduce((o,s)=>o+gu(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>=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.");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 de({signatures:t,bitmap:r})}};de.BITMAP_LEN=4,de.MAX_SIGNATURES_SUPPORTED=de.BITMAP_LEN*8;var Oe=de;var Te=class Te extends Pn{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 Xt=Te,le=class le extends M{constructor(e){super();let{signatures:t,bitmap:r}=e;if(t.length>le.MAX_SIGNATURES_SUPPORTED)throw new Error(`The number of signatures cannot be greater than ${le.MAX_SIGNATURES_SUPPORTED}`);if(this.signatures=t,!(r instanceof Uint8Array))this.bitmap=le.createBitmap({bits:r});else{if(r.length!==le.BITMAP_LEN)throw new Error(`"bitmap" length should be ${le.BITMAP_LEN}`);this.bitmap=r}}toUint8Array(){let e=new Uint8Array(this.signatures.length*K.LENGTH+le.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 le({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>=le.MAX_SIGNATURES_SUPPORTED)throw new Error(`Cannot have a signature larger than ${le.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}};le.MAX_SIGNATURES_SUPPORTED=32,le.BITMAP_LEN=4;var Qe=le;var j=class extends _chunkMVCKMP5Ujs.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 se.load(e);case 3:return Ge.load(e);case 4:return Yt.load(e);case 5:return _n.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 se}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=Xt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},se= 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=z.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)}},Yt= exports.AccountAuthenticatorNoAccountAuthenticator =class n extends j{serialize(e){e.serializeU32AsUleb128(4)}static load(e){return new n}},_n= exports.AccountAuthenticatorAbstraction =class n extends j{constructor(e,t,r){if(super(),!_chunkMVCKMP5Ujs.ma.call(void 0, e))throw new Error(`Invalid function info ${e} passed into AccountAuthenticatorAbstraction`);this.functionInfo=e,this.authenticator=_chunkMVCKMP5Ujs.j.fromHexInput(r),this.signingMessageDigest=_chunkMVCKMP5Ujs.j.fromHexInput(_chunkMVCKMP5Ujs.j.fromHexInput(t).toUint8Array())}serialize(e){e.serializeU32AsUleb128(5);let{moduleAddress:t,moduleName:r,functionName:i}=_chunkMVCKMP5Ujs.la.call(void 0, this.functionInfo);_chunkMVCKMP5Ujs.Z.fromString(t).serialize(e),e.serializeStr(r),e.serializeStr(i),e.serializeU32AsUleb128(0),e.serializeBytes(this.signingMessageDigest.toUint8Array()),e.serializeFixedBytes(this.authenticator.toUint8Array())}static load(e){let t=_chunkMVCKMP5Ujs.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)}throw new Error(`Unknown variant index for AccountAuthenticatorAbstraction: ${o}`)}};var Zt=class n extends _chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.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 xn=class n extends _chunkMVCKMP5Ujs.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(_chunkMVCKMP5Ujs.Z.fromString(t[0]),new k(t[1]))}serialize(e){this.address.serialize(e),this.name.serialize(e)}static deserialize(e){let t=_chunkMVCKMP5Ujs.Z.deserialize(e),r=k.deserialize(e);return new n(t,r)}};var O=class n extends _chunkMVCKMP5Ujs.l{deserialize(e){let t=_chunkMVCKMP5Ujs.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 ge.load(e);case 2:return J.load(e);case 3:return Ye.load(e);case 4:return F.load(e);case 5:return vt.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 vt}isVector(){return this instanceof C}isStruct(){return this instanceof A}isU8(){return this instanceof ge}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 vt||this instanceof F||this instanceof L||this instanceof ge||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}},ge= 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}},vt= exports.TypeTagSigner =class n extends O{toString(){return"signer"}serialize(e){e.serializeU32AsUleb128(5)}static load(e){return new n}},fr= 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 ge)}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(_chunkMVCKMP5Ujs.Z.ONE,"string","String")}isOption(){return this.isTypeTag(_chunkMVCKMP5Ujs.Z.ONE,"option","Option")}isObject(){return this.isTypeTag(_chunkMVCKMP5Ujs.Z.ONE,"object","Object")}isDelegationKey(){return this.isTypeTag(_chunkMVCKMP5Ujs.Z.ONE,"permissioned_delegation","DelegationKey")}isRateLimiter(){return this.isTypeTag(_chunkMVCKMP5Ujs.Z.ONE,"rate_limiter","RateLimiter")}},Be= exports.StructTag =class n extends _chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.Z.deserialize(e),r=k.deserialize(e),i=k.deserialize(e),o=e.deserializeVector(O);return new n(t,r,i,o)}};function Yy(){return new Be(_chunkMVCKMP5Ujs.Z.ONE,new k("aptos_coin"),new k("AptosCoin"),[])}function _(){return new Be(_chunkMVCKMP5Ujs.Z.ONE,new k("string"),new k("String"),[])}function Zy(n){return new Be(_chunkMVCKMP5Ujs.Z.ONE,new k("option"),new k("Option"),[n])}function me(n){return new Be(_chunkMVCKMP5Ujs.Z.ONE,new k("object"),new k("Object"),[n])}function mu(n){let e=n.deserializeUleb128AsU32();switch(e){case 0:return Y.deserialize(n);case 1:return Q.deserialize(n);case 2:return xe.deserialize(n);case 3:return _chunkMVCKMP5Ujs.Z.deserialize(n);case 4:return S.deserialize(n,Y);case 5:return N.deserialize(n);case 6:return Pe.deserialize(n);case 7:return _e.deserialize(n);case 8:return fe.deserialize(n);case 9:return fn.deserialize(n);default:throw new Error(`Unknown variant index for ScriptTransactionArgument: ${e}`)}}var Kt=class extends _chunkMVCKMP5Ujs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Rt.load(e);case 2:return In.load(e);case 3:return Cn.load(e);default:throw new Error(`Unknown variant index for TransactionPayload: ${t}`)}}},Rt= exports.TransactionPayloadScript =class n extends Kt{constructor(e){super(),this.script=e}serialize(e){e.serializeU32AsUleb128(0),this.script.serialize(e)}static load(e){let t=vn.deserialize(e);return new n(t)}},In= exports.TransactionPayloadEntryFunction =class n extends Kt{constructor(e){super(),this.entryFunction=e}serialize(e){e.serializeU32AsUleb128(2),this.entryFunction.serialize(e)}static load(e){let t=Ut.deserialize(e);return new n(t)}},Cn= exports.TransactionPayloadMultiSig =class n extends Kt{constructor(e){super(),this.multiSig=e}serialize(e){e.serializeU32AsUleb128(3),this.multiSig.serialize(e)}static load(e){let t=Kn.deserialize(e);return new n(t)}},Ut= 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(xn.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=xn.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=rr.deserialize(e,c);s.push(p)}return new n(t,r,i,s)}},vn= 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=mu(e);o.push(a)}return new n(t,r,o)}},Kn= 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=_chunkMVCKMP5Ujs.Z.deserialize(e),r=e.deserializeBool(),i;return r&&(i=Rn.deserialize(e)),new n(t,i)}},Rn= exports.MultiSigTransactionPayload =class n extends _chunkMVCKMP5Ujs.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(Ut.deserialize(e))}};var be=class n extends _chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.Z.deserialize(e),r=e.deserializeU64(),i=Kt.deserialize(e),o=e.deserializeU64(),s=e.deserializeU64(),a=e.deserializeU64(),c=Zt.deserialize(e);return new n(t,r,i,o,s,a,c)}},Ar= exports.RawTransactionWithData =class extends _chunkMVCKMP5Ujs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return kt.load(e);case 1:return Dt.load(e);default:throw new Error(`Unknown variant index for RawTransactionWithData: ${t}`)}}},kt= exports.MultiAgentRawTransaction =class n extends Ar{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(_chunkMVCKMP5Ujs.Z);return new n(t,r)}},Dt= exports.FeePayerRawTransaction =class n extends Ar{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(_chunkMVCKMP5Ujs.Z),i=_chunkMVCKMP5Ujs.Z.deserialize(e);return new n(t,r,i)}};var hr=class extends _chunkMVCKMP5Ujs.l{constructor(t){super();this.accountAddress=_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.l{static deserialize(e){let t=e.deserializeUleb128AsU32();switch(t){case 0:return Nt.load(e);case 1:return en.load(e);case 2:return zt.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 en}isMultiAgent(){return this instanceof zt}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)}},en= 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=Xt.deserialize(e),r=Qe.deserialize(e);return new n(t,r)}},zt= 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(_chunkMVCKMP5Ujs.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(_chunkMVCKMP5Ujs.Z),i=e.deserializeVector(j),o=_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.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 tn=class n extends _chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.Z.deserialize(e)),new n(t,i)}};var Tr=class n extends _chunkMVCKMP5Ujs.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(_chunkMVCKMP5Ujs.Z),i=e.deserializeBool(),o;return i&&(o=_chunkMVCKMP5Ujs.Z.deserialize(e)),new n(t,r,o)}};function br(n){return n.feePayerAddress?new Dt(n.rawTransaction,_nullishCoalesce(n.secondarySignerAddresses, () => ([])),n.feePayerAddress):n.secondarySignerAddresses?new kt(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 dA(n){return yt(n.bcsToBytes(),`APTOS::${n.constructor.name}`)}function Ke(n){let e=br(n);return n.feePayerAddress?yt(e.bcsToBytes(),ui):n.secondarySignerAddresses?yt(e.bcsToBytes(),ui):yt(e.bcsToBytes(),Co)}var ae=class n{constructor(e){this.signingScheme=0;let{privateKey:t,address:r}=e;this.privateKey=t,this.publicKey=t.publicKey(),this.accountAddress=r?_chunkMVCKMP5Ujs.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 wi(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 z(t.publicKey()),this.accountAddress=r?_chunkMVCKMP5Ujs.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 se(this.publicKey,this.sign(e))}signTransactionWithAuthenticator(e){return new se(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?ae.generate():we.generate({scheme:t})}static fromPrivateKey(e){let{privateKey:t,address:r,legacy:i=!0}=e;return t instanceof q&&i?new ae({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?ae.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 Au=1209600,nn=class nn extends _chunkMVCKMP5Ujs.l{constructor(e){super();let{privateKey:t,expiryDateSecs:r,blinder:i}=e;this.privateKey=t,this.publicKey=new lt(t.publicKey()),this.expiryDateSecs=r||_chunkMVCKMP5Ujs.ea.call(void 0, _chunkMVCKMP5Ujs.da.call(void 0, )+Au),this.blinder=i!==void 0?_chunkMVCKMP5Ujs.j.fromHexInput(i).toUint8Array():hu();let o=Tn(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 nn({privateKey:r,expiryDateSecs:Number(i),blinder:o})}static fromBytes(e){return nn.deserialize(new R(e))}static generate(e){let t;switch(_optionalChain([e, 'optionalAccess', _71 => _71.scheme])){case 0:default:t=q.generate()}return new nn({privateKey:t,expiryDateSecs:_optionalChain([e, 'optionalAccess', _72 => _72.expiryDateSecs])})}sign(e){if(this.isExpired())throw new Error("EphemeralKeyPair has expired");return new Ue(this.privateKey.sign(e))}};nn.BLINDER_LENGTH=31;var Ot=nn;function hu(){return _utils3.randomBytes.call(void 0, Ot.BLINDER_LENGTH)}var _eventemitter3 = require('eventemitter3'); var _eventemitter32 = _interopRequireDefault(_eventemitter3);function Sr(n){return n!=null&&typeof n.checkKeylessAccountValidity=="function"}var rn=class rn extends _chunkMVCKMP5Ujs.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?_chunkMVCKMP5Ujs.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 pe)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=_chunkMVCKMP5Ujs.j.fromHexInput(p).toUint8Array();if(b.length!==rn.PEPPER_LENGTH)throw new Error(`Pepper length in bytes should be ${rn.PEPPER_LENGTH}`);if(this.pepper=b,g!==void 0){if(_chunkMVCKMP5Ujs.j.hexInputToUint8Array(g).length!==32)throw new Error("verificationKeyHash must be 32 bytes");this.verificationKeyHash=_chunkMVCKMP5Ujs.j.hexInputToUint8Array(g)}}getAnyPublicKey(){return new z(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=_chunkMVCKMP5Ujs.Z.deserialize(t),i=t.deserializeStr(),o=t.deserializeStr(),s=t.deserializeFixedBytes(31),a=Ot.deserialize(t),c=pe.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 z(this.publicKey);return new se(i,r)}signTransactionWithAuthenticator(t){let r=new H(this.signTransaction(t)),i=new z(this.publicKey);return new se(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 jt({aptosConfig:t});if(_chunkMVCKMP5Ujs.j.hexInputToString(i.hash())!==_chunkMVCKMP5Ujs.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 rn.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:_chunkMVCKMP5Ujs.fa.call(void 0, this.jwt.split(".")[0]),ephemeralCertificate:new Wt(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=br(t),o=new wr(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=br(t);return new wr(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 bi(t)}};rn.PEPPER_LENGTH=31;var ye=rn,wr= exports.TransactionAndProof =class extends _chunkMVCKMP5Ujs.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 ye{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}=ye.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(_chunkMVCKMP5Ujs.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 Gt=class n extends ye{constructor(e){let t=te.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}=ye.partialDeserialize(e),p=_chunkMVCKMP5Ujs.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:_chunkMVCKMP5Ujs.Z.from(a),jwt:i,proofFetchCallback:p,verificationKeyHash:l?l.hash():void 0})}};var Un=class n{constructor(e){this.signingScheme=3;let{multiKey:t,address:r}=e,i=e.signers.map(a=>a instanceof ae?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?_chunkMVCKMP5Ujs.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 ye).map(async r=>r.waitForProofFetch());await Promise.all(t)}async checkKeylessAccountValidity(e){let r=this.signers.filter(i=>i instanceof ye).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 Er=class{constructor(e){this.signingScheme=1;let{signers:t,publicKey:r,address:i}=e;if(this.publicKey=r,this.accountAddress=i?_chunkMVCKMP5Ujs.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 Bo(n){let e=n.deserializeUleb128AsU32();if(!Object.values(_chunkMVCKMP5Ujs.U).includes(e))throw new Error(`Deserialization of Account failed: SigningScheme variant ${e} is invalid`);return{address:_chunkMVCKMP5Ujs.Z.deserialize(n),signingScheme:e}}function Mo(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 Vo(n){let e=n.deserializeStr(),t=n.deserializeStr(),r=n.deserializeFixedBytes(31),i=Ot.deserialize(n),o=pe.deserialize(n),s=n.deserializeOption("fixedBytes",32);return{jwt:e,uidKey:t,pepper:r,ephemeralKeyPair:i,proof:o,verificationKeyHash:s}}var Ho;(h=>{function n(d){let g=new _chunkMVCKMP5Ujs.m;switch(g.serializeU32AsUleb128(d.signingScheme),d.accountAddress.serialize(g),d.signingScheme){case 0:return d.privateKey.serialize(g),g.toUint8Array();case 2:{if(!wi(d))throw new Error("Account is not a SingleKeySigner");let b=d.getAnyPublicKey();switch(g.serializeU32AsUleb128(b.variant),b.variant){case 3:return Mo(d,g),g.toUint8Array();case 4:{let v=d;return Mo(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 _chunkMVCKMP5Ujs.j.hexInputToStringWithoutPrefix(n(d))}h.toHexStringWithoutPrefix=e;function t(d){return _chunkMVCKMP5Ujs.j.hexInputToString(n(d))}h.toHexString=t;function r(d){let{address:g,signingScheme:b}=Bo(d);switch(b){case 0:{let v=q.deserialize(d);return new ae({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=Vo(d),Me=qe(W);return new rt({...W,...Me})}case 4:{let W=Vo(d),Me=_chunkMVCKMP5Ujs.Z.deserialize(d),st=d.deserializeBool(),at=qe(W);return new Gt({...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(!wi(at)&&!(at instanceof ae))throw new Error("Deserialization of MultiKeyAccount failed. Signer is not a SingleKeySigner or Ed25519Account");Me.push(at)}return new Un({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 Gt))throw new Error("Deserialization of FederatedKeylessAccount failed");return g}h.federatedKeylessAccountFromHex=o;function s(d){let g=p(d);if(!(g instanceof Un))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 ae))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})(Ho||(Ho= exports.AccountUtils ={}));var qo=class n extends nt{constructor({signer:t,accountAddress:r,authenticationFunction:i}){super();this.signingScheme=2;if(!_chunkMVCKMP5Ujs.ma.call(void 0, i))throw new Error(`Invalid authentication function ${i} passed into AbstractedAccount`);this.authenticationFunction=i,this.accountAddress=r,this.publicKey=new ir(this.accountAddress),this.sign=o=>new An(t(o))}static fromPermissionedSigner({signer:t,accountAddress:r}){return new n({signer:i=>{let o=new _chunkMVCKMP5Ujs.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 _n(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 An(t(r))}};var wu=`
|
|
7
7
|
fragment TokenActivitiesFields on token_activities_v2 {
|
|
8
8
|
after_value
|
|
9
9
|
before_value
|
|
@@ -168,7 +168,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
168
168
|
...CurrentTokenOwnershipFields
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
${Pr}`,
|
|
171
|
+
${Pr}`,QT=`
|
|
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
|
-
${Su}`,
|
|
354
|
+
${Su}`,Si=`
|
|
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
|
|
@@ -375,7 +375,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
375
375
|
is_deleted
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
|
-
`,
|
|
378
|
+
`,Ei=`
|
|
379
379
|
query getProcessorStatus($where_condition: processor_status_bool_exp) {
|
|
380
380
|
processor_status(where: $where_condition) {
|
|
381
381
|
last_success_version
|
|
@@ -423,7 +423,7 @@ KeylessErrorResolutionTip: ${t}`,o}static fromErrorType(e){let{error:t,type:r,de
|
|
|
423
423
|
...TokenActivitiesFields
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
|
-
${wu}`,
|
|
426
|
+
${wu}`,Pi=`
|
|
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 xr(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function ps(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Zo,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 Eu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Si},originMethod:"getProcessorStatuses"})).processor_status}async function Ir(n){let e=await Eu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function vr(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 ls(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return mr({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunk5GUWOXQGjs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _64 => _64.ledgerVersion]),offset:_optionalChain([r, 'optionalAccess', _65 => _65.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _66 => _66.limit]), () => (1e3))}})}async function Cr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunk5GUWOXQGjs.Z.from(t).toString()}`});return r}async function gs(n){return _optionalChain([n, 'access', _67 => _67.options, 'optionalAccess', _68 => _68.ledgerVersion])!==void 0?ds(n):ke(async()=>ds(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ds(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunk5GUWOXQGjs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _69 => _69.ledgerVersion])}});return o}async function Kr(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', _70 => _70.ledgerVersion])},body:r})).data}async function ms(n){let{aptosConfig:e,options:t}=n,r={query:ss,variables:{where_condition:_optionalChain([t, 'optionalAccess', _71 => _71.where]),offset:_optionalChain([t, 'optionalAccess', _72 => _72.offset]),limit:_optionalChain([t, 'optionalAccess', _73 => _73.limit]),order_by:_optionalChain([t, 'optionalAccess', _74 => _74.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function ys(n){let{aptosConfig:e,options:t}=n,r={query:as,variables:{where_condition:_optionalChain([t, 'optionalAccess', _75 => _75.where]),offset:_optionalChain([t, 'optionalAccess', _76 => _76.offset]),limit:_optionalChain([t, 'optionalAccess', _77 => _77.limit]),order_by:_optionalChain([t, 'optionalAccess', _78 => _78.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function _i(n){let{aptosConfig:e,options:t}=n;return gr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _79 => _79.offset]),limit:_optionalChain([t, 'optionalAccess', _80 => _80.limit])}})}async function Ur(n){let{aptosConfig:e}=n;return ke(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 fs(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function kn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function As(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await kn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _81 => _81.status])===404)return!0;throw r}}async function Pu(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', _82 => _82.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _83 => _83.checkSuccess]), () => (!0)),s=!0,a=0,c,p,l=200,h=1.5;function d(g){if(!(g instanceof ee)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await kn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){d(g)}if(s){let g=Date.now();try{c=await Pu({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 kn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){d(g)}await _chunk5GUWOXQGjs._.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new Rr(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Rr(`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 kr(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 Ir({aptosConfig:e}):s=(await vr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunk5GUWOXQGjs._.call(void 0, 200)}}var Rr=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 hs(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', _84 => _84.withTransactions])}});return bs({block:i,...n})}async function Ts(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', _85 => _85.withTransactions])}});return bs({block:i,...n})}async function bs(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _86 => _86.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', _87 => _87.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 ws(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function Ss(n){return!!n.match(/\s/)}function _u(n){return!!n.match(/^T[0-9]+$/)}function xu(n){return!!n.match(/^&.+$/)}function Iu(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 vu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!Ss(r))break}return t}var Cu=(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))(Cu||{}),$= exports.TypeTagParserError =class extends Error{constructor(e,t){super(`Failed to parse typeTag '${e}', ${t}`)}};function Ke(n,e){let t=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _88 => _88.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=Dn(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=Dn(a,i,t);i=[],o.push(l),a="",c+=1}else if(Ss(p)){let l=!1;if(a.length!==0){let d=Dn(a,i,t);i=[],o.push(d),a="",l=!0}s=vu(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 Dn(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function Dn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Iu(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new Ct;case"bool":return new H;case"address":return new F;case"u8":return new ge;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 v(e[0]);default:if(xu(r)){let a=r.substring(1);return new fr(Dn(a,e,t))}if(_u(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=_chunk5GUWOXQGjs.Z.fromString(o[0])}catch (e3){throw new $(n,"struct address must be valid")}if(!ws(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!ws(o[2]))throw new $(n,"struct name must only contain alphanumeric or '_' characters");return new A(new Ge(s,new U(o[1]),new U(o[2]),e))}}function Es(n){return typeof n=="boolean"}function it(n){return typeof n=="string"}function Ku(n){return typeof n=="number"}function Dr(n){if(Ku(n))return n;if(it(n)&&n!=="")return Number.parseInt(n,10)}function Nr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Ps(n){return n==null}function _s(n){return xi(n)||vi(n)||Ci(n)||Ki(n)||Ri(n)||Ui(n)||ki(n)||zr(n)||Ii(n)||Ru(n)||n instanceof S||n instanceof Z}function xi(n){return n instanceof D}function zr(n){return n instanceof _chunk5GUWOXQGjs.Z}function Ii(n){return n instanceof x}function Ru(n){return n instanceof Se}function vi(n){return n instanceof Y}function Ci(n){return n instanceof Ee}function Ki(n){return n instanceof Pe}function Ri(n){return n instanceof Q}function Ui(n){return n instanceof _e}function ki(n){return n instanceof fe}function xs(n){return"bytecode"in n}function k(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function Is(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Uu=new TextEncoder;function sn(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _89 => _89.map, 'call', _90 => _90(e=>it(e)?Ke(e):e)]), () => ([]))}async function Ni(n,e,t){return(await Fr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function zi(n,e,t,r){let i=await Ni(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 Mb(n,e,t,r){let i=await zi(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(Ke(i.params[s],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o}}async function vs(n,e,t,r){let i=await zi(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=Is(i),s=[];for(let a=o;a<i.params.length;a+=1)s.push(Ke(i.params[a],{allowGenerics:!0}));return{signers:o,typeParameters:i.generic_type_params,parameters:s}}async function Cs(n,e,t,r){let i=await zi(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(Ke(i.params[a],{allowGenerics:!0}));let s=[];for(let a=0;a<i.return.length;a+=1)s.push(Ke(i.return[a],{allowGenerics:!0}));return{typeParameters:i.generic_type_params,parameters:o,returnTypes:s}}function Vb(n,e,t,r,i){return n instanceof _chunk5GUWOXQGjs.X?n:_chunk5GUWOXQGjs.X.newBytes(an(e,t,n,r,i).bcsToBytes())}function an(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=Ke(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 Bt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Bt(n,e,t,r,i,o){return _s(n)?(Di(e,n,t),n):ku(n,e,t,r,i,o)}function ku(n,e,t,r,i,o){if(e.isBool()){if(Es(n))return new D(n);if(it(n)){if(n==="true")return new D(!0);if(n==="false")return new D(!1)}k("boolean",t)}if(e.isAddress()){if(it(n))return _chunk5GUWOXQGjs.Z.fromString(n);k("string | AccountAddress",t)}if(e.isU8()){let s=Dr(n);if(s!==void 0)return new Y(s);k("number | string",t)}if(e.isU16()){let s=Dr(n);if(s!==void 0)return new Ee(s);k("number | string",t)}if(e.isU32()){let s=Dr(n);if(s!==void 0)return new Pe(s);k("number | string",t)}if(e.isU64()){if(Nr(n))return new Q(BigInt(n));k("bigint | number | string",t)}if(e.isU128()){if(Nr(n))return new _e(BigInt(n));k("bigint | number | string",t)}if(e.isU256()){if(Nr(n))return new fe(BigInt(n));k("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 Bt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(it(n))return S.U8(Uu.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 Bt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Bt(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);k("string",t)}if(e.isObject()){if(it(n))return _chunk5GUWOXQGjs.Z.fromString(n);k("string | AccountAddress",t)}if(e.isDelegationKey()||e.isRateLimiter()){if(n instanceof Uint8Array)return new Se(n);k("Uint8Array",t)}if(e.isOption()){if(Ps(n)){let a=e.value.typeArgs[0];return a instanceof H?new Z(null):a instanceof F?new Z(null):a instanceof ge?new Z(null):a instanceof Je?new Z(null):a instanceof Xe?new Z(null):a instanceof J?new Z(null):a instanceof Ye?new Z(null):a instanceof Ze?new Z(null):new Z(null)}return new Z(Bt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _91 => _91.structs, 'access', _92 => _92.find, 'call', _93 => _93(a=>a.name===e.value.name.identifier), 'optionalAccess', _94 => _94.fields, 'access', _95 => _95.length])===0&&n instanceof Uint8Array)return new Se(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _96 => _96.allowUnknownStructs]))return console.warn(`Unsupported struct input type for argument ${t}. Continuing since 'allowUnknownStructs' is enabled.`),new Se(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;k("Bool",t)}if(n.isAddress()){if(zr(e))return;k("AccountAddress",t)}if(n.isU8()){if(vi(e))return;k("U8",t)}if(n.isU16()){if(Ci(e))return;k("U16",t)}if(n.isU32()){if(Ki(e))return;k("U32",t)}if(n.isU64()){if(Ri(e))return;k("U64",t)}if(n.isU128()){if(Ui(e))return;k("U128",t)}if(n.isU256()){if(ki(e))return;k("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Di(n.value,e.values[0],t);return}k("MoveVector",t)}if(n instanceof A){if(n.isString()){if(Ii(e))return;k("MoveString",t)}if(n.isObject()){if(zr(e))return;k("AccountAddress",t)}if(n.isOption()){if(e instanceof Z){e.value!==void 0&&Di(n.value.typeArgs[0],e.value,t);return}k("MoveOption",t)}}throw new Error(`Type mismatch for argument ${t}, expected '${n.toString()}'`)}async function Or(n){if(xs(n))return Fu(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunk5GUWOXQGjs.ia.call(void 0, n.function),i=await Us({key:"entry-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:vs});return Nu({...n,abi:i})}function Nu(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk5GUWOXQGjs.ia.call(void 0, n.function),o=sn(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)=>an(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=Ut.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunk5GUWOXQGjs.Z.from(n.multisigAddress);return new vn(new Kn(c,new Rn(a)))}return new In(a)}async function Gr(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunk5GUWOXQGjs.ia.call(void 0, n.function),i=await Us({key:"view-function",moduleAddress:e,moduleName:t,functionName:r,aptosConfig:n.aptosConfig,abi:n.abi,fetch:Cs});return zu({abi:i,...n})}function zu(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunk5GUWOXQGjs.ia.call(void 0, n.function),o=sn(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', _97 => _97.functionArguments, 'optionalAccess', _98 => _98.map, 'call', _99 => _99((a,c)=>an(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 Ut.build(`${t}::${r}`,i,o,s)}function Fu(n){return new Rt(new Cn(_chunk5GUWOXQGjs.j.fromHexInput(n.bytecode).toUint8Array(),sn(n.typeArguments),n.functionArguments))}async function Fi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>ai[e.network]?{chainId:ai[e.network]}:{chainId:(await xr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _100 => _100.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Ur({aptosConfig:e})).gas_estimate},c=async()=>{let C=async()=>_optionalChain([i, 'optionalAccess', _101 => _101.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await Cr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunk5GUWOXQGjs.Z.from(o).equals(_chunk5GUWOXQGjs.Z.ZERO))try{return await C()}catch (e4){return 0}else return C()},[{chainId:p},{gasEstimate:l},h]=await Promise.all([s(),a(),c()]),{maxGasAmount:d,gasUnitPrice:g,expireTimestamp:b}={maxGasAmount:_optionalChain([i, 'optionalAccess', _102 => _102.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _103 => _103.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _104 => _104.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new Te(_chunk5GUWOXQGjs.Z.from(t),BigInt(h),r,BigInt(d),BigInt(g),BigInt(b),new Zt(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', _105 => _105.secondarySignerAddresses, 'optionalAccess', _106 => _106.map, 'call', _107 => _107(c=>_chunk5GUWOXQGjs.Z.from(c))]), () => ([]));return new Tr(s,a,n.feePayerAddress?_chunk5GUWOXQGjs.Z.from(n.feePayerAddress):void 0)}return new tn(s,n.feePayerAddress?_chunk5GUWOXQGjs.Z.from(n.feePayerAddress):void 0)}function Ks(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=cn(e);if(t.feePayerAddress){let a=new Dt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>cn(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>cn(void 0)));let p=cn(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 kt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>cn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>cn(void 0));let p=new zt(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 se||o instanceof Oe)s=new ft(o);else if(o instanceof Yt)s=new ft(o);else throw new Error("Invalid public key");return new tt(t.rawTransaction,s).bcsToBytes()}function cn(n){if(!n)return new Yt;let t=N.isInstance(n)||te.isInstance(n)||qe.isInstance(n)?new z(n):n,r=new K(new Uint8Array(64));if(I.isInstance(t))return new ve(t,r);if(z.isInstance(t))return N.isInstance(t.publicKey)?new se(t,new q(Ne.getSimulationSignature())):new se(t,new q(r));if(Fe.isInstance(t))return new Oe(t,new We({signatures:t.publicKeys.map(i=>N.isInstance(i.publicKey)||te.isInstance(i.publicKey)?new q(Ne.getSimulationSignature()):new q(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=Co(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 zt(i,e.secondarySignerAddresses,r)}else i instanceof ve?o=new Nt(i.public_key,i.signature):i instanceof je?o=new en(i.public_key,i.signature):o=new ft(i);return new tt(e.rawTransaction,o).bcsToBytes()}function Rs(n){let e=_sha3.sha3_256.create();for(let t of n)e.update(t);return e.digest()}var Ou=Rs(["APTOS::Transaction"]);function gw(n){let e=Gi(n);return new (0, _chunk5GUWOXQGjs.j)(Rs([Ou,new Uint8Array([0]),e])).toString()}async function Us({key:n,moduleAddress:e,moduleName:t,functionName:r,aptosConfig:i,abi:o,fetch:s}){return o!==void 0?o:ke(async()=>s(e,t,r,i),`${n}-${i.network}-${e}-${t}-${r}`,1e3*60*5)()}var _scriptcomposerpack = require('@aptos-labs/script-composer-pack');var Br=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}=_chunk5GUWOXQGjs.ia.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=sn(e.typeArguments),a=await Ni(t,r,this.config);if(!a)throw new Error(`Could not find module ABI for '${t}::${r}'`);let c=_optionalChain([a, 'optionalAccess', _108 => _108.exposed_functions, 'access', _109 => _109.find, 'call', _110 => _110(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', _111 => _111.generic_type_params, 'access', _112 => _112.length])}, received ${s.length}`);let p=e.functionArguments.map((l,h)=>l instanceof _chunk5GUWOXQGjs.X?l:_chunk5GUWOXQGjs.X.newBytes(an(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 Gu(n);return Bu(n,e)}async function Gu(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 Bu(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Mu(n)&&(o=_chunk5GUWOXQGjs.Z.ZERO.toString()),Vu(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 Mu(n){return n.withFeePayer===!0}function Vu(n){return"secondarySignerAddresses"in n}function ks(n){let{transaction:e}=n;return Ce(e)}function Mr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Vr(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,Mr({signer:e,transaction:t})}async function Mi(n){let{aptosConfig:e,transaction:t,signerPublicKey:r,secondarySignersPublicKeys:i,feePayerPublicKey:o,options:s}=n,a=Ks({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', _113 => _113.options, 'optionalAccess', _114 => _114.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _115 => _115.options, 'optionalAccess', _116 => _116.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _117 => _117.options, 'optionalAccess', _118 => _118.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Nn(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 N||i.authenticator.sender.public_key.publicKey instanceof te)&&await ye.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;Sr(t)&&await t.checkKeylessAccountValidity(e),Sr(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Vr({signer:r,transaction:i}),s=Mr({signer:t,transaction:i});return Nn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function Ds(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;Sr(r)&&await r.checkKeylessAccountValidity(e);let o=Vr({signer:r,transaction:i});return Nn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Hu={typeParameters:[],parameters:[v.u8(),new v(v.u8())]};async function Ns(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:_chunk5GUWOXQGjs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Hu},options:o})}async function Mt(n){return Cr(n)}async function Fs(n){return ls(n)}async function Fr(n){return gs(n)}async function Os(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return gr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunk5GUWOXQGjs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _119 => _119.offset]),limit:_optionalChain([r, 'optionalAccess', _120 => _120.limit])}})}async function Gs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return mr({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunk5GUWOXQGjs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _121 => _121.ledgerVersion]),offset:_optionalChain([r, 'optionalAccess', _122 => _122.offset]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _123 => _123.limit]), () => (999))}})}async function Hi(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunk5GUWOXQGjs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _124 => _124.ledgerVersion])}});return o.data}async function un(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=_chunk5GUWOXQGjs.Z.from(t);try{let a=await Kr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunk5GUWOXQGjs.Z.from(a)}catch(a){if(a instanceof ee&&a.data.error_code==="table_item_not_found")return s;throw a}}async function Bs(n){let{aptosConfig:e,accountAddress:t}=n,i={owner_address:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Xo,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 Ms(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk5GUWOXQGjs.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:jo,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 Vs(n){let{aptosConfig:e,accountAddress:t,collectionAddress:r,options:i}=n,o=_chunk5GUWOXQGjs.Z.from(t).toStringLong(),s=_chunk5GUWOXQGjs.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 Hs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk5GUWOXQGjs.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:Qo,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 Ls(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk5GUWOXQGjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Yo,variables:{address:r}},originMethod:"getAccountTransactionsCount"});return o.account_transactions_aggregate.aggregate?o.account_transactions_aggregate.aggregate.count:0}async function qs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,i=_chunk5GUWOXQGjs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _140 => _140.where]),owner_address:{_eq:i}},s={query:Wo,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 $s(n){let{aptosConfig:e,accountAddress:t}=n,r=_chunk5GUWOXQGjs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:$o,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 Ws(n){let{aptosConfig:e,accountAddress:t,options:r}=n,o={owner_address:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()}},s={query:_r,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 Qs(n){let{aptosConfig:e,privateKey:t}=n,r=new z(t.publicKey());if(t instanceof $e){let o=B.fromPublicKey({publicKey:r}).derivedAddress();return nt.fromPrivateKey({privateKey:t,address:o})}if(t instanceof L){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 un({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Mt({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 Lu={typeParameters:[],parameters:[new ge,v.u8(),new ge,v.u8(),v.u8(),v.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 ae)return Vi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof Er)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 $u({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 Mt({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=nt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new hr({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:_chunk5GUWOXQGjs.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 Y(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new Y(i.signingScheme),S.U8(i.publicKey.toUint8Array()),S.U8(a.toUint8Array()),S.U8(c.toUint8Array())],abi:Lu}});return ht({aptosConfig:e,signer:t,transaction:p})}var qu={typeParameters:[],parameters:[v.u8()]};async function $u(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:qu}});return ht({aptosConfig:e,signer:t,transaction:o})}async function E(n){n.minimumLedgerVersion!==void 0&&await kr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function ce(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Gr({...t,aptosConfig:e}),o=new _chunk5GUWOXQGjs.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 Js(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 Xs(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk5GUWOXQGjs.ia.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 Ys(n){let{aptosConfig:e,sender:t,authenticationFunction:r,options:i}=n,{moduleAddress:o,moduleName:s,functionName:a}=_chunk5GUWOXQGjs.ia.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 Zs(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 Vt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunk5GUWOXQGjs.ia.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _149 => _149.some, 'call', _150 => _150(s=>_chunk5GUWOXQGjs.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 Xs({aptosConfig:this.config,authenticationFunction:r,sender:t,options:i})}async removeAuthenticationFunctionTransaction(e){let{accountAddress:t,authenticationFunction:r,options:i}=e;return Ys({aptosConfig:this.config,sender:t,authenticationFunction:r,options:i})}async removeDispatchableAuthenticatorTransaction(e){let{accountAddress:t,options:r}=e;return Zs({aptosConfig:this.config,sender:t,options:r})}async getAuthenticationFunction(e){let{accountAddress:t}=e,[{vec:r}]=await ce({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunk5GUWOXQGjs.Z.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunk5GUWOXQGjs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var zn=class{constructor(e){this.config=e;this.abstraction=new Vt(e)}async getAccountInfo(e){return Mt({aptosConfig:this.config,...e})}async getAccountModules(e){return Fs({aptosConfig:this.config,...e})}async getAccountModule(e){return Fr({aptosConfig:this.config,...e})}async getAccountTransactions(e){return Os({aptosConfig:this.config,...e})}async getAccountResources(e){return Gs({aptosConfig:this.config,...e})}async getAccountResource(e){return Hi({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return un({aptosConfig:this.config,...e})}async getAccountTokensCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Bs({aptosConfig:this.config,...e})}async getAccountOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Ms({aptosConfig:this.config,...e})}async getAccountOwnedTokensFromCollectionAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Vs({aptosConfig:this.config,...e})}async getAccountCollectionsWithOwnedTokens(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),Hs({aptosConfig:this.config,...e})}async getAccountTransactionsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"account_transactions_processor"}),Ls({aptosConfig:this.config,...e})}async getAccountCoinsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),qs({aptosConfig:this.config,...e})}async getAccountCoinsCount(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"fungible_asset_processor"}),$s({aptosConfig:this.config,...e})}async getAccountAPTAmount(e){return this.getAccountCoinAmount({coinType:xt,faMetadataAddress:xo,...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 xr(n){let{aptosConfig:e}=n,{data:t}=await V({aptosConfig:e,originMethod:"getLedgerInfo",path:""});return t}async function ps(n){let{aptosConfig:e,limit:t}=n;return(await w({aptosConfig:e,query:{query:Zo,variables:{limit:t}},originMethod:"getChainTopUserTransactions"})).user_transactions}async function w(n){let{aptosConfig:e,query:t,originMethod:r}=n,{data:i}=await ko({aptosConfig:e,originMethod:_nullishCoalesce(r, () => ("queryIndexer")),path:"",body:t,overrides:{WITH_CREDENTIALS:!1}});return i}async function Eu(n){let{aptosConfig:e}=n;return(await w({aptosConfig:e,query:{query:Ei},originMethod:"getProcessorStatuses"})).processor_status}async function Ir(n){let e=await Eu({aptosConfig:n.aptosConfig});return BigInt(e[0].last_success_version)}async function Cr(n){let{aptosConfig:e,processorType:t}=n;return(await w({aptosConfig:e,query:{query:Ei,variables:{where_condition:{processor:{_eq:t}}}},originMethod:"getProcessorStatus"})).processor_status[0]}async function vr(n){let{aptosConfig:e,accountAddress:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getInfo",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}`});return r}async function ls(n){return _optionalChain([n, 'access', _73 => _73.options, 'optionalAccess', _74 => _74.ledgerVersion])!==void 0?ds(n):De(async()=>ds(n),`module-${n.accountAddress}-${n.moduleName}`,1e3*60*5)()}async function ds(n){let{aptosConfig:e,accountAddress:t,moduleName:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getModule",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/module/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _75 => _75.ledgerVersion])}});return o}async function Kr(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', _76 => _76.ledgerVersion])},body:r})).data}async function gs(n){let{aptosConfig:e,options:t}=n,r={query:ss,variables:{where_condition:_optionalChain([t, 'optionalAccess', _77 => _77.where]),offset:_optionalChain([t, 'optionalAccess', _78 => _78.offset]),limit:_optionalChain([t, 'optionalAccess', _79 => _79.limit]),order_by:_optionalChain([t, 'optionalAccess', _80 => _80.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsData"})).table_items}async function ms(n){let{aptosConfig:e,options:t}=n,r={query:as,variables:{where_condition:_optionalChain([t, 'optionalAccess', _81 => _81.where]),offset:_optionalChain([t, 'optionalAccess', _82 => _82.offset]),limit:_optionalChain([t, 'optionalAccess', _83 => _83.limit]),order_by:_optionalChain([t, 'optionalAccess', _84 => _84.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getTableItemsMetadata"})).table_metadatas}async function xi(n){let{aptosConfig:e,options:t}=n;return gr({aptosConfig:e,originMethod:"getTransactions",path:"transactions",params:{start:_optionalChain([t, 'optionalAccess', _85 => _85.offset]),limit:_optionalChain([t, 'optionalAccess', _86 => _86.limit])}})}async function Ur(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 ys(n){let{aptosConfig:e,ledgerVersion:t}=n,{data:r}=await V({aptosConfig:e,originMethod:"getTransactionByVersion",path:`transactions/by_version/${t}`});return r}async function kn(n){let{aptosConfig:e,transactionHash:t}=n,{data:r}=await V({aptosConfig:e,path:`transactions/by_hash/${t}`,originMethod:"getTransactionByHash"});return r}async function fs(n){let{aptosConfig:e,transactionHash:t}=n;try{return(await kn({aptosConfig:e,transactionHash:t})).type==="pending_transaction"}catch(r){if(_optionalChain([r, 'optionalAccess', _87 => _87.status])===404)return!0;throw r}}async function Pu(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', _88 => _88.timeoutSecs]), () => (20)),o=_nullishCoalesce(_optionalChain([r, 'optionalAccess', _89 => _89.checkSuccess]), () => (!0)),s=!0,a=0,c,p,l=200,h=1.5;function d(g){if(!(g instanceof ee)||(p=g,g.status!==404&&g.status>=400&&g.status<500))throw g}try{c=await kn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction"}catch(g){d(g)}if(s){let g=Date.now();try{c=await Pu({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 kn({aptosConfig:e,transactionHash:t}),s=c.type==="pending_transaction",!s)break}catch(g){d(g)}await _chunkMVCKMP5Ujs.ba.call(void 0, l),a+=l/1e3,l*=h}if(c===void 0)throw p||new Rr(`Fetching transaction ${t} failed and timed out after ${i} seconds`,c);if(c.type==="pending_transaction")throw new Rr(`Transaction ${t} timed out in pending state after ${i} seconds`,c);if(!o)return c;if(!c.success)throw new _i(`Transaction ${t} failed with an error: ${c.vm_status}`,c);return c}async function kr(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 Ir({aptosConfig:e}):s=(await Cr({aptosConfig:e,processorType:t})).last_success_version,s>=r)break;await _chunkMVCKMP5Ujs.ba.call(void 0, 200)}}var Rr=class extends Error{constructor(e,t){super(e),this.lastSubmittedTransaction=t}},_i=class extends Error{constructor(e,t){super(e),this.transaction=t}};async function As(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', _90 => _90.withTransactions])}});return Ts({block:i,...n})}async function hs(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', _91 => _91.withTransactions])}});return Ts({block:i,...n})}async function Ts(n){let{aptosConfig:e,block:t,options:r}=n;if(_optionalChain([r, 'optionalAccess', _92 => _92.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', _93 => _93.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(xi({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 bs(n){return!!n.match(/^[_a-zA-Z0-9]+$/)}function ws(n){return!!n.match(/\s/)}function _u(n){return!!n.match(/^T[0-9]+$/)}function xu(n){return!!n.match(/^&.+$/)}function Iu(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 Cu(n,e){let t=e;for(;t<n.length;t+=1){let r=n[t];if(!ws(r))break}return t}var vu=(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))(vu||{}),$= 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', _94 => _94.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=Dn(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=Dn(a,i,t);i=[],o.push(l),a="",c+=1}else if(ws(p)){let l=!1;if(a.length!==0){let d=Dn(a,i,t);i=[],o.push(d),a="",l=!0}s=Cu(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 Dn(a,i,t);case 1:if(a==="")return o[0];throw new $(n,"unexpected ','");default:throw new $(n,"unexpected whitespace character")}}function Dn(n,e,t){let r=n.trim(),i=r.toLowerCase();if(Iu(i)&&e.length>0)throw new $(n,"primitive types not expected to have type arguments");switch(r.toLowerCase()){case"signer":return new vt;case"bool":return new L;case"address":return new F;case"u8":return new ge;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(xu(r)){let a=r.substring(1);return new fr(Dn(a,e,t))}if(_u(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=_chunkMVCKMP5Ujs.Z.fromString(o[0])}catch (e4){throw new $(n,"struct address must be valid")}if(!bs(o[1]))throw new $(n,"module name must only contain alphanumeric or '_' characters");if(!bs(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 Ss(n){return typeof n=="boolean"}function it(n){return typeof n=="string"}function Ku(n){return typeof n=="number"}function Dr(n){if(Ku(n))return n;if(it(n)&&n!=="")return Number.parseInt(n,10)}function Nr(n){return typeof n=="number"||typeof n=="bigint"||typeof n=="string"}function Es(n){return n==null}function Ps(n){return Ii(n)||vi(n)||Ki(n)||Ri(n)||Ui(n)||ki(n)||Di(n)||zr(n)||Ci(n)||Ru(n)||n instanceof S||n instanceof Z}function Ii(n){return n instanceof N}function zr(n){return n instanceof _chunkMVCKMP5Ujs.Z}function Ci(n){return n instanceof x}function Ru(n){return n instanceof Ee}function vi(n){return n instanceof Y}function Ki(n){return n instanceof Pe}function Ri(n){return n instanceof _e}function Ui(n){return n instanceof Q}function ki(n){return n instanceof xe}function Di(n){return n instanceof fe}function _s(n){return"bytecode"in n}function D(n,e){throw new Error(`Type mismatch for argument ${e}, expected '${n}'`)}function xs(n){let e=n.params.findIndex(t=>t!=="signer"&&t!=="&signer");return e<0?n.params.length:e}var Uu=new TextEncoder;function sn(n){return _nullishCoalesce(_optionalChain([n, 'optionalAccess', _95 => _95.map, 'call', _96 => _96(e=>it(e)?Re(e):e)]), () => ([]))}async function zi(n,e,t){return(await Fr({aptosConfig:t,accountAddress:n,moduleName:e})).abi}async function Fi(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 Bb(n,e,t,r){let i=await Fi(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 Is(n,e,t,r){let i=await Fi(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=xs(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 Cs(n,e,t,r){let i=await Fi(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 Mb(n,e,t,r,i){return n instanceof _chunkMVCKMP5Ujs.X?n:_chunkMVCKMP5Ujs.X.newBytes(an(e,t,n,r,i).bcsToBytes())}function an(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 Bt(t,s,r,i,"exposed_functions"in e?e:void 0,o)}function Bt(n,e,t,r,i,o){return Ps(n)?(Ni(e,n,t),n):ku(n,e,t,r,i,o)}function ku(n,e,t,r,i,o){if(e.isBool()){if(Ss(n))return new N(n);if(it(n)){if(n==="true")return new N(!0);if(n==="false")return new N(!1)}D("boolean",t)}if(e.isAddress()){if(it(n))return _chunkMVCKMP5Ujs.Z.fromString(n);D("string | AccountAddress",t)}if(e.isU8()){let s=Dr(n);if(s!==void 0)return new Y(s);D("number | string",t)}if(e.isU16()){let s=Dr(n);if(s!==void 0)return new Pe(s);D("number | string",t)}if(e.isU32()){let s=Dr(n);if(s!==void 0)return new _e(s);D("number | string",t)}if(e.isU64()){if(Nr(n))return new Q(BigInt(n));D("bigint | number | string",t)}if(e.isU128()){if(Nr(n))return new xe(BigInt(n));D("bigint | number | string",t)}if(e.isU256()){if(Nr(n))return new fe(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 Bt(n,r[s],t,r,i)}if(e.isVector()){if(e.value.isU8()){if(it(n))return S.U8(Uu.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 Bt(JSON.parse(n),e,t,r);if(Array.isArray(n))return new S(n.map(s=>Bt(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 _chunkMVCKMP5Ujs.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(Es(n)){let a=e.value.typeArgs[0];return a instanceof L?new Z(null):a instanceof F?new Z(null):a instanceof ge?new Z(null):a instanceof Je?new Z(null):a instanceof Xe?new Z(null):a instanceof J?new Z(null):a instanceof Ye?new Z(null):a instanceof Ze?new Z(null):new Z(null)}return new Z(Bt(n,e.value.typeArgs[0],t,r,i))}if(_optionalChain([i, 'optionalAccess', _97 => _97.structs, 'access', _98 => _98.find, 'call', _99 => _99(a=>a.name===e.value.name.identifier), 'optionalAccess', _100 => _100.fields, 'access', _101 => _101.length])===0&&n instanceof Uint8Array)return new Ee(n);if(n instanceof Uint8Array&&_optionalChain([o, 'optionalAccess', _102 => _102.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 Ni(n,e,t){if(n.isBool()){if(Ii(e))return;D("Bool",t)}if(n.isAddress()){if(zr(e))return;D("AccountAddress",t)}if(n.isU8()){if(vi(e))return;D("U8",t)}if(n.isU16()){if(Ki(e))return;D("U16",t)}if(n.isU32()){if(Ri(e))return;D("U32",t)}if(n.isU64()){if(Ui(e))return;D("U64",t)}if(n.isU128()){if(ki(e))return;D("U128",t)}if(n.isU256()){if(Di(e))return;D("U256",t)}if(n.isVector()){if(e instanceof S){e.values.length>0&&Ni(n.value,e.values[0],t);return}D("MoveVector",t)}if(n instanceof A){if(n.isString()){if(Ci(e))return;D("MoveString",t)}if(n.isObject()){if(zr(e))return;D("AccountAddress",t)}if(n.isOption()){if(e instanceof Z){e.value!==void 0&&Ni(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(_s(n))return Fu(n);let{moduleAddress:e,moduleName:t,functionName:r}=_chunkMVCKMP5Ujs.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:Is});return Nu({...n,abi:i})}function Nu(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkMVCKMP5Ujs.la.call(void 0, n.function),o=sn(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)=>an(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=Ut.build(`${t}::${r}`,i,o,s);if("multisigAddress"in n){let c=_chunkMVCKMP5Ujs.Z.from(n.multisigAddress);return new Cn(new Kn(c,new Rn(a)))}return new In(a)}async function Gr(n){let{moduleAddress:e,moduleName:t,functionName:r}=_chunkMVCKMP5Ujs.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:Cs});return zu({abi:i,...n})}function zu(n){let e=n.abi,{moduleAddress:t,moduleName:r,functionName:i}=_chunkMVCKMP5Ujs.la.call(void 0, n.function),o=sn(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', _103 => _103.functionArguments, 'optionalAccess', _104 => _104.map, 'call', _105 => _105((a,c)=>an(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 Ut.build(`${t}::${r}`,i,o,s)}function Fu(n){return new Rt(new vn(_chunkMVCKMP5Ujs.j.fromHexInput(n.bytecode).toUint8Array(),sn(n.typeArguments),n.functionArguments))}async function Oi(n){let{aptosConfig:e,sender:t,payload:r,options:i,feePayerAddress:o}=n,s=async()=>ci[e.network]?{chainId:ci[e.network]}:{chainId:(await xr({aptosConfig:e})).chain_id},a=async()=>_optionalChain([i, 'optionalAccess', _106 => _106.gasUnitPrice])?{gasEstimate:i.gasUnitPrice}:{gasEstimate:(await Ur({aptosConfig:e})).gas_estimate},c=async()=>{let v=async()=>_optionalChain([i, 'optionalAccess', _107 => _107.accountSequenceNumber])!==void 0?i.accountSequenceNumber:(await vr({aptosConfig:e,accountAddress:t})).sequence_number;if(o&&_chunkMVCKMP5Ujs.Z.from(o).equals(_chunkMVCKMP5Ujs.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', _108 => _108.maxGasAmount])?BigInt(i.maxGasAmount):BigInt(2e5),gasUnitPrice:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _109 => _109.gasUnitPrice]), () => (BigInt(l))),expireTimestamp:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _110 => _110.expireTimestamp]), () => (BigInt(Math.floor(Date.now()/1e3)+20)))};return new be(_chunkMVCKMP5Ujs.Z.from(t),BigInt(h),r,BigInt(d),BigInt(g),BigInt(b),new Zt(p))}async function Gi(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', _111 => _111.secondarySignerAddresses, 'optionalAccess', _112 => _112.map, 'call', _113 => _113(c=>_chunkMVCKMP5Ujs.Z.from(c))]), () => ([]));return new Tr(s,a,n.feePayerAddress?_chunkMVCKMP5Ujs.Z.from(n.feePayerAddress):void 0)}return new tn(s,n.feePayerAddress?_chunkMVCKMP5Ujs.Z.from(n.feePayerAddress):void 0)}function vs(n){let{signerPublicKey:e,transaction:t,secondarySignersPublicKeys:r,feePayerPublicKey:i}=n,o=cn(e);if(t.feePayerAddress){let a=new Dt(t.rawTransaction,_nullishCoalesce(t.secondarySignerAddresses, () => ([])),t.feePayerAddress),c=[];t.secondarySignerAddresses&&(r?c=r.map(h=>cn(h)):c=Array.from({length:t.secondarySignerAddresses.length},()=>cn(void 0)));let p=cn(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 kt(t.rawTransaction,t.secondarySignerAddresses),c=[];r?c=r.map(l=>cn(l)):c=Array.from({length:t.secondarySignerAddresses.length},()=>cn(void 0));let p=new zt(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 se||o instanceof Ge)s=new ft(o);else if(o instanceof Yt)s=new ft(o);else throw new Error("Invalid public key");return new tt(t.rawTransaction,s).bcsToBytes()}function cn(n){if(!n)return new Yt;let t=U.isInstance(n)||te.isInstance(n)||$e.isInstance(n)?new z(n):n,r=new K(new Uint8Array(64));if(I.isInstance(t))return new ve(t,r);if(z.isInstance(t))return U.isInstance(t.publicKey)?new se(t,new H(he.getSimulationSignature())):new se(t,new H(r));if(Fe.isInstance(t))return new Ge(t,new Oe({signatures:t.publicKeys.map(i=>U.isInstance(i.publicKey)||te.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 Bi(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 zt(i,e.secondarySignerAddresses,r)}else i instanceof ve?o=new Nt(i.public_key,i.signature):i instanceof je?o=new en(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 Ou=Ks(["APTOS::Transaction"]);function lw(n){let e=Bi(n);return new (0, _chunkMVCKMP5Ujs.j)(Ks([Ou,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 Br=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}=_chunkMVCKMP5Ujs.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=sn(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', _114 => _114.exposed_functions, 'access', _115 => _115.find, 'call', _116 => _116(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', _117 => _117.generic_type_params, 'access', _118 => _118.length])}, received ${s.length}`);let p=e.functionArguments.map((l,h)=>l instanceof _chunkMVCKMP5Ujs.X?l:_chunkMVCKMP5Ujs.X.newBytes(an(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 Gu(n);return Bu(n,e)}async function Gu(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 Bu(n,e){let{aptosConfig:t,sender:r,options:i}=n,o;if(Mu(n)&&(o=_chunkMVCKMP5Ujs.Z.ZERO.toString()),Vu(n)){let{secondarySignerAddresses:s}=n;return Gi({aptosConfig:t,sender:r,payload:e,options:i,secondarySignerAddresses:s,feePayerAddress:o})}return Gi({aptosConfig:t,sender:r,payload:e,options:i,feePayerAddress:o})}function Mu(n){return n.withFeePayer===!0}function Vu(n){return"secondarySignerAddresses"in n}function Us(n){let{transaction:e}=n;return Ke(e)}function Mr(n){let{signer:e,transaction:t}=n;return e.signTransactionWithAuthenticator(t)}function Vr(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,Mr({signer:e,transaction:t})}async function Vi(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', _119 => _119.options, 'optionalAccess', _120 => _120.estimateGasUnitPrice]), () => (!1)),estimate_max_gas_amount:_nullishCoalesce(_optionalChain([n, 'access', _121 => _121.options, 'optionalAccess', _122 => _122.estimateMaxGasAmount]), () => (!1)),estimate_prioritized_gas_unit_price:_nullishCoalesce(_optionalChain([n, 'access', _123 => _123.options, 'optionalAccess', _124 => _124.estimatePrioritizedGasUnitPrice]), () => (!1))},originMethod:"simulateTransaction",contentType:"application/x.aptos.signed_transaction+bcs"});return c}async function Nn(n){let{aptosConfig:e}=n,t=Bi({...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 te)&&await ye.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;Sr(t)&&await t.checkKeylessAccountValidity(e),Sr(r)&&await r.checkKeylessAccountValidity(e);let o=n.feePayerAuthenticator||r&&Vr({signer:r,transaction:i}),s=Mr({signer:t,transaction:i});return Nn({aptosConfig:e,transaction:i,senderAuthenticator:s,feePayerAuthenticator:o})}async function ks(n){let{aptosConfig:e,senderAuthenticator:t,feePayer:r,transaction:i}=n;Sr(r)&&await r.checkKeylessAccountValidity(e);let o=Vr({signer:r,transaction:i});return Nn({aptosConfig:e,transaction:i,senderAuthenticator:t,feePayerAuthenticator:o})}var Hu={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:_chunkMVCKMP5Ujs.Z.from(t),data:{function:"0x1::code::publish_package_txn",functionArguments:[S.U8(r),new S(s)],abi:Hu},options:o})}async function Mt(n){return vr(n)}async function zs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return di({aptosConfig:e,originMethod:"getModules",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _125 => _125.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _126 => _126.limit]), () => (1e3))}})}async function Fs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await mr({aptosConfig:e,originMethod:"getModulesPage",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/modules`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _127 => _127.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _128 => _128.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _129 => _129.limit]), () => (100))}});return{modules:i.data,cursor:o}}async function Fr(n){return ls(n)}async function Os(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return gr({aptosConfig:e,originMethod:"getTransactions",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/transactions`,params:{start:_optionalChain([r, 'optionalAccess', _130 => _130.offset]),limit:_optionalChain([r, 'optionalAccess', _131 => _131.limit])}})}async function Gs(n){let{aptosConfig:e,accountAddress:t,options:r}=n;return di({aptosConfig:e,originMethod:"getResources",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _132 => _132.ledgerVersion]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _133 => _133.limit]), () => (999))}})}async function Bs(n){let{aptosConfig:e,accountAddress:t,options:r}=n,{response:i,cursor:o}=await mr({aptosConfig:e,originMethod:"getResourcesPage",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/resources`,params:{ledger_version:_optionalChain([r, 'optionalAccess', _134 => _134.ledgerVersion]),cursor:_optionalChain([r, 'optionalAccess', _135 => _135.cursor]),limit:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _136 => _136.limit]), () => (100))}});return{resources:i.data,cursor:o}}async function Li(n){let{aptosConfig:e,accountAddress:t,resourceType:r,options:i}=n,{data:o}=await V({aptosConfig:e,originMethod:"getResource",path:`accounts/${_chunkMVCKMP5Ujs.Z.from(t).toString()}/resource/${r}`,params:{ledger_version:_optionalChain([i, 'optionalAccess', _137 => _137.ledgerVersion])}});return o.data}async function un(n){let{aptosConfig:e,authenticationKey:t,options:r}=n,i=await Li({aptosConfig:e,accountAddress:"0x1",resourceType:"0x1::account::OriginatingAddress",options:r}),{address_map:{handle:o}}=i,s=_chunkMVCKMP5Ujs.Z.from(t);try{let a=await Kr({aptosConfig:e,handle:o,data:{key:s.toString(),key_type:"address",value_type:"address"},options:r});return _chunkMVCKMP5Ujs.Z.from(a)}catch(a){if(a instanceof ee&&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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()},amount:{_gt:0}},s=await w({aptosConfig:e,query:{query:Xo,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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()},amount:{_gt:0}};_optionalChain([r, 'optionalAccess', _138 => _138.tokenStandard])&&(o.token_standard={_eq:_optionalChain([r, 'optionalAccess', _139 => _139.tokenStandard])});let s={query:jo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _140 => _140.offset]),limit:_optionalChain([r, 'optionalAccess', _141 => _141.limit]),order_by:_optionalChain([r, 'optionalAccess', _142 => _142.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=_chunkMVCKMP5Ujs.Z.from(t).toStringLong(),s=_chunkMVCKMP5Ujs.Z.from(r).toStringLong(),a={owner_address:{_eq:o},current_token_data:{collection_id:{_eq:s}},amount:{_gt:0}};_optionalChain([i, 'optionalAccess', _143 => _143.tokenStandard])&&(a.token_standard={_eq:_optionalChain([i, 'optionalAccess', _144 => _144.tokenStandard])});let c={query:Jo,variables:{where_condition:a,offset:_optionalChain([i, 'optionalAccess', _145 => _145.offset]),limit:_optionalChain([i, 'optionalAccess', _146 => _146.limit]),order_by:_optionalChain([i, 'optionalAccess', _147 => _147.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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}};_optionalChain([r, 'optionalAccess', _148 => _148.tokenStandard])&&(o.current_collection={token_standard:{_eq:_optionalChain([r, 'optionalAccess', _149 => _149.tokenStandard])}});let s={query:Qo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _150 => _150.offset]),limit:_optionalChain([r, 'optionalAccess', _151 => _151.limit]),order_by:_optionalChain([r, 'optionalAccess', _152 => _152.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=_chunkMVCKMP5Ujs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Yo,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=_chunkMVCKMP5Ujs.Z.from(t).toStringLong(),o={..._optionalChain([r, 'optionalAccess', _153 => _153.where]),owner_address:{_eq:i}},s={query:Wo,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _154 => _154.offset]),limit:_optionalChain([r, 'optionalAccess', _155 => _155.limit]),order_by:_optionalChain([r, 'optionalAccess', _156 => _156.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=_chunkMVCKMP5Ujs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:$o,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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}},s={query:_r,variables:{where_condition:o,offset:_optionalChain([r, 'optionalAccess', _157 => _157.offset]),limit:_optionalChain([r, 'optionalAccess', _158 => _158.limit]),order_by:_optionalChain([r, 'optionalAccess', _159 => _159.orderBy])}};return(await w({aptosConfig:e,query:s,originMethod:"getAccountOwnedObjects"})).current_objects}async function js(n){let{aptosConfig:e,privateKey:t}=n,r=new z(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 Ns({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 Ns({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 Ns(n){let{aptosConfig:e,authKey:t}=n,r=await un({aptosConfig:e,authenticationKey:t.derivedAddress()});try{return await Mt({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 Lu={typeParameters:[],parameters:[new ge,C.u8(),new ge,C.u8(),C.u8(),C.u8()]};async function Js(n){let{aptosConfig:e,fromAccount:t,dangerouslySkipVerification:r}=n;if("toNewPrivateKey"in n)return Hi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toNewPrivateKey});let i;if("toAccount"in n){if(n.toAccount instanceof ae)return Hi({aptosConfig:e,fromAccount:t,toNewPrivateKey:n.toAccount.privateKey});if(n.toAccount instanceof Er)return Hi({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 $u({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 Hi(n){let{aptosConfig:e,fromAccount:t}=n,r=await Mt({aptosConfig:e,accountAddress:t.accountAddress}),i;"toNewPrivateKey"in n?i=nt.fromPrivateKey({privateKey:n.toNewPrivateKey,legacy:!0}):i=n.toAccount;let s=new hr({sequenceNumber:BigInt(r.sequence_number),originator:t.accountAddress,currentAuthKey:_chunkMVCKMP5Ujs.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 Y(t.signingScheme),S.U8(t.publicKey.toUint8Array()),new Y(i.signingScheme),S.U8(i.publicKey.toUint8Array()),S.U8(a.toUint8Array()),S.U8(c.toUint8Array())],abi:Lu}});return ht({aptosConfig:e,signer:t,transaction:p})}var qu={typeParameters:[],parameters:[C.u8()]};async function $u(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:qu}});return ht({aptosConfig:e,signer:t,transaction:o})}async function E(n){n.minimumLedgerVersion!==void 0&&await kr({aptosConfig:n.config,minimumLedgerVersion:n.minimumLedgerVersion,processorType:n.processorType})}async function ce(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Gr({...t,aptosConfig:e}),o=new _chunkMVCKMP5Ujs.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', _160 => _160.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', _161 => _161.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}=_chunkMVCKMP5Ujs.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}=_chunkMVCKMP5Ujs.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 Vt=class{constructor(e){this.config=e;this.isAccountAbstractionEnabled=async e=>{let t=await this.getAuthenticationFunction(e),{moduleAddress:r,moduleName:i,functionName:o}=_chunkMVCKMP5Ujs.la.call(void 0, e.authenticationFunction);return _nullishCoalesce(_optionalChain([t, 'optionalAccess', _162 => _162.some, 'call', _163 => _163(s=>_chunkMVCKMP5Ujs.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 ce({aptosConfig:this.config,payload:{function:"0x1::account_abstraction::dispatchable_authenticator",functionArguments:[_chunkMVCKMP5Ujs.Z.from(t)],abi:{typeParameters:[],parameters:[new F],returnTypes:[]}}});if(r.length!==0)return r[0].map(i=>({moduleAddress:_chunkMVCKMP5Ujs.Z.fromString(i.module_address),moduleName:i.module_name,functionName:i.function_name}))}};var zn=class{constructor(e){this.config=e;this.abstraction=new Vt(e)}async getAccountInfo(e){return Mt({aptosConfig:this.config,...e})}async getAccountModules(e){return zs({aptosConfig:this.config,...e})}async getAccountModulesPage(e){return Fs({aptosConfig:this.config,...e})}async getAccountModule(e){return Fr({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 Li({aptosConfig:this.config,...e})}async lookupOriginalAccountAddress(e){return un({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 ke(async()=>{try{let p=(await ce({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunk5GUWOXQGjs.ha.call(void 0, p.vec[0]))return _chunk5GUWOXQGjs.ga.call(void 0, p.vec[0])}catch (e5){}},`coin-mapping-${i.toString()}`,1e3*60*5)());let a;if(r!==void 0&&i!==void 0)a=_chunk5GUWOXQGjs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===xt?a=_chunk5GUWOXQGjs.Z.A.toStringLong():a=yr(_chunk5GUWOXQGjs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let p=_chunk5GUWOXQGjs.Z.from(i);a=p.toStringLong(),p===_chunk5GUWOXQGjs.Z.A&&(s=xt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await ce({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await ce({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"}),Ws({aptosConfig:this.config,...e})}async deriveAccountFromPrivateKey(e){return Qs({aptosConfig:this.config,...e})}};var _aptosclient = require('@aptos-labs/aptos-client'); var _aptosclient2 = _interopRequireDefault(_aptosclient);var Hr=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,binaryProvider:_aptosclient.bcsRequest})),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 So[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 Eo[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 wo[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 ii[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 oi[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return ii[this.network]===e}isProverServiceRequest(e){return oi[this.network]===e}};var ju={typeParameters:[{constraints:[]}],parameters:[new F,new J]};async function ea(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:ju},options:s})}var Fn=class{constructor(e){this.config=e}async transferCoinTransaction(e){return ea({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>"},we="0x4::token::Token";async function ta(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:us,variables:{where_condition:r}},originMethod:"getDigitalAssetData"})).current_token_datas_v2[0]}async function na(n){let{aptosConfig:e,digitalAssetAddress:t}=n,r={token_data_id:{_eq:_chunk5GUWOXQGjs.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 ra(n){let{aptosConfig:e,ownerAddress:t,options:r}=n,i={owner_address:{_eq:_chunk5GUWOXQGjs.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 ia(n){let{aptosConfig:e,digitalAssetAddress:t,options:r}=n,i={token_data_id:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()}},o={query:cs,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 Ju={typeParameters:[],parameters:[new A(_()),new J,new A(_()),new A(_()),new H,new H,new H,new H,new H,new H,new H,new H,new H,new J,new J]};async function oa(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, () => (_chunk5GUWOXQGjs.e))),new x(n.name),new x(n.uri),new D(_nullishCoalesce(n.mutableDescription, () => (!0))),new D(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new D(_nullishCoalesce(n.mutableURI, () => (!0))),new D(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new D(_nullishCoalesce(n.mutableTokenName, () => (!0))),new D(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new D(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new D(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new D(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(n.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Ju},options:t})}async function pn(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:es,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 sa(n){let{aptosConfig:e,creatorAddress:t,collectionName:r,options:i}=n,o=_chunk5GUWOXQGjs.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"))}),pn({aptosConfig:e,options:{...i,where:s}})}async function aa(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _175 => _175.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _176 => _176.tokenStandard]), () => ("v2"))}),pn({aptosConfig:e,options:{...r,where:o}})}async function ca(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _177 => _177.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _178 => _178.tokenStandard]), () => ("v2"))}),pn({aptosConfig:e,options:{...r,where:o}})}async function ua(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunk5GUWOXQGjs.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 pn({aptosConfig:i,options:{where:s}})).collection_id}var Xu={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new v(new A(_())),new v(new A(_())),new v(v.u8())]};async function pa(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, () => ([]))),Pa(_nullishCoalesce(l, () => ([])),_nullishCoalesce(h, () => ([])))],abi:Xu},options:t})}var Yu={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new F]};async function da(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(r),_chunk5GUWOXQGjs.Z.from(i)],abi:Yu},options:s})}var Zu={typeParameters:[],parameters:[new A(_()),new A(_()),new A(_()),new A(_()),new v(new A(_())),new v(new A(_())),new v(v.u8()),new F]};async function la(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, () => ([]))),Pa(_nullishCoalesce(l, () => ([])),_nullishCoalesce(d, () => ([]))),a],abi:Zu},options:h})}var ep={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0)))]};async function ga(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(r)],abi:ep},options:o})}var tp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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::freeze_transfer",typeArguments:[_nullishCoalesce(i, () => (we))],functionArguments:[r],abi:tp},options:o})}var np={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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::unfreeze_transfer",typeArguments:[_nullishCoalesce(i, () => (we))],functionArguments:[r],abi:np},options:o})}var rp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new A(_())]};async function fa(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(i),new x(r)],abi:rp},options:s})}var ip={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new A(_())]};async function Aa(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(i),new x(r)],abi:ip},options:s})}var op={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new A(_())]};async function ha(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(i),new x(r)],abi:op},options:s})}var sp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new A(_()),new A(_()),v.u8()]};async function Ta(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(s),new x(r),new x(Tt[i]),S.U8(Li(o,Tt[i]))],abi:sp},options:c})}var ap={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new A(_())]};async function ba(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(i),new x(r)],abi:ap},options:s})}var cp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(new G(0))),new A(_()),new A(_()),v.u8()]};async function wa(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, () => (we))],functionArguments:[_chunk5GUWOXQGjs.Z.from(s),new x(r),new x(Tt[i]),Li(o,Tt[i])],abi:cp},options:c})}var up={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(me(new G(0))),new A(_()),new G(1)]};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::add_typed_property",typeArguments:[_nullishCoalesce(a, () => (we)),Tt[i]],functionArguments:[_chunk5GUWOXQGjs.Z.from(s),new x(r),o],abi:up},options:c})}var pp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(me(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::update_typed_property",typeArguments:[_nullishCoalesce(a, () => (we)),Tt[i]],functionArguments:[_chunk5GUWOXQGjs.Z.from(s),new x(r),o],abi:pp},options:c})}function Pa(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(Li(n[i],r))}),t}function Li(n,e){let t=Ke(e);return Bt(n,t,0,[]).bcsToBytes()}var On=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=_chunk5GUWOXQGjs.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"))}),pn({aptosConfig:this.config,options:{where:s}})}async getCollectionDataByCreatorAddressAndCollectionName(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),sa({aptosConfig:this.config,...e})}async getCollectionDataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),aa({aptosConfig:this.config,...e})}async getCollectionDataByCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ca({aptosConfig:this.config,...e})}async getCollectionId(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ua({aptosConfig:this.config,...e})}async getDigitalAssetData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ta({aptosConfig:this.config,...e})}async getCurrentDigitalAssetOwnership(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),na({aptosConfig:this.config,...e})}async getOwnedDigitalAssets(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ra({aptosConfig:this.config,...e})}async getDigitalAssetActivity(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"token_v2_processor"}),ia({aptosConfig:this.config,...e})}async createCollectionTransaction(e){return oa({aptosConfig:this.config,...e})}async mintDigitalAssetTransaction(e){return pa({aptosConfig:this.config,...e})}async transferDigitalAssetTransaction(e){return da({aptosConfig:this.config,...e})}async mintSoulBoundTransaction(e){return la({aptosConfig:this.config,...e})}async burnDigitalAssetTransaction(e){return ga({aptosConfig:this.config,...e})}async freezeDigitalAssetTransaferTransaction(e){return ma({aptosConfig:this.config,...e})}async unfreezeDigitalAssetTransaferTransaction(e){return ya({aptosConfig:this.config,...e})}async setDigitalAssetDescriptionTransaction(e){return fa({aptosConfig:this.config,...e})}async setDigitalAssetNameTransaction(e){return Aa({aptosConfig:this.config,...e})}async setDigitalAssetURITransaction(e){return ha({aptosConfig:this.config,...e})}async addDigitalAssetPropertyTransaction(e){return Ta({aptosConfig:this.config,...e})}async removeDigitalAssetPropertyTransaction(e){return ba({aptosConfig:this.config,...e})}async updateDigitalAssetPropertyTransaction(e){return wa({aptosConfig:this.config,...e})}async addDigitalAssetTypedPropertyTransaction(e){return Sa({aptosConfig:this.config,...e})}async updateDigitalAssetTypedPropertyTransaction(e){return Ea({aptosConfig:this.config,...e})}};var _a=300,dp=n=>{if(n&&n.length>_a)throw new Error(`Event type length exceeds the maximum length of ${_a}`)};async function xa(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 Gn({aptosConfig:e,options:{...r,where:i}})}async function Ia(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunk5GUWOXQGjs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Gn({aptosConfig:t,options:{...i,where:s}})}async function va(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunk5GUWOXQGjs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Gn({aptosConfig:t,options:{...i,where:s}})}async function Gn(n){let{aptosConfig:e,options:t}=n;dp(_optionalChain([t, 'optionalAccess', _191 => _191.where, 'optionalAccess', _192 => _192.indexed_type, 'optionalAccess', _193 => _193._eq]));let r={query:rs,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 Bn=class{constructor(e){this.config=e}async getModuleEventsByEventType(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),xa({aptosConfig:this.config,...e})}async getAccountEventsByCreationNumber(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"events_processor"}),Ia({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"}),Gn({aptosConfig:this.config,...e})}};async function Ca(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:_chunk5GUWOXQGjs.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 Mn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ca({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 kr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Lr(n){let{aptosConfig:e,options:t}=n,r={query:os,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 Ka(n){let{aptosConfig:e,options:t}=n,r={query:is,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 Ra(n){let{aptosConfig:e,options:t}=n,r={query:ts,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 lp={typeParameters:[{constraints:[]}],parameters:[Ke("0x1::object::Object"),new F,new J]};async function Ua(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:lp},options:s})}var Vn=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"}),Lr({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 Lr({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 Lr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunk5GUWOXQGjs.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"}),Ka({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _218 => _218.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ra({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return Ua({aptosConfig:this.config,...e})}};var Hn=class{constructor(e){this.config=e}async getLedgerInfo(){return xr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return hs({aptosConfig:this.config,...e})}async getBlockByHeight(e){return Ts({aptosConfig:this.config,...e})}async view(e){return ce({aptosConfig:this.config,...e})}async viewJson(e){return Js({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return ps({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Ir({aptosConfig:this.config})}async getProcessorStatus(e){return vr({aptosConfig:this.config,processorType:e})}};var ka=["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 Da(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(!Da(e))throw new Error(`${e} is not valid. ${ka}`);if(t&&!Da(t))throw new Error(`${t} is not valid. ${ka}`);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 gp="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",mp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:gp,custom:null,devnet:null};function ot(n){let e=mp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var qr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function za(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ce({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=qr(s[0]);return a?_chunk5GUWOXQGjs.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 ce({aptosConfig:e,payload:{function:`${r}::router::get_expiration`,functionArguments:[i,o]}});return Number(s[0])*1e3}catch (e6){return}}async function Oa(n){let{aptosConfig:e,address:t}=n,r=ot(e),i=await ce({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunk5GUWOXQGjs.Z.from(t).toString()]}}),o=qr(i[1]),s=qr(i[0]);if(o)return[s,o].filter(Boolean).join(".")}async function Ga(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 Ba(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ce({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=qr(s[0]);return a?_chunk5GUWOXQGjs.Z.from(a):void 0}async function Ma(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 Va(n){let{aptosConfig:e,name:t}=n,{domainName:r,subdomainName:i=""}=bt(t),a=(await w({aptosConfig:e,query:{query:on,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Ln(a)),Na(a)?a:void 0}async function Ha(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:on,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(Ln)}async function La(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await $i({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:on,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(Ln)}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:on,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(Ln)}async function $a(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:on,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(Ln).filter(Na)}async function $i(n){let{aptosConfig:e}=n,t=ot(e),[r]=await ce({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 Wa(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 Ln(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var qn=class{constructor(e){this.config=e}async getOwnerAddress(e){return za({aptosConfig:this.config,...e})}async getExpiration(e){return qi({aptosConfig:this.config,...e})}async getTargetAddress(e){return Ba({aptosConfig:this.config,...e})}async setTargetAddress(e){return Ma({aptosConfig:this.config,...e})}async getPrimaryName(e){return Oa({aptosConfig:this.config,...e})}async setPrimaryName(e){return Ga({aptosConfig:this.config,...e})}async registerName(e){return Fa({aptosConfig:this.config,...e})}async renewDomain(e){return Wa({aptosConfig:this.config,...e})}async getName(e){return Va({aptosConfig:this.config,...e})}async getAccountNames(e){return Ha({aptosConfig:this.config,...e})}async getAccountDomains(e){return La({aptosConfig:this.config,...e})}async getAccountSubdomains(e){return qa({aptosConfig:this.config,...e})}async getDomainSubdomains(e){return $a({aptosConfig:this.config,...e})}};async function Qa(n){let{aptosConfig:e,poolAddress:t}=n,r=_chunk5GUWOXQGjs.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 Ja(n){let{aptosConfig:e,delegatorAddress:t,poolAddress:r}=n,i={query:ns,variables:{delegatorAddress:_chunk5GUWOXQGjs.Z.from(t).toStringLong(),poolAddress:_chunk5GUWOXQGjs.Z.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var $n=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"}),Qa({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"}),Ja({aptosConfig:this.config,...e})}};var $r=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Br(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Fi({aptosConfig:this.config,payload:Rt.load(new R(i)),...e});return new tn(o,e.withFeePayer===!0?_chunk5GUWOXQGjs.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 dn=class{constructor(e){this.config=e}async simple(e){return Mi({aptosConfig:this.config,...e})}async multiAgent(e){return Mi({aptosConfig:this.config,...e})}};_chunk5GUWOXQGjs.a.call(void 0, [Qi],dn.prototype,"simple",1),_chunk5GUWOXQGjs.a.call(void 0, [Qi],dn.prototype,"multiAgent",1);var ln=class{constructor(e){this.config=e}async simple(e){return Nn({aptosConfig:this.config,...e})}async multiAgent(e){return Nn({aptosConfig:this.config,...e})}};_chunk5GUWOXQGjs.a.call(void 0, [Wi],ln.prototype,"simple",1),_chunk5GUWOXQGjs.a.call(void 0, [Wi],ln.prototype,"multiAgent",1);var Wr=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 _chunk5GUWOXQGjs._.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=_chunk5GUWOXQGjs.aa.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunk5GUWOXQGjs._.call(void 0, this.sleepTime),_chunk5GUWOXQGjs.aa.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 Mt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Mt({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 _chunk5GUWOXQGjs._.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunk5GUWOXQGjs.aa.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunk5GUWOXQGjs.aa.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 _chunk5GUWOXQGjs._.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 gn=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 mn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},mn=class extends Error{};var Xa="fulfilled",Ya= exports.TransactionWorkerEventsEnum =(o=>(o.TransactionSent="transactionSent",o.TransactionSendFailed="transactionSendFailed",o.TransactionExecuted="transactionExecuted",o.TransactionExecutionFailed="transactionExecutionFailed",o.ExecutionFinish="executionFinish",o))(Ya||{}),Qr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new gn;this.transactionsQueue=new gn;this.outstandingTransactions=new gn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Wr(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 mn)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===Xa?(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 mn)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===Xa?(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 jr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new Qr(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 Wn=class{constructor(e){this.config=e,this.build=new $r(this.config),this.simulate=new dn(this.config),this.submit=new ln(this.config),this.batch=new jr(this.config)}async getTransactions(e){return _i({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return fs({aptosConfig:this.config,...e})}async getTransactionByHash(e){return kn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return As({aptosConfig:this.config,...e})}async waitForTransaction(e){return At({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Ur({aptosConfig:this.config})}getSigningMessage(e){return ks(e)}async publishPackageTransaction(e){return Ns({aptosConfig:this.config,...e})}async rotateAuthKey(e){return js({aptosConfig:this.config,...e})}sign(e){return Mr({...e})}signAsFeePayer(e){return Vr({...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 Ds({aptosConfig:this.config,...e})}};var Qn=class{constructor(e){this.config=e}async getTableItem(e){return Kr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ms({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ys({aptosConfig:this.config,...e})}};async function Jr(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:_chunk5GUWOXQGjs.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 _chunk5GUWOXQGjs.j.fromHexInput(a.pepper).toUint8Array()}async function ji(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Jr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await jt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunk5GUWOXQGjs.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:_chunk5GUWOXQGjs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunk5GUWOXQGjs.j.fromHexInput(i).toStringWithoutPrefix(),uid_key:o},{data:p}=await No({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 pe({proof:new Qt(h,0),trainingWheelsSignature:Re.fromHex(p.training_wheels_signature),expHorizonSecs:s})}async function Za(n){let{aptosConfig:e,jwt:t,jwkAddress:r,uidKey:i,proofFetchCallback:o,pepper:s=await Jr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await jt({aptosConfig:e}),p=ji({...n,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(r!==void 0){let g=te.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await un({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Gt.create({...n,address:b,proof:l,pepper:s,proofFetchCallback:o,jwkAddress:r,verificationKey:a})}let h=N.fromJwtAndPepper({jwt:t,pepper:s,uidKey:i}),d=await un({aptosConfig:e,authenticationKey:h.authKey().derivedAddress()});return rt.create({...n,address:d,proof:l,pepper:s,proofFetchCallback:o,verificationKey:a})}async function ec(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 jn=class{constructor(e){this.config=e}async getPepper(e){return Jr({aptosConfig:this.config,...e})}async getProof(e){return ji({aptosConfig:this.config,...e})}async deriveKeylessAccount(e){return Za({aptosConfig:this.config,...e})}async updateFederatedKeylessJwkSetTransaction(e){return ec({aptosConfig:this.config,...e})}};async function hp(n){let{aptosConfig:e,options:t}=n,r={query:_r,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 tc(n){let{aptosConfig:e,objectAddress:t,options:r}=n,o={object_address:{_eq:_chunk5GUWOXQGjs.Z.from(t).toStringLong()}};return(await hp({aptosConfig:e,options:{...r,where:o}}))[0]}var Jn=class{constructor(e){this.config=e}async getObjectDataByObjectAddress(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"objects_processor"}),tc({aptosConfig:this.config,...e})}};async function nc(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Gr({...t,aptosConfig:e}),o=new _chunk5GUWOXQGjs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Ro({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",acceptType:"application/x-bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _252 => _252.ledgerVersion])},body:s}),c=new Uint8Array(a);return _optionalChain([r, 'optionalAccess', _253 => _253.convert])?r.convert(c):c}var Xn=class{constructor(e){this.config=e}async viewBinary(e){return nc({...e,aptosConfig:this.config})}};var X=class{constructor(e){this.config=new Hr(e),this.account=new zn(this.config),this.abstraction=new Vt(this.config),this.ans=new qn(this.config),this.coin=new Fn(this.config),this.digitalAsset=new On(this.config),this.event=new Bn(this.config),this.experimental=new Xn(this.config),this.faucet=new Mn(this.config),this.fungibleAsset=new Vn(this.config),this.general=new Hn(this.config),this.staking=new $n(this.config),this.transaction=new Wn(this.config),this.table=new Qn(this.config),this.keyless=new jn(this.config),this.object=new Jn(this.config)}};function re(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))})}re(X,zn,"account");re(X,Vt,"abstraction");re(X,qn,"ans");re(X,Fn,"coin");re(X,On,"digitalAsset");re(X,Bn,"event");re(X,Xn,"experimental");re(X,Mn,"faucet");re(X,Vn,"fungibleAsset");re(X,Hn,"general");re(X,$n,"staking");re(X,Wn,"transaction");re(X,Qn,"table");re(X,jn,"keyless");re(X,Jn,"object");exports.APTOS_BIP44_REGEX = fc; exports.APTOS_COIN = xt; exports.APTOS_FA = xo; exports.APTOS_HARDENED_REGEX = yc; exports.AbstractKeylessAccount = ye; exports.AbstractMultiKey = Pn; exports.AbstractPublicKey = ir; exports.AbstractSignature = An; exports.AbstractedAccount = qo; exports.Account = nt; exports.AccountAddress = _chunk5GUWOXQGjs.Z; exports.AccountAuthenticator = j; exports.AccountAuthenticatorAbstraction = _n; exports.AccountAuthenticatorEd25519 = ve; exports.AccountAuthenticatorMultiEd25519 = je; exports.AccountAuthenticatorMultiKey = Oe; exports.AccountAuthenticatorNoAccountAuthenticator = Yt; exports.AccountAuthenticatorSingleKey = se; exports.AccountAuthenticatorVariant = _chunk5GUWOXQGjs.w; exports.AccountPublicKey = oe; exports.AccountSequenceNumber = Wr; exports.AccountUtils = Ho; exports.AddressInvalidReason = _chunk5GUWOXQGjs.Y; exports.AnyPublicKey = z; exports.AnyPublicKeyVariant = _chunk5GUWOXQGjs.y; exports.AnySignature = q; exports.AnySignatureVariant = _chunk5GUWOXQGjs.z; exports.Aptos = X; exports.AptosApiError = ee; exports.AptosApiType = _t; exports.AptosConfig = Hr; exports.AptosScriptComposer = Br; exports.AuthenticationKey = B; exports.Bool = D; exports.CKDPriv = Ao; exports.CallArgument = _chunk5GUWOXQGjs.X; exports.ChainId = Zt; exports.DEFAULT_MAX_GAS_AMOUNT = Po; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = _o; exports.DEFAULT_TXN_TIMEOUT_SEC = cr; exports.DeriveScheme = _chunk5GUWOXQGjs.W; exports.Deserializer = R; exports.EPK_HORIZON_SECS = Zc; exports.Ed25519Account = ae; exports.Ed25519PrivateKey = L; exports.Ed25519PublicKey = I; exports.Ed25519Signature = K; exports.EntryFunction = Ut; exports.EntryFunctionBytes = rr; exports.EphemeralCertificate = Wt; exports.EphemeralCertificateVariant = _chunk5GUWOXQGjs.C; exports.EphemeralKeyPair = Ot; exports.EphemeralPublicKey = lt; exports.EphemeralPublicKeyVariant = _chunk5GUWOXQGjs.A; exports.EphemeralSignature = Re; exports.EphemeralSignatureVariant = _chunk5GUWOXQGjs.B; exports.FIREBASE_AUTH_ISS_PATTERN = vo; exports.FederatedKeylessAccount = Gt; exports.FederatedKeylessPublicKey = te; exports.FeePayerRawTransaction = Dt; exports.FixedBytes = Se; exports.Groth16ProofAndStatement = gi; exports.Groth16VerificationKey = yi; exports.Groth16Zkp = mt; exports.HARDENED_OFFSET = mo; exports.Hex = _chunk5GUWOXQGjs.j; exports.HexInvalidReason = _chunk5GUWOXQGjs.i; exports.Identifier = U; exports.KeyType = Ac; exports.KeylessAccount = rt; exports.KeylessConfiguration = mi; exports.KeylessError = P; exports.KeylessErrorCategory = Vc; exports.KeylessErrorResolutionTip = Hc; exports.KeylessErrorType = ur; exports.KeylessPublicKey = N; exports.KeylessSignature = Ne; exports.MAX_AUD_VAL_BYTES = di; exports.MAX_COMMITED_EPK_BYTES = ou; exports.MAX_EXTRA_FIELD_BYTES = ru; exports.MAX_ISS_VAL_BYTES = nu; exports.MAX_JWT_HEADER_B64_BYTES = iu; exports.MAX_UID_KEY_BYTES = eu; exports.MAX_UID_VAL_BYTES = tu; exports.MimeType = _chunk5GUWOXQGjs.q; exports.ModuleId = xn; exports.MoveAbility = _chunk5GUWOXQGjs.S; exports.MoveFunctionVisibility = _chunk5GUWOXQGjs.R; exports.MoveJWK = fi; exports.MoveOption = Z; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = kt; exports.MultiAgentTransaction = Tr; exports.MultiEd25519Account = Er; exports.MultiEd25519PublicKey = Xt; exports.MultiEd25519Signature = Qe; exports.MultiKey = Fe; exports.MultiKeyAccount = Un; exports.MultiKeySignature = We; exports.MultiSig = Kn; exports.MultiSigTransactionPayload = Rn; exports.Network = si; exports.NetworkToChainId = ai; exports.NetworkToFaucetAPI = Eo; exports.NetworkToIndexerAPI = wo; exports.NetworkToNetworkName = Il; exports.NetworkToNodeAPI = So; exports.NetworkToPepperAPI = ii; exports.NetworkToProverAPI = oi; exports.ParsingError = _chunk5GUWOXQGjs.h; exports.PrivateKey = pt; exports.PrivateKeyVariants = _chunk5GUWOXQGjs.x; exports.ProcessorType = Ve; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Io; exports.RAW_TRANSACTION_WITH_DATA_SALT = ci; exports.RawTransaction = Te; exports.RawTransactionWithData = Ar; exports.RoleType = _chunk5GUWOXQGjs.T; exports.RotationProofChallenge = hr; exports.Script = Cn; exports.ScriptTransactionArgumentVariants = _chunk5GUWOXQGjs.s; exports.Secp256k1PrivateKey = $e; exports.Secp256k1PublicKey = qe; exports.Secp256k1Signature = vt; exports.Serializable = _chunk5GUWOXQGjs.l; exports.Serialized = fn; exports.Serializer = _chunk5GUWOXQGjs.m; exports.Signature = M; exports.SignedTransaction = tt; exports.SigningScheme = _chunk5GUWOXQGjs.U; exports.SigningSchemeInput = _chunk5GUWOXQGjs.V; exports.SimpleTransaction = tn; exports.SingleKeyAccount = be; exports.StructTag = Ge; exports.TransactionAndProof = wr; exports.TransactionAuthenticator = et; exports.TransactionAuthenticatorEd25519 = Nt; exports.TransactionAuthenticatorFeePayer = Ft; exports.TransactionAuthenticatorMultiAgent = zt; exports.TransactionAuthenticatorMultiEd25519 = en; exports.TransactionAuthenticatorSingleSender = ft; exports.TransactionAuthenticatorVariant = _chunk5GUWOXQGjs.v; exports.TransactionPayload = Kt; exports.TransactionPayloadEntryFunction = In; exports.TransactionPayloadMultiSig = vn; exports.TransactionPayloadScript = Rt; exports.TransactionPayloadVariants = _chunk5GUWOXQGjs.t; exports.TransactionResponseType = _chunk5GUWOXQGjs.E; exports.TransactionVariants = _chunk5GUWOXQGjs.u; exports.TransactionWorker = Qr; exports.TransactionWorkerEventsEnum = Ya; exports.TypeTag = O; exports.TypeTagAddress = F; exports.TypeTagBool = H; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = Cu; exports.TypeTagReference = fr; exports.TypeTagSigner = Ct; exports.TypeTagStruct = A; exports.TypeTagU128 = Ye; exports.TypeTagU16 = Je; exports.TypeTagU256 = Ze; exports.TypeTagU32 = Xe; exports.TypeTagU64 = J; exports.TypeTagU8 = ge; exports.TypeTagVariants = _chunk5GUWOXQGjs.r; exports.TypeTagVector = v; exports.U128 = _e; exports.U16 = Ee; exports.U256 = fe; exports.U32 = Pe; exports.U64 = Q; exports.U8 = Y; exports.ZeroKnowledgeSig = pe; exports.ZkProof = Qt; exports.ZkpVariant = _chunk5GUWOXQGjs.D; exports.aptosBinaryRequest = dr; exports.aptosCoinStructTag = nf; exports.aptosRequest = pr; exports.base64UrlDecode = _chunk5GUWOXQGjs.ca; exports.base64UrlToBytes = _chunk5GUWOXQGjs.da; exports.bigIntToBytesLE = ni; exports.binaryRequest = Wc; exports.buildTransaction = Oi; exports.bytesToBigIntLE = Et; exports.checkOrConvertArgument = Bt; exports.convertAmountFromHumanReadableToOnChain = _chunk5GUWOXQGjs.ea; exports.convertAmountFromOnChainToHumanReadable = _chunk5GUWOXQGjs.fa; exports.convertArgument = an; exports.convertCallArgument = Vb; exports.convertNumber = Dr; exports.createObjectAddress = yr; exports.createResourceAddress = dy; exports.createTokenAddress = ly; exports.deriveKey = Zr; exports.deriveTransactionType = br; exports.deserializeFromScriptArgument = mu; exports.ensureBoolean = _chunk5GUWOXQGjs.n; exports.fetchEntryFunctionAbi = vs; exports.fetchFunctionAbi = zi; exports.fetchJWK = Ti; exports.fetchModuleAbi = Ni; exports.fetchMoveFunctionAbi = Mb; exports.fetchViewFunctionAbi = Cs; exports.findFirstNonSignerArg = Is; exports.floorToWholeHour = _chunk5GUWOXQGjs.ba; exports.generateRawTransaction = Fi; exports.generateSignedTransaction = Gi; exports.generateSignedTransactionForSimulation = Ks; exports.generateSigningMessage = yt; exports.generateSigningMessageForSerializable = yA; exports.generateSigningMessageForTransaction = Ce; exports.generateTransactionPayload = Or; exports.generateTransactionPayloadWithABI = Nu; exports.generateUserTransactionHash = gw; exports.generateViewFunctionPayload = Gr; exports.generateViewFunctionPayloadWithABI = zu; exports.get = lr; exports.getAptosFullNode = V; exports.getAptosPepperService = tg; exports.getAuthenticatorForSimulation = cn; exports.getBinary = Qc; exports.getBinaryAptosFullNode = eg; exports.getErrorMessage = _chunk5GUWOXQGjs.$; exports.getFunctionParts = _chunk5GUWOXQGjs.ia; exports.getIssAudAndUidVal = Le; exports.getKeylessConfig = jt; exports.getKeylessJWKs = uu; exports.hashStrToField = Ue; exports.hashValues = Rs; exports.hexToAsciiString = _chunk5GUWOXQGjs.k; exports.isBcsAddress = zr; exports.isBcsBool = xi; exports.isBcsFixedBytes = Ru; exports.isBcsString = Ii; exports.isBcsU128 = Ui; exports.isBcsU16 = Ci; exports.isBcsU256 = ki; exports.isBcsU32 = Ki; exports.isBcsU64 = Ri; exports.isBcsU8 = vi; exports.isBlockEpilogueTransactionResponse = _chunk5GUWOXQGjs.L; exports.isBlockMetadataTransactionResponse = _chunk5GUWOXQGjs.I; exports.isBool = Es; exports.isCanonicalEd25519Signature = Tc; exports.isEd25519Signature = _chunk5GUWOXQGjs.M; exports.isEmptyOption = Ps; exports.isEncodedEntryFunctionArgument = _s; exports.isEncodedStruct = _chunk5GUWOXQGjs.ha; exports.isFeePayerSignature = _chunk5GUWOXQGjs.P; exports.isGenesisTransactionResponse = _chunk5GUWOXQGjs.H; exports.isKeylessSigner = Sr; exports.isLargeNumber = Nr; exports.isMultiAgentSignature = _chunk5GUWOXQGjs.O; exports.isMultiEd25519Signature = _chunk5GUWOXQGjs.Q; exports.isNumber = Ku; exports.isPendingTransactionResponse = _chunk5GUWOXQGjs.F; exports.isScriptDataInput = xs; exports.isSecp256k1Signature = _chunk5GUWOXQGjs.N; exports.isSingleKeySigner = bi; exports.isStateCheckpointTransactionResponse = _chunk5GUWOXQGjs.J; exports.isString = it; exports.isUserTransactionResponse = _chunk5GUWOXQGjs.G; exports.isValidBIP44Path = yo; exports.isValidFunctionInfo = _chunk5GUWOXQGjs.ja; exports.isValidHardenedPath = fo; exports.isValidatorTransactionResponse = _chunk5GUWOXQGjs.K; exports.mnemonicToSeed = or; exports.normalizeBundle = Co; exports.nowInSeconds = _chunk5GUWOXQGjs.aa; exports.objectStructTag = me; exports.optionStructTag = rf; exports.outOfRangeErrorMessage = _chunk5GUWOXQGjs.o; exports.padAndPackBytesWithLen = Tn; exports.paginateWithCursor = gr; exports.paginateWithObfuscatedCursor = mr; exports.parseEncodedStruct = _chunk5GUWOXQGjs.ga; exports.parseJwtHeader = du; exports.parseTypeTag = Ke; exports.poseidonHash = Pt; exports.post = bn; exports.postAptosFaucet = ko; exports.postAptosFullNode = gt; exports.postAptosIndexer = Uo; exports.postAptosPepperService = Do; exports.postAptosProvingService = No; exports.postBinary = jc; exports.postBinaryAptosFullNode = Ro; exports.promiseFulfilledStatus = Xa; exports.request = $c; exports.sleep = _chunk5GUWOXQGjs._; exports.splitPath = ho; exports.standardizeTypeTags = sn; exports.stringStructTag = _; exports.throwTypeMismatch = k; exports.truncateAddress = _chunk5GUWOXQGjs.ka; exports.validateNumberInRange = _chunk5GUWOXQGjs.p; exports.verifyKeylessSignature = Ai; exports.verifyKeylessSignatureWithJwkAndConfig = hi;
|
|
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 ce({aptosConfig:this.config,payload:{function:"0x1::coin::paired_coin",functionArguments:[i]}})).at(0);if(p.vec.length>0&&_chunkMVCKMP5Ujs.ka.call(void 0, p.vec[0]))return _chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.Z.from(i).toStringLong();else if(r!==void 0&&i===void 0)r===xt?a=_chunkMVCKMP5Ujs.Z.A.toStringLong():a=_chunkMVCKMP5Ujs._.call(void 0, _chunkMVCKMP5Ujs.Z.A,r).toStringLong();else if(r===void 0&&i!==void 0){let p=_chunkMVCKMP5Ujs.Z.from(i);a=p.toStringLong(),p===_chunkMVCKMP5Ujs.Z.A&&(s=xt)}else throw new Error("Either coinType, faMetadataAddress, or both must be provided");if(s!==void 0){let[p]=await ce({aptosConfig:this.config,payload:{function:"0x1::coin::balance",typeArguments:[s],functionArguments:[t]}});return parseInt(p,10)}let[c]=await ce({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 Hr=class{constructor(e){this.network=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _164 => _164.network]), () => ("devnet")),this.fullnode=_optionalChain([e, 'optionalAccess', _165 => _165.fullnode]),this.faucet=_optionalChain([e, 'optionalAccess', _166 => _166.faucet]),this.pepper=_optionalChain([e, 'optionalAccess', _167 => _167.pepper]),this.prover=_optionalChain([e, 'optionalAccess', _168 => _168.prover]),this.indexer=_optionalChain([e, 'optionalAccess', _169 => _169.indexer]),this.client=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _170 => _170.client]), () => ({provider:_aptosclient2.default,binaryProvider:_aptosclient.bcsRequest})),this.clientConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _171 => _171.clientConfig]), () => ({})),this.fullnodeConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _172 => _172.fullnodeConfig]), () => ({})),this.indexerConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _173 => _173.indexerConfig]), () => ({})),this.faucetConfig=_nullishCoalesce(_optionalChain([e, 'optionalAccess', _174 => _174.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 oi[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 si[this.network];default:throw Error(`apiType ${e} is not supported`)}}isPepperServiceRequest(e){return oi[this.network]===e}isProverServiceRequest(e){return si[this.network]===e}};var ju={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:ju},options:s})}var Fn=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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}};return(await w({aptosConfig:e,query:{query:us,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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()},amount:{_gt:0}};return(await w({aptosConfig:e,query:{query:Pi,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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()},amount:{_gt:0}},o={query:Pi,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _175 => _175.offset]),limit:_optionalChain([r, 'optionalAccess', _176 => _176.limit]),order_by:_optionalChain([r, 'optionalAccess', _177 => _177.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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}},o={query:cs,variables:{where_condition:i,offset:_optionalChain([r, 'optionalAccess', _178 => _178.offset]),limit:_optionalChain([r, 'optionalAccess', _179 => _179.limit]),order_by:_optionalChain([r, 'optionalAccess', _180 => _180.orderBy])}};return(await w({aptosConfig:e,query:o,originMethod:"getDigitalAssetActivity"})).token_activities_v2}var Ju={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, () => (_chunkMVCKMP5Ujs.e))),new x(n.name),new x(n.uri),new N(_nullishCoalesce(n.mutableDescription, () => (!0))),new N(_nullishCoalesce(n.mutableRoyalty, () => (!0))),new N(_nullishCoalesce(n.mutableURI, () => (!0))),new N(_nullishCoalesce(n.mutableTokenDescription, () => (!0))),new N(_nullishCoalesce(n.mutableTokenName, () => (!0))),new N(_nullishCoalesce(n.mutableTokenProperties, () => (!0))),new N(_nullishCoalesce(n.mutableTokenURI, () => (!0))),new N(_nullishCoalesce(n.tokensBurnableByCreator, () => (!0))),new N(_nullishCoalesce(n.tokensFreezableByCreator, () => (!0))),new Q(_nullishCoalesce(n.royaltyNumerator, () => (0))),new Q(_nullishCoalesce(n.royaltyDenominator, () => (1)))],abi:Ju},options:t})}async function pn(n){let{aptosConfig:e,options:t}=n,r=_optionalChain([t, 'optionalAccess', _181 => _181.where]);_optionalChain([t, 'optionalAccess', _182 => _182.tokenStandard])&&(r.token_standard={_eq:_nullishCoalesce(_optionalChain([t, 'optionalAccess', _183 => _183.tokenStandard]), () => ("v2"))});let i={query:es,variables:{where_condition:r,offset:_optionalChain([t, 'optionalAccess', _184 => _184.offset]),limit:_optionalChain([t, 'optionalAccess', _185 => _185.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=_chunkMVCKMP5Ujs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _186 => _186.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _187 => _187.tokenStandard]), () => ("v2"))}),pn({aptosConfig:e,options:{...i,where:s}})}async function ca(n){let{aptosConfig:e,creatorAddress:t,options:r}=n,o={creator_address:{_eq:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _188 => _188.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _189 => _189.tokenStandard]), () => ("v2"))}),pn({aptosConfig:e,options:{...r,where:o}})}async function ua(n){let{aptosConfig:e,collectionId:t,options:r}=n,o={collection_id:{_eq:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}};return _optionalChain([r, 'optionalAccess', _190 => _190.tokenStandard])&&(o.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _191 => _191.tokenStandard]), () => ("v2"))}),pn({aptosConfig:e,options:{...r,where:o}})}async function pa(n){let{creatorAddress:e,collectionName:t,options:r,aptosConfig:i}=n,o=_chunkMVCKMP5Ujs.Z.from(e),s={collection_name:{_eq:t},creator_address:{_eq:o.toStringLong()}};return _optionalChain([r, 'optionalAccess', _192 => _192.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([r, 'optionalAccess', _193 => _193.tokenStandard]), () => ("v2"))}),(await pn({aptosConfig:i,options:{where:s}})).collection_id}var Xu={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', _194 => _194.map, 'call', _195 => _195(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:Xu},options:t})}var Yu={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(r),_chunkMVCKMP5Ujs.Z.from(i)],abi:Yu},options:s})}var Zu={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', _196 => _196.length])!==_optionalChain([l, 'optionalAccess', _197 => _197.length]))throw new Error("Property keys and property values counts do not match");if(_optionalChain([p, 'optionalAccess', _198 => _198.length])!==_optionalChain([l, 'optionalAccess', _199 => _199.length]))throw new Error("Property types and property values counts do not match");let d=_optionalChain([p, 'optionalAccess', _200 => _200.map, 'call', _201 => _201(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:Zu},options:h})}var ep={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(r)],abi:ep},options:o})}var tp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:tp},options:o})}var np={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:np},options:o})}var rp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(i),new x(r)],abi:rp},options:s})}var ip={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(i),new x(r)],abi:ip},options:s})}var op={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(i),new x(r)],abi:op},options:s})}var sp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(s),new x(r),new x(Tt[i]),S.U8(qi(o,Tt[i]))],abi:sp},options:c})}var ap={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(i),new x(r)],abi:ap},options:s})}var cp={typeParameters:[{constraints:["key"]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(s),new x(r),new x(Tt[i]),qi(o,Tt[i])],abi:cp},options:c})}var up={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(s),new x(r),o],abi:up},options:c})}var pp={typeParameters:[{constraints:["key"]},{constraints:[]}],parameters:[new A(me(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:[_chunkMVCKMP5Ujs.Z.from(s),new x(r),o],abi:pp},options:c})}function _a(n,e){let t=new Array;return e.forEach((r,i)=>{t.push(qi(n[i],r))}),t}function qi(n,e){let t=Re(e);return Bt(n,t,0,[]).bcsToBytes()}var On=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=_chunkMVCKMP5Ujs.Z.from(t),s={collection_name:{_eq:r},creator_address:{_eq:o.toStringLong()}};return _optionalChain([i, 'optionalAccess', _202 => _202.tokenStandard])&&(s.token_standard={_eq:_nullishCoalesce(_optionalChain([i, 'optionalAccess', _203 => _203.tokenStandard]), () => ("v2"))}),pn({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,dp=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 Gn({aptosConfig:e,options:{...r,where:i}})}async function Ca(n){let{accountAddress:e,aptosConfig:t,creationNumber:r,options:i}=n,s={account_address:{_eq:_chunkMVCKMP5Ujs.Z.from(e).toStringLong()},creation_number:{_eq:r}};return Gn({aptosConfig:t,options:{...i,where:s}})}async function va(n){let{accountAddress:e,aptosConfig:t,eventType:r,options:i}=n,s={account_address:{_eq:_chunkMVCKMP5Ujs.Z.from(e).toStringLong()},indexed_type:{_eq:r}};return Gn({aptosConfig:t,options:{...i,where:s}})}async function Gn(n){let{aptosConfig:e,options:t}=n;dp(_optionalChain([t, 'optionalAccess', _204 => _204.where, 'optionalAccess', _205 => _205.indexed_type, 'optionalAccess', _206 => _206._eq]));let r={query:rs,variables:{where_condition:_optionalChain([t, 'optionalAccess', _207 => _207.where]),offset:_optionalChain([t, 'optionalAccess', _208 => _208.offset]),limit:_optionalChain([t, 'optionalAccess', _209 => _209.limit]),order_by:_optionalChain([t, 'optionalAccess', _210 => _210.orderBy])}};return(await w({aptosConfig:e,query:r,originMethod:"getEvents"})).events}var Bn=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', _211 => _211.minimumLedgerVersion]),processorType:"events_processor"}),Gn({aptosConfig:this.config,...e})}};async function Ka(n){let{aptosConfig:e,accountAddress:t,amount:r,options:i}=n,o=_optionalChain([i, 'optionalAccess', _212 => _212.timeoutSecs])||20,{data:s}=await Do({aptosConfig:e,path:"fund",body:{address:_chunkMVCKMP5Ujs.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', _213 => _213.checkSuccess])}});if(c.type==="user_transaction")return c;throw new Error(`Unexpected transaction received for fund account: ${c.type}`)}var Mn=class{constructor(e){this.config=e}async fundAccount(e){let t=await Ka({aptosConfig:this.config,...e});return(_optionalChain([e, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.waitForIndexer])===void 0||_optionalChain([e, 'access', _216 => _216.options, 'optionalAccess', _217 => _217.waitForIndexer]))&&await kr({aptosConfig:this.config,minimumLedgerVersion:BigInt(t.version),processorType:"fungible_asset_processor"}),t}};async function Lr(n){let{aptosConfig:e,options:t}=n,r={query:os,variables:{where_condition:_optionalChain([t, 'optionalAccess', _218 => _218.where]),limit:_optionalChain([t, 'optionalAccess', _219 => _219.limit]),offset:_optionalChain([t, 'optionalAccess', _220 => _220.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:is,variables:{where_condition:_optionalChain([t, 'optionalAccess', _221 => _221.where]),limit:_optionalChain([t, 'optionalAccess', _222 => _222.limit]),offset:_optionalChain([t, 'optionalAccess', _223 => _223.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:ts,variables:{where_condition:_optionalChain([t, 'optionalAccess', _224 => _224.where]),limit:_optionalChain([t, 'optionalAccess', _225 => _225.limit]),offset:_optionalChain([t, 'optionalAccess', _226 => _226.offset])}};return(await w({aptosConfig:e,query:r,originMethod:"getCurrentFungibleAssetBalances"})).current_fungible_asset_balances}var lp={typeParameters:[{constraints:[]}],parameters:[Re("0x1::object::Object"),new F,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:lp},options:s})}var Vn=class{constructor(e){this.config=e}async getFungibleAssetMetadata(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _227 => _227.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Lr({aptosConfig:this.config,...e})}async getFungibleAssetMetadataByAssetType(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _228 => _228.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),(await Lr({aptosConfig:this.config,options:{where:{asset_type:{_eq:e.assetType}}}}))[0]}async getFungibleAssetMetadataByCreatorAddress(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _229 => _229.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),await Lr({aptosConfig:this.config,options:{where:{creator_address:{_eq:_chunkMVCKMP5Ujs.Z.from(e.creatorAddress).toStringLong()}}}})}async getFungibleAssetActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _230 => _230.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ra({aptosConfig:this.config,...e})}async getCurrentFungibleAssetBalances(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _231 => _231.minimumLedgerVersion]),processorType:"fungible_asset_processor"}),Ua({aptosConfig:this.config,...e})}async transferFungibleAsset(e){return ka({aptosConfig:this.config,...e})}};var Hn=class{constructor(e){this.config=e}async getLedgerInfo(){return xr({aptosConfig:this.config})}async getChainId(){return(await this.getLedgerInfo()).chain_id}async getBlockByVersion(e){return As({aptosConfig:this.config,...e})}async getBlockByHeight(e){return hs({aptosConfig:this.config,...e})}async view(e){return ce({aptosConfig:this.config,...e})}async viewJson(e){return Xs({aptosConfig:this.config,...e})}async getChainTopUserTransactions(e){return ps({aptosConfig:this.config,...e})}async queryIndexer(e){return w({aptosConfig:this.config,...e})}async getIndexerLastSuccessVersion(){return Ir({aptosConfig:this.config})}async getProcessorStatus(e){return Cr({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 Na(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(!Na(e))throw new Error(`${e} is not valid. ${Da}`);if(t&&!Na(t))throw new Error(`${t} is not valid. ${Da}`);return{domainName:t||e,subdomainName:t?e:void 0}}function za(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 gp="0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",mp={testnet:"0x5f8fd2347449685cf41d4db97926ec3a096eaf381332be4f1318ad4d16a8497c",mainnet:"0x867ed1f6bf916171b1de3ee92849b8978b7d1b9e0a8cc982a3d19d535dfd9c0c",local:gp,custom:null,devnet:null};function ot(n){let e=mp[n.network];if(!e)throw new Error(`The ANS contract is not deployed to ${n.network}`);return e}var qr=n=>{if(n&&typeof n=="object"&&"vec"in n&&Array.isArray(n.vec))return n.vec[0]};async function Fa(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t),s=await ce({aptosConfig:e,payload:{function:`${r}::router::get_owner_addr`,functionArguments:[i,o]}}),a=qr(s[0]);return a?_chunkMVCKMP5Ujs.Z.from(a):void 0}async function Oa(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 $i({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 $i(n){let{aptosConfig:e,name:t}=n,r=ot(e),{domainName:i,subdomainName:o}=bt(t);try{let s=await ce({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 ce({aptosConfig:e,payload:{function:`${r}::router::get_primary_name`,functionArguments:[_chunkMVCKMP5Ujs.Z.from(t).toString()]}}),o=qr(i[1]),s=qr(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 ce({aptosConfig:e,payload:{function:`${r}::router::get_target_addr`,functionArguments:[i,o]}}),a=qr(s[0]);return a?_chunkMVCKMP5Ujs.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:on,variables:{where_condition:{domain:{_eq:r},subdomain:{_eq:i}},limit:1}},originMethod:"getName"})).current_aptos_names[0];return a&&(a=Ln(a)),za(a)?a:void 0}async function La(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Wi({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountNames",query:{query:on,variables:{limit:_optionalChain([t, 'optionalAccess', _232 => _232.limit]),offset:_optionalChain([t, 'optionalAccess', _233 => _233.offset]),order_by:_optionalChain([t, 'optionalAccess', _234 => _234.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _235 => _235.options, 'optionalAccess', _236 => _236.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i}}}}})).current_aptos_names.map(Ln)}async function qa(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Wi({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountDomains",query:{query:on,variables:{limit:_optionalChain([t, 'optionalAccess', _237 => _237.limit]),offset:_optionalChain([t, 'optionalAccess', _238 => _238.offset]),order_by:_optionalChain([t, 'optionalAccess', _239 => _239.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _240 => _240.options, 'optionalAccess', _241 => _241.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_eq:""}}}}})).current_aptos_names.map(Ln)}async function $a(n){let{aptosConfig:e,options:t,accountAddress:r}=n,i=await Wi({aptosConfig:e});return(await w({aptosConfig:e,originMethod:"getAccountSubdomains",query:{query:on,variables:{limit:_optionalChain([t, 'optionalAccess', _242 => _242.limit]),offset:_optionalChain([t, 'optionalAccess', _243 => _243.offset]),order_by:_optionalChain([t, 'optionalAccess', _244 => _244.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _245 => _245.options, 'optionalAccess', _246 => _246.where]), () => ({})),owner_address:{_eq:r.toString()},expiration_timestamp:{_gte:i},subdomain:{_neq:""}}}}})).current_aptos_names.map(Ln)}async function Wa(n){let{aptosConfig:e,options:t,domain:r}=n;return(await w({aptosConfig:e,originMethod:"getDomainSubdomains",query:{query:on,variables:{limit:_optionalChain([t, 'optionalAccess', _247 => _247.limit]),offset:_optionalChain([t, 'optionalAccess', _248 => _248.offset]),order_by:_optionalChain([t, 'optionalAccess', _249 => _249.orderBy]),where_condition:{..._nullishCoalesce(_optionalChain([n, 'access', _250 => _250.options, 'optionalAccess', _251 => _251.where]), () => ({})),domain:{_eq:r},subdomain:{_neq:""}}}}})).current_aptos_names.map(Ln).filter(za)}async function Wi(n){let{aptosConfig:e}=n,t=ot(e),[r]=await ce({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 Ln(n){return{...n,expiration_timestamp:new Date(n.expiration_timestamp).getTime()}}var qn=class{constructor(e){this.config=e}async getOwnerAddress(e){return Fa({aptosConfig:this.config,...e})}async getExpiration(e){return $i({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 Oa({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=_chunkMVCKMP5Ujs.Z.from(t).toStringLong(),o=await w({aptosConfig:e,query:{query:Si,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:Si,variables:{order_by:_optionalChain([t, 'optionalAccess', _252 => _252.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:ns,variables:{delegatorAddress:_chunkMVCKMP5Ujs.Z.from(t).toStringLong(),poolAddress:_chunkMVCKMP5Ujs.Z.from(r).toStringLong()}};return(await w({aptosConfig:e,query:i})).delegated_staking_activities}var $n=class{constructor(e){this.config=e}async getNumberOfDelegators(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _253 => _253.minimumLedgerVersion]),processorType:"stake_processor"}),ja({aptosConfig:this.config,...e})}async getNumberOfDelegatorsForAllPools(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _254 => _254.minimumLedgerVersion]),processorType:"stake_processor"}),Ja({aptosConfig:this.config,...e})}async getDelegatedStakingActivities(e){return await E({config:this.config,minimumLedgerVersion:_optionalChain([e, 'optionalAccess', _255 => _255.minimumLedgerVersion]),processorType:"stake_processor"}),Xa({aptosConfig:this.config,...e})}};var $r=class{constructor(e){this.config=e}async simple(e){return T({aptosConfig:this.config,...e})}async scriptComposer(e){let t=new Br(this.config);await t.init();let i=(await e.builder(t)).build(),o=await Oi({aptosConfig:this.config,payload:Rt.load(new R(i)),...e});return new tn(o,e.withFeePayer===!0?_chunkMVCKMP5Ujs.Z.ZERO:void 0)}async multiAgent(e){return T({aptosConfig:this.config,...e})}};function Qi(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 ji(n,e,t){let r=t.value;return t.value=async function(...i){return r.apply(this,i)},t}var dn=class{constructor(e){this.config=e}async simple(e){return Vi({aptosConfig:this.config,...e})}async multiAgent(e){return Vi({aptosConfig:this.config,...e})}};_chunkMVCKMP5Ujs.a.call(void 0, [ji],dn.prototype,"simple",1),_chunkMVCKMP5Ujs.a.call(void 0, [ji],dn.prototype,"multiAgent",1);var ln=class{constructor(e){this.config=e}async simple(e){return Nn({aptosConfig:this.config,...e})}async multiAgent(e){return Nn({aptosConfig:this.config,...e})}};_chunkMVCKMP5Ujs.a.call(void 0, [Qi],ln.prototype,"simple",1),_chunkMVCKMP5Ujs.a.call(void 0, [Qi],ln.prototype,"multiAgent",1);var Wr=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 _chunkMVCKMP5Ujs.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=_chunkMVCKMP5Ujs.da.call(void 0, );for(;this.currentNumber-this.lastUncommintedNumber>=this.maximumInFlight;)await _chunkMVCKMP5Ujs.ba.call(void 0, this.sleepTime),_chunkMVCKMP5Ujs.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 Mt({aptosConfig:this.aptosConfig,accountAddress:this.account.accountAddress});this.currentNumber=BigInt(e),this.lastUncommintedNumber=BigInt(e)}async update(){let{sequence_number:e}=await Mt({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 _chunkMVCKMP5Ujs.ba.call(void 0, this.sleepTime);this.lock=!0;try{await this.update();let e=_chunkMVCKMP5Ujs.da.call(void 0, );for(;this.lastUncommintedNumber!==this.currentNumber;)_chunkMVCKMP5Ujs.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 _chunkMVCKMP5Ujs.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 gn=class{constructor(){this.queue=[];this.pendingDequeue=[];this.cancelled=!1}enqueue(e){if(this.cancelled=!1,this.pendingDequeue.length>0){_optionalChain([this, 'access', _256 => _256.pendingDequeue, 'access', _257 => _257.shift, 'call', _258 => _258(), 'optionalAccess', _259 => _259.resolve, 'call', _260 => _260(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 mn("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},mn=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||{}),Qr= exports.TransactionWorker =class extends _eventemitter32.default{constructor(t,r,i=30,o=100,s=10){super();this.taskQueue=new gn;this.transactionsQueue=new gn;this.outstandingTransactions=new gn;this.sentTransactions=[];this.executedTransactions=[];this.aptosConfig=t,this.account=r,this.started=!1,this.accountSequnceNumber=new Wr(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 mn)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 mn)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 jr=class extends _eventemitter32.default{constructor(e){super(),this.config=e}start(e){let{sender:t}=e;this.account=t,this.transactionWorker=new Qr(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 Wn=class{constructor(e){this.config=e,this.build=new $r(this.config),this.simulate=new dn(this.config),this.submit=new ln(this.config),this.batch=new jr(this.config)}async getTransactions(e){return xi({aptosConfig:this.config,...e})}async getTransactionByVersion(e){return ys({aptosConfig:this.config,...e})}async getTransactionByHash(e){return kn({aptosConfig:this.config,...e})}async isPendingTransaction(e){return fs({aptosConfig:this.config,...e})}async waitForTransaction(e){return At({aptosConfig:this.config,...e})}async getGasPriceEstimation(){return Ur({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 Mr({...e})}signAsFeePayer(e){return Vr({...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 Qn=class{constructor(e){this.config=e}async getTableItem(e){return Kr({aptosConfig:this.config,...e})}async getTableItemsData(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),gs({aptosConfig:this.config,...e})}async getTableItemsMetadata(e){return await E({config:this.config,minimumLedgerVersion:e.minimumLedgerVersion,processorType:"default_processor"}),ms({aptosConfig:this.config,...e})}};async function Jr(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:_chunkMVCKMP5Ujs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),uid_key:i,derivation_path:o},{data:a}=await No({aptosConfig:e,path:"fetch",body:s,originMethod:"getPepper",overrides:{WITH_CREDENTIALS:!1}});return _chunkMVCKMP5Ujs.j.fromHexInput(a.pepper).toUint8Array()}async function Ji(n){let{aptosConfig:e,jwt:t,ephemeralKeyPair:r,pepper:i=await Jr(n),uidKey:o="sub",maxExpHorizonSecs:s=(await jt({aptosConfig:e})).maxExpHorizonSecs}=n;if(_chunkMVCKMP5Ujs.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:_chunkMVCKMP5Ujs.j.fromHexInput(r.blinder).toStringWithoutPrefix(),exp_date_secs:r.expiryDateSecs,exp_horizon_secs:s,pepper:_chunkMVCKMP5Ujs.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 pe({proof:new Qt(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 Jr(n)}=n,{verificationKey:a,maxExpHorizonSecs:c}=await jt({aptosConfig:e}),p=Ji({...n,pepper:s,maxExpHorizonSecs:c}),l=o?p:await p;if(r!==void 0){let g=te.fromJwtAndPepper({jwt:t,pepper:s,jwkAddress:r,uidKey:i}),b=await un({aptosConfig:e,authenticationKey:g.authKey().derivedAddress()});return Gt.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 un({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 jn=class{constructor(e){this.config=e}async getPepper(e){return Jr({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 hp(n){let{aptosConfig:e,options:t}=n,r={query:_r,variables:{where_condition:_optionalChain([t, 'optionalAccess', _261 => _261.where]),offset:_optionalChain([t, 'optionalAccess', _262 => _262.offset]),limit:_optionalChain([t, 'optionalAccess', _263 => _263.limit]),order_by:_optionalChain([t, 'optionalAccess', _264 => _264.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:_chunkMVCKMP5Ujs.Z.from(t).toStringLong()}};return(await hp({aptosConfig:e,options:{...r,where:o}}))[0]}var Jn=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})}};async function rc(n){let{aptosConfig:e,payload:t,options:r}=n,i=await Gr({...t,aptosConfig:e}),o=new _chunkMVCKMP5Ujs.m;i.serialize(o);let s=o.toUint8Array(),{data:a}=await Uo({aptosConfig:e,path:"view",originMethod:"view",contentType:"application/x.aptos.view_function+bcs",acceptType:"application/x-bcs",params:{ledger_version:_optionalChain([r, 'optionalAccess', _265 => _265.ledgerVersion])},body:s}),c=new Uint8Array(a);return _optionalChain([r, 'optionalAccess', _266 => _266.convert])?r.convert(c):c}var Xn=class{constructor(e){this.config=e}async viewBinary(e){return rc({...e,aptosConfig:this.config})}};var X=class{constructor(e){this.config=new Hr(e),this.account=new zn(this.config),this.abstraction=new Vt(this.config),this.ans=new qn(this.config),this.coin=new Fn(this.config),this.digitalAsset=new On(this.config),this.event=new Bn(this.config),this.experimental=new Xn(this.config),this.faucet=new Mn(this.config),this.fungibleAsset=new Vn(this.config),this.general=new Hn(this.config),this.staking=new $n(this.config),this.transaction=new Wn(this.config),this.table=new Qn(this.config),this.keyless=new jn(this.config),this.object=new Jn(this.config)}};function re(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))})}re(X,zn,"account");re(X,Vt,"abstraction");re(X,qn,"ans");re(X,Fn,"coin");re(X,On,"digitalAsset");re(X,Bn,"event");re(X,Xn,"experimental");re(X,Mn,"faucet");re(X,Vn,"fungibleAsset");re(X,Hn,"general");re(X,$n,"staking");re(X,Wn,"transaction");re(X,Qn,"table");re(X,jn,"keyless");re(X,Jn,"object");exports.APTOS_BIP44_REGEX = fc; exports.APTOS_COIN = xt; exports.APTOS_FA = Io; exports.APTOS_HARDENED_REGEX = yc; exports.AbstractKeylessAccount = ye; exports.AbstractMultiKey = Pn; exports.AbstractPublicKey = ir; exports.AbstractSignature = An; exports.AbstractedAccount = qo; exports.Account = nt; exports.AccountAddress = _chunkMVCKMP5Ujs.Z; exports.AccountAuthenticator = j; exports.AccountAuthenticatorAbstraction = _n; exports.AccountAuthenticatorEd25519 = ve; exports.AccountAuthenticatorMultiEd25519 = je; exports.AccountAuthenticatorMultiKey = Ge; exports.AccountAuthenticatorNoAccountAuthenticator = Yt; exports.AccountAuthenticatorSingleKey = se; exports.AccountAuthenticatorVariant = _chunkMVCKMP5Ujs.w; exports.AccountPublicKey = oe; exports.AccountSequenceNumber = Wr; exports.AccountUtils = Ho; exports.AddressInvalidReason = _chunkMVCKMP5Ujs.Y; exports.AnyPublicKey = z; exports.AnyPublicKeyVariant = _chunkMVCKMP5Ujs.y; exports.AnySignature = H; exports.AnySignatureVariant = _chunkMVCKMP5Ujs.z; exports.Aptos = X; exports.AptosApiError = ee; exports.AptosApiType = _t; exports.AptosConfig = Hr; exports.AptosScriptComposer = Br; exports.AuthenticationKey = B; exports.Bool = N; exports.CKDPriv = ho; exports.CallArgument = _chunkMVCKMP5Ujs.X; exports.ChainId = Zt; exports.DEFAULT_MAX_GAS_AMOUNT = _o; exports.DEFAULT_TXN_EXP_SEC_FROM_NOW = xo; exports.DEFAULT_TXN_TIMEOUT_SEC = cr; exports.DeriveScheme = _chunkMVCKMP5Ujs.W; exports.Deserializer = R; exports.EPK_HORIZON_SECS = Zc; exports.Ed25519Account = ae; exports.Ed25519PrivateKey = q; exports.Ed25519PublicKey = I; exports.Ed25519Signature = K; exports.EntryFunction = Ut; exports.EntryFunctionBytes = rr; exports.EphemeralCertificate = Wt; exports.EphemeralCertificateVariant = _chunkMVCKMP5Ujs.C; exports.EphemeralKeyPair = Ot; exports.EphemeralPublicKey = lt; exports.EphemeralPublicKeyVariant = _chunkMVCKMP5Ujs.A; exports.EphemeralSignature = Ue; exports.EphemeralSignatureVariant = _chunkMVCKMP5Ujs.B; exports.FIREBASE_AUTH_ISS_PATTERN = vo; exports.FederatedKeylessAccount = Gt; exports.FederatedKeylessPublicKey = te; exports.FeePayerRawTransaction = Dt; exports.FixedBytes = Ee; exports.Groth16ProofAndStatement = yi; exports.Groth16VerificationKey = Ai; exports.Groth16Zkp = mt; exports.HARDENED_OFFSET = yo; exports.Hex = _chunkMVCKMP5Ujs.j; exports.HexInvalidReason = _chunkMVCKMP5Ujs.i; exports.Identifier = k; exports.KeyType = Ac; exports.KeylessAccount = rt; exports.KeylessConfiguration = fi; exports.KeylessError = P; exports.KeylessErrorCategory = Vc; exports.KeylessErrorResolutionTip = Hc; exports.KeylessErrorType = ur; exports.KeylessPublicKey = U; exports.KeylessSignature = he; exports.MAX_AUD_VAL_BYTES = gi; exports.MAX_COMMITED_EPK_BYTES = ou; exports.MAX_EXTRA_FIELD_BYTES = ru; exports.MAX_ISS_VAL_BYTES = nu; exports.MAX_JWT_HEADER_B64_BYTES = iu; exports.MAX_UID_KEY_BYTES = eu; exports.MAX_UID_VAL_BYTES = tu; exports.MimeType = _chunkMVCKMP5Ujs.q; exports.ModuleId = xn; exports.MoveAbility = _chunkMVCKMP5Ujs.S; exports.MoveFunctionVisibility = _chunkMVCKMP5Ujs.R; exports.MoveJWK = hi; exports.MoveOption = Z; exports.MoveString = x; exports.MoveVector = S; exports.MultiAgentRawTransaction = kt; exports.MultiAgentTransaction = Tr; exports.MultiEd25519Account = Er; exports.MultiEd25519PublicKey = Xt; exports.MultiEd25519Signature = Qe; exports.MultiKey = Fe; exports.MultiKeyAccount = Un; exports.MultiKeySignature = Oe; exports.MultiSig = Kn; exports.MultiSigTransactionPayload = Rn; exports.Network = ai; exports.NetworkToChainId = ci; exports.NetworkToFaucetAPI = Po; exports.NetworkToIndexerAPI = So; exports.NetworkToNetworkName = Rl; exports.NetworkToNodeAPI = Eo; exports.NetworkToPepperAPI = oi; exports.NetworkToProverAPI = si; exports.ParsingError = _chunkMVCKMP5Ujs.h; exports.PrivateKey = pt; exports.PrivateKeyVariants = _chunkMVCKMP5Ujs.x; exports.ProcessorType = He; exports.PublicKey = St; exports.RAW_TRANSACTION_SALT = Co; exports.RAW_TRANSACTION_WITH_DATA_SALT = ui; exports.RawTransaction = be; exports.RawTransactionWithData = Ar; exports.RoleType = _chunkMVCKMP5Ujs.T; exports.RotationProofChallenge = hr; exports.Script = vn; exports.ScriptTransactionArgumentVariants = _chunkMVCKMP5Ujs.s; exports.Secp256k1PrivateKey = We; exports.Secp256k1PublicKey = $e; exports.Secp256k1Signature = Ct; exports.Serializable = _chunkMVCKMP5Ujs.l; exports.Serialized = fn; exports.Serializer = _chunkMVCKMP5Ujs.m; exports.Signature = M; exports.SignedTransaction = tt; exports.SigningScheme = _chunkMVCKMP5Ujs.U; exports.SigningSchemeInput = _chunkMVCKMP5Ujs.V; exports.SimpleTransaction = tn; exports.SingleKeyAccount = we; exports.StructTag = Be; exports.TransactionAndProof = wr; exports.TransactionAuthenticator = et; exports.TransactionAuthenticatorEd25519 = Nt; exports.TransactionAuthenticatorFeePayer = Ft; exports.TransactionAuthenticatorMultiAgent = zt; exports.TransactionAuthenticatorMultiEd25519 = en; exports.TransactionAuthenticatorSingleSender = ft; exports.TransactionAuthenticatorVariant = _chunkMVCKMP5Ujs.v; exports.TransactionPayload = Kt; exports.TransactionPayloadEntryFunction = In; exports.TransactionPayloadMultiSig = Cn; exports.TransactionPayloadScript = Rt; exports.TransactionPayloadVariants = _chunkMVCKMP5Ujs.t; exports.TransactionResponseType = _chunkMVCKMP5Ujs.E; exports.TransactionVariants = _chunkMVCKMP5Ujs.u; exports.TransactionWorker = Qr; exports.TransactionWorkerEventsEnum = Za; exports.TypeTag = O; exports.TypeTagAddress = F; exports.TypeTagBool = L; exports.TypeTagGeneric = G; exports.TypeTagParserError = $; exports.TypeTagParserErrorType = vu; exports.TypeTagReference = fr; exports.TypeTagSigner = vt; exports.TypeTagStruct = A; exports.TypeTagU128 = Ye; exports.TypeTagU16 = Je; exports.TypeTagU256 = Ze; exports.TypeTagU32 = Xe; exports.TypeTagU64 = J; exports.TypeTagU8 = ge; exports.TypeTagVariants = _chunkMVCKMP5Ujs.r; exports.TypeTagVector = C; exports.U128 = xe; exports.U16 = Pe; exports.U256 = fe; exports.U32 = _e; exports.U64 = Q; exports.U8 = Y; exports.ZeroKnowledgeSig = pe; exports.ZkProof = Qt; exports.ZkpVariant = _chunkMVCKMP5Ujs.D; exports.aptosBinaryRequest = dr; exports.aptosCoinStructTag = Yy; exports.aptosRequest = pr; exports.base64UrlDecode = _chunkMVCKMP5Ujs.fa; exports.base64UrlToBytes = _chunkMVCKMP5Ujs.ga; exports.bigIntToBytesLE = ri; exports.binaryRequest = Wc; exports.buildTransaction = Gi; exports.bytesToBigIntLE = Et; exports.checkOrConvertArgument = Bt; exports.convertAmountFromHumanReadableToOnChain = _chunkMVCKMP5Ujs.ha; exports.convertAmountFromOnChainToHumanReadable = _chunkMVCKMP5Ujs.ia; exports.convertArgument = an; exports.convertCallArgument = Mb; exports.convertNumber = Dr; exports.createObjectAddress = _chunkMVCKMP5Ujs._; exports.createResourceAddress = _chunkMVCKMP5Ujs.$; exports.createTokenAddress = _chunkMVCKMP5Ujs.aa; exports.deriveKey = ei; exports.deriveTransactionType = br; exports.deserializeFromScriptArgument = mu; exports.ensureBoolean = _chunkMVCKMP5Ujs.n; exports.fetchEntryFunctionAbi = Is; exports.fetchFunctionAbi = Fi; exports.fetchJWK = bi; exports.fetchModuleAbi = zi; exports.fetchMoveFunctionAbi = Bb; exports.fetchViewFunctionAbi = Cs; exports.findFirstNonSignerArg = xs; exports.floorToWholeHour = _chunkMVCKMP5Ujs.ea; exports.generateRawTransaction = Oi; exports.generateSignedTransaction = Bi; exports.generateSignedTransactionForSimulation = vs; exports.generateSigningMessage = yt; exports.generateSigningMessageForSerializable = dA; exports.generateSigningMessageForTransaction = Ke; exports.generateTransactionPayload = Or; exports.generateTransactionPayloadWithABI = Nu; exports.generateUserTransactionHash = lw; exports.generateViewFunctionPayload = Gr; exports.generateViewFunctionPayloadWithABI = zu; exports.get = lr; exports.getAptosFullNode = V; exports.getAptosPepperService = og; exports.getAuthenticatorForSimulation = cn; exports.getBinary = Qc; exports.getBinaryAptosFullNode = ig; exports.getErrorMessage = _chunkMVCKMP5Ujs.ca; exports.getFunctionParts = _chunkMVCKMP5Ujs.la; exports.getIssAudAndUidVal = qe; exports.getKeylessConfig = jt; exports.getKeylessJWKs = uu; exports.getPageWithObfuscatedCursor = mr; exports.hashStrToField = ke; exports.hashValues = Ks; exports.hexToAsciiString = _chunkMVCKMP5Ujs.k; exports.isBcsAddress = zr; exports.isBcsBool = Ii; exports.isBcsFixedBytes = Ru; exports.isBcsString = Ci; exports.isBcsU128 = ki; exports.isBcsU16 = Ki; exports.isBcsU256 = Di; exports.isBcsU32 = Ri; exports.isBcsU64 = Ui; exports.isBcsU8 = vi; exports.isBlockEpilogueTransactionResponse = _chunkMVCKMP5Ujs.L; exports.isBlockMetadataTransactionResponse = _chunkMVCKMP5Ujs.I; exports.isBool = Ss; exports.isCanonicalEd25519Signature = Tc; exports.isEd25519Signature = _chunkMVCKMP5Ujs.M; exports.isEmptyOption = Es; exports.isEncodedEntryFunctionArgument = Ps; exports.isEncodedStruct = _chunkMVCKMP5Ujs.ka; exports.isFeePayerSignature = _chunkMVCKMP5Ujs.P; exports.isGenesisTransactionResponse = _chunkMVCKMP5Ujs.H; exports.isKeylessSigner = Sr; exports.isLargeNumber = Nr; exports.isMultiAgentSignature = _chunkMVCKMP5Ujs.O; exports.isMultiEd25519Signature = _chunkMVCKMP5Ujs.Q; exports.isNumber = Ku; exports.isPendingTransactionResponse = _chunkMVCKMP5Ujs.F; exports.isScriptDataInput = _s; exports.isSecp256k1Signature = _chunkMVCKMP5Ujs.N; exports.isSingleKeySigner = wi; exports.isStateCheckpointTransactionResponse = _chunkMVCKMP5Ujs.J; exports.isString = it; exports.isUserTransactionResponse = _chunkMVCKMP5Ujs.G; exports.isValidBIP44Path = fo; exports.isValidFunctionInfo = _chunkMVCKMP5Ujs.ma; exports.isValidHardenedPath = Ao; exports.isValidatorTransactionResponse = _chunkMVCKMP5Ujs.K; exports.mnemonicToSeed = or; exports.normalizeBundle = Ko; exports.nowInSeconds = _chunkMVCKMP5Ujs.da; exports.objectStructTag = me; exports.optionStructTag = Zy; exports.outOfRangeErrorMessage = _chunkMVCKMP5Ujs.o; exports.padAndPackBytesWithLen = Tn; exports.paginateWithCursor = gr; exports.paginateWithObfuscatedCursor = di; exports.pairedFaMetadataAddress = _chunkMVCKMP5Ujs.oa; exports.parseEncodedStruct = _chunkMVCKMP5Ujs.ja; exports.parseJwtHeader = du; exports.parseTypeTag = Re; exports.poseidonHash = Pt; exports.post = bn; exports.postAptosFaucet = Do; exports.postAptosFullNode = gt; exports.postAptosIndexer = ko; exports.postAptosPepperService = No; exports.postAptosProvingService = zo; exports.postBinary = jc; exports.postBinaryAptosFullNode = Uo; exports.promiseFulfilledStatus = Ya; exports.request = $c; exports.sleep = _chunkMVCKMP5Ujs.ba; exports.splitPath = To; exports.standardizeTypeTags = sn; exports.stringStructTag = _; exports.throwTypeMismatch = D; exports.truncateAddress = _chunkMVCKMP5Ujs.na; exports.validateNumberInRange = _chunkMVCKMP5Ujs.p; exports.verifyKeylessSignature = Ti; exports.verifyKeylessSignatureWithJwkAndConfig = yr;
|
|
480
480
|
//# sourceMappingURL=index.js.map
|