@hyperionxyz/sdk
Version:
This SDK allows you to interact with the Hyperion API. You can use it to request data, create pools/positions and more.
8 lines • 4.68 MB
JavaScript
"use strict";var Ri=Object.defineProperty;var Qi=(t,e,r)=>e in t?Ri(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var j1=(t,e,r)=>Qi(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t6=require("aptos-tool"),d1=require("bignumber.js"),E2=require("graphql-request"),qi=require("long");var l5=class{constructor(){this.queue=[],this.pendingDequeue=[],this.cancelled=!1}enqueue(e){var r;if(this.cancelled=!1,this.pendingDequeue.length>0){(r=this.pendingDequeue.shift())==null||r.resolve(e);return}this.queue.push(e)}async dequeue(){return this.queue.length>0?Promise.resolve(this.queue.shift()):new Promise((e,r)=>{this.pendingDequeue.push({resolve:e,reject:r})})}isEmpty(){return this.queue.length===0}cancel(){this.cancelled=!0,this.pendingDequeue.forEach(async({reject:e})=>{e(new N5("Task cancelled"))}),this.pendingDequeue=[],this.queue.length=0}isCancelled(){return this.cancelled}pendingDequeueLength(){return this.pendingDequeue.length}},N5=class extends Error{},o2=class extends Error{constructor(e,r){super(e),this.invalidReason=r}};const T0=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function B0(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function ji(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function a2(t,...e){if(!ji(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Te(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");B0(t.outputLen),B0(t.blockLen)}function $0(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Je(t,e){a2(t);const r=e.outputLen;if(t.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vi=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),C0=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),b2=(t,e)=>t<<32-e|t>>>e,S6=(t,e)=>t<<e|t>>>32-e>>>0,L8=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,Wi=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function F8(t){for(let e=0;e<t.length;e++)t[e]=Wi(t[e])}const Xi=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function P3(t){a2(t);let e="";for(let r=0;r<t.length;r++)e+=Xi[t[r]];return e}const S2={_0:48,_9:57,A:65,F:70,a:97,f:102};function D8(t){if(t>=S2._0&&t<=S2._9)return t-S2._0;if(t>=S2.A&&t<=S2.F)return t-(S2.A-10);if(t>=S2.a&&t<=S2.f)return t-(S2.a-10)}function G7(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){const o=D8(t.charCodeAt(s)),a=D8(t.charCodeAt(s+1));if(o===void 0||a===void 0){const c=t[s]+t[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[i]=o*16+a}return n}function Ne(t){if(typeof t!="string")throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array(new TextEncoder().encode(t))}function e3(t){return typeof t=="string"&&(t=Ne(t)),a2(t),t}function x3(...t){let e=0;for(let n=0;n<t.length;n++){const i=t[n];a2(i),e+=i.length}const r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){const s=t[n];r.set(s,i),i+=s.length}return r}class M7{clone(){return this._cloneInto()}}function Zi(t,e){if(e!==void 0&&{}.toString.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(t,e)}function N4(t){const e=n=>t().update(e3(n)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function z4(t=32){if(T0&&typeof T0.getRandomValues=="function")return T0.getRandomValues(new Uint8Array(t));if(T0&&typeof T0.randomBytes=="function")return T0.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")}var _i=(t=>(t.TOO_SHORT="too_short",t.INVALID_LENGTH="invalid_length",t.INVALID_HEX_CHARS="invalid_hex_chars",t))(_i||{}),R=class t0{constructor(e){this.data=e}toUint8Array(){return this.data}toStringWithoutPrefix(){return P3(this.data)}toString(){return`0x${this.toStringWithoutPrefix()}`}static fromHexString(e){let r=e;if(r.startsWith("0x")&&(r=r.slice(2)),r.length===0)throw new o2("Hex string is too short, must be at least 1 char long, excluding the optional leading 0x.","too_short");if(r.length%2!==0)throw new o2("Hex string must be an even number of hex characters.","invalid_length");try{return new t0(G7(r))}catch(n){throw new o2(`Hex string contains invalid hex characters: ${n==null?void 0:n.message}`,"invalid_hex_chars")}}static fromHexInput(e){return e instanceof Uint8Array?new t0(e):t0.fromHexString(e)}static hexInputToUint8Array(e){return e instanceof Uint8Array?e:t0.fromHexString(e).toUint8Array()}static hexInputToString(e){return t0.fromHexInput(e).toString()}static hexInputToStringWithoutPrefix(e){return t0.fromHexInput(e).toStringWithoutPrefix()}static isValid(e){try{return t0.fromHexString(e),{valid:!0}}catch(r){return{valid:!1,invalidReason:r==null?void 0:r.invalidReason,invalidReasonMessage:r==null?void 0:r.message}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,n)=>r===e.data[n])}},$i=t=>new TextDecoder().decode(R.fromHexInput(t).toUint8Array()),ze=255,Ye=65535,t3=4294967295,Y4=18446744073709551615n,x7=340282366920938463463374607431768211455n,Oe=115792089237316195423570985008687907853269984665640564039457584007913129639935n,es=Object.defineProperty,ts=Object.getOwnPropertyDescriptor,y2=(t,e,r,n)=>{for(var i=ts(e,r),s=t.length-1,o;s>=0;s--)(o=t[s])&&(i=o(e,r,i)||i);return i&&es(e,r,i),i},X=class{bcsToBytes(){let e=new T1;return this.serialize(e),e.toUint8Array()}bcsToHex(){let e=this.bcsToBytes();return R.fromHexInput(e)}toStringWithoutPrefix(){return this.bcsToHex().toStringWithoutPrefix()}toString(){return`0x${this.toStringWithoutPrefix()}`}},T1=class{constructor(e=64){if(e<=0)throw new Error("Length needs to be greater than 0");this.buffer=new ArrayBuffer(e),this.offset=0}ensureBufferWillHandleSize(e){for(;this.buffer.byteLength<this.offset+e;){let r=new ArrayBuffer(this.buffer.byteLength*2);new Uint8Array(r).set(new Uint8Array(this.buffer)),this.buffer=r}}appendToBuffer(e){this.ensureBufferWillHandleSize(e.length),new Uint8Array(this.buffer,this.offset).set(e),this.offset+=e.length}serializeWithFunction(e,r,n){this.ensureBufferWillHandleSize(r);let i=new DataView(this.buffer,this.offset);e.apply(i,[0,n,!0]),this.offset+=r}serializeStr(e){let r=new TextEncoder;this.serializeBytes(r.encode(e))}serializeBytes(e){this.serializeU32AsUleb128(e.length),this.appendToBuffer(e)}serializeFixedBytes(e){this.appendToBuffer(e)}serializeBool(e){Pe(e);let r=e?1:0;this.appendToBuffer(new Uint8Array([r]))}serializeU8(e){this.appendToBuffer(new Uint8Array([e]))}serializeU16(e){this.serializeWithFunction(DataView.prototype.setUint16,2,e)}serializeU32(e){this.serializeWithFunction(DataView.prototype.setUint32,4,e)}serializeU64(e){let r=BigInt(e)&BigInt(t3),n=BigInt(e)>>BigInt(32);this.serializeU32(Number(r)),this.serializeU32(Number(n))}serializeU128(e){let r=BigInt(e)&Y4,n=BigInt(e)>>BigInt(64);this.serializeU64(r),this.serializeU64(n)}serializeU256(e){let r=BigInt(e)&x7,n=BigInt(e)>>BigInt(128);this.serializeU128(r),this.serializeU128(n)}serializeU32AsUleb128(e){let r=e,n=[];for(;r>>>7;)n.push(r&127|128),r>>>=7;n.push(r),this.appendToBuffer(new Uint8Array(n))}toUint8Array(){return new Uint8Array(this.buffer).slice(0,this.offset)}serialize(e){e.serialize(this)}serializeVector(e){this.serializeU32AsUleb128(e.length),e.forEach(r=>{r.serialize(this)})}serializeOption(e,r){let n=e!==void 0;this.serializeBool(n),n&&(typeof e=="string"?this.serializeStr(e):e instanceof Uint8Array?r!==void 0?this.serializeFixedBytes(e):this.serializeBytes(e):e.serialize(this))}serializeOptionStr(e){e===void 0?this.serializeU32AsUleb128(0):(this.serializeU32AsUleb128(1),this.serializeStr(e))}};y2([w0(0,ze)],T1.prototype,"serializeU8"),y2([w0(0,Ye)],T1.prototype,"serializeU16"),y2([w0(0,t3)],T1.prototype,"serializeU32"),y2([w0(BigInt(0),Y4)],T1.prototype,"serializeU64"),y2([w0(BigInt(0),x7)],T1.prototype,"serializeU128"),y2([w0(BigInt(0),Oe)],T1.prototype,"serializeU256"),y2([w0(0,t3)],T1.prototype,"serializeU32AsUleb128");function Pe(t){if(typeof t!="boolean")throw new Error(`${t} is not a boolean value`)}var rs=(t,e,r)=>`${t} is out of range: [${e}, ${r}]`;function G0(t,e,r){let n=BigInt(t);if(n>BigInt(r)||n<BigInt(e))throw new Error(rs(t,e,r))}function w0(t,e){return(r,n,i)=>{let s=i.value;return i.value=function(o){return G0(o,t,e),s.apply(this,[o])},i}}var G1=class Re extends X{constructor(e){super(),Pe(e),this.value=e}serialize(e){e.serializeBool(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(5),e.serialize(this)}deserialize(e){return new u3(e.deserializeU256())}static deserialize(e){return new Re(e.deserializeBool())}},q2=class Qe extends X{constructor(e){super(),G0(e,0,ze),this.value=e}serialize(e){e.serializeU8(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(0),e.serialize(this)}static deserialize(e){return new Qe(e.deserializeU8())}},y6=class qe extends X{constructor(e){super(),G0(e,0,Ye),this.value=e}serialize(e){e.serializeU16(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(6),e.serialize(this)}static deserialize(e){return new qe(e.deserializeU16())}},w6=class je extends X{constructor(e){super(),G0(e,0,t3),this.value=e}serialize(e){e.serializeU32(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(7),e.serialize(this)}static deserialize(e){return new je(e.deserializeU32())}},P2=class Ve extends X{constructor(e){super(),G0(e,BigInt(0),Y4),this.value=BigInt(e)}serialize(e){e.serializeU64(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(1),e.serialize(this)}static deserialize(e){return new Ve(e.deserializeU64())}},A6=class We extends X{constructor(e){super(),G0(e,BigInt(0),x7),this.value=BigInt(e)}serialize(e){e.serializeU128(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(2),e.serialize(this)}static deserialize(e){return new We(e.deserializeU128())}},u3=class Xe extends X{constructor(e){super(),G0(e,BigInt(0),Oe),this.value=BigInt(e)}serialize(e){e.serializeU256(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(8),e.serialize(this)}static deserialize(e){return new Xe(e.deserializeU256())}},f2=class Ze{constructor(e){this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e,0),this.offset=0}static fromHex(e){let r=R.hexInputToUint8Array(e);return new Ze(r)}read(e){if(this.offset+e>this.buffer.byteLength)throw new Error("Reached to the end of buffer");let r=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,r}remaining(){return this.buffer.byteLength-this.offset}deserializeStr(){let e=this.deserializeBytes();return new TextDecoder().decode(e)}deserializeOptionStr(){return this.deserializeOption("string")}deserializeOption(e,r){if(this.deserializeBool()){if(e==="string")return this.deserializeStr();if(e==="bytes")return this.deserializeBytes();if(e==="fixedBytes"){if(r===void 0)throw new Error("Fixed bytes length not provided");return this.deserializeFixedBytes(r)}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(),r=this.deserializeU32();return BigInt(BigInt(r)<<BigInt(32)|BigInt(e))}deserializeU128(){let e=this.deserializeU64(),r=this.deserializeU64();return BigInt(r<<BigInt(64)|e)}deserializeU256(){let e=this.deserializeU128(),r=this.deserializeU128();return BigInt(r<<BigInt(128)|e)}deserializeUleb128AsU32(){let e=BigInt(0),r=0;for(;e<t3;){let n=this.deserializeU8();if(e|=BigInt(n&127)<<BigInt(r),!(n&128))break;r+=7}if(e>t3)throw new Error("Overflow while parsing uleb128-encoded uint32 value");return Number(e)}deserialize(e){return e.deserialize(this)}deserializeVector(e){let r=this.deserializeUleb128AsU32(),n=new Array;for(let i=0;i<r;i+=1)n.push(this.deserialize(e));return n}},l1=class C2 extends X{constructor(e){super(),this.values=e}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){if(this.values[0]!==void 0&&!(this.values[0]instanceof q2)){new _e(this.bcsToBytes()).serializeForScriptFunction(e);return}e.serializeU32AsUleb128(4),e.serialize(this)}static U8(e){let r;if(Array.isArray(e)&&e.length===0)r=[];else if(Array.isArray(e)&&typeof e[0]=="number")r=e;else if(typeof e=="string"){let n=R.fromHexInput(e);r=Array.from(n.toUint8Array())}else if(e instanceof Uint8Array)r=Array.from(e);else throw new Error("Invalid input type, must be an number[], Uint8Array, or hex string");return new C2(r.map(n=>new q2(n)))}static U16(e){return new C2(e.map(r=>new y6(r)))}static U32(e){return new C2(e.map(r=>new w6(r)))}static U64(e){return new C2(e.map(r=>new P2(r)))}static U128(e){return new C2(e.map(r=>new A6(r)))}static U256(e){return new C2(e.map(r=>new u3(r)))}static Bool(e){return new C2(e.map(r=>new G1(r)))}static MoveString(e){return new C2(e.map(r=>new I1(r)))}serialize(e){e.serializeVector(this.values)}static deserialize(e,r){let n=e.deserializeUleb128AsU32(),i=new Array;for(let s=0;s<n;s+=1)i.push(r.deserialize(e));return new C2(i)}},_e=class $e extends X{constructor(e){super(),this.value=R.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 $e(e.deserializeBytes())}toMoveVector(e){let r=new f2(this.bcsToBytes());r.deserializeUleb128AsU32();let n=r.deserializeVector(e);return new l1(n)}},I1=class et extends X{constructor(e){super(),this.value=e}serialize(e){e.serializeStr(this.value)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){let r=new TextEncoder().encode(this.value);l1.U8(r).serializeForScriptFunction(e)}static deserialize(e){return new et(e.deserializeStr())}},s2=class U2 extends X{constructor(e){super(),typeof e<"u"&&e!==null?this.vec=new l1([e]):this.vec=new l1([]),[this.value]=this.vec.values}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}unwrap(){if(this.isSome())return this.vec.values[0];throw new Error("Called unwrap on a MoveOption with no value")}isSome(){return this.vec.values.length===1}serialize(e){this.vec.serialize(e)}static U8(e){return new U2(e!=null?new q2(e):void 0)}static U16(e){return new U2(e!=null?new y6(e):void 0)}static U32(e){return new U2(e!=null?new w6(e):void 0)}static U64(e){return new U2(e!=null?new P2(e):void 0)}static U128(e){return new U2(e!=null?new A6(e):void 0)}static U256(e){return new U2(e!=null?new u3(e):void 0)}static Bool(e){return new U2(e!=null?new G1(e):void 0)}static MoveString(e){return new U2(e!=null?new I1(e):void 0)}static deserialize(e,r){let n=l1.deserialize(e,r);return new U2(n.values[0])}},ns=(t=>(t.INCORRECT_NUMBER_OF_BYTES="incorrect_number_of_bytes",t.INVALID_HEX_CHARS="invalid_hex_chars",t.TOO_SHORT="too_short",t.TOO_LONG="too_long",t.LEADING_ZERO_X_REQUIRED="leading_zero_x_required",t.LONG_FORM_REQUIRED_UNLESS_SPECIAL="long_form_required_unless_special",t.INVALID_PADDING_ZEROES="INVALID_PADDING_ZEROES",t.INVALID_PADDING_STRICTNESS="INVALID_PADDING_STRICTNESS",t))(ns||{}),P1=class e2 extends X{constructor(e){if(super(),e.length!==e2.LENGTH)throw new o2("AccountAddress data should be exactly 32 bytes long","incorrect_number_of_bytes");this.data=e}isSpecial(){return this.data.slice(0,this.data.length-1).every(e=>e===0)&&this.data[this.data.length-1]<16}toString(){return`0x${this.toStringWithoutPrefix()}`}toStringWithoutPrefix(){let e=P3(this.data);return this.isSpecial()&&(e=e[e.length-1]),e}toStringLong(){return`0x${this.toStringLongWithoutPrefix()}`}toStringLongWithoutPrefix(){return P3(this.data)}toStringShort(){return`0x${this.toStringShortWithoutPrefix()}`}toStringShortWithoutPrefix(){let e=P3(this.data).replace(/^0+/,"");return e===""?"0":e}toUint8Array(){return this.data}serialize(e){e.serializeFixedBytes(this.data)}serializeForEntryFunction(e){let r=this.bcsToBytes();e.serializeBytes(r)}serializeForScriptFunction(e){e.serializeU32AsUleb128(3),e.serialize(this)}static deserialize(e){let r=e.deserializeFixedBytes(e2.LENGTH);return new e2(r)}static fromStringStrict(e){if(!e.startsWith("0x"))throw new o2("Hex string must start with a leading 0x.","leading_zero_x_required");let r=e2.fromString(e);if(e.length!==e2.LONG_STRING_LENGTH+2)if(r.isSpecial()){if(e.length!==3)throw new o2(`The given hex string ${e} is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.`,"INVALID_PADDING_ZEROES")}else throw new o2(`The given hex string ${e} is not a special address, it must be represented as 0x + 64 chars.`,"long_form_required_unless_special");return r}static fromString(e,{maxMissingChars:r=4}={}){let n=e;if(e.startsWith("0x")&&(n=e.slice(2)),n.length===0)throw new o2("Hex string is too short, must be 1 to 64 chars long, excluding the leading 0x.","too_short");if(n.length>64)throw new o2("Hex string is too long, must be 1 to 64 chars long, excluding the leading 0x.","too_long");if(r>63||r<0)throw new o2(`maxMissingChars must be between or equal to 0 and 63. Received ${r}`,"INVALID_PADDING_STRICTNESS");let i;try{i=G7(n.padStart(64,"0"))}catch(o){throw new o2(`Hex characters are invalid: ${o==null?void 0:o.message}`,"invalid_hex_chars")}let s=new e2(i);if(n.length<64-r&&!s.isSpecial())throw new o2(`Hex string is too short, must be ${64-r} to 64 chars long, excluding the leading 0x. You may need to fix
the addresss by padding it with 0s before passing it to \`fromString\` (e.g. <addressString>.padStart(64, '0')).
Received ${e}`,"too_short");return s}static from(e,{maxMissingChars:r=4}={}){return typeof e=="string"?e2.fromString(e,{maxMissingChars:r}):e instanceof Uint8Array?new e2(e):e}static fromStrict(e){return typeof e=="string"?e2.fromStringStrict(e):e instanceof Uint8Array?new e2(e):e}static isValid(e){try{return e.strict?e2.fromStrict(e.input):e2.from(e.input),{valid:!0}}catch(r){return{valid:!1,invalidReason:r==null?void 0:r.invalidReason,invalidReasonMessage:r==null?void 0:r.message}}}equals(e){return this.data.length!==e.data.length?!1:this.data.every((r,n)=>r===e.data[n])}};P1.LENGTH=32,P1.LONG_STRING_LENGTH=64,P1.ZERO=P1.from("0x0"),P1.ONE=P1.from("0x1"),P1.TWO=P1.from("0x2"),P1.THREE=P1.from("0x3"),P1.FOUR=P1.from("0x4"),P1.A=P1.from("0xA");var k=P1,is=class extends X{constructor(e){super(),this.accountAddress=k.ONE,this.moduleName=new I1("account"),this.structName=new I1("RotationProofChallenge"),this.sequenceNumber=new P2(e.sequenceNumber),this.originator=e.originator,this.currentAuthKey=e.currentAuthKey,this.newPublicKey=l1.U8(e.newPublicKey.toUint8Array())}serialize(e){e.serialize(this.accountAddress),e.serialize(this.moduleName),e.serialize(this.structName),e.serialize(this.sequenceNumber),e.serialize(this.originator),e.serialize(this.currentAuthKey),e.serialize(this.newPublicKey)}},d5=new Map;function m6(t,e,r){return async(...n)=>{if(d5.has(e)){let{value:s,timestamp:o}=d5.get(e);if(Date.now()-o<=r)return s}let i=await t(...n);return d5.set(e,{value:i,timestamp:Date.now()}),i}}const G6=BigInt(2**32-1),z5=BigInt(32);function tt(t,e=!1){return e?{h:Number(t&G6),l:Number(t>>z5&G6)}:{h:Number(t>>z5&G6)|0,l:Number(t&G6)|0}}function rt(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:s,l:o}=tt(t[i],e);[r[i],n[i]]=[s,o]}return[r,n]}const ss=(t,e)=>BigInt(t>>>0)<<z5|BigInt(e>>>0),os=(t,e,r)=>t>>>r,as=(t,e,r)=>t<<32-r|e>>>r,cs=(t,e,r)=>t>>>r|e<<32-r,us=(t,e,r)=>t<<32-r|e>>>r,ls=(t,e,r)=>t<<64-r|e>>>r-32,ds=(t,e,r)=>t>>>r-32|e<<64-r,fs=(t,e)=>e,hs=(t,e)=>t,nt=(t,e,r)=>t<<r|e>>>32-r,it=(t,e,r)=>e<<r|t>>>32-r,st=(t,e,r)=>e<<r-32|t>>>64-r,ot=(t,e,r)=>t<<r-32|e>>>64-r;function ps(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:i|0}}const gs=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),ys=(t,e,r,n)=>e+r+n+(t/2**32|0)|0,ws=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),As=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,ms=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0),Es=(t,e,r,n,i,s)=>e+r+n+i+s+(t/2**32|0)|0,$={fromBig:tt,split:rt,toBig:ss,shrSH:os,shrSL:as,rotrSH:cs,rotrSL:us,rotrBH:ls,rotrBL:ds,rotr32H:fs,rotr32L:hs,rotlSH:nt,rotlSL:it,rotlBH:st,rotlBL:ot,add:ps,add3L:gs,add3H:ys,add4L:ws,add4H:As,add5H:Es,add5L:ms},at=[],ct=[],ut=[],Is=BigInt(0),A3=BigInt(1),bs=BigInt(2),Bs=BigInt(7),Cs=BigInt(256),Us=BigInt(113);for(let t=0,e=A3,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],at.push(2*(5*n+r)),ct.push((t+1)*(t+2)/2%64);let i=Is;for(let s=0;s<7;s++)e=(e<<A3^(e>>Bs)*Us)%Cs,e&bs&&(i^=A3<<(A3<<BigInt(s))-A3);ut.push(i)}const[ks,vs]=rt(ut,!0),K8=(t,e,r)=>r>32?st(t,e,r):nt(t,e,r),H8=(t,e,r)=>r>32?ot(t,e,r):it(t,e,r);function Ls(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)r[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=r[c],l=r[c+1],f=K8(u,l,1)^r[a],h=H8(u,l,1)^r[a+1];for(let g=0;g<50;g+=10)t[o+g]^=f,t[o+g+1]^=h}let i=t[2],s=t[3];for(let o=0;o<24;o++){const a=ct[o],c=K8(i,s,a),u=H8(i,s,a),l=at[o];i=t[l],s=t[l+1],t[l]=c,t[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)r[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~r[(a+2)%10]&r[(a+4)%10]}t[0]^=ks[n],t[1]^=vs[n]}r.fill(0)}class T7 extends M7{constructor(e,r,n,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,B0(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Vi(this.state)}keccak(){L8||F8(this.state32),Ls(this.state32,this.rounds),L8||F8(this.state32),this.posOut=0,this.pos=0}update(e){$0(this);const{blockLen:r,state:n}=this;e=e3(e);const i=e.length;for(let s=0;s<i;){const o=Math.min(r-this.pos,i-s);for(let a=0;a<o;a++)n[this.pos++]^=e[s++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:r,pos:n,blockLen:i}=this;e[n]^=r,(r&128)!==0&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){$0(this,!1),a2(e),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,s-i);e.set(r.subarray(this.posOut,this.posOut+o),i),this.posOut+=o,i+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return B0(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Je(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:r,suffix:n,outputLen:i,rounds:s,enableXOF:o}=this;return e||(e=new T7(r,n,i,o,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=o,e.destroyed=this.destroyed,e}}const Fs=(t,e,r)=>N4(()=>new T7(e,t,r)),l2=Fs(6,136,256/8);var Ds=(t,e)=>{let r=t.bcsToBytes(),n=typeof e=="string"?Buffer.from(e,"utf8"):e,i=new Uint8Array([...r,...n,254]);return new k(l2(i))};const l3=typeof Buffer=="function",S8=typeof TextDecoder=="function"?new TextDecoder:void 0,G8=typeof TextEncoder=="function"?new TextEncoder:void 0,Ks="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",T3=Array.prototype.slice.call(Ks),M6=(t=>{let e={};return t.forEach((r,n)=>e[r]=n),e})(T3),Hs=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,K1=String.fromCharCode.bind(String),M8=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),Ss=t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),lt=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),Gs=t=>{let e,r,n,i,s="";const o=t.length%3;for(let a=0;a<t.length;){if((r=t.charCodeAt(a++))>255||(n=t.charCodeAt(a++))>255||(i=t.charCodeAt(a++))>255)throw new TypeError("invalid character found");e=r<<16|n<<8|i,s+=T3[e>>18&63]+T3[e>>12&63]+T3[e>>6&63]+T3[e&63]}return o?s.slice(0,o-3)+"===".substring(o):s},dt=typeof btoa=="function"?t=>btoa(t):l3?t=>Buffer.from(t,"binary").toString("base64"):Gs,Ms=l3?t=>Buffer.from(t).toString("base64"):t=>{let r=[];for(let n=0,i=t.length;n<i;n+=4096)r.push(K1.apply(null,t.subarray(n,n+4096)));return dt(r.join(""))},xs=t=>{if(t.length<2){var e=t.charCodeAt(0);return e<128?t:e<2048?K1(192|e>>>6)+K1(128|e&63):K1(224|e>>>12&15)+K1(128|e>>>6&63)+K1(128|e&63)}else{var e=65536+(t.charCodeAt(0)-55296)*1024+(t.charCodeAt(1)-56320);return K1(240|e>>>18&7)+K1(128|e>>>12&63)+K1(128|e>>>6&63)+K1(128|e&63)}},Ts=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,Js=t=>t.replace(Ts,xs),x8=l3?t=>Buffer.from(t,"utf8").toString("base64"):G8?t=>Ms(G8.encode(t)):t=>dt(Js(t)),Ns=(t,e=!1)=>e?Ss(x8(t)):x8(t),zs=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Ys=t=>{switch(t.length){case 4:var e=(7&t.charCodeAt(0))<<18|(63&t.charCodeAt(1))<<12|(63&t.charCodeAt(2))<<6|63&t.charCodeAt(3),r=e-65536;return K1((r>>>10)+55296)+K1((r&1023)+56320);case 3:return K1((15&t.charCodeAt(0))<<12|(63&t.charCodeAt(1))<<6|63&t.charCodeAt(2));default:return K1((31&t.charCodeAt(0))<<6|63&t.charCodeAt(1))}},Os=t=>t.replace(zs,Ys),Ps=t=>{if(t=t.replace(/\s+/g,""),!Hs.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r="",n,i;for(let s=0;s<t.length;)e=M6[t.charAt(s++)]<<18|M6[t.charAt(s++)]<<12|(n=M6[t.charAt(s++)])<<6|(i=M6[t.charAt(s++)]),r+=n===64?K1(e>>16&255):i===64?K1(e>>16&255,e>>8&255):K1(e>>16&255,e>>8&255,e&255);return r},ft=typeof atob=="function"?t=>atob(lt(t)):l3?t=>Buffer.from(t,"base64").toString("binary"):Ps,Rs=l3?t=>M8(Buffer.from(t,"base64")):t=>M8(ft(t).split("").map(e=>e.charCodeAt(0))),Qs=l3?t=>Buffer.from(t,"base64").toString("utf8"):S8?t=>S8.decode(Rs(t)):t=>Os(ft(t)),qs=t=>lt(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),js=t=>Qs(qs(t));async function Y0(t){return new Promise(e=>{setTimeout(e,t)})}function ht(t){return t instanceof Error?t.message:String(t)}var O0=()=>Math.floor(Date.now()/1e3);function Vs(t){let e=new Date(t*1e3);return e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),Math.floor(e.getTime()/1e3)}function Ws(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r=e+"==".substring(0,(3-e.length%3)%3);return js(r)}function Xs(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");for(;e.length%4!==0;)e+="=";return new Uint8Array(Buffer.from(e,"base64"))}var T8=t=>{let e="";for(let r=2;r<t.length;r+=2)e+=String.fromCharCode(parseInt(t.substring(r,r+2),16));return e},Zs=t=>{let{account_address:e,module_name:r,struct_name:n}=t,i=T8(r),s=T8(n);return`${e}::${i}::${s}`},_s=t=>typeof t=="object"&&!Array.isArray(t)&&t!==null&&"account_address"in t&&"module_name"in t&&"struct_name"in t&&typeof t.account_address=="string"&&typeof t.module_name=="string"&&typeof t.struct_name=="string";function V2(t){let e=t.split("::");if(e.length!==3)throw new Error(`Invalid function ${t}`);let r=e[0],n=e[1],i=e[2];return{moduleAddress:r,moduleName:n,functionName:i}}function J7(t){let e=t.split("::");return e.length===3&&k.isValid({input:e[0]}).valid}k.A.toStringLong();var $s=(t=>(t[t.API_ERROR=0]="API_ERROR",t[t.EXTERNAL_API_ERROR=1]="EXTERNAL_API_ERROR",t[t.SESSION_EXPIRED=2]="SESSION_EXPIRED",t[t.INVALID_STATE=3]="INVALID_STATE",t[t.INVALID_SIGNATURE=4]="INVALID_SIGNATURE",t[t.UNKNOWN=5]="UNKNOWN",t))($s||{}),eo=(t=>(t.REAUTHENTICATE="Re-authentiate to continue using your keyless account",t.REAUTHENTICATE_UNSURE="Try re-authentiating. If the error persists join the telegram group at https://t.me/+h5CN-W35yUFiYzkx for further support",t.UPDATE_REQUEST_PARAMS="Update the invalid request parameters and reauthenticate.",t.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.",t.SERVER_ERROR="Try again later. See aptosApiError error for more context. For additional support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",t.CALL_PRECHECK="Call `await account.checkKeylessAccountValidity()` to wait for asyncronous changes and check for account validity before signing or serializing.",t.REINSTANTIATE="Try instantiating the account again. Avoid manipulating the account object directly",t.JOIN_SUPPORT_GROUP="For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",t.UNKNOWN="Error unknown. For support join the telegram group at https://t.me/+h5CN-W35yUFiYzkx",t))(eo||{}),to=(t=>(t[t.EPHEMERAL_KEY_PAIR_EXPIRED=0]="EPHEMERAL_KEY_PAIR_EXPIRED",t[t.PROOF_NOT_FOUND=1]="PROOF_NOT_FOUND",t[t.ASYNC_PROOF_FETCH_FAILED=2]="ASYNC_PROOF_FETCH_FAILED",t[t.INVALID_PROOF_VERIFICATION_FAILED=3]="INVALID_PROOF_VERIFICATION_FAILED",t[t.INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND=4]="INVALID_PROOF_VERIFICATION_KEY_NOT_FOUND",t[t.INVALID_JWT_SIG=5]="INVALID_JWT_SIG",t[t.INVALID_JWT_JWK_NOT_FOUND=6]="INVALID_JWT_JWK_NOT_FOUND",t[t.INVALID_JWT_ISS_NOT_RECOGNIZED=7]="INVALID_JWT_ISS_NOT_RECOGNIZED",t[t.INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED=8]="INVALID_JWT_FEDERATED_ISS_NOT_SUPPORTED",t[t.INVALID_TW_SIG_VERIFICATION_FAILED=9]="INVALID_TW_SIG_VERIFICATION_FAILED",t[t.INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND=10]="INVALID_TW_SIG_PUBLIC_KEY_NOT_FOUND",t[t.INVALID_EXPIRY_HORIZON=11]="INVALID_EXPIRY_HORIZON",t[t.JWT_PARSING_ERROR=12]="JWT_PARSING_ERROR",t[t.JWK_FETCH_FAILED=13]="JWK_FETCH_FAILED",t[t.JWK_FETCH_FAILED_FEDERATED=14]="JWK_FETCH_FAILED_FEDERATED",t[t.RATE_LIMIT_EXCEEDED=15]="RATE_LIMIT_EXCEEDED",t[t.PEPPER_SERVICE_INTERNAL_ERROR=16]="PEPPER_SERVICE_INTERNAL_ERROR",t[t.PEPPER_SERVICE_BAD_REQUEST=17]="PEPPER_SERVICE_BAD_REQUEST",t[t.PEPPER_SERVICE_OTHER=18]="PEPPER_SERVICE_OTHER",t[t.PROVER_SERVICE_INTERNAL_ERROR=19]="PROVER_SERVICE_INTERNAL_ERROR",t[t.PROVER_SERVICE_BAD_REQUEST=20]="PROVER_SERVICE_BAD_REQUEST",t[t.PROVER_SERVICE_OTHER=21]="PROVER_SERVICE_OTHER",t[t.FULL_NODE_CONFIG_LOOKUP_ERROR=22]="FULL_NODE_CONFIG_LOOKUP_ERROR",t[t.FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR=23]="FULL_NODE_VERIFICATION_KEY_LOOKUP_ERROR",t[t.FULL_NODE_JWKS_LOOKUP_ERROR=24]="FULL_NODE_JWKS_LOOKUP_ERROR",t[t.FULL_NODE_OTHER=25]="FULL_NODE_OTHER",t[t.SIGNATURE_TYPE_INVALID=26]="SIGNATURE_TYPE_INVALID",t[t.SIGNATURE_EXPIRED=27]="SIGNATURE_EXPIRED",t[t.MAX_EXPIRY_HORIZON_EXCEEDED=28]="MAX_EXPIRY_HORIZON_EXCEEDED",t[t.EPHEMERAL_SIGNATURE_VERIFICATION_FAILED=29]="EPHEMERAL_SIGNATURE_VERIFICATION_FAILED",t[t.TRAINING_WHEELS_SIGNATURE_MISSING=30]="TRAINING_WHEELS_SIGNATURE_MISSING",t[t.TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED=31]="TRAINING_WHEELS_SIGNATURE_VERIFICATION_FAILED",t[t.PROOF_VERIFICATION_FAILED=32]="PROOF_VERIFICATION_FAILED",t[t.UNKNOWN=33]="UNKNOWN",t))(to||{}),J8={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"]},o1=class Y5 extends Error{constructor(e){let{innerError:r,category:n,resolutionTip:i,type:s,message:o=J8[s][0],details:a}=e;super(o),this.name="KeylessError",this.innerError=r,this.category=n,this.resolutionTip=i,this.type=s,this.details=a,this.message=Y5.constructMessage(o,i,r,a)}static constructMessage(e,r,n,i){let s=`
Message: ${e}`;return i&&(s+=`
Details: ${i}`),n instanceof E0?s+=`
AptosApiError: ${n.message}`:n!==void 0&&(s+=`
Error: ${ht(n)}`),s+=`
KeylessErrorResolutionTip: ${r}`,s}static fromErrorType(e){let{error:r,type:n,details:i}=e,[s,o,a]=J8[n];return new Y5({message:s,details:i,innerError:r,category:o,resolutionTip:a,type:n})}},E0=class extends Error{constructor({apiType:e,aptosRequest:r,aptosResponse:n}){super(ro({apiType:e,aptosRequest:r,aptosResponse:n})),this.name="AptosApiError",this.url=n.url,this.status=n.status,this.statusText=n.statusText,this.data=n.data,this.request=r}};function ro({apiType:t,aptosRequest:e,aptosResponse:r}){var o,a,c,u,l,f,h;let n=(a=(o=r.headers)==null?void 0:o.traceparent)==null?void 0:a.split("-")[1],i=n?`(trace_id:${n}) `:"",s=`Request to [${t}]: ${e.method} ${r.url??e.url} ${i}failed with`;return t==="Indexer"&&((l=(u=(c=r.data)==null?void 0:c.errors)==null?void 0:u[0])==null?void 0:l.message)!=null?`${s}: ${r.data.errors[0].message}`:((f=r.data)==null?void 0:f.message)!=null&&((h=r.data)==null?void 0:h.error_code)!=null?`${s}: ${JSON.stringify(r.data)}`:`${s} status: ${r.statusText}(code:${r.status}) and response body: ${no(r.data)}`}var N8=400;function no(t){let e=JSON.stringify(t);return e.length<=N8?e:`truncated(original_size:${e.length}): ${e.slice(0,N8/2)}...${e.slice(-400/2)}`}var io="1.38.0";async function so(t,e){let{url:r,method:n,body:i,contentType:s,params:o,overrides:a,originMethod:c}=t,u={...a==null?void 0:a.HEADERS,"x-aptos-client":`aptos-typescript-sdk/${io}`,"content-type":s??"application/json","x-aptos-typescript-sdk-origin-method":c};return a!=null&&a.AUTH_TOKEN&&(u.Authorization=`Bearer ${a==null?void 0:a.AUTH_TOKEN}`),a!=null&&a.API_KEY&&(u.Authorization=`Bearer ${a==null?void 0:a.API_KEY}`),e.provider({url:r,method:n,body:i,params:o,headers:u,overrides:a})}async function pt(t,e,r){let{url:n,path:i}=t,s=i?`${n}/${i}`:n,o=await so({...t,url:s},e.client),a={status:o.status,statusText:o.statusText??"No status text provided",data:o.data,headers:o.headers,config:o.config,request:o.request,url:s};if(a.status===401)throw new E0({apiType:r,aptosRequest:t,aptosResponse:a});if(r==="Indexer"){let c=a.data;if(c.errors)throw new E0({apiType:r,aptosRequest:t,aptosResponse:a});a.data=c.data}else if((r==="Pepper"||r==="Prover")&&a.status>=400)throw new E0({apiType:r,aptosRequest:t,aptosResponse:a});if(a.status>=200&&a.status<300)return a;throw new E0({apiType:r,aptosRequest:t,aptosResponse:a})}async function N7(t){let{aptosConfig:e,overrides:r,params:n,contentType:i,acceptType:s,path:o,originMethod:a,type:c}=t,u=e.getRequestUrl(c);return pt({url:u,method:"GET",originMethod:a,path:o,contentType:i,acceptType:s,params:n,overrides:{...e.clientConfig,...r}},e,t.type)}async function Z1(t){var r,n;let{aptosConfig:e}=t;return N7({...t,type:"Fullnode",overrides:{...e.clientConfig,...e.fullnodeConfig,...t.overrides,HEADERS:{...(r=e.clientConfig)==null?void 0:r.HEADERS,...(n=e.fullnodeConfig)==null?void 0:n.HEADERS}}})}async function gt(t){let e=new Array(0),r,n=t.params;do{let i=await N7({type:"Fullnode",aptosConfig:t.aptosConfig,originMethod:t.originMethod,path:t.path,params:n,overrides:t.overrides});r=i.headers["x-aptos-cursor"],delete i.headers,e.push(...i.data),n.start=r}while(r!=null);return e}async function yt(t){let e=new Array(0),r,n=t.params,i=n.limit;do{let{response:s,cursor:o}=await z7({...t});if(r=o,e.push(...s.data),t!=null&&t.params&&(t.params.start=r),i!==void 0){let a=i-e.length;if(a<=0)break;n.limit=a}}while(r!=null);return e}async function z7(t){var i,s;let e,r={};typeof((i=t.params)==null?void 0:i.cursor)=="string"&&(r.start=t.params.cursor),typeof((s=t.params)==null?void 0:s.limit)=="number"&&(r.limit=t.params.limit);let n=await N7({type:"Fullnode",aptosConfig:t.aptosConfig,originMethod:t.originMethod,path:t.path,params:r,overrides:t.overrides});return e=n.headers["x-aptos-cursor"],{response:n,cursor:e}}async function wt(t){let{aptosConfig:e,accountAddress:r}=t,{data:n}=await Z1({aptosConfig:e,originMethod:"getInfo",path:`accounts/${k.from(r).toString()}`});return n}async function oo(t){var e;return((e=t.options)==null?void 0:e.ledgerVersion)!==void 0?z8(t):m6(async()=>z8(t),`module-${t.accountAddress}-${t.moduleName}`,1e3*60*5)()}async function z8(t){let{aptosConfig:e,accountAddress:r,moduleName:n,options:i}=t,{data:s}=await Z1({aptosConfig:e,originMethod:"getModule",path:`accounts/${k.from(r).toString()}/module/${n}`,params:{ledger_version:i==null?void 0:i.ledgerVersion}});return s}var At=class mt extends X{constructor(e){super(),this.chainId=e}serialize(e){e.serializeU8(this.chainId)}static deserialize(e){let r=e.deserializeU8();return new mt(r)}},_1=class Et extends X{constructor(e){super(),this.identifier=e}serialize(e){e.serializeStr(this.identifier)}static deserialize(e){let r=e.deserializeStr();return new Et(r)}};function ao(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var f5={},x6={},h5,Y8;function Y1(){if(Y8)return h5;Y8=1;const t=BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"),e=8,r=[56,57,56,60,60,63,64,63,60,66,60,65,70,60,64,68],n=o=>{let a=o*o;return o*a*a%t};function i(o,a){const c=[];for(let u=0;u<o.length;u++){let l=0n;for(let f=0;f<o.length;f++)l=l+a[u][f]*o[f];c.push(l%t)}return c}function s(o,a){const c=o.map(m=>BigInt(m));if(c.length<=0)throw new Error("poseidon-lite: Not enough inputs");if(c.length>r.length)throw new Error("poseidon-lite: Too many inputs");const u=c.length+1,l=e,f=r[u-2],{C:h,M:g}=a;if(g.length!==u)throw new Error(`poseidon-lite: Incorrect M length, expected ${u} got ${g.length}`);let d=[0n,...c];for(let m=0;m<l+f;m++){for(let p=0;p<d.length;p++)d[p]=d[p]+h[m*u+p],(m<l/2||m>=l/2+f||p===0)&&(d[p]=n(d[p]));d=i(d,g)}return d[0]}return h5=s,h5}var T6={},O8;function O1(){if(O8)return T6;O8=1,Object.defineProperty(T6,"__esModule",{value:!0}),T6.default=t;function t(e){if(Array.isArray(e))return e.map(t);if(typeof e=="object"){const i={};for(const[s,o]of Object.entries(e))i[s]=t(o);return i}const n=[...Uint8Array.from(atob(e),i=>i.charCodeAt(0))].map(i=>i.toString(16).padStart(2,"0")).join("");return BigInt(`0x${n}`)}return T6}var m3={},P8;function co(){if(P8)return m3;P8=1,Object.defineProperty(m3,"__esModule",{value:!0}),m3.default=void 0;var t={C:["CcRunsaOm9T+H6q6KUy6OKcaoXdTTN0bbH3A29Cr16c=","DANWUwiW7sQql+2TfzE1z8UUKzrkBbg0PB2D/6YEy4E=","Hiih2TVpitEULlEYK7VM9KAOpaq9Ymi9MX6pd8wVSjA=","J68tgxqdJ0gICWXbMOKY5A5XV8PgCNuWTPnisSuRJR8=","Hm8RzmD8j1E6ajz+Fq4XWkEpFGLyFM0Iear0NUW3TgM=","Kmc4TTu9XkOFQYGctoHwvgRGLtFMNhPY9xkgYmjRQtM=","C2b981YJOmEWCfjhL7/s8LmF44HwJRiJNkCPXVyfRdA=","AS7j7B541HCDDGEJPCreNwsmyDzFzr7t2qaFLb2wniE=","AlK6X2dgv739iPZ/gXXj/WzRxDGwmba7LRCOe0Rbsbk=","F5R0zOyl/2dsa+w871QpY1Q5Gok1/3HW71rqrXypMvE=","LCQmE3mlG/qSKP9KUD/U7Zwfl0omSWmzfholibvtK5E=","HMHXtiaS5j6sLyiL0GlbQ8L2P1AB/A/FU+ZsBVGAGwU=","JVBZMBqtqYuy7VX4UpeelgB4Tb8X+6zQXZ7/X9nJG1Y=","KEN746wcsuR54fXA7M0ys66iQjSXCoGTsRwpzn5Z79k=","KCFqRC8uH3EcpPprU3ZusRhUjaj7T3jUM4diw39fIEM=","LB9HzRf6Wt8fOfTnBW3QP+7h784DCUWBEx8jdzI0gsk=","B6utArel68SGMrzJNWzrfdna/KJ2Y4pjZGuFZqYhr8k=","AjAmRgH/3yknWzP/qrUd/pQp+QiAppzRN9oMTRX5bDw=","G8lzBU5R2QWg8WhlZJfKQKhkQUVX7iiecX5dZomaoKk=","Lhwi+WRDUAggbDFX6GNB7dJJr/XC2EIfKm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