@daydreamsai/ai-sdk-provider
Version:
Dreams Router AI SDK provider (forked from OpenRouter)
1,260 lines (1,236 loc) • 754 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
target[prop] = source[prop];
}
return target;
};
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __export = (target, all) => {
for (var name14 in all)
__defProp(target, name14, { get: all[name14], enumerable: true });
};
var __copyProps = (to, from5, except, desc) => {
if (from5 && typeof from5 === "object" || typeof from5 === "function") {
for (let key of __getOwnPropNames(from5))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from5[key], enumerable: !(desc = __getOwnPropDesc(from5, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
mod2
));
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/version.js
var version;
var init_version = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/version.js"() {
"use strict";
version = "1.0.8";
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/errors.js
var BaseError;
var init_errors = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/errors.js"() {
"use strict";
init_version();
BaseError = class _BaseError extends Error {
constructor(shortMessage, args = {}) {
var _a15;
const details = args.cause instanceof _BaseError ? args.cause.details : ((_a15 = args.cause) == null ? void 0 : _a15.message) ? args.cause.message : args.details;
const docsPath8 = args.cause instanceof _BaseError ? args.cause.docsPath || args.docsPath : args.docsPath;
const message = [
shortMessage || "An error occurred.",
"",
...args.metaMessages ? [...args.metaMessages, ""] : [],
...docsPath8 ? [`Docs: https://abitype.dev${docsPath8}`] : [],
...details ? [`Details: ${details}`] : [],
`Version: abitype@${version}`
].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 = docsPath8;
this.metaMessages = args.metaMessages;
this.shortMessage = shortMessage;
}
};
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/regex.js
function execTyped(regex, string) {
const match = regex.exec(string);
return match == null ? void 0 : match.groups;
}
var bytesRegex, integerRegex, isTupleRegex;
var init_regex = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/regex.js"() {
"use strict";
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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js
function formatAbiParameter(abiParameter) {
var _a15;
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 += `)${(_a15 = result == null ? void 0 : result.array) != null ? _a15 : ""}`;
return formatAbiParameter(__spreadProps(__spreadValues({}, 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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js"() {
"use strict";
init_regex();
tupleRegex = new RegExp("^tuple(?<array>(\\[(\\d*)\\])*)$");
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/formatAbiParameters.js"() {
"use strict";
init_formatAbiParameter();
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/formatAbiItem.js
function formatAbiItem(abiItem) {
var _a15;
if (abiItem.type === "function")
return `function ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability && abiItem.stateMutability !== "nonpayable" ? ` ${abiItem.stateMutability}` : ""}${((_a15 = abiItem.outputs) == null ? void 0 : _a15.length) ? ` returns (${formatAbiParameters(abiItem.outputs)})` : ""}`;
if (abiItem.type === "event")
return `event ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
if (abiItem.type === "error")
return `error ${abiItem.name}(${formatAbiParameters(abiItem.inputs)})`;
if (abiItem.type === "constructor")
return `constructor(${formatAbiParameters(abiItem.inputs)})${abiItem.stateMutability === "payable" ? " payable" : ""}`;
if (abiItem.type === "fallback")
return `fallback() external${abiItem.stateMutability === "payable" ? " payable" : ""}`;
return "receive() external payable";
}
var init_formatAbiItem = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/formatAbiItem.js"() {
"use strict";
init_formatAbiParameters();
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/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 execFallbackSignature(signature) {
return execTyped(fallbackSignatureRegex, signature);
}
function isReceiveSignature(signature) {
return receiveSignatureRegex.test(signature);
}
var errorSignatureRegex, eventSignatureRegex, functionSignatureRegex, structSignatureRegex, constructorSignatureRegex, fallbackSignatureRegex, receiveSignatureRegex, eventModifiers, functionModifiers;
var init_signatures = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/signatures.js"() {
"use strict";
init_regex();
errorSignatureRegex = new RegExp("^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\\((?<parameters>.*?)\\)$");
eventSignatureRegex = new RegExp("^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\\((?<parameters>.*?)\\)$");
functionSignatureRegex = new RegExp("^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\\((?<parameters>.*?)\\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\\s?\\((?<returns>.*?)\\))?$");
structSignatureRegex = new RegExp("^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \\{(?<properties>.*?)\\}$");
constructorSignatureRegex = new RegExp("^constructor\\((?<parameters>.*?)\\)(?:\\s(?<stateMutability>payable{1}))?$");
fallbackSignatureRegex = new RegExp("^fallback\\(\\) external(?:\\s(?<stateMutability>payable{1}))?$");
receiveSignatureRegex = /^receive\(\) external payable$/;
eventModifiers = /* @__PURE__ */ new Set(["indexed"]);
functionModifiers = /* @__PURE__ */ new Set([
"calldata",
"memory",
"storage"
]);
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/abiItem.js
var InvalidAbiItemError, UnknownTypeError, UnknownSolidityTypeError;
var init_abiItem = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/abiItem.js"() {
"use strict";
init_errors();
InvalidAbiItemError = class extends BaseError {
constructor({ signature }) {
super("Failed to parse ABI item.", {
details: `parseAbiItem(${JSON.stringify(signature, null, 2)})`,
docsPath: "/api/human#parseabiitem-1"
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidAbiItemError"
});
}
};
UnknownTypeError = class extends BaseError {
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 BaseError {
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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js
var InvalidParameterError, SolidityProtectedKeywordError, InvalidModifierError, InvalidFunctionModifierError, InvalidAbiTypeParameterError;
var init_abiParameter = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/abiParameter.js"() {
"use strict";
init_errors();
InvalidParameterError = class extends BaseError {
constructor({ param }) {
super("Invalid ABI parameter.", {
details: param
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidParameterError"
});
}
};
SolidityProtectedKeywordError = class extends BaseError {
constructor({ param, name: name14 }) {
super("Invalid ABI parameter.", {
details: param,
metaMessages: [
`"${name14}" 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 BaseError {
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 BaseError {
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 BaseError {
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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/signature.js
var InvalidSignatureError, UnknownSignatureError, InvalidStructSignatureError;
var init_signature = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/signature.js"() {
"use strict";
init_errors();
InvalidSignatureError = class extends BaseError {
constructor({ signature, type }) {
super(`Invalid ${type} signature.`, {
details: signature
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "InvalidSignatureError"
});
}
};
UnknownSignatureError = class extends BaseError {
constructor({ signature }) {
super("Unknown signature.", {
details: signature
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "UnknownSignatureError"
});
}
};
InvalidStructSignatureError = class extends BaseError {
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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/struct.js
var CircularReferenceError;
var init_struct = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/struct.js"() {
"use strict";
init_errors();
CircularReferenceError = class extends BaseError {
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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js
var InvalidParenthesisError;
var init_splitParameters = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/errors/splitParameters.js"() {
"use strict";
init_errors();
InvalidParenthesisError = class extends BaseError {
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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/cache.js
function getParameterCacheKey(param, type, structs) {
let structKey = "";
if (structs)
for (const struct of Object.entries(structs)) {
if (!struct)
continue;
let propertyKey = "";
for (const property of struct[1]) {
propertyKey += `[${property.type}${property.name ? `:${property.name}` : ""}]`;
}
structKey += `(${struct[0]}{${propertyKey}})`;
}
if (type)
return `${type}:${param}${structKey}`;
return param;
}
var parameterCache;
var init_cache = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/cache.js"() {
"use strict";
parameterCache = /* @__PURE__ */ new Map([
// Unnamed
["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" }],
// Named
["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" }],
// Indexed
[
"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/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/utils.js
function parseSignature(signature, structs = {}) {
if (isFunctionSignature(signature))
return parseFunctionSignature(signature, structs);
if (isEventSignature(signature))
return parseEventSignature(signature, structs);
if (isErrorSignature(signature))
return parseErrorSignature(signature, structs);
if (isConstructorSignature(signature))
return parseConstructorSignature(signature, structs);
if (isFallbackSignature(signature))
return parseFallbackSignature(signature);
if (isReceiveSignature(signature))
return {
type: "receive",
stateMutability: "payable"
};
throw new UnknownSignatureError({ signature });
}
function parseFunctionSignature(signature, structs = {}) {
var _a15;
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: (_a15 = match.stateMutability) != null ? _a15 : "nonpayable",
inputs,
outputs
};
}
function parseEventSignature(signature, structs = {}) {
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 };
}
function parseErrorSignature(signature, structs = {}) {
const match = execErrorSignature(signature);
if (!match)
throw new InvalidSignatureError({ signature, type: "error" });
const params = splitParameters(match.parameters);
const abiParameters = [];
const length = params.length;
for (let i = 0; i < length; i++)
abiParameters.push(parseAbiParameter(params[i], { structs, type: "error" }));
return { name: match.name, type: "error", inputs: abiParameters };
}
function parseConstructorSignature(signature, structs = {}) {
var _a15;
const match = execConstructorSignature(signature);
if (!match)
throw new InvalidSignatureError({ signature, type: "constructor" });
const params = splitParameters(match.parameters);
const abiParameters = [];
const length = params.length;
for (let i = 0; i < length; i++)
abiParameters.push(parseAbiParameter(params[i], { structs, type: "constructor" }));
return {
type: "constructor",
stateMutability: (_a15 = match.stateMutability) != null ? _a15 : "nonpayable",
inputs: abiParameters
};
}
function parseFallbackSignature(signature) {
var _a15;
const match = execFallbackSignature(signature);
if (!match)
throw new InvalidSignatureError({ signature, type: "fallback" });
return {
type: "fallback",
stateMutability: (_a15 = match.stateMutability) != null ? _a15 : "nonpayable"
};
}
function parseAbiParameter(param, options) {
var _a15, _b, _c, _d;
const parameterCacheKey = getParameterCacheKey(param, options == null ? void 0 : options.type, options == null ? void 0 : options.structs);
if (parameterCache.has(parameterCacheKey))
return parameterCache.get(parameterCacheKey);
const isTuple = isTupleRegex.test(param);
const match = execTyped(isTuple ? abiParameterWithTupleRegex : abiParameterWithoutTupleRegex, param);
if (!match)
throw new InvalidParameterError({ param });
if (match.name && isSolidityKeyword(match.name))
throw new SolidityProtectedKeywordError({ param, name: match.name });
const name14 = match.name ? { name: match.name } : {};
const indexed = match.modifier === "indexed" ? { indexed: true } : {};
const structs = (_a15 = options == null ? void 0 : options.structs) != null ? _a15 : {};
let type;
let components = {};
if (isTuple) {
type = "tuple";
const params = splitParameters(match.type);
const components_ = [];
const length = params.length;
for (let i = 0; i < length; i++) {
components_.push(parseAbiParameter(params[i], { structs }));
}
components = { components: components_ };
} else if (match.type in structs) {
type = "tuple";
components = { components: structs[match.type] };
} else if (dynamicIntegerRegex.test(match.type)) {
type = `${match.type}256`;
} else {
type = match.type;
if (!((options == null ? void 0 : options.type) === "struct") && !isSolidityType(type))
throw new UnknownSolidityTypeError({ type });
}
if (match.modifier) {
if (!((_c = (_b = options == null ? void 0 : options.modifiers) == null ? void 0 : _b.has) == null ? void 0 : _c.call(_b, match.modifier)))
throw new InvalidModifierError({
param,
type: options == null ? void 0 : options.type,
modifier: match.modifier
});
if (functionModifiers.has(match.modifier) && !isValidDataLocation(type, !!match.array))
throw new InvalidFunctionModifierError({
param,
type: options == null ? void 0 : options.type,
modifier: match.modifier
});
}
const abiParameter = __spreadValues(__spreadValues(__spreadValues({
type: `${type}${(_d = match.array) != null ? _d : ""}`
}, name14), indexed), components);
parameterCache.set(parameterCacheKey, abiParameter);
return abiParameter;
}
function splitParameters(params, result = [], current = "", depth = 0) {
const length = params.trim().length;
for (let i = 0; i < length; i++) {
const char = params[i];
const tail = params.slice(i + 1);
switch (char) {
case ",":
return depth === 0 ? splitParameters(tail, [...result, current.trim()]) : splitParameters(tail, result, `${current}${char}`, depth);
case "(":
return splitParameters(tail, result, `${current}${char}`, depth + 1);
case ")":
return splitParameters(tail, result, `${current}${char}`, depth - 1);
default:
return splitParameters(tail, result, `${current}${char}`, depth);
}
}
if (current === "")
return result;
if (depth !== 0)
throw new InvalidParenthesisError({ current, depth });
result.push(current.trim());
return result;
}
function isSolidityType(type) {
return type === "address" || type === "bool" || type === "function" || type === "string" || bytesRegex.test(type) || integerRegex.test(type);
}
function isSolidityKeyword(name14) {
return name14 === "address" || name14 === "bool" || name14 === "function" || name14 === "string" || name14 === "tuple" || bytesRegex.test(name14) || integerRegex.test(name14) || protectedKeywordsRegex.test(name14);
}
function isValidDataLocation(type, isArray) {
return isArray || type === "bytes" || type === "string" || type === "tuple";
}
var abiParameterWithoutTupleRegex, abiParameterWithTupleRegex, dynamicIntegerRegex, protectedKeywordsRegex;
var init_utils = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/utils.js"() {
"use strict";
init_regex();
init_abiItem();
init_abiParameter();
init_signature();
init_splitParameters();
init_cache();
init_signatures();
abiParameterWithoutTupleRegex = new RegExp("^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\\[\\d*?\\])+?)?(?:\\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$");
abiParameterWithTupleRegex = new RegExp("^\\((?<type>.+?)\\)(?<array>(?:\\[\\d*?\\])+?)?(?:\\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$");
dynamicIntegerRegex = /^u?int$/;
protectedKeywordsRegex = /^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/structs.js
function parseStructs(signatures) {
const shallowStructs = {};
const signaturesLength = signatures.length;
for (let i = 0; i < signaturesLength; i++) {
const signature = signatures[i];
if (!isStructSignature(signature))
continue;
const match = execStructSignature(signature);
if (!match)
throw new InvalidSignatureError({ signature, type: "struct" });
const properties = match.properties.split(";");
const components = [];
const propertiesLength = properties.length;
for (let k = 0; k < propertiesLength; k++) {
const property = properties[k];
const trimmed = property.trim();
if (!trimmed)
continue;
const abiParameter = parseAbiParameter(trimmed, {
type: "struct"
});
components.push(abiParameter);
}
if (!components.length)
throw new InvalidStructSignatureError({ signature });
shallowStructs[match.name] = components;
}
const resolvedStructs = {};
const entries = Object.entries(shallowStructs);
const entriesLength = entries.length;
for (let i = 0; i < entriesLength; i++) {
const [name14, parameters] = entries[i];
resolvedStructs[name14] = resolveStructs(parameters, shallowStructs);
}
return resolvedStructs;
}
function resolveStructs(abiParameters, structs, ancestors = /* @__PURE__ */ new Set()) {
var _a15;
const components = [];
const length = abiParameters.length;
for (let i = 0; i < length; i++) {
const abiParameter = abiParameters[i];
const isTuple = isTupleRegex.test(abiParameter.type);
if (isTuple)
components.push(abiParameter);
else {
const match = execTyped(typeWithoutTupleRegex, abiParameter.type);
if (!(match == null ? void 0 : match.type))
throw new InvalidAbiTypeParameterError({ abiParameter });
const { array, type } = match;
if (type in structs) {
if (ancestors.has(type))
throw new CircularReferenceError({ type });
components.push(__spreadProps(__spreadValues({}, abiParameter), {
type: `tuple${array != null ? array : ""}`,
components: resolveStructs((_a15 = structs[type]) != null ? _a15 : [], structs, /* @__PURE__ */ new Set([...ancestors, type]))
}));
} else {
if (isSolidityType(type))
components.push(abiParameter);
else
throw new UnknownTypeError({ type });
}
}
}
return components;
}
var typeWithoutTupleRegex;
var init_structs = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/runtime/structs.js"() {
"use strict";
init_regex();
init_abiItem();
init_abiParameter();
init_signature();
init_struct();
init_signatures();
init_utils();
typeWithoutTupleRegex = new RegExp("^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\\[\\d*?\\])+?)?$");
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/parseAbi.js
function parseAbi(signatures) {
const structs = parseStructs(signatures);
const abi2 = [];
const length = signatures.length;
for (let i = 0; i < length; i++) {
const signature = signatures[i];
if (isStructSignature(signature))
continue;
abi2.push(parseSignature(signature, structs));
}
return abi2;
}
var init_parseAbi = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/parseAbi.js"() {
"use strict";
init_signatures();
init_structs();
init_utils();
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/parseAbiItem.js
function parseAbiItem(signature) {
let abiItem;
if (typeof signature === "string")
abiItem = parseSignature(signature);
else {
const structs = parseStructs(signature);
const length = signature.length;
for (let i = 0; i < length; i++) {
const signature_ = signature[i];
if (isStructSignature(signature_))
continue;
abiItem = parseSignature(signature_, structs);
break;
}
}
if (!abiItem)
throw new InvalidAbiItemError({ signature });
return abiItem;
}
var init_parseAbiItem = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/human-readable/parseAbiItem.js"() {
"use strict";
init_abiItem();
init_signatures();
init_structs();
init_utils();
}
});
// node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/exports/index.js
var init_exports = __esm({
"node_modules/.pnpm/abitype@1.0.8_typescript@5.8.3_zod@3.25.76/node_modules/abitype/dist/esm/exports/index.js"() {
"use strict";
init_formatAbiItem();
init_parseAbi();
init_parseAbiItem();
}
});
// node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/abi/formatAbiItem.js
function formatAbiItem2(abiItem, { includeName = false } = {}) {
if (abiItem.type !== "function" && abiItem.type !== "event" && abiItem.type !== "error")
throw new InvalidDefinitionTypeError(abiItem.type);
return `${abiItem.name}(${formatAbiParams(abiItem.inputs, { includeName })})`;
}
function formatAbiParams(params, { includeName = false } = {}) {
if (!params)
return "";
return params.map((param) => formatAbiParam(param, { includeName })).join(includeName ? ", " : ",");
}
function formatAbiParam(param, { includeName }) {
if (param.type.startsWith("tuple")) {
return `(${formatAbiParams(param.components, { includeName })})${param.type.slice("tuple".length)}`;
}
return param.type + (includeName && param.name ? ` ${param.name}` : "");
}
var init_formatAbiItem2 = __esm({
"node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/abi/formatAbiItem.js"() {
"use strict";
init_abi();
}
});
// node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/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/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/data/isHex.js"() {
"use strict";
}
});
// node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/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/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/utils/data/size.js"() {
"use strict";
init_isHex();
}
});
// node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/version.js
var version2;
var init_version2 = __esm({
"node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/version.js"() {
"use strict";
version2 = "2.31.7";
}
});
// node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/base.js
function walk(err, fn) {
if (fn == null ? void 0 : fn(err))
return err;
if (err && typeof err === "object" && "cause" in err && err.cause !== void 0)
return walk(err.cause, fn);
return fn ? null : err;
}
var errorConfig, BaseError2;
var init_base = __esm({
"node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/base.js"() {
"use strict";
init_version2();
errorConfig = {
getDocsUrl: ({ docsBaseUrl, docsPath: docsPath8 = "", docsSlug }) => docsPath8 ? `${docsBaseUrl != null ? docsBaseUrl : "https://viem.sh"}${docsPath8}${docsSlug ? `#${docsSlug}` : ""}` : void 0,
version: `viem@${version2}`
};
BaseError2 = class _BaseError extends Error {
constructor(shortMessage, args = {}) {
var _a15, _b;
const details = (() => {
var _a16;
if (args.cause instanceof _BaseError)
return args.cause.details;
if ((_a16 = args.cause) == null ? void 0 : _a16.message)
return args.cause.message;
return args.details;
})();
const docsPath8 = (() => {
if (args.cause instanceof _BaseError)
return args.cause.docsPath || args.docsPath;
return args.docsPath;
})();
const docsUrl = (_a15 = errorConfig.getDocsUrl) == null ? void 0 : _a15.call(errorConfig, __spreadProps(__spreadValues({}, args), { docsPath: docsPath8 }));
const message = [
shortMessage || "An error occurred.",
"",
...args.metaMessages ? [...args.metaMessages, ""] : [],
...docsUrl ? [`Docs: ${docsUrl}`] : [],
...details ? [`Details: ${details}`] : [],
...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
].join("\n");
super(message, args.cause ? { cause: args.cause } : void 0);
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, "version", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "name", {
enumerable: true,
configurable: true,
writable: true,
value: "BaseError"
});
this.details = details;
this.docsPath = docsPath8;
this.metaMessages = args.metaMessages;
this.name = (_b = args.name) != null ? _b : this.name;
this.shortMessage = shortMessage;
this.version = version2;
}
walk(fn) {
return walk(this, fn);
}
};
}
});
// node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/abi.js
var AbiConstructorNotFoundError, AbiConstructorParamsNotFoundError, AbiDecodingDataSizeTooSmallError, AbiDecodingZeroDataError, AbiEncodingArrayLengthMismatchError, AbiEncodingBytesSizeMismatchError, AbiEncodingLengthMismatchError, AbiErrorInputsNotFoundError, AbiErrorNotFoundError, AbiErrorSignatureNotFoundError, AbiEventSignatureEmptyTopicsError, AbiEventSignatureNotFoundError, AbiEventNotFoundError, AbiFunctionNotFoundError, AbiFunctionOutputsNotFoundError, AbiFunctionSignatureNotFoundError, AbiItemAmbiguityError, BytesSizeMismatchError, DecodeLogDataMismatch, DecodeLogTopicsMismatch, InvalidAbiEncodingTypeError, InvalidAbiDecodingTypeError, InvalidArrayError, InvalidDefinitionTypeError;
var init_abi = __esm({
"node_modules/.pnpm/viem@2.31.7_bufferutil@4.0.9_typescript@5.8.3_utf-8-validate@5.0.10_zod@3.25.76/node_modules/viem/_esm/errors/abi.js"() {
"use strict";
init_formatAbiItem2();
init_size();
init_base();
AbiConstructorNotFoundError = class extends BaseError2 {
constructor({ docsPath: docsPath8 }) {
super([
"A constructor was not found on the ABI.",
"Make sure you are using the correct ABI and that the constructor exists on it."
].join("\n"), {
docsPath: docsPath8,
name: "AbiConstructorNotFoundError"
});
}
};
AbiConstructorParamsNotFoundError = class extends BaseError2 {
constructor({ docsPath: docsPath8 }) {
super([
"Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.",
"Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."
].join("\n"), {
docsPath: docsPath8,
name: "AbiConstructorParamsNotFoundError"
});
}
};
AbiDecodingDataSizeTooSmallError = class extends BaseError2 {
constructor({ data, params, size: size5 }) {
super([`Data size of ${size5} bytes is too small for given parameters.`].join("\n"), {
metaMessages: [
`Params: (${formatAbiParams(params, { includeName: true })})`,
`Data: ${data} (${size5} bytes)`
],
name: "AbiDecodingDataSizeTooSmallError"
});
Object.defineProperty(this, "data", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "params", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "size", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.data = data;
this.params = params;
this.size = size5;
}
};
AbiDecodingZeroDataError = class extends BaseError2 {
constructor() {
super('Cannot decode zero data ("0x") with ABI parameters.', {
name: "AbiDecodingZeroDataError"
});
}
};
AbiEncodingArrayLengthMismatchError = class extends BaseError2 {
constructor({ expectedLength, givenLength, type }) {
super([
`ABI encoding array length mismatch for type ${type}.`,
`Expected length: ${expectedLength}`,
`Given length: ${givenLength}`
].join("\n"), { name: "AbiEncodingArrayLengthMismatchError" });
}
};
AbiEncodingBytesSizeMismatchError = class extends BaseError2 {
constructor({ expectedSize, value }) {
super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" });
}
};
AbiEncodingLengthMismatchError = class extends BaseError2 {
constructor({ expectedLength, givenLength }) {
super([
"ABI encoding params/values length mismatch.",
`Expected length (params): ${expectedLength}`,
`Given length (values): ${givenLength}`
].join("\n"), { name: "AbiEncodingLengthMismatchError" });
}
};
AbiErrorInputsNotFoundError = class extends BaseError2 {
constructor(errorName, { docsPath: docsPath8 }) {
super([
`Arguments (\`args\`) were provided to "${errorName}", but "${errorName}" on the ABI does not contain any parameters (\`inputs\`).`,
"Cannot encode error result without knowing what the parameter types are.",
"Make sure you are using the correct ABI and that the inputs exist on it."
].join("\n"), {
docsPath: docsPath8,
name: "AbiErrorInputsNotFoundError"
});
}
};
AbiErrorNotFoundError = class extends BaseError2 {
constructor(errorName, { docsPath: docsPath8 } = {}) {
super([
`Error ${errorName ? `"${errorName}" ` : ""}not found on ABI.`,
"Make sure you are using the correct ABI and that the error exists on it."
].join("\n"), {
docsPath: docsPath8,
name: "AbiErrorNotFoundError"
});
}
};
AbiErrorSignatureNotFoundError = class extends BaseError2 {
constructor(signature, { docsPath: docsPath8 }) {
super([
`Encoded error signature "${signature}" not found on ABI.`,
"Make sure you are using the correct ABI and that the error exists on it.",
`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${signature}.`
].join("\n"), {
docsPath: docsPath8,
name: "AbiErrorSignatureNotFoundError"
});
Object.defineProperty(this, "signature", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.signature = signature;
}
};
AbiEventSignatureEmptyTopicsError = class extends BaseError2 {
constructor({ docsPath: docsPath8 }) {
super("Cannot extract event signature from empty topics.", {
docsPath: docsPath8,
name: "AbiEventSignatureEmptyTopicsError"
});
}
};
AbiEventSignatureNotFoundError = class extends BaseError2 {
constructor(signature, { docsPath: docsPath8 }) {
super([
`Encoded event signature "${signature}" not found on ABI.`,
"Make sure you are using the correct ABI and that the event exists on it.",
`You can look up the signature here: https://openchain.xyz/signatures?query=${signature}.`
].join("\n"), {
docsPath: docsPath8,
name: "AbiEventSignatureNotFoundError"
});
}
};
AbiEventNotFoundError = class extends BaseError2 {
constructor(eventName, { docsPath: docsPath8 } = {}) {
super([
`Event ${eventName ? `"${eventName}" ` : ""}not found on ABI.`,
"Make sure you are using the correct ABI and that the event ex