UNPKG

juna

Version:

A cross platform NFT lending client for serious lenders

1,500 lines (1,460 loc) 428 kB
'use strict'; var nc = require('crypto'); var axios = require('axios'); var gondi = require('gondi'); var puppeteer = require('puppeteer-extra'); var StealthPlugin = require('puppeteer-extra-plugin-stealth'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n.default = e; return Object.freeze(n); } var nc__namespace = /*#__PURE__*/_interopNamespace(nc); var axios__default = /*#__PURE__*/_interopDefault(axios); var puppeteer__default = /*#__PURE__*/_interopDefault(puppeteer); var StealthPlugin__default = /*#__PURE__*/_interopDefault(StealthPlugin); var __defProp = Object.defineProperty; var __getOwnPropNames = Object.getOwnPropertyNames; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // node_modules/viem/_esm/errors/version.js var version; var init_version = __esm({ "node_modules/viem/_esm/errors/version.js"() { version = "1.21.3"; } }); // node_modules/viem/_esm/errors/utils.js var getContractAddress, getUrl, getVersion; var init_utils = __esm({ "node_modules/viem/_esm/errors/utils.js"() { init_version(); getContractAddress = (address) => address; getUrl = (url) => url; getVersion = () => `viem@${version}`; } }); // node_modules/viem/_esm/errors/base.js function walk(err, fn) { if (fn?.(err)) return err; if (err && typeof err === "object" && "cause" in err) return walk(err.cause, fn); return fn ? null : err; } var BaseError; var init_base = __esm({ "node_modules/viem/_esm/errors/base.js"() { init_utils(); BaseError = class _BaseError extends Error { constructor(shortMessage, args = {}) { super(); Object.defineProperty(this, "details", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "docsPath", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "metaMessages", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "shortMessage", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "ViemError" }); Object.defineProperty(this, "version", { enumerable: true, configurable: true, writable: true, value: getVersion() }); const details = args.cause instanceof _BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details; const docsPath4 = args.cause instanceof _BaseError ? args.cause.docsPath || args.docsPath : args.docsPath; this.message = [ shortMessage || "An error occurred.", "", ...args.metaMessages ? [...args.metaMessages, ""] : [], ...docsPath4 ? [ `Docs: https://viem.sh${docsPath4}.html${args.docsSlug ? `#${args.docsSlug}` : ""}` ] : [], ...details ? [`Details: ${details}`] : [], `Version: ${this.version}` ].join("\n"); if (args.cause) this.cause = args.cause; this.details = details; this.docsPath = docsPath4; this.metaMessages = args.metaMessages; this.shortMessage = shortMessage; } walk(fn) { return walk(this, fn); } }; } }); // node_modules/viem/_esm/errors/encoding.js var IntegerOutOfRangeError, InvalidHexBooleanError, SizeOverflowError; var init_encoding = __esm({ "node_modules/viem/_esm/errors/encoding.js"() { init_base(); IntegerOutOfRangeError = class extends BaseError { constructor({ max, min, signed, size: size3, value }) { super(`Number "${value}" is not in safe ${size3 ? `${size3 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "IntegerOutOfRangeError" }); } }; InvalidHexBooleanError = class extends BaseError { constructor(hex) { super(`Hex value "${hex}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidHexBooleanError" }); } }; SizeOverflowError = class extends BaseError { constructor({ givenSize, maxSize }) { super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "SizeOverflowError" }); } }; } }); // node_modules/viem/_esm/utils/data/isHex.js function isHex(value, { strict = true } = {}) { if (!value) return false; if (typeof value !== "string") return false; return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x"); } var init_isHex = __esm({ "node_modules/viem/_esm/utils/data/isHex.js"() { } }); // node_modules/viem/_esm/utils/data/size.js function size(value) { if (isHex(value, { strict: false })) return Math.ceil((value.length - 2) / 2); return value.length; } var init_size = __esm({ "node_modules/viem/_esm/utils/data/size.js"() { init_isHex(); } }); // node_modules/viem/_esm/utils/data/trim.js function trim(hexOrBytes, { dir = "left" } = {}) { let data = typeof hexOrBytes === "string" ? hexOrBytes.replace("0x", "") : hexOrBytes; let sliceLength = 0; for (let i = 0; i < data.length - 1; i++) { if (data[dir === "left" ? i : data.length - i - 1].toString() === "0") sliceLength++; else break; } data = dir === "left" ? data.slice(sliceLength) : data.slice(0, data.length - sliceLength); if (typeof hexOrBytes === "string") { if (data.length === 1 && dir === "right") data = `${data}0`; return `0x${data.length % 2 === 1 ? `0${data}` : data}`; } return data; } var init_trim = __esm({ "node_modules/viem/_esm/utils/data/trim.js"() { } }); // node_modules/viem/_esm/errors/data.js var SliceOffsetOutOfBoundsError, SizeExceedsPaddingSizeError; var init_data = __esm({ "node_modules/viem/_esm/errors/data.js"() { init_base(); SliceOffsetOutOfBoundsError = class extends BaseError { constructor({ offset, position, size: size3 }) { super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size3}).`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "SliceOffsetOutOfBoundsError" }); } }; SizeExceedsPaddingSizeError = class extends BaseError { constructor({ size: size3, targetSize, type }) { super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size3}) exceeds padding size (${targetSize}).`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "SizeExceedsPaddingSizeError" }); } }; } }); // node_modules/viem/_esm/utils/data/pad.js function pad(hexOrBytes, { dir, size: size3 = 32 } = {}) { if (typeof hexOrBytes === "string") return padHex(hexOrBytes, { dir, size: size3 }); return padBytes(hexOrBytes, { dir, size: size3 }); } function padHex(hex_, { dir, size: size3 = 32 } = {}) { if (size3 === null) return hex_; const hex = hex_.replace("0x", ""); if (hex.length > size3 * 2) throw new SizeExceedsPaddingSizeError({ size: Math.ceil(hex.length / 2), targetSize: size3, type: "hex" }); return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size3 * 2, "0")}`; } function padBytes(bytes2, { dir, size: size3 = 32 } = {}) { if (size3 === null) return bytes2; if (bytes2.length > size3) throw new SizeExceedsPaddingSizeError({ size: bytes2.length, targetSize: size3, type: "bytes" }); const paddedBytes = new Uint8Array(size3); for (let i = 0; i < size3; i++) { const padEnd = dir === "right"; paddedBytes[padEnd ? i : size3 - i - 1] = bytes2[padEnd ? i : bytes2.length - i - 1]; } return paddedBytes; } var init_pad = __esm({ "node_modules/viem/_esm/utils/data/pad.js"() { init_data(); } }); // node_modules/viem/_esm/utils/encoding/toHex.js function toHex(value, opts = {}) { if (typeof value === "number" || typeof value === "bigint") return numberToHex(value, opts); if (typeof value === "string") { return stringToHex(value, opts); } if (typeof value === "boolean") return boolToHex(value, opts); return bytesToHex(value, opts); } function boolToHex(value, opts = {}) { const hex = `0x${Number(value)}`; if (typeof opts.size === "number") { assertSize(hex, { size: opts.size }); return pad(hex, { size: opts.size }); } return hex; } function bytesToHex(value, opts = {}) { let string = ""; for (let i = 0; i < value.length; i++) { string += hexes[value[i]]; } const hex = `0x${string}`; if (typeof opts.size === "number") { assertSize(hex, { size: opts.size }); return pad(hex, { dir: "right", size: opts.size }); } return hex; } function numberToHex(value_, opts = {}) { const { signed, size: size3 } = opts; const value = BigInt(value_); let maxValue; if (size3) { if (signed) maxValue = (1n << BigInt(size3) * 8n - 1n) - 1n; else maxValue = 2n ** (BigInt(size3) * 8n) - 1n; } else if (typeof value_ === "number") { maxValue = BigInt(Number.MAX_SAFE_INTEGER); } const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0; if (maxValue && value > maxValue || value < minValue) { const suffix = typeof value_ === "bigint" ? "n" : ""; throw new IntegerOutOfRangeError({ max: maxValue ? `${maxValue}${suffix}` : void 0, min: `${minValue}${suffix}`, signed, size: size3, value: `${value_}${suffix}` }); } const hex = `0x${(signed && value < 0 ? (1n << BigInt(size3 * 8)) + BigInt(value) : value).toString(16)}`; if (size3) return pad(hex, { size: size3 }); return hex; } function stringToHex(value_, opts = {}) { const value = encoder.encode(value_); return bytesToHex(value, opts); } var hexes, encoder; var init_toHex = __esm({ "node_modules/viem/_esm/utils/encoding/toHex.js"() { init_encoding(); init_pad(); init_fromHex(); hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0")); encoder = /* @__PURE__ */ new TextEncoder(); } }); // node_modules/viem/_esm/utils/encoding/toBytes.js function toBytes(value, opts = {}) { if (typeof value === "number" || typeof value === "bigint") return numberToBytes(value, opts); if (typeof value === "boolean") return boolToBytes(value, opts); if (isHex(value)) return hexToBytes(value, opts); return stringToBytes(value, opts); } function boolToBytes(value, opts = {}) { const bytes2 = new Uint8Array(1); bytes2[0] = Number(value); if (typeof opts.size === "number") { assertSize(bytes2, { size: opts.size }); return pad(bytes2, { size: opts.size }); } return bytes2; } function charCodeToBase16(char) { if (char >= charCodeMap.zero && char <= charCodeMap.nine) return char - charCodeMap.zero; if (char >= charCodeMap.A && char <= charCodeMap.F) return char - (charCodeMap.A - 10); if (char >= charCodeMap.a && char <= charCodeMap.f) return char - (charCodeMap.a - 10); return void 0; } function hexToBytes(hex_, opts = {}) { let hex = hex_; if (opts.size) { assertSize(hex, { size: opts.size }); hex = pad(hex, { dir: "right", size: opts.size }); } let hexString = hex.slice(2); if (hexString.length % 2) hexString = `0${hexString}`; const length = hexString.length / 2; const bytes2 = new Uint8Array(length); for (let index2 = 0, j = 0; index2 < length; index2++) { const nibbleLeft = charCodeToBase16(hexString.charCodeAt(j++)); const nibbleRight = charCodeToBase16(hexString.charCodeAt(j++)); if (nibbleLeft === void 0 || nibbleRight === void 0) { throw new BaseError(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`); } bytes2[index2] = nibbleLeft * 16 + nibbleRight; } return bytes2; } function numberToBytes(value, opts) { const hex = numberToHex(value, opts); return hexToBytes(hex); } function stringToBytes(value, opts = {}) { const bytes2 = encoder2.encode(value); if (typeof opts.size === "number") { assertSize(bytes2, { size: opts.size }); return pad(bytes2, { dir: "right", size: opts.size }); } return bytes2; } var encoder2, charCodeMap; var init_toBytes = __esm({ "node_modules/viem/_esm/utils/encoding/toBytes.js"() { init_base(); init_isHex(); init_pad(); init_fromHex(); init_toHex(); encoder2 = /* @__PURE__ */ new TextEncoder(); charCodeMap = { zero: 48, nine: 57, A: 65, F: 70, a: 97, f: 102 }; } }); // node_modules/viem/_esm/utils/encoding/fromHex.js function assertSize(hexOrBytes, { size: size3 }) { if (size(hexOrBytes) > size3) throw new SizeOverflowError({ givenSize: size(hexOrBytes), maxSize: size3 }); } function hexToBigInt(hex, opts = {}) { const { signed } = opts; if (opts.size) assertSize(hex, { size: opts.size }); const value = BigInt(hex); if (!signed) return value; const size3 = (hex.length - 2) / 2; const max = (1n << BigInt(size3) * 8n - 1n) - 1n; if (value <= max) return value; return value - BigInt(`0x${"f".padStart(size3 * 2, "f")}`) - 1n; } function hexToBool(hex_, opts = {}) { let hex = hex_; if (opts.size) { assertSize(hex, { size: opts.size }); hex = trim(hex); } if (trim(hex) === "0x00") return false; if (trim(hex) === "0x01") return true; throw new InvalidHexBooleanError(hex); } function hexToNumber(hex, opts = {}) { return Number(hexToBigInt(hex, opts)); } function hexToString(hex, opts = {}) { let bytes2 = hexToBytes(hex); if (opts.size) { assertSize(bytes2, { size: opts.size }); bytes2 = trim(bytes2, { dir: "right" }); } return new TextDecoder().decode(bytes2); } var init_fromHex = __esm({ "node_modules/viem/_esm/utils/encoding/fromHex.js"() { init_encoding(); init_size(); init_trim(); init_toBytes(); } }); // node_modules/viem/_esm/utils/formatters/transactionRequest.js function formatTransactionRequest(transactionRequest) { return { ...transactionRequest, gas: typeof transactionRequest.gas !== "undefined" ? numberToHex(transactionRequest.gas) : void 0, gasPrice: typeof transactionRequest.gasPrice !== "undefined" ? numberToHex(transactionRequest.gasPrice) : void 0, maxFeePerGas: typeof transactionRequest.maxFeePerGas !== "undefined" ? numberToHex(transactionRequest.maxFeePerGas) : void 0, maxPriorityFeePerGas: typeof transactionRequest.maxPriorityFeePerGas !== "undefined" ? numberToHex(transactionRequest.maxPriorityFeePerGas) : void 0, nonce: typeof transactionRequest.nonce !== "undefined" ? numberToHex(transactionRequest.nonce) : void 0, type: typeof transactionRequest.type !== "undefined" ? rpcTransactionType[transactionRequest.type] : void 0, value: typeof transactionRequest.value !== "undefined" ? numberToHex(transactionRequest.value) : void 0 }; } var rpcTransactionType; var init_transactionRequest = __esm({ "node_modules/viem/_esm/utils/formatters/transactionRequest.js"() { init_toHex(); rpcTransactionType = { legacy: "0x0", eip2930: "0x1", eip1559: "0x2" }; } }); // node_modules/viem/_esm/errors/address.js var InvalidAddressError; var init_address = __esm({ "node_modules/viem/_esm/errors/address.js"() { init_base(); InvalidAddressError = class extends BaseError { constructor({ address }) { super(`Address "${address}" is invalid.`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidAddressError" }); } }; } }); // node_modules/viem/_esm/errors/chain.js var ChainDoesNotSupportContract, ChainMismatchError, ChainNotFoundError, ClientChainNotConfiguredError, InvalidChainIdError; var init_chain = __esm({ "node_modules/viem/_esm/errors/chain.js"() { init_base(); ChainDoesNotSupportContract = class extends BaseError { constructor({ blockNumber, chain, contract }) { super(`Chain "${chain.name}" does not support contract "${contract.name}".`, { metaMessages: [ "This could be due to any of the following:", ...blockNumber && contract.blockCreated && contract.blockCreated > blockNumber ? [ `- The contract "${contract.name}" was not deployed until block ${contract.blockCreated} (current block ${blockNumber}).` ] : [ `- The chain does not have the contract "${contract.name}" configured.` ] ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "ChainDoesNotSupportContract" }); } }; ChainMismatchError = class extends BaseError { constructor({ chain, currentChainId }) { super(`The current chain of the wallet (id: ${currentChainId}) does not match the target chain for the transaction (id: ${chain.id} \u2013 ${chain.name}).`, { metaMessages: [ `Current Chain ID: ${currentChainId}`, `Expected Chain ID: ${chain.id} \u2013 ${chain.name}` ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "ChainMismatchError" }); } }; ChainNotFoundError = class extends BaseError { constructor() { super([ "No chain was provided to the request.", "Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient." ].join("\n")); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "ChainNotFoundError" }); } }; ClientChainNotConfiguredError = class extends BaseError { constructor() { super("No chain was provided to the Client."); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "ClientChainNotConfiguredError" }); } }; InvalidChainIdError = class extends BaseError { constructor({ chainId }) { super(`Chain ID "${chainId}" is invalid.`); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidChainIdError" }); } }; } }); // node_modules/viem/_esm/constants/unit.js var etherUnits, gweiUnits; var init_unit = __esm({ "node_modules/viem/_esm/constants/unit.js"() { etherUnits = { gwei: 9, wei: 18 }; gweiUnits = { ether: -9, wei: 9 }; } }); // node_modules/viem/_esm/utils/unit/formatUnits.js function formatUnits(value, decimals) { let display = value.toString(); const negative = display.startsWith("-"); if (negative) display = display.slice(1); display = display.padStart(decimals, "0"); let [integer, fraction] = [ display.slice(0, display.length - decimals), display.slice(display.length - decimals) ]; fraction = fraction.replace(/(0+)$/, ""); return `${negative ? "-" : ""}${integer || "0"}${fraction ? `.${fraction}` : ""}`; } var init_formatUnits = __esm({ "node_modules/viem/_esm/utils/unit/formatUnits.js"() { } }); // node_modules/viem/_esm/utils/unit/formatGwei.js function formatGwei(wei, unit = "wei") { return formatUnits(wei, gweiUnits[unit]); } var init_formatGwei = __esm({ "node_modules/viem/_esm/utils/unit/formatGwei.js"() { init_unit(); init_formatUnits(); } }); // node_modules/viem/_esm/errors/node.js var ExecutionRevertedError, FeeCapTooHighError, FeeCapTooLowError, NonceTooHighError, NonceTooLowError, NonceMaxValueError, InsufficientFundsError, IntrinsicGasTooHighError, IntrinsicGasTooLowError, TransactionTypeNotSupportedError, TipAboveFeeCapError, UnknownNodeError; var init_node = __esm({ "node_modules/viem/_esm/errors/node.js"() { init_formatGwei(); init_base(); ExecutionRevertedError = class extends BaseError { constructor({ cause, message } = {}) { const reason = message?.replace("execution reverted: ", "")?.replace("execution reverted", ""); super(`Execution reverted ${reason ? `with reason: ${reason}` : "for an unknown reason"}.`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "ExecutionRevertedError" }); } }; Object.defineProperty(ExecutionRevertedError, "code", { enumerable: true, configurable: true, writable: true, value: 3 }); Object.defineProperty(ExecutionRevertedError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /execution reverted/ }); FeeCapTooHighError = class extends BaseError { constructor({ cause, maxFeePerGas } = {}) { super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}) cannot be higher than the maximum allowed value (2^256-1).`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "FeeCapTooHigh" }); } }; Object.defineProperty(FeeCapTooHighError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/ }); FeeCapTooLowError = class extends BaseError { constructor({ cause, maxFeePerGas } = {}) { super(`The fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)}` : ""} gwei) cannot be lower than the block base fee.`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "FeeCapTooLow" }); } }; Object.defineProperty(FeeCapTooLowError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/ }); NonceTooHighError = class extends BaseError { constructor({ cause, nonce } = {}) { super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is higher than the next one expected.`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "NonceTooHighError" }); } }; Object.defineProperty(NonceTooHighError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /nonce too high/ }); NonceTooLowError = class extends BaseError { constructor({ cause, nonce } = {}) { super([ `Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}is lower than the current nonce of the account.`, "Try increasing the nonce or find the latest nonce with `getTransactionCount`." ].join("\n"), { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "NonceTooLowError" }); } }; Object.defineProperty(NonceTooLowError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /nonce too low|transaction already imported|already known/ }); NonceMaxValueError = class extends BaseError { constructor({ cause, nonce } = {}) { super(`Nonce provided for the transaction ${nonce ? `(${nonce}) ` : ""}exceeds the maximum allowed nonce.`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "NonceMaxValueError" }); } }; Object.defineProperty(NonceMaxValueError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /nonce has max value/ }); InsufficientFundsError = class extends BaseError { constructor({ cause } = {}) { super([ "The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account." ].join("\n"), { cause, metaMessages: [ "This error could arise when the account does not have enough funds to:", " - pay for the total gas fee,", " - pay for the value to send.", " ", "The cost of the transaction is calculated as `gas * gas fee + value`, where:", " - `gas` is the amount of gas needed for transaction to execute,", " - `gas fee` is the gas fee,", " - `value` is the amount of ether to send to the recipient." ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InsufficientFundsError" }); } }; Object.defineProperty(InsufficientFundsError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /insufficient funds/ }); IntrinsicGasTooHighError = class extends BaseError { constructor({ cause, gas } = {}) { super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction exceeds the limit allowed for the block.`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "IntrinsicGasTooHighError" }); } }; Object.defineProperty(IntrinsicGasTooHighError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /intrinsic gas too high|gas limit reached/ }); IntrinsicGasTooLowError = class extends BaseError { constructor({ cause, gas } = {}) { super(`The amount of gas ${gas ? `(${gas}) ` : ""}provided for the transaction is too low.`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "IntrinsicGasTooLowError" }); } }; Object.defineProperty(IntrinsicGasTooLowError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /intrinsic gas too low/ }); TransactionTypeNotSupportedError = class extends BaseError { constructor({ cause }) { super("The transaction type is not supported for this chain.", { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "TransactionTypeNotSupportedError" }); } }; Object.defineProperty(TransactionTypeNotSupportedError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /transaction type not valid/ }); TipAboveFeeCapError = class extends BaseError { constructor({ cause, maxPriorityFeePerGas, maxFeePerGas } = {}) { super([ `The provided tip (\`maxPriorityFeePerGas\`${maxPriorityFeePerGas ? ` = ${formatGwei(maxPriorityFeePerGas)} gwei` : ""}) cannot be higher than the fee cap (\`maxFeePerGas\`${maxFeePerGas ? ` = ${formatGwei(maxFeePerGas)} gwei` : ""}).` ].join("\n"), { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "TipAboveFeeCapError" }); } }; Object.defineProperty(TipAboveFeeCapError, "nodeMessage", { enumerable: true, configurable: true, writable: true, value: /max priority fee per gas higher than max fee per gas|tip higher than fee cap/ }); UnknownNodeError = class extends BaseError { constructor({ cause }) { super(`An error occurred while executing: ${cause?.shortMessage}`, { cause }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "UnknownNodeError" }); } }; } }); // node_modules/viem/_esm/utils/address/isAddress.js function isAddress(address) { return addressRegex.test(address); } var addressRegex; var init_isAddress = __esm({ "node_modules/viem/_esm/utils/address/isAddress.js"() { addressRegex = /^0x[a-fA-F0-9]{40}$/; } }); // node_modules/viem/_esm/utils/data/concat.js function concat(values) { if (typeof values[0] === "string") return concatHex(values); return concatBytes(values); } function concatBytes(values) { let length = 0; for (const arr of values) { length += arr.length; } const result = new Uint8Array(length); let offset = 0; for (const arr of values) { result.set(arr, offset); offset += arr.length; } return result; } function concatHex(values) { return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`; } var init_concat = __esm({ "node_modules/viem/_esm/utils/data/concat.js"() { } }); // node_modules/abitype/dist/esm/version.js var version2; var init_version2 = __esm({ "node_modules/abitype/dist/esm/version.js"() { version2 = "0.9.8"; } }); // node_modules/abitype/dist/esm/errors.js var BaseError2; var init_errors = __esm({ "node_modules/abitype/dist/esm/errors.js"() { init_version2(); BaseError2 = class _BaseError extends Error { constructor(shortMessage, args = {}) { const details = args.cause instanceof _BaseError ? args.cause.details : args.cause?.message ? args.cause.message : args.details; const docsPath4 = args.cause instanceof _BaseError ? args.cause.docsPath || args.docsPath : args.docsPath; const message = [ shortMessage || "An error occurred.", "", ...args.metaMessages ? [...args.metaMessages, ""] : [], ...docsPath4 ? [`Docs: https://abitype.dev${docsPath4}`] : [], ...details ? [`Details: ${details}`] : [], `Version: abitype@${version2}` ].join("\n"); super(message); Object.defineProperty(this, "details", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "docsPath", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "metaMessages", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "shortMessage", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "AbiTypeError" }); if (args.cause) this.cause = args.cause; this.details = details; this.docsPath = docsPath4; this.metaMessages = args.metaMessages; this.shortMessage = shortMessage; } }; } }); // node_modules/abitype/dist/esm/regex.js function execTyped(regex, string) { const match = regex.exec(string); return match?.groups; } var bytesRegex, integerRegex, isTupleRegex; var init_regex = __esm({ "node_modules/abitype/dist/esm/regex.js"() { bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/; integerRegex = /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/; isTupleRegex = /^\(.+?\).*?$/; } }); // node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js function formatAbiParameter(abiParameter) { let type = abiParameter.type; if (tupleRegex.test(abiParameter.type) && "components" in abiParameter) { type = "("; const length = abiParameter.components.length; for (let i = 0; i < length; i++) { const component = abiParameter.components[i]; type += formatAbiParameter(component); if (i < length - 1) type += ", "; } const result = execTyped(tupleRegex, abiParameter.type); type += `)${result?.array ?? ""}`; return formatAbiParameter({ ...abiParameter, type }); } if ("indexed" in abiParameter && abiParameter.indexed) type = `${type} indexed`; if (abiParameter.name) return `${type} ${abiParameter.name}`; return type; } var tupleRegex; var init_formatAbiParameter = __esm({ "node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js"() { init_regex(); tupleRegex = /^tuple(?<array>(\[(\d*)\])*)$/; } }); // node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js function formatAbiParameters(abiParameters) { let params = ""; const length = abiParameters.length; for (let i = 0; i < length; i++) { const abiParameter = abiParameters[i]; params += formatAbiParameter(abiParameter); if (i !== length - 1) params += ", "; } return params; } var init_formatAbiParameters = __esm({ "node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js"() { init_formatAbiParameter(); } }); // node_modules/abitype/dist/esm/human-readable/formatAbiItem.js function formatAbiItem(abiItem) { if (abiItem.type === "function") return `function ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability && abiItem.stateMutability !== "nonpayable" ? ` ${abiItem.stateMutability}` : ""}${abiItem.outputs.length ? ` returns (${formatAbiParameters(abiItem.outputs)})` : ""}`; else if (abiItem.type === "event") return `event ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`; else if (abiItem.type === "error") return `error ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`; else if (abiItem.type === "constructor") return `constructor(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability === "payable" ? " payable" : ""}`; else if (abiItem.type === "fallback") return "fallback()"; return "receive() external payable"; } var init_formatAbiItem = __esm({ "node_modules/abitype/dist/esm/human-readable/formatAbiItem.js"() { init_formatAbiParameters(); } }); // node_modules/abitype/dist/esm/human-readable/runtime/signatures.js function isErrorSignature(signature) { return errorSignatureRegex.test(signature); } function execErrorSignature(signature) { return execTyped(errorSignatureRegex, signature); } function isEventSignature(signature) { return eventSignatureRegex.test(signature); } function execEventSignature(signature) { return execTyped(eventSignatureRegex, signature); } function isFunctionSignature(signature) { return functionSignatureRegex.test(signature); } function execFunctionSignature(signature) { return execTyped(functionSignatureRegex, signature); } function isStructSignature(signature) { return structSignatureRegex.test(signature); } function execStructSignature(signature) { return execTyped(structSignatureRegex, signature); } function isConstructorSignature(signature) { return constructorSignatureRegex.test(signature); } function execConstructorSignature(signature) { return execTyped(constructorSignatureRegex, signature); } function isFallbackSignature(signature) { return fallbackSignatureRegex.test(signature); } function isReceiveSignature(signature) { return receiveSignatureRegex.test(signature); } var errorSignatureRegex, eventSignatureRegex, functionSignatureRegex, structSignatureRegex, constructorSignatureRegex, fallbackSignatureRegex, receiveSignatureRegex, eventModifiers, functionModifiers; var init_signatures = __esm({ "node_modules/abitype/dist/esm/human-readable/runtime/signatures.js"() { init_regex(); errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/; eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/; functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/; structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/; constructorSignatureRegex = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/; fallbackSignatureRegex = /^fallback\(\)$/; receiveSignatureRegex = /^receive\(\) external payable$/; eventModifiers = /* @__PURE__ */ new Set(["indexed"]); functionModifiers = /* @__PURE__ */ new Set([ "calldata", "memory", "storage" ]); } }); // node_modules/abitype/dist/esm/human-readable/errors/abiItem.js var UnknownTypeError, UnknownSolidityTypeError; var init_abiItem = __esm({ "node_modules/abitype/dist/esm/human-readable/errors/abiItem.js"() { init_errors(); UnknownTypeError = class extends BaseError2 { constructor({ type }) { super("Unknown type.", { metaMessages: [ `Type "${type}" is not a valid ABI type. Perhaps you forgot to include a struct signature?` ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "UnknownTypeError" }); } }; UnknownSolidityTypeError = class extends BaseError2 { constructor({ type }) { super("Unknown type.", { metaMessages: [`Type "${type}" is not a valid ABI type.`] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "UnknownSolidityTypeError" }); } }; } }); // node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js var InvalidParameterError, SolidityProtectedKeywordError, InvalidModifierError, InvalidFunctionModifierError, InvalidAbiTypeParameterError; var init_abiParameter = __esm({ "node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js"() { init_errors(); InvalidParameterError = class extends BaseError2 { constructor({ param }) { super("Invalid ABI parameter.", { details: param }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidParameterError" }); } }; SolidityProtectedKeywordError = class extends BaseError2 { constructor({ param, name }) { super("Invalid ABI parameter.", { details: param, metaMessages: [ `"${name}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html` ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "SolidityProtectedKeywordError" }); } }; InvalidModifierError = class extends BaseError2 { constructor({ param, type, modifier }) { super("Invalid ABI parameter.", { details: param, metaMessages: [ `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.` ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidModifierError" }); } }; InvalidFunctionModifierError = class extends BaseError2 { constructor({ param, type, modifier }) { super("Invalid ABI parameter.", { details: param, metaMessages: [ `Modifier "${modifier}" not allowed${type ? ` in "${type}" type` : ""}.`, `Data location can only be specified for array, struct, or mapping types, but "${modifier}" was given.` ] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidFunctionModifierError" }); } }; InvalidAbiTypeParameterError = class extends BaseError2 { constructor({ abiParameter }) { super("Invalid ABI parameter.", { details: JSON.stringify(abiParameter, null, 2), metaMessages: ["ABI parameter type is invalid."] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidAbiTypeParameterError" }); } }; } }); // node_modules/abitype/dist/esm/human-readable/errors/signature.js var InvalidSignatureError, UnknownSignatureError, InvalidStructSignatureError; var init_signature = __esm({ "node_modules/abitype/dist/esm/human-readable/errors/signature.js"() { init_errors(); InvalidSignatureError = class extends BaseError2 { constructor({ signature, type }) { super(`Invalid ${type} signature.`, { details: signature }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidSignatureError" }); } }; UnknownSignatureError = class extends BaseError2 { constructor({ signature }) { super("Unknown signature.", { details: signature }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "UnknownSignatureError" }); } }; InvalidStructSignatureError = class extends BaseError2 { constructor({ signature }) { super("Invalid struct signature.", { details: signature, metaMessages: ["No properties exist."] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidStructSignatureError" }); } }; } }); // node_modules/abitype/dist/esm/human-readable/errors/struct.js var CircularReferenceError; var init_struct = __esm({ "node_modules/abitype/dist/esm/human-readable/errors/struct.js"() { init_errors(); CircularReferenceError = class extends BaseError2 { constructor({ type }) { super("Circular reference detected.", { metaMessages: [`Struct "${type}" is a circular reference.`] }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "CircularReferenceError" }); } }; } }); // node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js var InvalidParenthesisError; var init_splitParameters = __esm({ "node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js"() { init_errors(); InvalidParenthesisError = class extends BaseError2 { constructor({ current, depth }) { super("Unbalanced parentheses.", { metaMessages: [ `"${current.trim()}" has too many ${depth > 0 ? "opening" : "closing"} parentheses.` ], details: `Depth "${depth}"` }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidParenthesisError" }); } }; } }); // node_modules/abitype/dist/esm/human-readable/runtime/cache.js function getParameterCacheKey(param, type) { if (type) return `${type}:${param}`; return param; } var parameterCache; var init_cache = __esm({ "node_modules/abitype/dist/esm/human-readable/runtime/cache.js"() { parameterCache = /* @__PURE__ */ new Map([ ["address", { type: "address" }], ["bool", { type: "bool" }], ["bytes", { type: "bytes" }], ["bytes32", { type: "bytes32" }], ["int", { type: "int256" }], ["int256", { type: "int256" }], ["string", { type: "string" }], ["uint", { type: "uint256" }], ["uint8", { type: "uint8" }], ["uint16", { type: "uint16" }], ["uint24", { type: "uint24" }], ["uint32", { type: "uint32" }], ["uint64", { type: "uint64" }], ["uint96", { type: "uint96" }], ["uint112", { type: "uint112" }], ["uint160", { type: "uint160" }], ["uint192", { type: "uint192" }], ["uint256", { type: "uint256" }], ["address owner", { type: "address", name: "owner" }], ["address to", { type: "address", name: "to" }], ["bool approved", { type: "bool", name: "approved" }], ["bytes _data", { type: "bytes", name: "_data" }], ["bytes data", { type: "bytes", name: "data" }], ["bytes signature", { type: "bytes", name: "signature" }], ["bytes32 hash", { type: "bytes32", name: "hash" }], ["bytes32 r", { type: "bytes32", name: "r" }], ["bytes32 root", { type: "bytes32", name: "root" }], ["bytes32 s", { type: "bytes32", name: "s" }], ["string name", { type: "string", name: "name" }], ["string symbol", { type: "string", name: "symbol" }], ["string tokenURI", { type: "string", name: "tokenURI" }], ["uint tokenId", { type: "uint256", name: "tokenId" }], ["uint8 v", { type: "uint8", name: "v" }], ["uint256 balance", { type: "uint256", name: "balance" }], ["uint256 tokenId", { type: "uint256", name: "tokenId" }], ["uint256 value", { type: "uint256", name: "value" }], [ "event:address indexed from", { type: "address", name: "from", indexed: true } ], ["event:address indexed to", { type: "address", name: "to", indexed: true }], [ "event:uint indexed tokenId", { type: "uint256", name: "tokenId", indexed: true } ], [ "event:uint256 indexed tokenId", { type: "uint256", name: "tokenId", indexed: true } ] ]); } }); // node_modules/abitype/dist/esm/human-readable/runtime/utils.js function parseSignature(signature, structs = {}) { if (isFunctionSignature(signature)) { const match = execFunctionSignature(signature); if (!match) throw new InvalidSignatureError({ signature, type: "function" }); const inputParams = splitParameters(match.parameters); const inputs = []; const inputLength = inputParams.length; for (let i = 0; i < inputLength; i++) { inputs.push(parseAbiParameter(inputParams[i], { modifiers: functionModifiers, structs, type: "function" })); } const outputs = []; if (match.returns) { const outputParams = splitParameters(match.returns); const outputLength = outputParams.length; for (let i = 0; i < outputLength; i++) { outputs.push(parseAbiParameter(outputParams[i], { modifiers: functionModifiers, structs, type: "function" })); } } return { name: match.name, type: "function", stateMutability: match.stateMutability ?? "nonpayable", inputs, outputs }; } if (isEventSignature(signature)) { const match = execEventSignature(signature); if (!match) throw new InvalidSignatureError({ signature, type: "event" }); const params = splitParameters(match.parameters); const abiParameters = []; const length = params.length; for (let i = 0; i < length; i++) { abiParameters.push(parseAbiParameter(params[i], { modifiers: eventModifiers, structs, type: "event" })); } return { name: match.name, type: "event", inputs: abiParameters }; } if (is