UNPKG

@etherspot/data-utils

Version:
1,463 lines (1,428 loc) 130 kB
import { Hash, abytes, aexists, anumber, aoutput, byteSwap32, isLE, toBytes, u32, wrapConstructor, wrapXOFConstructorWithOpts } from "./chunk-S2KUQIEG.mjs"; // node_modules/abitype/dist/esm/version.js var version = "1.0.8"; // node_modules/abitype/dist/esm/errors.js var BaseError = 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@${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 = 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 = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/; var 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)?$/; var isTupleRegex = /^\(.+?\).*?$/; // node_modules/abitype/dist/esm/human-readable/formatAbiParameter.js var tupleRegex = /^tuple(?<array>(\[(\d*)\])*)$/; 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; } // 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; } // 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)})` : ""}`; 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"; } // node_modules/abitype/dist/esm/human-readable/runtime/signatures.js var errorSignatureRegex = /^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/; function isErrorSignature(signature) { return errorSignatureRegex.test(signature); } function execErrorSignature(signature) { return execTyped(errorSignatureRegex, signature); } var eventSignatureRegex = /^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/; function isEventSignature(signature) { return eventSignatureRegex.test(signature); } function execEventSignature(signature) { return execTyped(eventSignatureRegex, signature); } var functionSignatureRegex = /^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/; function isFunctionSignature(signature) { return functionSignatureRegex.test(signature); } function execFunctionSignature(signature) { return execTyped(functionSignatureRegex, signature); } var structSignatureRegex = /^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/; function isStructSignature(signature) { return structSignatureRegex.test(signature); } function execStructSignature(signature) { return execTyped(structSignatureRegex, signature); } var constructorSignatureRegex = /^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/; function isConstructorSignature(signature) { return constructorSignatureRegex.test(signature); } function execConstructorSignature(signature) { return execTyped(constructorSignatureRegex, signature); } var fallbackSignatureRegex = /^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/; function isFallbackSignature(signature) { return fallbackSignatureRegex.test(signature); } function execFallbackSignature(signature) { return execTyped(fallbackSignatureRegex, signature); } var receiveSignatureRegex = /^receive\(\) external payable$/; function isReceiveSignature(signature) { return receiveSignatureRegex.test(signature); } var eventModifiers = /* @__PURE__ */ new Set(["indexed"]); var functionModifiers = /* @__PURE__ */ new Set([ "calldata", "memory", "storage" ]); // node_modules/abitype/dist/esm/human-readable/errors/abiItem.js var 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" }); } }; var 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/abitype/dist/esm/human-readable/errors/abiParameter.js var InvalidParameterError = class extends BaseError { constructor({ param }) { super("Invalid ABI parameter.", { details: param }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "InvalidParameterError" }); } }; var SolidityProtectedKeywordError = class extends BaseError { 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" }); } }; var 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" }); } }; var 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" }); } }; var 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/abitype/dist/esm/human-readable/errors/signature.js var 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" }); } }; var UnknownSignatureError = class extends BaseError { constructor({ signature }) { super("Unknown signature.", { details: signature }); Object.defineProperty(this, "name", { enumerable: true, configurable: true, writable: true, value: "UnknownSignatureError" }); } }; var 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/abitype/dist/esm/human-readable/errors/struct.js var 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/abitype/dist/esm/human-readable/errors/splitParameters.js var 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/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 = /* @__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/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 = {}) { 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 }; } 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 = {}) { 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: match.stateMutability ?? "nonpayable", inputs: abiParameters }; } function parseFallbackSignature(signature) { const match = execFallbackSignature(signature); if (!match) throw new InvalidSignatureError({ signature, type: "fallback" }); return { type: "fallback", stateMutability: match.stateMutability ?? "nonpayable" }; } var abiParameterWithoutTupleRegex = /^(?<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$_]*))?$/; var abiParameterWithTupleRegex = /^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/; var dynamicIntegerRegex = /^u?int$/; function parseAbiParameter(param, options) { const parameterCacheKey = getParameterCacheKey(param, options?.type, 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 name = match.name ? { name: match.name } : {}; const indexed = match.modifier === "indexed" ? { indexed: true } : {}; const structs = options?.structs ?? {}; 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?.type === "struct") && !isSolidityType(type)) throw new UnknownSolidityTypeError({ type }); } if (match.modifier) { if (!options?.modifiers?.has?.(match.modifier)) throw new InvalidModifierError({ param, type: options?.type, modifier: match.modifier }); if (functionModifiers.has(match.modifier) && !isValidDataLocation(type, !!match.array)) throw new InvalidFunctionModifierError({ param, type: options?.type, modifier: match.modifier }); } const abiParameter = { type: `${type}${match.array ?? ""}`, ...name, ...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); } var 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)$/; function isSolidityKeyword(name) { return name === "address" || name === "bool" || name === "function" || name === "string" || name === "tuple" || bytesRegex.test(name) || integerRegex.test(name) || protectedKeywordsRegex.test(name); } function isValidDataLocation(type, isArray) { return isArray || type === "bytes" || type === "string" || type === "tuple"; } // 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 [name, parameters] = entries[i]; resolvedStructs[name] = resolveStructs(parameters, shallowStructs); } return resolvedStructs; } var typeWithoutTupleRegex = /^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/; function resolveStructs(abiParameters, structs, ancestors = /* @__PURE__ */ new Set()) { 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?.type) throw new InvalidAbiTypeParameterError({ abiParameter }); const { array, type } = match; if (type in structs) { if (ancestors.has(type)) throw new CircularReferenceError({ type }); components.push({ ...abiParameter, type: `tuple${array ?? ""}`, components: resolveStructs(structs[type] ?? [], structs, /* @__PURE__ */ new Set([...ancestors, type])) }); } else { if (isSolidityType(type)) components.push(abiParameter); else throw new UnknownTypeError({ type }); } } } return components; } // node_modules/abitype/dist/esm/human-readable/parseAbi.js function parseAbi(signatures) { const structs = parseStructs(signatures); const abi = []; const length = signatures.length; for (let i = 0; i < length; i++) { const signature = signatures[i]; if (isStructSignature(signature)) continue; abi.push(parseSignature(signature, structs)); } return abi; } // node_modules/viem/_esm/accounts/utils/parseAccount.js function parseAccount(account) { if (typeof account === "string") return { address: account, type: "json-rpc" }; return account; } // node_modules/viem/_esm/constants/abis.js var multicall3Abi = [ { inputs: [ { components: [ { name: "target", type: "address" }, { name: "allowFailure", type: "bool" }, { name: "callData", type: "bytes" } ], name: "calls", type: "tuple[]" } ], name: "aggregate3", outputs: [ { components: [ { name: "success", type: "bool" }, { name: "returnData", type: "bytes" } ], name: "returnData", type: "tuple[]" } ], stateMutability: "view", type: "function" } ]; var universalResolverErrors = [ { inputs: [], name: "ResolverNotFound", type: "error" }, { inputs: [], name: "ResolverWildcardNotSupported", type: "error" }, { inputs: [], name: "ResolverNotContract", type: "error" }, { inputs: [ { name: "returnData", type: "bytes" } ], name: "ResolverError", type: "error" }, { inputs: [ { components: [ { name: "status", type: "uint16" }, { name: "message", type: "string" } ], name: "errors", type: "tuple[]" } ], name: "HttpError", type: "error" } ]; var universalResolverResolveAbi = [ ...universalResolverErrors, { name: "resolve", type: "function", stateMutability: "view", inputs: [ { name: "name", type: "bytes" }, { name: "data", type: "bytes" } ], outputs: [ { name: "", type: "bytes" }, { name: "address", type: "address" } ] }, { name: "resolve", type: "function", stateMutability: "view", inputs: [ { name: "name", type: "bytes" }, { name: "data", type: "bytes" }, { name: "gateways", type: "string[]" } ], outputs: [ { name: "", type: "bytes" }, { name: "address", type: "address" } ] } ]; var universalResolverReverseAbi = [ ...universalResolverErrors, { name: "reverse", type: "function", stateMutability: "view", inputs: [{ type: "bytes", name: "reverseName" }], outputs: [ { type: "string", name: "resolvedName" }, { type: "address", name: "resolvedAddress" }, { type: "address", name: "reverseResolver" }, { type: "address", name: "resolver" } ] }, { name: "reverse", type: "function", stateMutability: "view", inputs: [ { type: "bytes", name: "reverseName" }, { type: "string[]", name: "gateways" } ], outputs: [ { type: "string", name: "resolvedName" }, { type: "address", name: "resolvedAddress" }, { type: "address", name: "reverseResolver" }, { type: "address", name: "resolver" } ] } ]; // node_modules/viem/_esm/constants/contract.js var aggregate3Signature = "0x82ad56cb"; // node_modules/viem/_esm/constants/contracts.js var deploylessCallViaBytecodeBytecode = "0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe"; var deploylessCallViaFactoryBytecode = "0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe"; // node_modules/viem/_esm/errors/version.js var version2 = "2.22.19"; // node_modules/viem/_esm/errors/base.js var errorConfig = { getDocsUrl: ({ docsBaseUrl, docsPath: docsPath4 = "", docsSlug }) => docsPath4 ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath4}${docsSlug ? `#${docsSlug}` : ""}` : void 0, version: `viem@${version2}` }; var BaseError2 = class _BaseError extends Error { constructor(shortMessage, args = {}) { const details = (() => { if (args.cause instanceof _BaseError) return args.cause.details; if (args.cause?.message) return args.cause.message; return args.details; })(); const docsPath4 = (() => { if (args.cause instanceof _BaseError) return args.cause.docsPath || args.docsPath; return args.docsPath; })(); const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath: docsPath4 }); 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 = docsPath4; this.metaMessages = args.metaMessages; this.name = args.name ?? this.name; this.shortMessage = shortMessage; this.version = version2; } walk(fn) { return walk(this, fn); } }; function walk(err, fn) { if (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; } // node_modules/viem/_esm/errors/chain.js var ChainDoesNotSupportContract = class extends BaseError2 { 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.` ] ], name: "ChainDoesNotSupportContract" }); } }; var ClientChainNotConfiguredError = class extends BaseError2 { constructor() { super("No chain was provided to the Client.", { name: "ClientChainNotConfiguredError" }); } }; // node_modules/viem/_esm/constants/solidity.js var solidityError = { inputs: [ { name: "message", type: "string" } ], name: "Error", type: "error" }; var solidityPanic = { inputs: [ { name: "reason", type: "uint256" } ], name: "Panic", type: "error" }; // 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}` : ""); } // 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"); } // 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; } // node_modules/viem/_esm/errors/abi.js var AbiConstructorNotFoundError = class extends BaseError2 { constructor({ docsPath: docsPath4 }) { 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: docsPath4, name: "AbiConstructorNotFoundError" }); } }; var AbiConstructorParamsNotFoundError = class extends BaseError2 { constructor({ docsPath: docsPath4 }) { 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: docsPath4, name: "AbiConstructorParamsNotFoundError" }); } }; var AbiDecodingDataSizeTooSmallError = class extends BaseError2 { constructor({ data, params, size: size2 }) { super([`Data size of ${size2} bytes is too small for given parameters.`].join("\n"), { metaMessages: [ `Params: (${formatAbiParams(params, { includeName: true })})`, `Data: ${data} (${size2} 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 = size2; } }; var AbiDecodingZeroDataError = class extends BaseError2 { constructor() { super('Cannot decode zero data ("0x") with ABI parameters.', { name: "AbiDecodingZeroDataError" }); } }; var 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" }); } }; var AbiEncodingBytesSizeMismatchError = class extends BaseError2 { constructor({ expectedSize, value }) { super(`Size of bytes "${value}" (bytes${size(value)}) does not match expected size (bytes${expectedSize}).`, { name: "AbiEncodingBytesSizeMismatchError" }); } }; var 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" }); } }; var AbiErrorSignatureNotFoundError = class extends BaseError2 { constructor(signature, { docsPath: docsPath4 }) { 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: docsPath4, name: "AbiErrorSignatureNotFoundError" }); Object.defineProperty(this, "signature", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.signature = signature; } }; var AbiFunctionNotFoundError = class extends BaseError2 { constructor(functionName, { docsPath: docsPath4 } = {}) { super([ `Function ${functionName ? `"${functionName}" ` : ""}not found on ABI.`, "Make sure you are using the correct ABI and that the function exists on it." ].join("\n"), { docsPath: docsPath4, name: "AbiFunctionNotFoundError" }); } }; var AbiFunctionOutputsNotFoundError = class extends BaseError2 { constructor(functionName, { docsPath: docsPath4 }) { super([ `Function "${functionName}" does not contain any \`outputs\` on ABI.`, "Cannot decode function result without knowing what the parameter types are.", "Make sure you are using the correct ABI and that the function exists on it." ].join("\n"), { docsPath: docsPath4, name: "AbiFunctionOutputsNotFoundError" }); } }; var AbiItemAmbiguityError = class extends BaseError2 { constructor(x, y) { super("Found ambiguous types in overloaded ABI items.", { metaMessages: [ `\`${x.type}\` in \`${formatAbiItem2(x.abiItem)}\`, and`, `\`${y.type}\` in \`${formatAbiItem2(y.abiItem)}\``, "", "These types encode differently and cannot be distinguished at runtime.", "Remove one of the ambiguous items in the ABI." ], name: "AbiItemAmbiguityError" }); } }; var BytesSizeMismatchError = class extends BaseError2 { constructor({ expectedSize, givenSize }) { super(`Expected bytes${expectedSize}, got bytes${givenSize}.`, { name: "BytesSizeMismatchError" }); } }; var InvalidAbiEncodingTypeError = class extends BaseError2 { constructor(type, { docsPath: docsPath4 }) { super([ `Type "${type}" is not a valid encoding type.`, "Please provide a valid ABI type." ].join("\n"), { docsPath: docsPath4, name: "InvalidAbiEncodingType" }); } }; var InvalidAbiDecodingTypeError = class extends BaseError2 { constructor(type, { docsPath: docsPath4 }) { super([ `Type "${type}" is not a valid decoding type.`, "Please provide a valid ABI type." ].join("\n"), { docsPath: docsPath4, name: "InvalidAbiDecodingType" }); } }; var InvalidArrayError = class extends BaseError2 { constructor(value) { super([`Value "${value}" is not a valid array.`].join("\n"), { name: "InvalidArrayError" }); } }; var InvalidDefinitionTypeError = class extends BaseError2 { constructor(type) { super([ `"${type}" is not a valid definition type.`, 'Valid types: "function", "event", "error"' ].join("\n"), { name: "InvalidDefinitionTypeError" }); } }; var UnsupportedPackedAbiType = class extends BaseError2 { constructor(type) { super(`Type "${type}" is not supported for packed encoding.`, { name: "UnsupportedPackedAbiType" }); } }; // node_modules/viem/_esm/errors/data.js var SliceOffsetOutOfBoundsError = class extends BaseError2 { constructor({ offset, position, size: size2 }) { super(`Slice ${position === "start" ? "starting" : "ending"} at offset "${offset}" is out-of-bounds (size: ${size2}).`, { name: "SliceOffsetOutOfBoundsError" }); } }; var SizeExceedsPaddingSizeError = class extends BaseError2 { constructor({ size: size2, targetSize, type }) { super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size2}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" }); } }; var InvalidBytesLengthError = class extends BaseError2 { constructor({ size: size2, targetSize, type }) { super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} is expected to be ${targetSize} ${type} long, but is ${size2} ${type} long.`, { name: "InvalidBytesLengthError" }); } }; // node_modules/viem/_esm/utils/data/slice.js function slice(value, start, end, { strict } = {}) { if (isHex(value, { strict: false })) return sliceHex(value, start, end, { strict }); return sliceBytes(value, start, end, { strict }); } function assertStartOffset(value, start) { if (typeof start === "number" && start > 0 && start > size(value) - 1) throw new SliceOffsetOutOfBoundsError({ offset: start, position: "start", size: size(value) }); } function assertEndOffset(value, start, end) { if (typeof start === "number" && typeof end === "number" && size(value) !== end - start) { throw new SliceOffsetOutOfBoundsError({ offset: end, position: "end", size: size(value) }); } } function sliceBytes(value_, start, end, { strict } = {}) { assertStartOffset(value_, start); const value = value_.slice(start, end); if (strict) assertEndOffset(value, start, end); return value; } function sliceHex(value_, start, end, { strict } = {}) { assertStartOffset(value_, start); const value = `0x${value_.replace("0x", "").slice((start ?? 0) * 2, (end ?? value_.length) * 2)}`; if (strict) assertEndOffset(value, start, end); return value; } // node_modules/viem/_esm/utils/data/pad.js function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) { if (typeof hexOrBytes === "string") return padHex(hexOrBytes, { dir, size: size2 }); return padBytes(hexOrBytes, { dir, size: size2 }); } function padHex(hex_, { dir, size: size2 = 32 } = {}) { if (size2 === null) return hex_; const hex = hex_.replace("0x", ""); if (hex.length > size2 * 2) throw new SizeExceedsPaddingSizeError({ size: Math.ceil(hex.length / 2), targetSize: size2, type: "hex" }); return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`; } function padBytes(bytes, { dir, size: size2 = 32 } = {}) { if (size2 === null) return bytes; if (bytes.length > size2) throw new SizeExceedsPaddingSizeError({ size: bytes.length, targetSize: size2, type: "bytes" }); const paddedBytes = new Uint8Array(size2); for (let i = 0; i < size2; i++) { const padEnd = dir === "right"; paddedBytes[padEnd ? i : size2 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1]; } return paddedBytes; } // node_modules/viem/_esm/errors/encoding.js var IntegerOutOfRangeError = class extends BaseError2 { constructor({ max, min, signed, size: size2, value }) { super(`Number "${value}" is not in safe ${size2 ? `${size2 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" }); } }; var InvalidBytesBooleanError = class extends BaseError2 { constructor(bytes) { super(`Bytes value "${bytes}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`, { name: "InvalidBytesBooleanError" }); } }; var SizeOverflowError = class extends BaseError2 { constructor({ givenSize, maxSize }) { super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" }); } }; // 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; } // node_modules/viem/_esm/utils/encoding/fromHex.js function assertSize(hexOrBytes, { size: size2 }) { if (size(hexOrBytes) > size2) throw new SizeOverflowError({ givenSize: size(hexOrBytes), maxSize: size2 }); } function hexToBigInt(hex, opts = {}) { const { signed } = opts; if (opts.size) assertSize(hex, { size: opts.size }); const value = BigInt(hex); if (!signed) return value; const size2 = (hex.length - 2) / 2; const max = (1n << BigInt(size2) * 8n - 1n) - 1n; if (value <= max) return value; return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n; } function hexToNumber(hex, opts = {}) { return Number(hexToBigInt(hex, opts)); } // node_modules/viem/_esm/utils/encoding/toHex.js var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0")); 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: size2 } = opts; const value = BigInt(value_); let maxValue; if (size2) { if (signed) maxValue = (1n << BigInt(size2) * 8n - 1n) - 1n; else maxValue = 2n ** (BigInt(size2) * 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: size2, value: `${value_}${suffix}` }); } const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`; if (size2) return pad(hex, { size: size2 }); return hex; } var encoder = /* @__PURE__ */ new TextEncoder(); functio