{"version":3,"file":"contract-loading-BmGOAF0h-BqfZUnaa.mjs","names":[],"sources":["../../adapter-evm-core/dist/contract-loading-BmGOAF0h.mjs"],"sourcesContent":["import { n as transformAbiToSchema } from \"./transformer-0vQSxsqD.mjs\";\nimport { i as resolveExplorerConfig, t as getEvmExplorerAddressUrl } from \"./explorer-DClCq_90.mjs\";\nimport { n as shouldUseV2Api, t as loadAbiFromEtherscanV2 } from \"./etherscan-v2-DMXR3bdG.mjs\";\nimport { i as resolveRpcUrl } from \"./rpc-BMyYpWRW.mjs\";\nimport { a as getEvmContractDefinitionProviders, i as getEvmContractDefinitionInputs, m as isEvmProviderKey, n as asTypedEvmNetworkConfig, p as EvmProviderKeys, u as withRuntimeCapability } from \"./helpers-CYDHdjrw.mjs\";\nimport { appConfigService, logger, simpleHash, userNetworkServiceConfigService, withTimeout } from \"@openzeppelin/ui-utils\";\nimport { createPublicClient, http, isAddress, keccak256, parseAbi, toHex } from \"viem\";\n\n//#region src/abi/etherscan.ts\n/**\n* IMPORTANT: Etherscan V1 API Deprecation Notice\n*\n* Etherscan has announced the deprecation of their V1 API endpoints in favor of the new V2 unified API.\n* The V2 API provides a single endpoint that works across all EVM chains, making it more scalable and\n* easier to maintain.\n*\n* Key differences:\n* - V1: Each chain has its own API endpoint (e.g., api.etherscan.io, api.bscscan.com, etc.)\n* - V2: Single unified endpoint (api.etherscan.io/v2/api) with chainId parameter\n*\n* Migration strategy:\n* - Networks with `supportsEtherscanV2: true` will automatically use V2 API\n* - Legacy networks without V2 support will continue using V1 until they're updated\n* - New networks should always be configured with V2 support\n*\n* The V1 API functions are maintained for backward compatibility but should be considered\n* deprecated and will be removed in a future release.\n*/\n/**\n* Fetches and parses an ABI from Etherscan-compatible explorers using a contract address and network config.\n* Automatically selects V1 or V2 API based on network support and user configuration.\n*\n* @param address - Contract address to fetch ABI for\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n*/\nasync function loadAbiFromEtherscan(address, networkConfig) {\n\tif (shouldUseV2Api(networkConfig)) {\n\t\tlogger.info(\"loadAbiFromEtherscan\", \"Using V2 API for fetching ABI\");\n\t\treturn loadAbiFromEtherscanV2(address, networkConfig);\n\t}\n\tlogger.info(\"loadAbiFromEtherscan\", \"Using V1 API for fetching ABI\");\n\treturn loadAbiFromEtherscanV1(address, networkConfig);\n}\n/**\n* Fetches and parses an ABI from Etherscan V1 API using a contract address and network config.\n*\n* @param address - Contract address to fetch ABI for\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n*/\nasync function loadAbiFromEtherscanV1(address, networkConfig) {\n\tconst explorerConfig = resolveExplorerConfig(networkConfig);\n\tif (!explorerConfig.apiUrl) {\n\t\tlogger.error(\"loadAbiFromEtherscanV1\", `API URL is missing for ${networkConfig.name} explorer.`);\n\t\tthrow new Error(`Explorer API URL for ${networkConfig.name} is not configured.`);\n\t}\n\tconst url = new URL(explorerConfig.apiUrl);\n\turl.searchParams.append(\"module\", \"contract\");\n\turl.searchParams.append(\"action\", \"getabi\");\n\turl.searchParams.append(\"address\", address);\n\tif (explorerConfig.apiKey) url.searchParams.append(\"apikey\", explorerConfig.apiKey);\n\tlet response;\n\ttry {\n\t\tlogger.info(\"loadAbiFromEtherscanV1\", `Fetching ABI from ${explorerConfig.apiUrl} for address: ${address}`);\n\t\tresponse = await fetch(url);\n\t} catch (networkError) {\n\t\tlogger.error(\"loadAbiFromEtherscanV1\", `Network error fetching ABI from Explorer API: ${networkError}`);\n\t\tthrow new Error(`Network error fetching ABI: ${networkError.message}`);\n\t}\n\tif (!response.ok) {\n\t\tlogger.error(\"loadAbiFromEtherscanV1\", `Explorer API request failed with status: ${response.status}`);\n\t\tthrow new Error(`Explorer API request failed: ${response.status} ${response.statusText}`);\n\t}\n\tlet apiResult;\n\ttry {\n\t\tapiResult = await response.json();\n\t} catch (jsonError) {\n\t\tlogger.error(\"loadAbiFromEtherscanV1\", `Failed to parse Explorer API response as JSON: ${jsonError}`);\n\t\tthrow new Error(\"Invalid JSON response received from Explorer API.\");\n\t}\n\tif (apiResult.status !== \"1\") {\n\t\tlogger.warn(\"loadAbiFromEtherscanV1\", `Explorer API error: Status ${apiResult.status}, Message: ${apiResult.message}, Result: ${apiResult.result}`);\n\t\tif (apiResult.result?.includes(\"Contract source code not verified\")) throw new Error(`Contract not verified on ${networkConfig.name} explorer (address: ${address}). ABI not available. You can provide the contract's ABI manually.`);\n\t\tthrow new Error(`Explorer API Error: ${apiResult.result || apiResult.message}`);\n\t}\n\tconst originalAbiString = apiResult.result;\n\tlet abi;\n\ttry {\n\t\tabi = JSON.parse(originalAbiString);\n\t\tif (!Array.isArray(abi)) throw new Error(\"Parsed ABI from Explorer API is not an array.\");\n\t} catch (error) {\n\t\tlogger.error(\"loadAbiFromEtherscanV1\", `Failed to parse ABI JSON string from Explorer API result: ${error}`);\n\t\tthrow new Error(`Invalid ABI JSON received from Explorer API: ${error.message}`);\n\t}\n\tlogger.info(\"loadAbiFromEtherscanV1\", `Successfully parsed ABI for ${networkConfig.name} with ${abi.length} items.`);\n\tconst contractName = `Contract_${address.substring(0, 6)}`;\n\treturn {\n\t\tschema: transformAbiToSchema(abi, contractName, address),\n\t\toriginalAbi: originalAbiString\n\t};\n}\n\n//#endregion\n//#region src/abi/sourcify.ts\nconst SOURCIFY_APP_BASE = \"https://repo.sourcify.dev\";\nfunction getSourcifyContractAppUrl(chainId, address) {\n\treturn `${SOURCIFY_APP_BASE}/${chainId}/${address}`;\n}\nconst SOURCIFY_API_BASE = \"https://sourcify.dev/server/v2\";\nfunction buildSourcifyApiUrl(chainId, address) {\n\tconst normalizedAddress = address.toLowerCase();\n\treturn new URL(`${SOURCIFY_API_BASE}/contract/${chainId}/${normalizedAddress}?fields=abi,metadata`).toString();\n}\n/**\n* Fetches and parses an ABI from Sourcify using a contract address and network config.\n*\n* @param address - Contract address to fetch ABI for\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n* @param timeoutMs - Timeout in milliseconds (default: 4000ms)\n*/\nasync function loadAbiFromSourcify(address, networkConfig, timeoutMs = 4e3) {\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), timeoutMs);\n\ttry {\n\t\tconst url = buildSourcifyApiUrl(networkConfig.chainId, address);\n\t\tlogger.info(\"loadAbiFromSourcify\", `Fetching contract from ${url}`);\n\t\tconst response = await fetch(url, { signal: controller.signal });\n\t\tif (!response.ok) throw new Error(`Sourcify request failed: ${response.status} ${response.statusText}`);\n\t\tconst payload = await response.json();\n\t\tconst abi = payload.abi ?? payload.metadata?.output?.abi;\n\t\tif (!abi || !Array.isArray(abi)) throw new Error(\"Sourcify metadata did not include a valid ABI array\");\n\t\tconst normalizedAddress = address.toLowerCase();\n\t\treturn {\n\t\t\tschema: transformAbiToSchema(abi, payload.metadata?.contractName || `Contract_${normalizedAddress.substring(0, 6).toUpperCase()}`, address),\n\t\t\toriginalAbi: JSON.stringify(abi)\n\t\t};\n\t} catch (error) {\n\t\tlogger.warn(\"loadAbiFromSourcify\", `Failed to fetch ABI from Sourcify: ${String(error)}`);\n\t\tthrow error;\n\t} finally {\n\t\tclearTimeout(timeout);\n\t}\n}\n\n//#endregion\n//#region src/proxy/detection.ts\n/**\n* Proxy Contract Detection Utilities\n*\n* Automatically detects proxy contracts and resolves implementation addresses\n* for UUPS, Transparent, Beacon, and other proxy patterns.\n*/\n/**\n* Analyzes an ABI to determine if it belongs to a proxy contract\n*/\nfunction detectProxyFromAbi(abi) {\n\tconst functions = abi.filter((item) => item.type === \"function\");\n\tconst events = abi.filter((item) => item.type === \"event\");\n\tconst errors = abi.filter((item) => item.type === \"error\");\n\tconst indicators = [];\n\tlet proxyType = null;\n\tlet confidence = \"low\";\n\tconst hasUpgradeEvent = events.some((e) => e.name === \"Upgraded\");\n\tconst hasImplementationFunction = functions.some((f) => f.name === \"implementation\");\n\tconst hasUUPSErrors = errors.some((e) => e.name?.includes(\"ERC1967\"));\n\tconst hasUpgradeToFunction = functions.some((f) => f.name === \"upgradeToAndCall\" || f.name === \"upgradeTo\");\n\tif (hasUpgradeEvent || hasUUPSErrors) {\n\t\tindicators.push(\"ERC1967 upgrade pattern detected\");\n\t\tproxyType = \"uups\";\n\t\tconfidence = \"high\";\n\t}\n\tif (hasImplementationFunction) {\n\t\tindicators.push(\"implementation() function found\");\n\t\tif (proxyType === \"uups\") confidence = \"high\";\n\t\telse {\n\t\t\tproxyType = \"transparent\";\n\t\t\tconfidence = \"medium\";\n\t\t}\n\t}\n\tif (hasUpgradeToFunction && proxyType === \"uups\") {\n\t\tindicators.push(\"UUPS upgrade functions found\");\n\t\tconfidence = \"high\";\n\t}\n\tconst hasAdminFunction = functions.some((f) => f.name === \"admin\");\n\tconst hasProxyAdminErrors = errors.some((e) => e.name?.includes(\"ProxyDenied\"));\n\tconst hasChangeAdminFunction = functions.some((f) => f.name === \"changeAdmin\");\n\tif (hasAdminFunction || hasProxyAdminErrors || hasChangeAdminFunction) {\n\t\tindicators.push(\"Transparent proxy admin pattern detected\");\n\t\tif (proxyType === null) {\n\t\t\tproxyType = \"transparent\";\n\t\t\tconfidence = \"medium\";\n\t\t}\n\t}\n\tconst hasBeaconFunction = functions.some((f) => f.name === \"beacon\");\n\tconst hasBeaconUpgrade = events.some((e) => e.name === \"BeaconUpgraded\");\n\tif (hasBeaconFunction || hasBeaconUpgrade) {\n\t\tindicators.push(\"Beacon proxy pattern detected\");\n\t\tproxyType = \"beacon\";\n\t\tconfidence = \"high\";\n\t}\n\tconst hasDiamondCut = functions.some((f) => f.name === \"diamondCut\");\n\tconst hasFacets = functions.some((f) => f.name === \"facets\");\n\tconst hasFacetFunctionSelectors = functions.some((f) => f.name === \"facetFunctionSelectors\");\n\tif (hasDiamondCut || hasFacets && hasFacetFunctionSelectors) {\n\t\tindicators.push(\"Diamond (EIP-2535) proxy pattern detected\");\n\t\tproxyType = \"diamond\";\n\t\tconfidence = \"high\";\n\t}\n\tconst hasFallback = abi.some((item) => item.type === \"fallback\");\n\tconst hasProxyConstructor = abi.some((item) => item.type === \"constructor\" && item.inputs?.some((input) => input.name === \"implementation\" || input.name === \"_logic\" || input.name === \"_data\"));\n\tif (hasFallback) indicators.push(\"Fallback function present\");\n\tif (hasProxyConstructor) indicators.push(\"Proxy-style constructor detected\");\n\tconst hasMinimalFunctions = functions.length <= 1;\n\tconst hasNoEvents = events.length === 0;\n\tif (hasMinimalFunctions && hasNoEvents && hasFallback && proxyType === null) {\n\t\tindicators.push(\"Minimal proxy pattern detected\");\n\t\tproxyType = \"minimal\";\n\t\tconfidence = \"medium\";\n\t}\n\tconst isProxy = proxyType !== null || hasFallback && hasMinimalFunctions && (hasProxyConstructor || functions.length === 0);\n\tif (isProxy && proxyType === null) {\n\t\tproxyType = \"unknown\";\n\t\tindicators.push(\"Generic proxy pattern detected\");\n\t\tconfidence = \"low\";\n\t}\n\treturn {\n\t\tisProxy,\n\t\tproxyType,\n\t\tconfidence,\n\t\tindicators\n\t};\n}\n/**\n* Attempts to resolve the implementation address for a proxy contract\n*\n* @param proxyAddress - Address of the proxy contract\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n* @param proxyType - Type of proxy (uups, transparent, beacon, diamond, minimal, unknown)\n*/\nasync function getImplementationAddress(proxyAddress, networkConfig, proxyType) {\n\tlogger.info(\"getImplementationAddress\", `Resolving implementation for ${proxyType} proxy: ${proxyAddress}`);\n\ttry {\n\t\tswitch (proxyType) {\n\t\t\tcase \"uups\":\n\t\t\tcase \"transparent\": {\n\t\t\t\tconst eip1967Impl = await getEIP1967Implementation(proxyAddress, networkConfig);\n\t\t\t\tif (eip1967Impl) return eip1967Impl;\n\t\t\t\tconst legacyImpl = await getLegacyOZImplementation(proxyAddress, networkConfig);\n\t\t\t\tif (legacyImpl) return legacyImpl;\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tcase \"beacon\": return await getBeaconImplementation(proxyAddress, networkConfig);\n\t\t\tcase \"diamond\":\n\t\t\t\tlogger.info(\"getImplementationAddress\", \"Diamond proxies not fully supported yet\");\n\t\t\t\treturn null;\n\t\t\tcase \"minimal\": return await getMinimalProxyImplementation(proxyAddress, networkConfig);\n\t\t\tdefault: return await tryCommonImplementationMethods(proxyAddress, networkConfig);\n\t\t}\n\t} catch (error) {\n\t\tlogger.warn(\"getImplementationAddress\", `Failed to resolve implementation: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Attempts to resolve the admin address for a proxy contract\n* Tries EIP-1967 admin slot first, then legacy OZ slot\n*\n* @param proxyAddress - Address of the proxy contract\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n*/\nasync function getAdminAddress(proxyAddress, networkConfig) {\n\ttry {\n\t\tconst eip1967Admin = await getEIP1967Admin(proxyAddress, networkConfig);\n\t\tif (eip1967Admin) return eip1967Admin;\n\t\tconst legacyAdmin = await getLegacyOZAdmin(proxyAddress, networkConfig);\n\t\tif (legacyAdmin) return legacyAdmin;\n\t\treturn null;\n\t} catch (error) {\n\t\tlogger.warn(\"getAdminAddress\", `Failed to resolve admin: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Reads implementation address from EIP-1967 storage slot\n*/\nasync function getEIP1967Implementation(proxyAddress, networkConfig) {\n\treturn await readStorageSlot(proxyAddress, \"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\", networkConfig);\n}\n/**\n* Reads admin address from EIP-1967 admin storage slot\n* Slot: bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)\n*/\nasync function getEIP1967Admin(proxyAddress, networkConfig) {\n\treturn await readStorageSlot(proxyAddress, \"0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\", networkConfig);\n}\n/**\n* Reads admin address from legacy OpenZeppelin Unstructured Storage slot\n* Slot: keccak256(\"org.zeppelinos.proxy.admin\")\n*/\nasync function getLegacyOZAdmin(proxyAddress, networkConfig) {\n\ttry {\n\t\tconst slot = keccak256(toHex(\"org.zeppelinos.proxy.admin\"));\n\t\tlogger.info(\"getLegacyOZAdmin\", `Trying legacy OZ admin slot: ${slot}`);\n\t\treturn await readStorageSlot(proxyAddress, slot, networkConfig);\n\t} catch (error) {\n\t\tlogger.warn(\"getLegacyOZAdmin\", `Failed computing or reading legacy admin slot: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Reads implementation address from legacy OpenZeppelin Unstructured Storage slot\n* Slot: keccak256(\"org.zeppelinos.proxy.implementation\")\n*/\nasync function getLegacyOZImplementation(proxyAddress, networkConfig) {\n\ttry {\n\t\tconst slot = keccak256(toHex(\"org.zeppelinos.proxy.implementation\"));\n\t\tlogger.info(\"getLegacyOZImplementation\", `Trying legacy OZ slot: ${slot}`);\n\t\treturn await readStorageSlot(proxyAddress, slot, networkConfig);\n\t} catch (error) {\n\t\tlogger.warn(\"getLegacyOZImplementation\", `Failed computing or reading legacy slot: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Resolves implementation through beacon proxy pattern\n*/\nasync function getBeaconImplementation(proxyAddress, networkConfig) {\n\tconst beaconAddress = await readStorageSlot(proxyAddress, \"0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50\", networkConfig);\n\tif (!beaconAddress) return null;\n\treturn await callContractFunction(beaconAddress, \"implementation()\", [], networkConfig);\n}\n/**\n* Extracts implementation from minimal proxy bytecode\n*/\nasync function getMinimalProxyImplementation(proxyAddress, networkConfig) {\n\ttry {\n\t\tconst bytecode = await getContractBytecode(proxyAddress, networkConfig);\n\t\tif (!bytecode || bytecode.length < 42) return null;\n\t\tif (bytecode.startsWith(\"0x363d3d373d3d3d363d73\") && bytecode.includes(\"5af43d82803e903d91602b57fd5bf3\")) return \"0x\" + bytecode.slice(22, 62);\n\t\treturn null;\n\t} catch (error) {\n\t\tlogger.warn(\"getMinimalProxyImplementation\", `Error reading bytecode: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Tries common proxy implementation methods\n*/\nasync function tryCommonImplementationMethods(proxyAddress, networkConfig) {\n\tfor (const method of [\n\t\t\"implementation()\",\n\t\t\"getImplementation()\",\n\t\t\"_implementation()\",\n\t\t\"target()\"\n\t]) try {\n\t\tconst result = await callContractFunction(proxyAddress, method, [], networkConfig);\n\t\tif (result && result !== \"0x0000000000000000000000000000000000000000\") {\n\t\t\tlogger.info(\"tryCommonImplementationMethods\", `Found implementation via ${method}: ${result}`);\n\t\t\treturn result;\n\t\t}\n\t} catch {\n\t\tcontinue;\n\t}\n\treturn await getEIP1967Implementation(proxyAddress, networkConfig);\n}\n/**\n* Creates a viem public client for the given network configuration\n*/\nfunction createViemClient(networkConfig) {\n\treturn createPublicClient({ transport: http(resolveRpcUrl(networkConfig)) });\n}\n/**\n* Reads a storage slot from a contract using viem\n*/\nasync function readStorageSlot(address, slot, networkConfig) {\n\ttry {\n\t\tconst storageValue = await createViemClient(networkConfig).getStorageAt({\n\t\t\taddress,\n\t\t\tslot\n\t\t});\n\t\tif (storageValue && storageValue !== \"0x0000000000000000000000000000000000000000000000000000000000000000\") {\n\t\t\tlogger.info(\"readStorageSlot\", `Found non-zero value at slot ${slot}: ${storageValue}`);\n\t\t\treturn \"0x\" + storageValue.slice(-40);\n\t\t}\n\t\treturn null;\n\t} catch (error) {\n\t\tlogger.warn(\"readStorageSlot\", `Failed to read storage slot ${slot}: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Calls a function on a contract using viem's readContract\n* Supports functions with parameters and proper return value decoding\n*/\nasync function callContractFunction(address, signature, params, networkConfig) {\n\ttry {\n\t\tconst client = createViemClient(networkConfig);\n\t\tconst abi = parseAbi([signature]);\n\t\tconst func = abi[0];\n\t\tconst addressResult = await client.readContract({\n\t\t\taddress,\n\t\t\tabi,\n\t\t\tfunctionName: func.name,\n\t\t\targs: params\n\t\t});\n\t\tif (addressResult && addressResult !== \"0x0000000000000000000000000000000000000000\") return addressResult;\n\t\treturn null;\n\t} catch (error) {\n\t\tlogger.warn(\"callContractFunction\", `Failed to call ${signature}: ${error}`);\n\t\treturn null;\n\t}\n}\n/**\n* Gets contract bytecode using viem\n*/\nasync function getContractBytecode(address, networkConfig) {\n\ttry {\n\t\treturn await createViemClient(networkConfig).getCode({ address }) || null;\n\t} catch (error) {\n\t\tlogger.warn(\"getContractBytecode\", `Failed to get bytecode: ${error}`);\n\t\treturn null;\n\t}\n}\n\n//#endregion\n//#region src/abi/loader.ts\n/**\n* Loads and parses an ABI directly from a JSON string.\n*/\nasync function loadAbiFromJson(abiJsonString) {\n\tlet abi;\n\ttry {\n\t\tabi = JSON.parse(abiJsonString);\n\t\tif (!Array.isArray(abi)) throw new Error(\"Parsed JSON is not an array.\");\n\t} catch (error) {\n\t\tlogger.error(\"loadAbiFromJson\", \"Failed to parse source string as JSON ABI:\", error);\n\t\tthrow new Error(`Invalid JSON ABI provided: ${error.message}`);\n\t}\n\tlogger.info(\"loadAbiFromJson\", `Successfully parsed JSON ABI with ${abi.length} items.`);\n\treturn transformAbiToSchema(abi, \"ContractFromABI\", void 0);\n}\nconst PER_PROVIDER_TIMEOUT_MS = 4e3;\nconst OVERALL_BUDGET_MS = 1e4;\n/**\n* Loads contract schema from artifacts provided by the UI, prioritizing manual ABI input.\n* Returns enhanced result with schema source information and automatic proxy detection.\n*\n* @param artifacts - Contract artifacts containing address and optional ABI\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n* @param options - Optional loading options\n*/\nasync function loadEvmContract(artifacts, networkConfig, options = {}) {\n\tconst { contractAddress, contractDefinition, __proxyDetectionOptions } = artifacts;\n\tif (__proxyDetectionOptions?.skipProxyDetection) options.skipProxyDetection = true;\n\tif (!contractAddress || typeof contractAddress !== \"string\" || !isAddress(contractAddress)) throw new Error(\"A valid contract address is required.\");\n\tif (contractDefinition && typeof contractDefinition === \"string\" && contractDefinition.trim().length > 0) {\n\t\tconst trimmed = contractDefinition.trim();\n\t\tif (trimmed.includes(\"[\") && trimmed.includes(\"]\") && trimmed.includes(\"{\")) {\n\t\t\tlogger.info(\"loadEvmContract\", \"Manual contract definition provided. Attempting to parse...\");\n\t\t\ttry {\n\t\t\t\tconst schema = await loadAbiFromJson(contractDefinition);\n\t\t\t\treturn {\n\t\t\t\t\tschema: {\n\t\t\t\t\t\t...schema,\n\t\t\t\t\t\taddress: contractAddress\n\t\t\t\t\t},\n\t\t\t\t\tsource: \"manual\",\n\t\t\t\t\tcontractDefinitionOriginal: contractDefinition,\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\tcontractName: schema.name,\n\t\t\t\t\t\tfetchTimestamp: /* @__PURE__ */ new Date(),\n\t\t\t\t\t\tverificationStatus: \"unknown\"\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(\"loadEvmContract\", \"Failed to parse manually provided ABI:\", error);\n\t\t\t\tthrow new Error(`The provided ABI JSON is invalid: ${error.message}`);\n\t\t\t}\n\t\t}\n\t}\n\tconst forcedRaw = artifacts.__forcedProvider || artifacts.service;\n\tconst forcedProvider = isEvmProviderKey(forcedRaw) ? forcedRaw : null;\n\tlogger.info(\"loadEvmContract\", `No manual ABI detected. Attempting Etherscan fetch for address: ${contractAddress}...`);\n\treturn await loadContractWithProxyDetection(contractAddress, networkConfig, options, forcedProvider);\n}\n/**\n* Builds a standard contract result with metadata\n*/\nfunction buildContractResult(contractAddress, abiResult, networkConfig, sourceProvider, proxyInfo) {\n\tlet fetchedFrom = void 0;\n\tif (sourceProvider === EvmProviderKeys.Etherscan) fetchedFrom = getEvmExplorerAddressUrl(contractAddress, networkConfig) || void 0;\n\telse if (sourceProvider === EvmProviderKeys.Sourcify) fetchedFrom = getSourcifyContractAppUrl(networkConfig.chainId, contractAddress);\n\telse fetchedFrom = getEvmExplorerAddressUrl(contractAddress, networkConfig) || void 0;\n\treturn {\n\t\tschema: {\n\t\t\t...abiResult.schema,\n\t\t\taddress: contractAddress\n\t\t},\n\t\tsource: \"fetched\",\n\t\tcontractDefinitionOriginal: abiResult.originalAbi,\n\t\tmetadata: {\n\t\t\tfetchedFrom,\n\t\t\tcontractName: abiResult.schema.name,\n\t\t\tverificationStatus: \"verified\",\n\t\t\tfetchTimestamp: /* @__PURE__ */ new Date(),\n\t\t\tdefinitionHash: simpleHash(abiResult.originalAbi)\n\t\t},\n\t\tproxyInfo\n\t};\n}\n/**\n* Attempts to load implementation ABI for a detected proxy\n*/\nasync function loadImplementationAbi(_contractAddress, implementationAddress, networkConfig, _proxyType) {\n\ttry {\n\t\tconst implementationResult = await loadAbiFromEtherscan(implementationAddress, networkConfig);\n\t\tlogger.info(\"loadImplementationAbi\", `Successfully fetched implementation ABI with ${implementationResult.schema.functions.length} functions`);\n\t\treturn implementationResult;\n\t} catch (implementationError) {\n\t\tlogger.warn(\"loadImplementationAbi\", `Failed to load implementation ABI: ${implementationError}`);\n\t\treturn null;\n\t}\n}\n/**\n* Handles the proxy detection flow and returns appropriate result\n*/\nasync function handleProxyDetection(contractAddress, initialResult, networkConfig, initialProvider) {\n\tconst proxyDetection = detectProxyFromAbi(JSON.parse(initialResult.originalAbi));\n\tif (!proxyDetection.isProxy) return null;\n\tlogger.info(\"handleProxyDetection\", `Proxy detected: ${proxyDetection.proxyType} (confidence: ${proxyDetection.confidence})`);\n\tconst proxyType = proxyDetection.proxyType || \"unknown\";\n\tconst implementationAddress = await getImplementationAddress(contractAddress, networkConfig, proxyType);\n\tconst adminAddress = await getAdminAddress(contractAddress, networkConfig);\n\tif (!implementationAddress) {\n\t\tlogger.info(\"handleProxyDetection\", \"Proxy detected but implementation address not found\");\n\t\treturn buildContractResult(contractAddress, initialResult, networkConfig, initialProvider, {\n\t\t\tisProxy: true,\n\t\t\tproxyType,\n\t\t\tproxyAddress: contractAddress,\n\t\t\tdetectionMethod: \"automatic\"\n\t\t});\n\t}\n\tlogger.info(\"handleProxyDetection\", `Found implementation at: ${implementationAddress}`);\n\tconst implementationResult = await loadImplementationAbi(contractAddress, implementationAddress, networkConfig, proxyType);\n\tconst baseProxyInfo = {\n\t\tisProxy: true,\n\t\tproxyType,\n\t\timplementationAddress,\n\t\tproxyAddress: contractAddress,\n\t\tdetectionMethod: \"automatic\",\n\t\t...adminAddress ? { adminAddress } : {}\n\t};\n\tif (implementationResult) return buildContractResult(contractAddress, implementationResult, networkConfig, EvmProviderKeys.Etherscan, baseProxyInfo);\n\telse return buildContractResult(contractAddress, initialResult, networkConfig, initialProvider, baseProxyInfo);\n}\n/**\n* Loads contract with automatic proxy detection and implementation resolution\n*/\nasync function loadContractWithProxyDetection(contractAddress, networkConfig, options = {}, forcedProvider = null) {\n\ttry {\n\t\tlet uiDefault = null;\n\t\tconst svcCfg = userNetworkServiceConfigService.get(networkConfig.id, \"contract-definitions\");\n\t\tif (svcCfg && typeof svcCfg === \"object\" && \"defaultProvider\" in svcCfg) {\n\t\t\tconst raw = svcCfg.defaultProvider;\n\t\t\tif (isEvmProviderKey(raw)) uiDefault = raw;\n\t\t}\n\t\tconst appDefaultRaw = appConfigService.getGlobalServiceParam(\"contractdefinition\", \"defaultProvider\");\n\t\tconst appDefault = typeof appDefaultRaw === \"string\" && isEvmProviderKey(appDefaultRaw) ? appDefaultRaw : null;\n\t\tconst buildProviderArray = (primary) => [primary, primary === EvmProviderKeys.Etherscan ? EvmProviderKeys.Sourcify : EvmProviderKeys.Etherscan];\n\t\tconst providers = forcedProvider ? [forcedProvider] : uiDefault ? buildProviderArray(uiDefault) : appDefault ? buildProviderArray(appDefault) : [EvmProviderKeys.Etherscan, EvmProviderKeys.Sourcify];\n\t\tconst overallDeadline = Date.now() + OVERALL_BUDGET_MS;\n\t\tlet initialResult = null;\n\t\tlet lastError = null;\n\t\tlet usedProvider = null;\n\t\tfor (const provider of providers) try {\n\t\t\tconst remainingOverall = Math.max(100, overallDeadline - Date.now());\n\t\t\tconst attemptTimeout = Math.min(PER_PROVIDER_TIMEOUT_MS, remainingOverall);\n\t\t\tif (provider === EvmProviderKeys.Etherscan) initialResult = await withTimeout(loadAbiFromEtherscan(contractAddress, networkConfig), attemptTimeout, \"etherscan\");\n\t\t\telse if (provider === EvmProviderKeys.Sourcify) initialResult = await withTimeout(loadAbiFromSourcify(contractAddress, networkConfig, attemptTimeout), attemptTimeout, \"sourcify\");\n\t\t\tif (initialResult) {\n\t\t\t\tusedProvider = provider;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tlastError = err;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!initialResult) throw lastError ?? /* @__PURE__ */ new Error(\"No provider succeeded\");\n\t\tlogger.info(\"loadContractWithProxyDetection\", `Successfully fetched initial ABI for ${contractAddress} with ${initialResult.schema.functions.length} functions`);\n\t\tif (!options.skipProxyDetection && !options.treatAsImplementation) {\n\t\t\tconst proxyResult = await handleProxyDetection(contractAddress, initialResult, networkConfig, usedProvider);\n\t\t\tif (proxyResult) return proxyResult;\n\t\t}\n\t\treturn buildContractResult(contractAddress, initialResult, networkConfig, usedProvider);\n\t} catch (error) {\n\t\tlogger.warn(\"loadContractWithProxyDetection\", `Contract loading failed: ${error}`);\n\t\tif (forcedProvider) throw error;\n\t\tif ((error.message || \"\").includes(\"Contract not verified\")) throw new Error(`Contract at ${contractAddress} is not verified on the block explorer. Verification status: unverified. Please provide the contract ABI manually.`);\n\t\tthrow error;\n\t}\n}\n/**\n* Convenience wrapper that loads a contract and returns just the schema.\n* Handles artifact validation, ABI fetching, and proxy detection.\n*\n* @param source - Contract address string or artifacts object\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n* @param options - Optional loading options\n* @returns The contract schema\n*\n* @example\n* ```typescript\n* // Load by address (fetches ABI from explorer)\n* const schema = await loadContractSchema('0x1234...', networkConfig);\n*\n* // Load with manual ABI\n* const schema = await loadContractSchema(\n*   { contractAddress: '0x1234...', contractDefinition: '[...]' },\n*   networkConfig\n* );\n* ```\n*/\nasync function loadContractSchema(source, networkConfig, options) {\n\tconst { validateAndConvertEvmArtifacts } = await import(\"./utils-BvOJg1qy.mjs\");\n\treturn (await loadEvmContract(validateAndConvertEvmArtifacts(source), networkConfig, options)).schema;\n}\n/**\n* Convenience wrapper that loads a contract with full metadata.\n* Returns schema, source information, original ABI, metadata, and proxy info.\n*\n* @param source - Contract address string or artifacts object\n* @param networkConfig - EVM-compatible network configuration (works with any ecosystem)\n* @returns Full contract load result with metadata\n*\n* @example\n* ```typescript\n* const result = await loadContractWithFullMetadata('0x1234...', networkConfig);\n* console.log(result.schema.name);          // Contract name\n* console.log(result.source);               // 'fetched' | 'manual'\n* console.log(result.metadata?.fetchedFrom); // Explorer URL\n* console.log(result.proxyInfo?.isProxy);   // Proxy detection result\n* ```\n*/\nasync function loadContractWithFullMetadata(source, networkConfig) {\n\tconst { validateAndConvertEvmArtifacts } = await import(\"./utils-BvOJg1qy.mjs\");\n\treturn loadEvmContract(validateAndConvertEvmArtifacts(source), networkConfig);\n}\n\n//#endregion\n//#region src/abi/types.ts\n/**\n* Type guard to check if a value is a valid ABI array\n*/\nfunction isValidAbiArray(value) {\n\treturn Array.isArray(value) && value.every(isValidAbiItem);\n}\n/**\n* Type guard to check if a value is a valid ABI item\n*/\nfunction isValidAbiItem(item) {\n\tif (typeof item !== \"object\" || item === null) return false;\n\tconst abiItem = item;\n\tif (typeof abiItem.type !== \"string\") return false;\n\tif (![\n\t\t\"function\",\n\t\t\"event\",\n\t\t\"constructor\",\n\t\t\"error\",\n\t\t\"fallback\",\n\t\t\"receive\"\n\t].includes(abiItem.type)) return false;\n\tif ((abiItem.type === \"function\" || abiItem.type === \"event\") && typeof abiItem.name !== \"string\") return false;\n\tif ((abiItem.type === \"function\" || abiItem.type === \"event\" || abiItem.type === \"constructor\") && abiItem.inputs !== void 0 && !Array.isArray(abiItem.inputs)) return false;\n\treturn true;\n}\n\n//#endregion\n//#region src/abi/comparison.ts\n/**\n* Service for comparing and validating EVM ABIs\n*/\nvar AbiComparisonService = class {\n\t/**\n\t* Compares two ABIs and returns detailed difference analysis\n\t*/\n\tcompareAbis(abi1, abi2) {\n\t\ttry {\n\t\t\tconst validation1 = this.validateAbi(abi1);\n\t\t\tconst validation2 = this.validateAbi(abi2);\n\t\t\tif (!validation1.valid || !validation2.valid) return {\n\t\t\t\tidentical: false,\n\t\t\t\tdifferences: [],\n\t\t\t\tseverity: \"breaking\",\n\t\t\t\tsummary: \"One or both ABIs are invalid and cannot be compared\"\n\t\t\t};\n\t\t\tconst normalized1 = this.normalizeAbi(validation1.normalizedAbi);\n\t\t\tconst normalized2 = this.normalizeAbi(validation2.normalizedAbi);\n\t\t\tif (simpleHash(JSON.stringify(normalized1)) === simpleHash(JSON.stringify(normalized2))) return {\n\t\t\t\tidentical: true,\n\t\t\t\tdifferences: [],\n\t\t\t\tseverity: \"none\",\n\t\t\t\tsummary: \"ABIs are identical\"\n\t\t\t};\n\t\t\tconst differences = this.findDifferences(normalized1, normalized2);\n\t\t\treturn {\n\t\t\t\tidentical: false,\n\t\t\t\tdifferences,\n\t\t\t\tseverity: this.calculateSeverity(differences),\n\t\t\t\tsummary: this.generateSummary(differences)\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tlogger.error(\"ABI comparison failed:\", error.message);\n\t\t\treturn {\n\t\t\t\tidentical: false,\n\t\t\t\tdifferences: [],\n\t\t\t\tseverity: \"breaking\",\n\t\t\t\tsummary: `Comparison failed: ${error.message}`\n\t\t\t};\n\t\t}\n\t}\n\t/**\n\t* Validates ABI structure and format\n\t*/\n\tvalidateAbi(abiString) {\n\t\tconst errors = [];\n\t\tconst warnings = [];\n\t\ttry {\n\t\t\tconst abi = JSON.parse(abiString);\n\t\t\tif (!Array.isArray(abi)) {\n\t\t\t\terrors.push(\"ABI must be an array\");\n\t\t\t\treturn {\n\t\t\t\t\tvalid: false,\n\t\t\t\t\terrors,\n\t\t\t\t\twarnings\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (abi.length === 0) {\n\t\t\t\terrors.push(\"ABI array cannot be empty - contract must have at least one function, event, or constructor\");\n\t\t\t\treturn {\n\t\t\t\t\tvalid: false,\n\t\t\t\t\terrors,\n\t\t\t\t\twarnings\n\t\t\t\t};\n\t\t\t}\n\t\t\tfor (let i = 0; i < abi.length; i++) {\n\t\t\t\tconst item = abi[i];\n\t\t\t\tif (!item.type) {\n\t\t\t\t\terrors.push(`Item ${i}: Missing 'type' field`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (![\n\t\t\t\t\t\"function\",\n\t\t\t\t\t\"event\",\n\t\t\t\t\t\"constructor\",\n\t\t\t\t\t\"error\",\n\t\t\t\t\t\"fallback\",\n\t\t\t\t\t\"receive\"\n\t\t\t\t].includes(item.type)) errors.push(`Item ${i}: Invalid type '${item.type}'`);\n\t\t\t\tif (item.type === \"function\" && !item.name) errors.push(`Item ${i}: Function missing 'name' field`);\n\t\t\t\tif ((item.type === \"function\" || item.type === \"event\") && !Array.isArray(item.inputs)) errors.push(`Item ${i}: Missing or invalid 'inputs' array`);\n\t\t\t\tif (item.type === \"function\" && !Array.isArray(item.outputs)) warnings.push(`Item ${i}: Function missing 'outputs' array`);\n\t\t\t}\n\t\t\tif (errors.length === 0 && !isValidAbiArray(abi)) errors.push(\"ABI does not conform to expected format\");\n\t\t\treturn {\n\t\t\t\tvalid: errors.length === 0,\n\t\t\t\terrors,\n\t\t\t\twarnings,\n\t\t\t\tnormalizedAbi: errors.length === 0 ? abi : void 0\n\t\t\t};\n\t\t} catch (parseError) {\n\t\t\terrors.push(`Invalid JSON: ${parseError.message}`);\n\t\t\treturn {\n\t\t\t\tvalid: false,\n\t\t\t\terrors,\n\t\t\t\twarnings\n\t\t\t};\n\t\t}\n\t}\n\t/**\n\t* Creates deterministic hash of ABI for quick comparison\n\t*/\n\thashAbi(abiString) {\n\t\ttry {\n\t\t\tconst validation = this.validateAbi(abiString);\n\t\t\tif (!validation.valid || !validation.normalizedAbi) throw new Error(\"Cannot hash invalid ABI\");\n\t\t\tconst normalized = this.normalizeAbi(validation.normalizedAbi);\n\t\t\treturn simpleHash(JSON.stringify(normalized));\n\t\t} catch (error) {\n\t\t\tlogger.error(\"ABI hashing failed:\", error.message);\n\t\t\tthrow new Error(`Failed to hash ABI: ${error.message}`);\n\t\t}\n\t}\n\t/**\n\t* Normalizes ABI for consistent comparison\n\t*/\n\tnormalizeAbi(abi) {\n\t\treturn abi.map((item) => {\n\t\t\tconst normalized = { ...item };\n\t\t\tif (normalized.inputs) normalized.inputs = [...normalized.inputs].sort((a, b) => (a.name || \"\").localeCompare(b.name || \"\"));\n\t\t\tif (normalized.outputs) normalized.outputs = [...normalized.outputs].sort((a, b) => (a.name || \"\").localeCompare(b.name || \"\"));\n\t\t\treturn normalized;\n\t\t}).sort((a, b) => {\n\t\t\tconst typeOrder = {\n\t\t\t\tconstructor: 0,\n\t\t\t\tfallback: 1,\n\t\t\t\treceive: 2,\n\t\t\t\tfunction: 3,\n\t\t\t\tevent: 4,\n\t\t\t\terror: 5\n\t\t\t};\n\t\t\tconst aOrder = typeOrder[a.type] ?? 99;\n\t\t\tconst bOrder = typeOrder[b.type] ?? 99;\n\t\t\tif (aOrder !== bOrder) return aOrder - bOrder;\n\t\t\tconst aName = a.name || \"\";\n\t\t\tconst bName = b.name || \"\";\n\t\t\treturn aName.localeCompare(bName);\n\t\t});\n\t}\n\t/**\n\t* Finds detailed differences between two normalized ABIs\n\t*/\n\tfindDifferences(abi1, abi2) {\n\t\tconst differences = [];\n\t\tconst map1 = this.createAbiMap(abi1);\n\t\tconst map2 = this.createAbiMap(abi2);\n\t\tfor (const [key, item] of map1) if (!map2.has(key)) differences.push({\n\t\t\ttype: \"removed\",\n\t\t\tsection: item.type,\n\t\t\tname: item.name || item.type,\n\t\t\tdetails: `${item.type} was removed`,\n\t\t\timpact: this.calculateImpact(item.type, \"removed\"),\n\t\t\toldSignature: this.generateSignature(item)\n\t\t});\n\t\tfor (const [key, item] of map2) if (!map1.has(key)) differences.push({\n\t\t\ttype: \"added\",\n\t\t\tsection: item.type,\n\t\t\tname: item.name || item.type,\n\t\t\tdetails: `${item.type} was added`,\n\t\t\timpact: this.calculateImpact(item.type, \"added\"),\n\t\t\tnewSignature: this.generateSignature(item)\n\t\t});\n\t\tfor (const [key, item1] of map1) {\n\t\t\tconst item2 = map2.get(key);\n\t\t\tif (item2 && !this.itemsEqual(item1, item2)) differences.push({\n\t\t\t\ttype: \"modified\",\n\t\t\t\tsection: item1.type,\n\t\t\t\tname: item1.name || item1.type,\n\t\t\t\tdetails: `${item1.type} signature changed`,\n\t\t\t\timpact: this.calculateImpact(item1.type, \"modified\"),\n\t\t\t\toldSignature: this.generateSignature(item1),\n\t\t\t\tnewSignature: this.generateSignature(item2)\n\t\t\t});\n\t\t}\n\t\treturn differences;\n\t}\n\tcreateAbiMap(abi) {\n\t\tconst map = /* @__PURE__ */ new Map();\n\t\tfor (const item of abi) {\n\t\t\tconst key = this.generateItemKey(item);\n\t\t\tmap.set(key, item);\n\t\t}\n\t\treturn map;\n\t}\n\tgenerateItemKey(item) {\n\t\tif (item.type === \"constructor\" || item.type === \"fallback\" || item.type === \"receive\") return item.type;\n\t\tconst name = item.name || \"\";\n\t\tconst inputs = item.inputs?.map((input) => input.type).join(\",\") || \"\";\n\t\treturn `${item.type}:${name}(${inputs})`;\n\t}\n\tgenerateSignature(item) {\n\t\tif (item.type === \"constructor\") return `constructor(${item.inputs?.map((input) => `${input.type} ${input.name || \"\"}`).join(\", \") || \"\"})`;\n\t\tif (item.type === \"fallback\" || item.type === \"receive\") return item.type + \"()\";\n\t\tif (item.type === \"function\") {\n\t\t\tconst inputs = item.inputs?.map((input) => `${input.type} ${input.name || \"\"}`).join(\", \") || \"\";\n\t\t\tconst outputs = item.outputs?.map((output) => output.type).join(\", \") || \"\";\n\t\t\tconst mutability = item.stateMutability ? ` ${item.stateMutability}` : \"\";\n\t\t\treturn `function ${item.name}(${inputs})${mutability}${outputs ? ` returns (${outputs})` : \"\"}`;\n\t\t}\n\t\tif (item.type === \"event\") {\n\t\t\tconst inputs = item.inputs?.map((input) => {\n\t\t\t\tconst indexed = input.indexed ? \" indexed\" : \"\";\n\t\t\t\treturn `${input.type}${indexed} ${input.name || \"\"}`;\n\t\t\t}).join(\", \") || \"\";\n\t\t\treturn `event ${item.name}(${inputs})`;\n\t\t}\n\t\treturn JSON.stringify(item);\n\t}\n\titemsEqual(item1, item2) {\n\t\treturn JSON.stringify(item1) === JSON.stringify(item2);\n\t}\n\tcalculateImpact(type, changeType) {\n\t\tif (type === \"constructor\" || type === \"fallback\" || type === \"receive\") return changeType === \"modified\" ? \"high\" : \"medium\";\n\t\tif (type === \"function\") {\n\t\t\tif (changeType === \"removed\") return \"high\";\n\t\t\tif (changeType === \"modified\") return \"medium\";\n\t\t\tif (changeType === \"added\") return \"low\";\n\t\t}\n\t\tif (type === \"event\") return \"low\";\n\t\tif (type === \"error\") return \"low\";\n\t\treturn \"medium\";\n\t}\n\tcalculateSeverity(differences) {\n\t\tif (differences.length === 0) return \"none\";\n\t\tconst hasHighImpact = differences.some((d) => d.impact === \"high\");\n\t\tconst hasMediumImpact = differences.some((d) => d.impact === \"medium\");\n\t\tif (differences.some((d) => d.type === \"removed\" && d.section === \"function\") || hasHighImpact) return \"breaking\";\n\t\tif (hasMediumImpact) return \"major\";\n\t\treturn \"minor\";\n\t}\n\tgenerateSummary(differences) {\n\t\tconst counts = {\n\t\t\tadded: differences.filter((d) => d.type === \"added\").length,\n\t\t\tremoved: differences.filter((d) => d.type === \"removed\").length,\n\t\t\tmodified: differences.filter((d) => d.type === \"modified\").length\n\t\t};\n\t\tconst parts = [];\n\t\tif (counts.added > 0) parts.push(`${counts.added} added`);\n\t\tif (counts.removed > 0) parts.push(`${counts.removed} removed`);\n\t\tif (counts.modified > 0) parts.push(`${counts.modified} modified`);\n\t\treturn `${parts.join(\", \")}`;\n\t}\n};\nconst abiComparisonService = new AbiComparisonService();\n/**\n* Compare two contract definitions (ABI strings).\n* Convenience wrapper around abiComparisonService.compareAbis().\n*\n* @param storedSchema - The stored/original ABI JSON string\n* @param freshSchema - The new/fresh ABI JSON string to compare against\n* @returns Comparison result with differences and severity\n*\n* @example\n* ```typescript\n* const result = await compareContractDefinitions(oldAbi, newAbi);\n* if (!result.identical) {\n*   console.log(`Changes detected: ${result.summary}`);\n*   console.log(`Severity: ${result.severity}`);\n* }\n* ```\n*/\nasync function compareContractDefinitions(storedSchema, freshSchema) {\n\treturn abiComparisonService.compareAbis(storedSchema, freshSchema);\n}\n/**\n* Validate a contract definition (ABI string).\n* Convenience wrapper around abiComparisonService.validateAbi().\n*\n* @param definition - The ABI JSON string to validate\n* @returns Validation result with errors and warnings\n*\n* @example\n* ```typescript\n* const result = validateContractDefinition(abiJson);\n* if (!result.valid) {\n*   console.log('Validation errors:', result.errors);\n* }\n* ```\n*/\nfunction validateContractDefinition(definition) {\n\treturn abiComparisonService.validateAbi(definition);\n}\n/**\n* Hash a contract definition (ABI string) for comparison.\n* Convenience wrapper around abiComparisonService.hashAbi().\n*\n* @param definition - The ABI JSON string to hash\n* @returns Deterministic hash of the normalized ABI\n*\n* @example\n* ```typescript\n* const hash1 = hashContractDefinition(abi1);\n* const hash2 = hashContractDefinition(abi2);\n* if (hash1 === hash2) {\n*   console.log('ABIs are identical');\n* }\n* ```\n*/\nfunction hashContractDefinition(definition) {\n\treturn abiComparisonService.hashAbi(definition);\n}\n\n//#endregion\n//#region src/capabilities/contract-loading.ts\nfunction createContractLoading(config) {\n\tconst networkConfig = asTypedEvmNetworkConfig(config);\n\treturn Object.assign(withRuntimeCapability(networkConfig, \"contractLoading\"), {\n\t\tloadContract(source) {\n\t\t\treturn loadContractSchema(source, networkConfig);\n\t\t},\n\t\tloadContractWithMetadata(source) {\n\t\t\treturn loadContractWithFullMetadata(source, networkConfig);\n\t\t},\n\t\tgetContractDefinitionInputs() {\n\t\t\treturn getEvmContractDefinitionInputs();\n\t\t},\n\t\tgetSupportedContractDefinitionProviders() {\n\t\t\treturn getEvmContractDefinitionProviders();\n\t\t},\n\t\tcompareContractDefinitions,\n\t\tvalidateContractDefinition,\n\t\thashContractDefinition\n\t});\n}\n\n//#endregion\nexport { loadAbiFromEtherscan as _, hashContractDefinition as a, isValidAbiItem as c, loadEvmContract as d, detectProxyFromAbi as f, loadAbiFromSourcify as g, getSourcifyContractAppUrl as h, compareContractDefinitions as i, loadContractSchema as l, getImplementationAddress as m, AbiComparisonService as n, validateContractDefinition as o, getAdminAddress as p, abiComparisonService as r, isValidAbiArray as s, createContractLoading as t, loadContractWithFullMetadata as u, loadAbiFromEtherscanV1 as v };\n//# sourceMappingURL=contract-loading-BmGOAF0h.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,eAAe,qBAAqB,SAAS,eAAe;AAC3D,KAAI,eAAe,cAAc,EAAE;AAClC,SAAO,KAAK,wBAAwB,gCAAgC;AACpE,SAAO,uBAAuB,SAAS,cAAc;;AAEtD,QAAO,KAAK,wBAAwB,gCAAgC;AACpE,QAAO,uBAAuB,SAAS,cAAc;;;;;;;;AAQtD,eAAe,uBAAuB,SAAS,eAAe;CAC7D,MAAM,iBAAiB,sBAAsB,cAAc;AAC3D,KAAI,CAAC,eAAe,QAAQ;AAC3B,SAAO,MAAM,0BAA0B,0BAA0B,cAAc,KAAK,YAAY;AAChG,QAAM,IAAI,MAAM,wBAAwB,cAAc,KAAK,qBAAqB;;CAEjF,MAAM,MAAM,IAAI,IAAI,eAAe,OAAO;AAC1C,KAAI,aAAa,OAAO,UAAU,WAAW;AAC7C,KAAI,aAAa,OAAO,UAAU,SAAS;AAC3C,KAAI,aAAa,OAAO,WAAW,QAAQ;AAC3C,KAAI,eAAe,OAAQ,KAAI,aAAa,OAAO,UAAU,eAAe,OAAO;CACnF,IAAI;AACJ,KAAI;AACH,SAAO,KAAK,0BAA0B,qBAAqB,eAAe,OAAO,gBAAgB,UAAU;AAC3G,aAAW,MAAM,MAAM,IAAI;UACnB,cAAc;AACtB,SAAO,MAAM,0BAA0B,iDAAiD,eAAe;AACvG,QAAM,IAAI,MAAM,+BAA+B,aAAa,UAAU;;AAEvE,KAAI,CAAC,SAAS,IAAI;AACjB,SAAO,MAAM,0BAA0B,4CAA4C,SAAS,SAAS;AACrG,QAAM,IAAI,MAA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