@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.
1,059 lines • 6.15 MB
JavaScript
var Ni = Object.defineProperty;
var zi = (t, e, r) => e in t ? Ni(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
var j1 = (t, e, r) => zi(t, typeof e != "symbol" ? e + "" : e, r);
import { TokenPairs as I4, Token as Yi } from "aptos-tool";
import d1 from "bignumber.js";
import k8, { gql as j2 } from "graphql-request";
import Oi from "long";
var u5 = 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 J5("Task cancelled"));
}), this.pendingDequeue = [], this.queue.length = 0;
}
isCancelled() {
return this.cancelled;
}
pendingDequeueLength() {
return this.pendingDequeue.length;
}
}, J5 = 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 Pi(t) {
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
}
function a2(t, ...e) {
if (!Pi(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 xe(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 Te(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 Ri = (t) => new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4)), C0 = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength), I2 = (t, e) => t << 32 - e | t >>> e, L6 = (t, e) => t << e | t >>> 32 - e >>> 0, v8 = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68, Qi = (t) => t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
function L8(t) {
for (let e = 0; e < t.length; e++)
t[e] = Qi(t[e]);
}
const qi = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0"));
function O3(t) {
a2(t);
let e = "";
for (let r = 0; r < t.length; r++)
e += qi[t[r]];
return e;
}
const H2 = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
function F8(t) {
if (t >= H2._0 && t <= H2._9)
return t - H2._0;
if (t >= H2.A && t <= H2.F)
return t - (H2.A - 10);
if (t >= H2.a && t <= H2.f)
return t - (H2.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 = F8(t.charCodeAt(s)), a = F8(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 Je(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 = Je(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 {
// Safe version that clones internal state
clone() {
return this._cloneInto();
}
}
function ji(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 J4(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 N4(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 Vi = ((t) => (t.TOO_SHORT = "too_short", t.INVALID_LENGTH = "invalid_length", t.INVALID_HEX_CHARS = "invalid_hex_chars", t))(Vi || {}), R = class t0 {
constructor(e) {
this.data = e;
}
toUint8Array() {
return this.data;
}
toStringWithoutPrefix() {
return O3(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]);
}
}, Wi = (t) => new TextDecoder().decode(R.fromHexInput(t).toUint8Array()), Ne = 255, ze = 65535, t3 = 4294967295, z4 = 18446744073709551615n, x7 = 340282366920938463463374607431768211455n, Ye = 115792089237316195423570985008687907853269984665640564039457584007913129639935n, Xi = Object.defineProperty, Zi = Object.getOwnPropertyDescriptor, y2 = (t, e, r, n) => {
for (var i = Zi(e, r), s = t.length - 1, o; s >= 0; s--) (o = t[s]) && (i = o(e, r, i) || i);
return i && Xi(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) {
Oe(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) & z4, 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, Ne)], T1.prototype, "serializeU8"), y2([w0(0, ze)], T1.prototype, "serializeU16"), y2([w0(0, t3)], T1.prototype, "serializeU32"), y2([w0(BigInt(0), z4)], T1.prototype, "serializeU64"), y2([w0(BigInt(0), x7)], T1.prototype, "serializeU128"), y2([w0(BigInt(0), Ye)], T1.prototype, "serializeU256"), y2([w0(0, t3)], T1.prototype, "serializeU32AsUleb128");
function Oe(t) {
if (typeof t != "boolean") throw new Error(`${t} is not a boolean value`);
}
var _i = (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(_i(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 Pe extends X {
constructor(e) {
super(), Oe(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 Pe(e.deserializeBool());
}
}, Q2 = class Re extends X {
constructor(e) {
super(), G0(e, 0, Ne), 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 Re(e.deserializeU8());
}
}, d6 = class Qe extends X {
constructor(e) {
super(), G0(e, 0, ze), 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());
}
}, f6 = class qe 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 qe(e.deserializeU32());
}
}, O2 = class je extends X {
constructor(e) {
super(), G0(e, BigInt(0), z4), 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 je(e.deserializeU64());
}
}, h6 = class Ve 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 Ve(e.deserializeU128());
}
}, u3 = class We extends X {
constructor(e) {
super(), G0(e, BigInt(0), Ye), 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 We(e.deserializeU256());
}
}, f2 = class Xe {
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 Xe(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 B2 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 Ze(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 B2(r.map((n) => new Q2(n)));
}
static U16(e) {
return new B2(e.map((r) => new d6(r)));
}
static U32(e) {
return new B2(e.map((r) => new f6(r)));
}
static U64(e) {
return new B2(e.map((r) => new O2(r)));
}
static U128(e) {
return new B2(e.map((r) => new h6(r)));
}
static U256(e) {
return new B2(e.map((r) => new u3(r)));
}
static Bool(e) {
return new B2(e.map((r) => new G1(r)));
}
static MoveString(e) {
return new B2(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 B2(i);
}
}, Ze = 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 $e 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 $e(e.deserializeStr());
}
}, s2 = class C2 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 C2(e != null ? new Q2(e) : void 0);
}
static U16(e) {
return new C2(e != null ? new d6(e) : void 0);
}
static U32(e) {
return new C2(e != null ? new f6(e) : void 0);
}
static U64(e) {
return new C2(e != null ? new O2(e) : void 0);
}
static U128(e) {
return new C2(e != null ? new h6(e) : void 0);
}
static U256(e) {
return new C2(e != null ? new u3(e) : void 0);
}
static Bool(e) {
return new C2(e != null ? new G1(e) : void 0);
}
static MoveString(e) {
return new C2(e != null ? new I1(e) : void 0);
}
static deserialize(e, r) {
let n = l1.deserialize(e, r);
return new C2(n.values[0]);
}
}, $i = ((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))($i || {}), 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 = O3(this.data);
return this.isSpecial() && (e = e[e.length - 1]), e;
}
toStringLong() {
return `0x${this.toStringLongWithoutPrefix()}`;
}
toStringLongWithoutPrefix() {
return O3(this.data);
}
toStringShort() {
return `0x${this.toStringShortWithoutPrefix()}`;
}
toStringShortWithoutPrefix() {
let e = O3(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, es = class extends X {
constructor(e) {
super(), this.accountAddress = k.ONE, this.moduleName = new I1("account"), this.structName = new I1("RotationProofChallenge"), this.sequenceNumber = new O2(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);
}
}, l5 = /* @__PURE__ */ new Map();
function p6(t, e, r) {
return async (...n) => {
if (l5.has(e)) {
let { value: s, timestamp: o } = l5.get(e);
if (Date.now() - o <= r) return s;
}
let i = await t(...n);
return l5.set(e, { value: i, timestamp: Date.now() }), i;
};
}
const F6 = /* @__PURE__ */ BigInt(2 ** 32 - 1), N5 = /* @__PURE__ */ BigInt(32);
function et(t, e = !1) {
return e ? { h: Number(t & F6), l: Number(t >> N5 & F6) } : { h: Number(t >> N5 & F6) | 0, l: Number(t & F6) | 0 };
}
function tt(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 } = et(t[i], e);
[r[i], n[i]] = [s, o];
}
return [r, n];
}
const ts = (t, e) => BigInt(t >>> 0) << N5 | BigInt(e >>> 0), rs = (t, e, r) => t >>> r, ns = (t, e, r) => t << 32 - r | e >>> r, is = (t, e, r) => t >>> r | e << 32 - r, ss = (t, e, r) => t << 32 - r | e >>> r, os = (t, e, r) => t << 64 - r | e >>> r - 32, as = (t, e, r) => t >>> r - 32 | e << 64 - r, cs = (t, e) => e, us = (t, e) => t, rt = (t, e, r) => t << r | e >>> 32 - r, nt = (t, e, r) => e << r | t >>> 32 - r, it = (t, e, r) => e << r - 32 | t >>> 64 - r, st = (t, e, r) => t << r - 32 | e >>> 64 - r;
function ls(t, e, r, n) {
const i = (e >>> 0) + (n >>> 0);
return { h: t + r + (i / 2 ** 32 | 0) | 0, l: i | 0 };
}
const ds = (t, e, r) => (t >>> 0) + (e >>> 0) + (r >>> 0), fs = (t, e, r, n) => e + r + n + (t / 2 ** 32 | 0) | 0, hs = (t, e, r, n) => (t >>> 0) + (e >>> 0) + (r >>> 0) + (n >>> 0), ps = (t, e, r, n, i) => e + r + n + i + (t / 2 ** 32 | 0) | 0, gs = (t, e, r, n, i) => (t >>> 0) + (e >>> 0) + (r >>> 0) + (n >>> 0) + (i >>> 0), ys = (t, e, r, n, i, s) => e + r + n + i + s + (t / 2 ** 32 | 0) | 0, $ = {
fromBig: et,
split: tt,
toBig: ts,
shrSH: rs,
shrSL: ns,
rotrSH: is,
rotrSL: ss,
rotrBH: os,
rotrBL: as,
rotr32H: cs,
rotr32L: us,
rotlSH: rt,
rotlSL: nt,
rotlBH: it,
rotlBL: st,
add: ls,
add3L: ds,
add3H: fs,
add4L: hs,
add4H: ps,
add5H: ys,
add5L: gs
}, ot = [], at = [], ct = [], ws = /* @__PURE__ */ BigInt(0), A3 = /* @__PURE__ */ BigInt(1), As = /* @__PURE__ */ BigInt(2), ms = /* @__PURE__ */ BigInt(7), Es = /* @__PURE__ */ BigInt(256), Is = /* @__PURE__ */ BigInt(113);
for (let t = 0, e = A3, r = 1, n = 0; t < 24; t++) {
[r, n] = [n, (2 * r + 3 * n) % 5], ot.push(2 * (5 * n + r)), at.push((t + 1) * (t + 2) / 2 % 64);
let i = ws;
for (let s = 0; s < 7; s++)
e = (e << A3 ^ (e >> ms) * Is) % Es, e & As && (i ^= A3 << (A3 << /* @__PURE__ */ BigInt(s)) - A3);
ct.push(i);
}
const [bs, Bs] = /* @__PURE__ */ tt(ct, !0), D8 = (t, e, r) => r > 32 ? it(t, e, r) : rt(t, e, r), K8 = (t, e, r) => r > 32 ? st(t, e, r) : nt(t, e, r);
function Cs(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 = D8(u, l, 1) ^ r[a], h = K8(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 = at[o], c = D8(i, s, a), u = K8(i, s, a), l = ot[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] ^= bs[n], t[1] ^= Bs[n];
}
r.fill(0);
}
class T7 extends M7 {
// NOTE: we accept arguments in bytes instead of bits here.
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 = Ri(this.state);
}
keccak() {
v8 || L8(this.state32), Cs(this.state32, this.rounds), v8 || L8(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 (Te(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 Us = (t, e, r) => J4(() => new T7(e, t, r)), l2 = /* @__PURE__ */ Us(6, 136, 256 / 8);
var ks = (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", H8 = typeof TextDecoder == "function" ? new TextDecoder() : void 0, S8 = typeof TextEncoder == "function" ? new TextEncoder() : void 0, vs = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", T3 = Array.prototype.slice.call(vs), D6 = ((t) => {
let e = {};
return t.forEach((r, n) => e[r] = n), e;
})(T3), Ls = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, K1 = String.fromCharCode.bind(String), G8 = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), Fs = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), ut = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), Ds = (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;
}, lt = typeof btoa == "function" ? (t) => btoa(t) : l3 ? (t) => Buffer.from(t, "binary").toString("base64") : Ds, Ks = 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 lt(r.join(""));
}, Hs = (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);
}
}, Ss = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, Gs = (t) => t.replace(Ss, Hs), M8 = l3 ? (t) => Buffer.from(t, "utf8").toString("base64") : S8 ? (t) => Ks(S8.encode(t)) : (t) => lt(Gs(t)), Ms = (t, e = !1) => e ? Fs(M8(t)) : M8(t), xs = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g, Ts = (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));
}
}, Js = (t) => t.replace(xs, Ts), Ns = (t) => {
if (t = t.replace(/\s+/g, ""), !Ls.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 = D6[t.charAt(s++)] << 18 | D6[t.charAt(s++)] << 12 | (n = D6[t.charAt(s++)]) << 6 | (i = D6[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;
}, dt = typeof atob == "function" ? (t) => atob(ut(t)) : l3 ? (t) => Buffer.from(t, "base64").toString("binary") : Ns, zs = l3 ? (t) => G8(Buffer.from(t, "base64")) : (t) => G8(dt(t).split("").map((e) => e.charCodeAt(0))), Ys = l3 ? (t) => Buffer.from(t, "base64").toString("utf8") : H8 ? (t) => H8.decode(zs(t)) : (t) => Js(dt(t)), Os = (t) => ut(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), Ps = (t) => Ys(Os(t));
async function Y0(t) {
return new Promise((e) => {
setTimeout(e, t);
});
}
function ft(t) {
return t instanceof Error ? t.message : String(t);
}
var O0 = () => Math.floor(Date.now() / 1e3);
function Rs(t) {
let e = new Date(t * 1e3);
return e.setMinutes(0), e.setSeconds(0), e.setMilliseconds(0), Math.floor(e.getTime() / 1e3);
}
function Qs(t) {
let e = t.replace(/-/g, "+").replace(/_/g, "/"), r = e + "==".substring(0, (3 - e.length % 3) % 3);
return Ps(r);
}
function qs(t) {
let e = t.replace(/-/g, "+").replace(/_/g, "/");
for (; e.length % 4 !== 0; ) e += "=";
return new Uint8Array(Buffer.from(e, "base64"));
}
var x8 = (t) => {
let e = "";
for (let r = 2; r < t.length; r += 2) e += String.fromCharCode(parseInt(t.substring(r, r + 2), 16));
return e;
}, js = (t) => {
let { account_address: e, module_name: r, struct_name: n } = t, i = x8(r), s = x8(n);
return `${e}::${i}::${s}`;
}, Vs = (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 Ws = ((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))(Ws || {}), Xs = ((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))(Xs || {}), Zs = ((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))(Zs || {}), T8 = { 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 z5 extends Error {
constructor(e) {
let { innerError: r, category: n, resolutionTip: i, type: s, message: o = T8[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 = z5.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: ${ft(n)}`), s += `
KeylessErrorResolutionTip: ${r}`, s;
}
static fromErrorType(e) {
let { error: r, type: n, details: i } = e, [s, o, a] = T8[n];
return new z5({ message: s, details: i, innerError: r, category: o, resolutionTip: a, type: n });
}
}, E0 = class extends Error {
constructor({ apiType: e, aptosRequest: r, aptosResponse: n }) {
super(_s({ 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 _s({ 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: ${$s(r.data)}`;
}
var J8 = 400;
function $s(t) {
let e = JSON.stringify(t);
return e.length <= J8 ? e : `truncated(original_size:${e.length}): ${e.slice(0, J8 / 2)}...${e.slice(-400 / 2)}`;
}
var eo = "1.38.0";
async function to(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/${eo}`, "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 ht(t, e, r) {
let { url: n, path: i } = t, s = i ? `${n}/${i}` : n, o = await to({ ...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 ht({ 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 pt(t) {
let e = new Array(0),