UNPKG

@descent-protocol/sdk

Version:

A Typescript library for interacting with the Descent Protocol

1,864 lines (1,847 loc) 215 kB
// node_modules/ethers/lib.esm/_version.js var version = "6.9.1"; // node_modules/ethers/lib.esm/utils/properties.js function checkType(value, type, name) { const types = type.split("|").map((t) => t.trim()); for (let i = 0; i < types.length; i++) { switch (type) { case "any": return; case "bigint": case "boolean": case "number": case "string": if (typeof value === type) { return; } } } const error = new Error(`invalid value for type ${type}`); error.code = "INVALID_ARGUMENT"; error.argument = `value.${name}`; error.value = value; throw error; } async function resolveProperties(value) { const keys = Object.keys(value); const results = await Promise.all(keys.map((k) => Promise.resolve(value[k]))); return results.reduce((accum, v, index) => { accum[keys[index]] = v; return accum; }, {}); } function defineProperties(target, values, types) { for (let key in values) { let value = values[key]; const type = types ? types[key] : null; if (type) { checkType(value, type, key); } Object.defineProperty(target, key, { enumerable: true, value, writable: false }); } } // node_modules/ethers/lib.esm/utils/errors.js function stringify(value) { if (value == null) { return "null"; } if (Array.isArray(value)) { return "[ " + value.map(stringify).join(", ") + " ]"; } if (value instanceof Uint8Array) { const HEX = "0123456789abcdef"; let result = "0x"; for (let i = 0; i < value.length; i++) { result += HEX[value[i] >> 4]; result += HEX[value[i] & 15]; } return result; } if (typeof value === "object" && typeof value.toJSON === "function") { return stringify(value.toJSON()); } switch (typeof value) { case "boolean": case "symbol": return value.toString(); case "bigint": return BigInt(value).toString(); case "number": return value.toString(); case "string": return JSON.stringify(value); case "object": { const keys = Object.keys(value); keys.sort(); return "{ " + keys.map((k) => `${stringify(k)}: ${stringify(value[k])}`).join(", ") + " }"; } } return `[ COULD NOT SERIALIZE ]`; } function isError(error, code) { return error && error.code === code; } function isCallException(error) { return isError(error, "CALL_EXCEPTION"); } function makeError(message, code, info) { let shortMessage = message; { const details = []; if (info) { if ("message" in info || "code" in info || "name" in info) { throw new Error(`value will overwrite populated values: ${stringify(info)}`); } for (const key in info) { if (key === "shortMessage") { continue; } const value = info[key]; details.push(key + "=" + stringify(value)); } } details.push(`code=${code}`); details.push(`version=${version}`); if (details.length) { message += " (" + details.join(", ") + ")"; } } let error; switch (code) { case "INVALID_ARGUMENT": error = new TypeError(message); break; case "NUMERIC_FAULT": case "BUFFER_OVERRUN": error = new RangeError(message); break; default: error = new Error(message); } defineProperties(error, { code }); if (info) { Object.assign(error, info); } if (error.shortMessage == null) { defineProperties(error, { shortMessage }); } return error; } function assert(check, message, code, info) { if (!check) { throw makeError(message, code, info); } } function assertArgument(check, message, name, value) { assert(check, message, "INVALID_ARGUMENT", { argument: name, value }); } function assertArgumentCount(count, expectedCount, message) { if (message == null) { message = ""; } if (message) { message = ": " + message; } assert(count >= expectedCount, "missing arguemnt" + message, "MISSING_ARGUMENT", { count, expectedCount }); assert(count <= expectedCount, "too many arguemnts" + message, "UNEXPECTED_ARGUMENT", { count, expectedCount }); } var _normalizeForms = ["NFD", "NFC", "NFKD", "NFKC"].reduce((accum, form) => { try { if ("test".normalize(form) !== "test") { throw new Error("bad"); } ; if (form === "NFD") { const check = String.fromCharCode(233).normalize("NFD"); const expected = String.fromCharCode(101, 769); if (check !== expected) { throw new Error("broken"); } } accum.push(form); } catch (error) { } return accum; }, []); function assertNormalize(form) { assert(_normalizeForms.indexOf(form) >= 0, "platform missing String.prototype.normalize", "UNSUPPORTED_OPERATION", { operation: "String.prototype.normalize", info: { form } }); } function assertPrivate(givenGuard, guard, className) { if (className == null) { className = ""; } if (givenGuard !== guard) { let method = className, operation = "new"; if (className) { method += "."; operation += " " + className; } assert(false, `private constructor; use ${method}from* methods`, "UNSUPPORTED_OPERATION", { operation }); } } // node_modules/ethers/lib.esm/utils/data.js function _getBytes(value, name, copy) { if (value instanceof Uint8Array) { if (copy) { return new Uint8Array(value); } return value; } if (typeof value === "string" && value.match(/^0x([0-9a-f][0-9a-f])*$/i)) { const result = new Uint8Array((value.length - 2) / 2); let offset = 2; for (let i = 0; i < result.length; i++) { result[i] = parseInt(value.substring(offset, offset + 2), 16); offset += 2; } return result; } assertArgument(false, "invalid BytesLike value", name || "value", value); } function getBytes(value, name) { return _getBytes(value, name, false); } function getBytesCopy(value, name) { return _getBytes(value, name, true); } function isHexString(value, length) { if (typeof value !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { return false; } if (typeof length === "number" && value.length !== 2 + 2 * length) { return false; } if (length === true && value.length % 2 !== 0) { return false; } return true; } var HexCharacters = "0123456789abcdef"; function hexlify(data) { const bytes2 = getBytes(data); let result = "0x"; for (let i = 0; i < bytes2.length; i++) { const v = bytes2[i]; result += HexCharacters[(v & 240) >> 4] + HexCharacters[v & 15]; } return result; } function concat(datas) { return "0x" + datas.map((d) => hexlify(d).substring(2)).join(""); } function dataSlice(data, start, end) { const bytes2 = getBytes(data); if (end != null && end > bytes2.length) { assert(false, "cannot slice beyond data bounds", "BUFFER_OVERRUN", { buffer: bytes2, length: bytes2.length, offset: end }); } return hexlify(bytes2.slice(start == null ? 0 : start, end == null ? bytes2.length : end)); } function zeroPad(data, length, left) { const bytes2 = getBytes(data); assert(length >= bytes2.length, "padding exceeds data length", "BUFFER_OVERRUN", { buffer: new Uint8Array(bytes2), length, offset: length + 1 }); const result = new Uint8Array(length); result.fill(0); if (left) { result.set(bytes2, length - bytes2.length); } else { result.set(bytes2, 0); } return hexlify(result); } function zeroPadValue(data, length) { return zeroPad(data, length, true); } function zeroPadBytes(data, length) { return zeroPad(data, length, false); } // node_modules/ethers/lib.esm/utils/maths.js var BN_0 = BigInt(0); var BN_1 = BigInt(1); var maxValue = 9007199254740991; function fromTwos(_value, _width) { const value = getUint(_value, "value"); const width = BigInt(getNumber(_width, "width")); assert(value >> width === BN_0, "overflow", "NUMERIC_FAULT", { operation: "fromTwos", fault: "overflow", value: _value }); if (value >> width - BN_1) { const mask2 = (BN_1 << width) - BN_1; return -((~value & mask2) + BN_1); } return value; } function toTwos(_value, _width) { let value = getBigInt(_value, "value"); const width = BigInt(getNumber(_width, "width")); const limit = BN_1 << width - BN_1; if (value < BN_0) { value = -value; assert(value <= limit, "too low", "NUMERIC_FAULT", { operation: "toTwos", fault: "overflow", value: _value }); const mask2 = (BN_1 << width) - BN_1; return (~value & mask2) + BN_1; } else { assert(value < limit, "too high", "NUMERIC_FAULT", { operation: "toTwos", fault: "overflow", value: _value }); } return value; } function mask(_value, _bits) { const value = getUint(_value, "value"); const bits = BigInt(getNumber(_bits, "bits")); return value & (BN_1 << bits) - BN_1; } function getBigInt(value, name) { switch (typeof value) { case "bigint": return value; case "number": assertArgument(Number.isInteger(value), "underflow", name || "value", value); assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value); return BigInt(value); case "string": try { if (value === "") { throw new Error("empty string"); } if (value[0] === "-" && value[1] !== "-") { return -BigInt(value.substring(1)); } return BigInt(value); } catch (e) { assertArgument(false, `invalid BigNumberish string: ${e.message}`, name || "value", value); } } assertArgument(false, "invalid BigNumberish value", name || "value", value); } function getUint(value, name) { const result = getBigInt(value, name); assert(result >= BN_0, "unsigned value cannot be negative", "NUMERIC_FAULT", { fault: "overflow", operation: "getUint", value }); return result; } var Nibbles = "0123456789abcdef"; function toBigInt(value) { if (value instanceof Uint8Array) { let result = "0x0"; for (const v of value) { result += Nibbles[v >> 4]; result += Nibbles[v & 15]; } return BigInt(result); } return getBigInt(value); } function getNumber(value, name) { switch (typeof value) { case "bigint": assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value); return Number(value); case "number": assertArgument(Number.isInteger(value), "underflow", name || "value", value); assertArgument(value >= -maxValue && value <= maxValue, "overflow", name || "value", value); return value; case "string": try { if (value === "") { throw new Error("empty string"); } return getNumber(BigInt(value), name); } catch (e) { assertArgument(false, `invalid numeric string: ${e.message}`, name || "value", value); } } assertArgument(false, "invalid numeric value", name || "value", value); } function toNumber(value) { return getNumber(toBigInt(value)); } function toBeHex(_value, _width) { const value = getUint(_value, "value"); let result = value.toString(16); if (_width == null) { if (result.length % 2) { result = "0" + result; } } else { const width = getNumber(_width, "width"); assert(width * 2 >= result.length, `value exceeds width (${width} bytes)`, "NUMERIC_FAULT", { operation: "toBeHex", fault: "overflow", value: _value }); while (result.length < width * 2) { result = "0" + result; } } return "0x" + result; } function toBeArray(_value) { const value = getUint(_value, "value"); if (value === BN_0) { return new Uint8Array([]); } let hex = value.toString(16); if (hex.length % 2) { hex = "0" + hex; } const result = new Uint8Array(hex.length / 2); for (let i = 0; i < result.length; i++) { const offset = i * 2; result[i] = parseInt(hex.substring(offset, offset + 2), 16); } return result; } // node_modules/ethers/lib.esm/utils/events.js var EventPayload = class { /** * The event filter. */ filter; /** * The **EventEmitterable**. */ emitter; #listener; /** * Create a new **EventPayload** for %%emitter%% with * the %%listener%% and for %%filter%%. */ constructor(emitter, listener, filter) { this.#listener = listener; defineProperties(this, { emitter, filter }); } /** * Unregister the triggered listener for future events. */ async removeListener() { if (this.#listener == null) { return; } await this.emitter.off(this.filter, this.#listener); } }; // node_modules/ethers/lib.esm/utils/utf8.js function errorFunc(reason, offset, bytes2, output2, badCodepoint) { assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, "bytes", bytes2); } function ignoreFunc(reason, offset, bytes2, output2, badCodepoint) { if (reason === "BAD_PREFIX" || reason === "UNEXPECTED_CONTINUE") { let i = 0; for (let o = offset + 1; o < bytes2.length; o++) { if (bytes2[o] >> 6 !== 2) { break; } i++; } return i; } if (reason === "OVERRUN") { return bytes2.length - offset - 1; } return 0; } function replaceFunc(reason, offset, bytes2, output2, badCodepoint) { if (reason === "OVERLONG") { assertArgument(typeof badCodepoint === "number", "invalid bad code point for replacement", "badCodepoint", badCodepoint); output2.push(badCodepoint); return 0; } output2.push(65533); return ignoreFunc(reason, offset, bytes2, output2, badCodepoint); } var Utf8ErrorFuncs = Object.freeze({ error: errorFunc, ignore: ignoreFunc, replace: replaceFunc }); function getUtf8CodePoints(_bytes, onError) { if (onError == null) { onError = Utf8ErrorFuncs.error; } const bytes2 = getBytes(_bytes, "bytes"); const result = []; let i = 0; while (i < bytes2.length) { const c = bytes2[i++]; if (c >> 7 === 0) { result.push(c); continue; } let extraLength = null; let overlongMask = null; if ((c & 224) === 192) { extraLength = 1; overlongMask = 127; } else if ((c & 240) === 224) { extraLength = 2; overlongMask = 2047; } else if ((c & 248) === 240) { extraLength = 3; overlongMask = 65535; } else { if ((c & 192) === 128) { i += onError("UNEXPECTED_CONTINUE", i - 1, bytes2, result); } else { i += onError("BAD_PREFIX", i - 1, bytes2, result); } continue; } if (i - 1 + extraLength >= bytes2.length) { i += onError("OVERRUN", i - 1, bytes2, result); continue; } let res = c & (1 << 8 - extraLength - 1) - 1; for (let j = 0; j < extraLength; j++) { let nextChar = bytes2[i]; if ((nextChar & 192) != 128) { i += onError("MISSING_CONTINUE", i, bytes2, result); res = null; break; } ; res = res << 6 | nextChar & 63; i++; } if (res === null) { continue; } if (res > 1114111) { i += onError("OUT_OF_RANGE", i - 1 - extraLength, bytes2, result, res); continue; } if (res >= 55296 && res <= 57343) { i += onError("UTF16_SURROGATE", i - 1 - extraLength, bytes2, result, res); continue; } if (res <= overlongMask) { i += onError("OVERLONG", i - 1 - extraLength, bytes2, result, res); continue; } result.push(res); } return result; } function toUtf8Bytes(str, form) { if (form != null) { assertNormalize(form); str = str.normalize(form); } let result = []; for (let i = 0; i < str.length; i++) { const c = str.charCodeAt(i); if (c < 128) { result.push(c); } else if (c < 2048) { result.push(c >> 6 | 192); result.push(c & 63 | 128); } else if ((c & 64512) == 55296) { i++; const c2 = str.charCodeAt(i); assertArgument(i < str.length && (c2 & 64512) === 56320, "invalid surrogate pair", "str", str); const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023); result.push(pair >> 18 | 240); result.push(pair >> 12 & 63 | 128); result.push(pair >> 6 & 63 | 128); result.push(pair & 63 | 128); } else { result.push(c >> 12 | 224); result.push(c >> 6 & 63 | 128); result.push(c & 63 | 128); } } return new Uint8Array(result); } function _toUtf8String(codePoints) { return codePoints.map((codePoint) => { if (codePoint <= 65535) { return String.fromCharCode(codePoint); } codePoint -= 65536; return String.fromCharCode((codePoint >> 10 & 1023) + 55296, (codePoint & 1023) + 56320); }).join(""); } function toUtf8String(bytes2, onError) { return _toUtf8String(getUtf8CodePoints(bytes2, onError)); } // node_modules/ethers/lib.esm/utils/rlp-encode.js function arrayifyInteger(value) { const result = []; while (value) { result.unshift(value & 255); value >>= 8; } return result; } function _encode(object) { if (Array.isArray(object)) { let payload = []; object.forEach(function(child) { payload = payload.concat(_encode(child)); }); if (payload.length <= 55) { payload.unshift(192 + payload.length); return payload; } const length2 = arrayifyInteger(payload.length); length2.unshift(247 + length2.length); return length2.concat(payload); } const data = Array.prototype.slice.call(getBytes(object, "object")); if (data.length === 1 && data[0] <= 127) { return data; } else if (data.length <= 55) { data.unshift(128 + data.length); return data; } const length = arrayifyInteger(data.length); length.unshift(183 + length.length); return length.concat(data); } var nibbles = "0123456789abcdef"; function encodeRlp(object) { let result = "0x"; for (const v of _encode(object)) { result += nibbles[v >> 4]; result += nibbles[v & 15]; } return result; } // node_modules/ethers/lib.esm/abi/coders/abstract-coder.js var WordSize = 32; var Padding = new Uint8Array(WordSize); var passProperties = ["then"]; var _guard = {}; function throwError(name, error) { const wrapped = new Error(`deferred error during ABI decoding triggered accessing ${name}`); wrapped.error = error; throw wrapped; } var Result = class _Result extends Array { #names; /** * @private */ constructor(...args) { const guard = args[0]; let items = args[1]; let names = (args[2] || []).slice(); let wrap = true; if (guard !== _guard) { items = args; names = []; wrap = false; } super(items.length); items.forEach((item, index) => { this[index] = item; }); const nameCounts = names.reduce((accum, name) => { if (typeof name === "string") { accum.set(name, (accum.get(name) || 0) + 1); } return accum; }, /* @__PURE__ */ new Map()); this.#names = Object.freeze(items.map((item, index) => { const name = names[index]; if (name != null && nameCounts.get(name) === 1) { return name; } return null; })); if (!wrap) { return; } Object.freeze(this); return new Proxy(this, { get: (target, prop, receiver) => { if (typeof prop === "string") { if (prop.match(/^[0-9]+$/)) { const index = getNumber(prop, "%index"); if (index < 0 || index >= this.length) { throw new RangeError("out of result range"); } const item = target[index]; if (item instanceof Error) { throwError(`index ${index}`, item); } return item; } if (passProperties.indexOf(prop) >= 0) { return Reflect.get(target, prop, receiver); } const value = target[prop]; if (value instanceof Function) { return function(...args2) { return value.apply(this === receiver ? target : this, args2); }; } else if (!(prop in target)) { return target.getValue.apply(this === receiver ? target : this, [prop]); } } return Reflect.get(target, prop, receiver); } }); } /** * Returns the Result as a normal Array. * * This will throw if there are any outstanding deferred * errors. */ toArray() { const result = []; this.forEach((item, index) => { if (item instanceof Error) { throwError(`index ${index}`, item); } result.push(item); }); return result; } /** * Returns the Result as an Object with each name-value pair. * * This will throw if any value is unnamed, or if there are * any outstanding deferred errors. */ toObject() { return this.#names.reduce((accum, name, index) => { assert(name != null, "value at index ${ index } unnamed", "UNSUPPORTED_OPERATION", { operation: "toObject()" }); if (!(name in accum)) { accum[name] = this.getValue(name); } return accum; }, {}); } /** * @_ignore */ slice(start, end) { if (start == null) { start = 0; } if (start < 0) { start += this.length; if (start < 0) { start = 0; } } if (end == null) { end = this.length; } if (end < 0) { end += this.length; if (end < 0) { end = 0; } } if (end > this.length) { end = this.length; } const result = [], names = []; for (let i = start; i < end; i++) { result.push(this[i]); names.push(this.#names[i]); } return new _Result(_guard, result, names); } /** * @_ignore */ filter(callback, thisArg) { const result = [], names = []; for (let i = 0; i < this.length; i++) { const item = this[i]; if (item instanceof Error) { throwError(`index ${i}`, item); } if (callback.call(thisArg, item, i, this)) { result.push(item); names.push(this.#names[i]); } } return new _Result(_guard, result, names); } /** * @_ignore */ map(callback, thisArg) { const result = []; for (let i = 0; i < this.length; i++) { const item = this[i]; if (item instanceof Error) { throwError(`index ${i}`, item); } result.push(callback.call(thisArg, item, i, this)); } return result; } /** * Returns the value for %%name%%. * * Since it is possible to have a key whose name conflicts with * a method on a [[Result]] or its superclass Array, or any * JavaScript keyword, this ensures all named values are still * accessible by name. */ getValue(name) { const index = this.#names.indexOf(name); if (index === -1) { return void 0; } const value = this[index]; if (value instanceof Error) { throwError(`property ${JSON.stringify(name)}`, value.error); } return value; } /** * Creates a new [[Result]] for %%items%% with each entry * also accessible by its corresponding name in %%keys%%. */ static fromItems(items, keys) { return new _Result(_guard, items, keys); } }; function getValue(value) { let bytes2 = toBeArray(value); assert(bytes2.length <= WordSize, "value out-of-bounds", "BUFFER_OVERRUN", { buffer: bytes2, length: WordSize, offset: bytes2.length }); if (bytes2.length !== WordSize) { bytes2 = getBytesCopy(concat([Padding.slice(bytes2.length % WordSize), bytes2])); } return bytes2; } var Coder = class { // The coder name: // - address, uint256, tuple, array, etc. name; // The fully expanded type, including composite types: // - address, uint256, tuple(address,bytes), uint256[3][4][], etc. type; // The localName bound in the signature, in this example it is "baz": // - tuple(address foo, uint bar) baz localName; // Whether this type is dynamic: // - Dynamic: bytes, string, address[], tuple(boolean[]), etc. // - Not Dynamic: address, uint256, boolean[3], tuple(address, uint8) dynamic; constructor(name, type, localName, dynamic) { defineProperties(this, { name, type, localName, dynamic }, { name: "string", type: "string", localName: "string", dynamic: "boolean" }); } _throwError(message, value) { assertArgument(false, message, this.localName, value); } }; var Writer = class { // An array of WordSize lengthed objects to concatenation #data; #dataLength; constructor() { this.#data = []; this.#dataLength = 0; } get data() { return concat(this.#data); } get length() { return this.#dataLength; } #writeData(data) { this.#data.push(data); this.#dataLength += data.length; return data.length; } appendWriter(writer) { return this.#writeData(getBytesCopy(writer.data)); } // Arrayish item; pad on the right to *nearest* WordSize writeBytes(value) { let bytes2 = getBytesCopy(value); const paddingOffset = bytes2.length % WordSize; if (paddingOffset) { bytes2 = getBytesCopy(concat([bytes2, Padding.slice(paddingOffset)])); } return this.#writeData(bytes2); } // Numeric item; pad on the left *to* WordSize writeValue(value) { return this.#writeData(getValue(value)); } // Inserts a numeric place-holder, returning a callback that can // be used to asjust the value later writeUpdatableValue() { const offset = this.#data.length; this.#data.push(Padding); this.#dataLength += WordSize; return (value) => { this.#data[offset] = getValue(value); }; } }; var Reader = class _Reader { // Allows incomplete unpadded data to be read; otherwise an error // is raised if attempting to overrun the buffer. This is required // to deal with an old Solidity bug, in which event data for // external (not public thoguh) was tightly packed. allowLoose; #data; #offset; constructor(data, allowLoose) { defineProperties(this, { allowLoose: !!allowLoose }); this.#data = getBytesCopy(data); this.#offset = 0; } get data() { return hexlify(this.#data); } get dataLength() { return this.#data.length; } get consumed() { return this.#offset; } get bytes() { return new Uint8Array(this.#data); } #peekBytes(offset, length, loose) { let alignedLength = Math.ceil(length / WordSize) * WordSize; if (this.#offset + alignedLength > this.#data.length) { if (this.allowLoose && loose && this.#offset + length <= this.#data.length) { alignedLength = length; } else { assert(false, "data out-of-bounds", "BUFFER_OVERRUN", { buffer: getBytesCopy(this.#data), length: this.#data.length, offset: this.#offset + alignedLength }); } } return this.#data.slice(this.#offset, this.#offset + alignedLength); } // Create a sub-reader with the same underlying data, but offset subReader(offset) { return new _Reader(this.#data.slice(this.#offset + offset), this.allowLoose); } // Read bytes readBytes(length, loose) { let bytes2 = this.#peekBytes(0, length, !!loose); this.#offset += bytes2.length; return bytes2.slice(0, length); } // Read a numeric values readValue() { return toBigInt(this.readBytes(WordSize)); } readIndex() { return toNumber(this.readBytes(WordSize)); } }; // node_modules/@noble/hashes/esm/_assert.js function number(n2) { if (!Number.isSafeInteger(n2) || n2 < 0) throw new Error(`Wrong positive integer: ${n2}`); } function bytes(b2, ...lengths) { if (!(b2 instanceof Uint8Array)) throw new Error("Expected Uint8Array"); if (lengths.length > 0 && !lengths.includes(b2.length)) throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b2.length}`); } function exists(instance, checkFinished = true) { if (instance.destroyed) throw new Error("Hash instance has been destroyed"); if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called"); } function output(out, instance) { bytes(out); const min = instance.outputLen; if (out.length < min) { throw new Error(`digestInto() expects output buffer of length at least ${min}`); } } // node_modules/@noble/hashes/esm/utils.js var u8a = (a) => a instanceof Uint8Array; var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4)); var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68; if (!isLE) throw new Error("Non little-endian hardware is not supported"); function utf8ToBytes(str) { if (typeof str !== "string") throw new Error(`utf8ToBytes expected string, got ${typeof str}`); return new Uint8Array(new TextEncoder().encode(str)); } function toBytes(data) { if (typeof data === "string") data = utf8ToBytes(data); if (!u8a(data)) throw new Error(`expected Uint8Array, got ${typeof data}`); return data; } var Hash = class { // Safe version that clones internal state clone() { return this._cloneInto(); } }; var toStr = {}.toString; function wrapConstructor(hashCons) { const hashC = (msg) => hashCons().update(toBytes(msg)).digest(); const tmp = hashCons(); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = () => hashCons(); return hashC; } function wrapXOFConstructorWithOpts(hashCons) { const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest(); const tmp = hashCons({}); hashC.outputLen = tmp.outputLen; hashC.blockLen = tmp.blockLen; hashC.create = (opts) => hashCons(opts); return hashC; } // node_modules/@noble/hashes/esm/_u64.js var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1); var _32n = /* @__PURE__ */ BigInt(32); function fromBig(n2, le = false) { if (le) return { h: Number(n2 & U32_MASK64), l: Number(n2 >> _32n & U32_MASK64) }; return { h: Number(n2 >> _32n & U32_MASK64) | 0, l: Number(n2 & U32_MASK64) | 0 }; } function split(lst, le = false) { let Ah = new Uint32Array(lst.length); let Al = new Uint32Array(lst.length); for (let i = 0; i < lst.length; i++) { const { h, l } = fromBig(lst[i], le); [Ah[i], Al[i]] = [h, l]; } return [Ah, Al]; } var rotlSH = (h, l, s) => h << s | l >>> 32 - s; var rotlSL = (h, l, s) => l << s | h >>> 32 - s; var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s; var rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s; // node_modules/@noble/hashes/esm/sha3.js var [SHA3_PI, SHA3_ROTL, _SHA3_IOTA] = [[], [], []]; var _0n = /* @__PURE__ */ BigInt(0); var _1n = /* @__PURE__ */ BigInt(1); var _2n = /* @__PURE__ */ BigInt(2); var _7n = /* @__PURE__ */ BigInt(7); var _256n = /* @__PURE__ */ BigInt(256); var _0x71n = /* @__PURE__ */ BigInt(113); for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) { [x, y] = [y, (2 * x + 3 * y) % 5]; SHA3_PI.push(2 * (5 * y + x)); SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64); let t = _0n; for (let j = 0; j < 7; j++) { R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n; if (R & _2n) t ^= _1n << (_1n << /* @__PURE__ */ BigInt(j)) - _1n; } _SHA3_IOTA.push(t); } var [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true); var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s); var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s); function keccakP(s, rounds = 24) { const B = new Uint32Array(5 * 2); for (let round = 24 - rounds; round < 24; round++) { for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40]; for (let x = 0; x < 10; x += 2) { const idx1 = (x + 8) % 10; const idx0 = (x + 2) % 10; const B0 = B[idx0]; const B1 = B[idx0 + 1]; const Th = rotlH(B0, B1, 1) ^ B[idx1]; const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1]; for (let y = 0; y < 50; y += 10) { s[x + y] ^= Th; s[x + y + 1] ^= Tl; } } let curH = s[2]; let curL = s[3]; for (let t = 0; t < 24; t++) { const shift = SHA3_ROTL[t]; const Th = rotlH(curH, curL, shift); const Tl = rotlL(curH, curL, shift); const PI = SHA3_PI[t]; curH = s[PI]; curL = s[PI + 1]; s[PI] = Th; s[PI + 1] = Tl; } for (let y = 0; y < 50; y += 10) { for (let x = 0; x < 10; x++) B[x] = s[y + x]; for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10]; } s[0] ^= SHA3_IOTA_H[round]; s[1] ^= SHA3_IOTA_L[round]; } B.fill(0); } var Keccak = class _Keccak extends Hash { // NOTE: we accept arguments in bytes instead of bits here. constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) { super(); this.blockLen = blockLen; this.suffix = suffix; this.outputLen = outputLen; this.enableXOF = enableXOF; this.rounds = rounds; this.pos = 0; this.posOut = 0; this.finished = false; this.destroyed = false; number(outputLen); if (0 >= this.blockLen || this.blockLen >= 200) throw new Error("Sha3 supports only keccak-f1600 function"); this.state = new Uint8Array(200); this.state32 = u32(this.state); } keccak() { keccakP(this.state32, this.rounds); this.posOut = 0; this.pos = 0; } update(data) { exists(this); const { blockLen, state } = this; data = toBytes(data); const len = data.length; for (let pos = 0; pos < len; ) { const take = Math.min(blockLen - this.pos, len - pos); for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++]; if (this.pos === blockLen) this.keccak(); } return this; } finish() { if (this.finished) return; this.finished = true; const { state, suffix, pos, blockLen } = this; state[pos] ^= suffix; if ((suffix & 128) !== 0 && pos === blockLen - 1) this.keccak(); state[blockLen - 1] ^= 128; this.keccak(); } writeInto(out) { exists(this, false); bytes(out); this.finish(); const bufferOut = this.state; const { blockLen } = this; for (let pos = 0, len = out.length; pos < len; ) { if (this.posOut >= blockLen) this.keccak(); const take = Math.min(blockLen - this.posOut, len - pos); out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos); this.posOut += take; pos += take; } return out; } xofInto(out) { if (!this.enableXOF) throw new Error("XOF is not possible for this instance"); return this.writeInto(out); } xof(bytes2) { number(bytes2); return this.xofInto(new Uint8Array(bytes2)); } digestInto(out) { output(out, this); if (this.finished) throw new Error("digest() was already called"); this.writeInto(out); this.destroy(); return out; } digest() { return this.digestInto(new Uint8Array(this.outputLen)); } destroy() { this.destroyed = true; this.state.fill(0); } _cloneInto(to) { const { blockLen, suffix, outputLen, rounds, enableXOF } = this; to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds)); to.state32.set(this.state32); to.pos = this.pos; to.posOut = this.posOut; to.finished = this.finished; to.rounds = rounds; to.suffix = suffix; to.outputLen = outputLen; to.enableXOF = enableXOF; to.destroyed = this.destroyed; return to; } }; var gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak(blockLen, suffix, outputLen)); var sha3_224 = /* @__PURE__ */ gen(6, 144, 224 / 8); var sha3_256 = /* @__PURE__ */ gen(6, 136, 256 / 8); var sha3_384 = /* @__PURE__ */ gen(6, 104, 384 / 8); var sha3_512 = /* @__PURE__ */ gen(6, 72, 512 / 8); var keccak_224 = /* @__PURE__ */ gen(1, 144, 224 / 8); var keccak_256 = /* @__PURE__ */ gen(1, 136, 256 / 8); var keccak_384 = /* @__PURE__ */ gen(1, 104, 384 / 8); var keccak_512 = /* @__PURE__ */ gen(1, 72, 512 / 8); var genShake = (suffix, blockLen, outputLen) => wrapXOFConstructorWithOpts((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true)); var shake128 = /* @__PURE__ */ genShake(31, 168, 128 / 8); var shake256 = /* @__PURE__ */ genShake(31, 136, 256 / 8); // node_modules/ethers/lib.esm/crypto/keccak.js var locked = false; var _keccak256 = function(data) { return keccak_256(data); }; var __keccak256 = _keccak256; function keccak256(_data) { const data = getBytes(_data, "data"); return hexlify(__keccak256(data)); } keccak256._ = _keccak256; keccak256.lock = function() { locked = true; }; keccak256.register = function(func) { if (locked) { throw new TypeError("keccak256 is locked"); } __keccak256 = func; }; Object.freeze(keccak256); // node_modules/ethers/lib.esm/address/address.js var BN_02 = BigInt(0); var BN_36 = BigInt(36); function getChecksumAddress(address) { address = address.toLowerCase(); const chars = address.substring(2).split(""); const expanded = new Uint8Array(40); for (let i = 0; i < 40; i++) { expanded[i] = chars[i].charCodeAt(0); } const hashed = getBytes(keccak256(expanded)); for (let i = 0; i < 40; i += 2) { if (hashed[i >> 1] >> 4 >= 8) { chars[i] = chars[i].toUpperCase(); } if ((hashed[i >> 1] & 15) >= 8) { chars[i + 1] = chars[i + 1].toUpperCase(); } } return "0x" + chars.join(""); } var ibanLookup = {}; for (let i = 0; i < 10; i++) { ibanLookup[String(i)] = String(i); } for (let i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); } var safeDigits = 15; function ibanChecksum(address) { address = address.toUpperCase(); address = address.substring(4) + address.substring(0, 2) + "00"; let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join(""); while (expanded.length >= safeDigits) { let block = expanded.substring(0, safeDigits); expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); } let checksum = String(98 - parseInt(expanded, 10) % 97); while (checksum.length < 2) { checksum = "0" + checksum; } return checksum; } var Base36 = function() { ; const result = {}; for (let i = 0; i < 36; i++) { const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i]; result[key] = BigInt(i); } return result; }(); function fromBase36(value) { value = value.toLowerCase(); let result = BN_02; for (let i = 0; i < value.length; i++) { result = result * BN_36 + Base36[value[i]]; } return result; } function getAddress(address) { assertArgument(typeof address === "string", "invalid address", "address", address); if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { if (!address.startsWith("0x")) { address = "0x" + address; } const result = getChecksumAddress(address); assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address); return result; } if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address); let result = fromBase36(address.substring(4)).toString(16); while (result.length < 40) { result = "0" + result; } return getChecksumAddress("0x" + result); } assertArgument(false, "invalid address", "address", address); } // node_modules/ethers/lib.esm/address/contract-address.js function getCreateAddress(tx) { const from = getAddress(tx.from); const nonce = getBigInt(tx.nonce, "tx.nonce"); let nonceHex = nonce.toString(16); if (nonceHex === "0") { nonceHex = "0x"; } else if (nonceHex.length % 2) { nonceHex = "0x0" + nonceHex; } else { nonceHex = "0x" + nonceHex; } return getAddress(dataSlice(keccak256(encodeRlp([from, nonceHex])), 12)); } // node_modules/ethers/lib.esm/address/checks.js function isAddressable(value) { return value && typeof value.getAddress === "function"; } async function checkAddress(target, promise) { const result = await promise; if (result == null || result === "0x0000000000000000000000000000000000000000") { assert(typeof target !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target }); assertArgument(false, "invalid AddressLike value; did not resolve to a value address", "target", target); } return getAddress(result); } function resolveAddress(target, resolver) { if (typeof target === "string") { if (target.match(/^0x[0-9a-f]{40}$/i)) { return getAddress(target); } assert(resolver != null, "ENS resolution requires a provider", "UNSUPPORTED_OPERATION", { operation: "resolveName" }); return checkAddress(target, resolver.resolveName(target)); } else if (isAddressable(target)) { return checkAddress(target, target.getAddress()); } else if (target && typeof target.then === "function") { return checkAddress(target, target); } assertArgument(false, "unsupported addressable value", "target", target); } // node_modules/ethers/lib.esm/abi/typed.js var _gaurd = {}; function n(value, width) { let signed = false; if (width < 0) { signed = true; width *= -1; } return new Typed(_gaurd, `${signed ? "" : "u"}int${width}`, value, { signed, width }); } function b(value, size) { return new Typed(_gaurd, `bytes${size ? size : ""}`, value, { size }); } var _typedSymbol = Symbol.for("_ethers_typed"); var Typed = class _Typed { /** * The type, as a Solidity-compatible type. */ type; /** * The actual value. */ value; #options; /** * @_ignore: */ _typedSymbol; /** * @_ignore: */ constructor(gaurd, type, value, options) { if (options == null) { options = null; } assertPrivate(_gaurd, gaurd, "Typed"); defineProperties(this, { _typedSymbol, type, value }); this.#options = options; this.format(); } /** * Format the type as a Human-Readable type. */ format() { if (this.type === "array") { throw new Error(""); } else if (this.type === "dynamicArray") { throw new Error(""); } else if (this.type === "tuple") { return `tuple(${this.value.map((v) => v.format()).join(",")})`; } return this.type; } /** * The default value returned by this type. */ defaultValue() { return 0; } /** * The minimum value for numeric types. */ minValue() { return 0; } /** * The maximum value for numeric types. */ maxValue() { return 0; } /** * Returns ``true`` and provides a type guard is this is a [[TypedBigInt]]. */ isBigInt() { return !!this.type.match(/^u?int[0-9]+$/); } /** * Returns ``true`` and provides a type guard is this is a [[TypedData]]. */ isData() { return this.type.startsWith("bytes"); } /** * Returns ``true`` and provides a type guard is this is a [[TypedString]]. */ isString() { return this.type === "string"; } /** * Returns the tuple name, if this is a tuple. Throws otherwise. */ get tupleName() { if (this.type !== "tuple") { throw TypeError("not a tuple"); } return this.#options; } // Returns the length of this type as an array // - `null` indicates the length is unforced, it could be dynamic // - `-1` indicates the length is dynamic // - any other value indicates it is a static array and is its length /** * Returns the length of the array type or ``-1`` if it is dynamic. * * Throws if the type is not an array. */ get arrayLength() { if (this.type !== "array") { throw TypeError("not an array"); } if (this.#options === true) { return -1; } if (this.#options === false) { return this.value.length; } return null; } /** * Returns a new **Typed** of %%type%% with the %%value%%. */ static from(type, value) { return new _Typed(_gaurd, type, value); } /** * Return a new ``uint8`` type for %%v%%. */ static uint8(v) { return n(v, 8); } /** * Return a new ``uint16`` type for %%v%%. */ static uint16(v) { return n(v, 16); } /** * Return a new ``uint24`` type for %%v%%. */ static uint24(v) { return n(v, 24); } /** * Return a new ``uint32`` type for %%v%%. */ static uint32(v) { return n(v, 32); } /** * Return a new ``uint40`` type for %%v%%. */ static uint40(v) { return n(v, 40); } /** * Return a new ``uint48`` type for %%v%%. */ static uint48(v) { return n(v, 48); } /** * Return a new ``uint56`` type for %%v%%. */ static uint56(v) { return n(v, 56); } /** * Return a new ``uint64`` type for %%v%%. */ static uint64(v) { return n(v, 64); } /** * Return a new ``uint72`` type for %%v%%. */ static uint72(v) { return n(v, 72); } /** * Return a new ``uint80`` type for %%v%%. */ static uint80(v) { return n(v, 80); } /** * Return a new ``uint88`` type for %%v%%. */ static uint88(v) { return n(v, 88); } /** * Return a new ``uint96`` type for %%v%%. */ static uint96(v) { return n(v, 96); } /** * Return a new ``uint104`` type for %%v%%. */ static uint104(v) { return n(v, 104); } /** * Return a new ``uint112`` type for %%v%%. */ static uint112(v) { return n(v, 112); } /** * Return a new ``uint120`` type for %%v%%. */ static uint120(v) { return n(v, 120); } /** * Return a new ``uint128`` type for %%v%%. */ static uint128(v) { return n(v, 128); } /** * Return a new ``uint136`` type for %%v%%. */ static uint136(v) { return n(v, 136); } /** * Return a new ``uint144`` type for %%v%%. */ static uint144(v) { return n(v, 144); } /** * Return a new ``uint152`` type for %%v%%. */ static uint152(v) { return n(v, 152); } /** * Return a new ``uint160`` type for %%v%%. */ static uint160(v) { return n(v, 160); } /** * Return a new ``uint168`` type for %%v%%. */ static uint168(v) { return n(v, 168); } /** * Return a new ``uint176`` type for %%v%%. */ static uint176(v) { return n(v, 176); } /** * Return a new ``uint184`` type for %%v%%. */ static uint184(v) { return n(v, 184); } /** * Return a new ``uint192`` type for %%v%%. */ static uint192(v) { return n(v, 192); } /** * Return a new ``uint200`` type for %%v%%. */ static uint200(v) { return n(v, 200); } /** * Return a new ``uint208`` type for %%v%%. */ static uint208(v) { return n(v, 208); } /** * Return a new ``uint216`` type for %%v%%. */ static uint216(v) { return n(v, 216); } /** * Return a new ``uint224`` type for %%v%%. */ static uint224(v) { return n(v, 224); } /** * Return a new ``uint232`` type for %%v%%. */ static uint232(v) { return n(v, 232); } /** * Return a new ``uint240`` type for %%v%%. */ static uint240(v) { return n(v, 240); } /** * Return a new ``uint248`` type for %%v%%. */ static uint248(v) { return n(v, 248); } /** * Return a new ``uint256`` type for %%v%%. */ static uint256(v) { return n(v, 256); } /** * Return a new ``uint256`` type for %%v%%. */ static uint(v) { return n(v, 256); } /** * Return a new ``int8`` type for %%v%%. */ static int8(v) { return n(v, -8); } /** * Return a new ``int16`` type for %%v%%. */ static int16(v) { return n(v, -16); } /** * Return a new ``int24`` type for %%v%%. */ static int24(v) { return n(v, -24); } /** * Return a new ``int32`` type for %%v%%. */ static int32(v) { return n(v, -32); } /** * Return a new ``int40`` type for %%v%%. */ static int40(v) { return n(v, -40); } /** * Return a new ``int48`` type for %%v%%. */ static int48(v) { return n(v, -48); } /** * Return a new ``int56`` type for %%v%%. */ static int56(v) { return n(v, -56); } /** * Return a new ``int64`` type for %%v%%. */ static int64(v) { return n(v, -64); } /** * Return a new ``int72`` type for %%v%%. */ static int72(v) { return n(v, -72); } /** * Return a new ``int80`` type for %%v%%. */ static int80(v) { return n(v, -80); } /** * Return a new ``int88`` type for %%v%%. */ static int88(v) { return n(v, -88); } /** * Return a new ``int96`` type for %%v%%. */ static int96(v) { return n(v, -96); } /** * Return a new ``int104`` type for %%v%%. */ static int104(v) { return n(v, -104); } /** * Return a new ``int112`` type for %%v%%. */ static int112(v) { return n(v, -112); } /** * Return a new ``int120`` type for %%v%%. */ static int120(v) { return n(v, -120); } /** * Return a new ``int128`` type for %%v%%. */ static int128(v) { return n(v, -128); } /** * Return a new ``int136`` type for %%v%%. */ static int136(v) { return n(v, -136); } /** * Return a new ``int144`` type for %%v%%. */ static int144(v) { return n(v, -144); } /** * Return a new ``int52`` type for %%v%%. */ static int152(v) { return n(v, -152); } /** * Return a new ``int160`` type for %%v%%. */ static int160(v) { return n(v, -160); } /** * Return a new ``int168`` type for %%v%%. */ static int168(v) { return n(v, -168); } /** * Return a new ``int176`` type for %%v%%. */ static int176(v) { return n(v, -176); } /** * Return a new ``int184`` type for %%v%%. */ static int184(v) { return n(v, -184); } /** * Retu