{"version":3,"file":"relayer-d6Ozyrna.cjs","names":["resolveExplorerApiKeyFromAppConfig","appConfigService","userNetworkServiceConfigService","EvmProviderKeys","createCoreRelayer","testEvmNetworkServiceConnection","validateEvmNetworkServiceConfig"],"sources":["../src/configuration/network-services.ts","../src/capabilities/relayer.ts"],"sourcesContent":["// Import from core package via barrel files\nimport {\n  EvmProviderKeys,\n  resolveExplorerApiKeyFromAppConfig,\n  type TypedEvmNetworkConfig,\n} from '@openzeppelin/adapter-evm-core';\nimport type { EvmNetworkConfig, NetworkServiceForm } from '@openzeppelin/ui-types';\nimport { appConfigService, userNetworkServiceConfigService } from '@openzeppelin/ui-utils';\n\n/**\n * Returns the default service configuration values for a given service ID.\n * Used for proactive health checks when no user overrides are configured.\n *\n * @param networkConfig The network configuration\n * @param serviceId The service identifier (e.g., 'rpc', 'explorer', 'contract-definitions', 'access-control-indexer')\n * @returns The default configuration values, or null if not available\n */\nexport function getEvmDefaultServiceConfig(\n  networkConfig: EvmNetworkConfig,\n  serviceId: string\n): Record<string, unknown> | null {\n  switch (serviceId) {\n    case 'rpc':\n      if (networkConfig.rpcUrl) {\n        return { rpcUrl: networkConfig.rpcUrl };\n      }\n      break;\n    case 'explorer': {\n      // For explorer service, we need to include the API key if available\n      // Use the shared helper from adapter-evm-core to resolve the API key\n      const typedConfig = networkConfig as TypedEvmNetworkConfig;\n      const apiKey = resolveExplorerApiKeyFromAppConfig(typedConfig);\n\n      // Return config if we have at least an explorer URL or an API key\n      if (networkConfig.explorerUrl || apiKey) {\n        return {\n          explorerUrl: networkConfig.explorerUrl,\n          apiUrl: networkConfig.apiUrl,\n          ...(apiKey ? { apiKey } : {}),\n        };\n      }\n      break;\n    }\n    case 'access-control-indexer': {\n      // Access control indexer is optional — return default URL from network config if available\n      const typedNetworkConfig = networkConfig as TypedEvmNetworkConfig;\n      if (typedNetworkConfig.accessControlIndexerUrl) {\n        return { accessControlIndexerUrl: typedNetworkConfig.accessControlIndexerUrl };\n      }\n      return null;\n    }\n    case 'contract-definitions':\n      // No connection test for contract definitions service\n      return null;\n  }\n  return null;\n}\n\n/**\n * Returns the network service forms for EVM networks.\n * Defines the UI configuration for RPC, Explorer, and Contract Definitions services.\n */\nexport function getEvmNetworkServiceForms(\n  networkConfig: TypedEvmNetworkConfig\n): NetworkServiceForm[] {\n  const globalV2ApiKey = appConfigService.getGlobalServiceConfig('etherscanv2')?.apiKey as\n    | string\n    | undefined;\n  const v2DefaultEnabled = Boolean(globalV2ApiKey);\n  // Read any saved contract-definitions config to seed defaults in the UI\n  const savedContractDefCfg = userNetworkServiceConfigService.get(\n    networkConfig.id,\n    'contract-definitions'\n  ) as Record<string, unknown> | null;\n  const savedDefaultProvider =\n    savedContractDefCfg && typeof savedContractDefCfg.defaultProvider === 'string'\n      ? (savedContractDefCfg.defaultProvider as string)\n      : undefined;\n  return [\n    {\n      id: 'rpc',\n      label: 'RPC Provider',\n      description:\n        'Setting your own RPC endpoint ensures better reliability, faster response times, and higher rate limits. Public endpoints may be rate-limited or experience congestion during high traffic periods.',\n      fields: [\n        {\n          id: 'evm-rpc-url',\n          name: 'rpcUrl',\n          type: 'text',\n          label: 'RPC URL',\n          placeholder: 'https://mainnet.infura.io/v3/your-key',\n          validation: { required: true, pattern: '^https?://.+' },\n          width: 'full',\n        },\n      ],\n    },\n    {\n      id: 'explorer',\n      label: 'Block Explorer',\n      description:\n        'Public API keys are rate-limited and may be exhausted quickly. Using your own key ensures reliable access to explorer services.',\n      fields: [\n        // Adapter-led informational notes (rendered generically by the panel)\n        {\n          id: 'evm-explorer-note-etherscan',\n          name: '_note_etherscan',\n          type: 'hidden',\n          label: '',\n          validation: {},\n          isHidden: true,\n          metadata: {\n            note: {\n              variant: 'warning',\n              title: 'Etherscan API Support',\n              html: true,\n              lines: [\n                '<strong>V2 API (Recommended):</strong> Supports all Etherscan-compatible explorers across multiple chains with a single API key.',\n                '<strong>V1 API (Legacy):</strong> Requires chain-specific API endpoints. Some explorers may not be supported.',\n                '<strong>Note:</strong> Non-Etherscan explorers (Blockscout, Routescan, etc.) are not supported.',\n              ],\n            },\n          },\n        },\n        {\n          id: 'evm-explorer-api-key',\n          name: 'apiKey',\n          type: 'password',\n          label: 'API Key',\n          placeholder: 'Your explorer API key',\n          helperText: 'Required for fetching contract ABIs and other API operations',\n          validation: {},\n          width: 'full',\n        },\n        {\n          id: 'evm-explorer-use-v2',\n          name: 'useV2Api',\n          type: 'checkbox',\n          label: 'Use Etherscan V2 API',\n          helperText:\n            'Enable the new V2 API for all Etherscan-compatible networks. V2 provides unified access across all chains.',\n          validation: {},\n          defaultValue: v2DefaultEnabled,\n          metadata: {\n            section: 'api-config',\n            sectionLabel: 'API Configuration',\n            sectionHelp: 'Configure API version and network application settings.',\n          },\n        },\n        {\n          id: 'evm-explorer-apply-all',\n          name: 'applyToAllNetworks',\n          type: 'checkbox',\n          label: 'Apply to all compatible networks',\n          helperText: 'Apply these settings to all Etherscan-compatible networks in your project.',\n          validation: {},\n          defaultValue: v2DefaultEnabled,\n          // UI hinting for generic renderer to indent under and disable when V2 is off\n          metadata: {\n            section: 'api-config',\n            nestUnder: 'useV2Api',\n            disabledWhen: { field: 'useV2Api', equals: false },\n          },\n        },\n        {\n          id: 'evm-explorer-url',\n          name: 'explorerUrl',\n          type: 'text',\n          label: 'Explorer Base URL (optional)',\n          placeholder: 'https://etherscan.io',\n          validation: {},\n          helperText:\n            'Base URL for viewing transactions and addresses. If not provided, defaults from the network will be used.',\n          width: 'full',\n          metadata: {\n            section: 'custom-endpoints',\n            sectionLabel: 'Custom Endpoints',\n            sectionHelp: 'Override default URLs for explorer and API endpoints.',\n          },\n        },\n        {\n          id: 'evm-explorer-api-url',\n          name: 'apiUrl',\n          type: 'text',\n          label: 'Explorer API URL (legacy / V1)',\n          placeholder: 'https://api.etherscan.io/api',\n          validation: {},\n          helperText:\n            'API endpoint for fetching contract data. If not provided, defaults from the network will be used.',\n          width: 'full',\n          metadata: { section: 'custom-endpoints' },\n        },\n      ],\n    },\n    {\n      id: 'access-control-indexer',\n      label: 'Access Control Indexer',\n      description:\n        'Optional GraphQL indexer endpoint for historical access control data. Overrides the default indexer URL for this network.',\n      supportsConnectionTest: true,\n      requiredFeature: 'access_control_indexer',\n      fields: [\n        {\n          id: 'evm-access-control-indexer-url',\n          name: 'accessControlIndexerUrl',\n          type: 'text',\n          label: 'Access Control Indexer GraphQL Endpoint',\n          placeholder: 'https://gateway.subquery.network/query/...',\n          validation: { required: false, pattern: '^https?://.+' },\n          width: 'full',\n          helperText:\n            'Optional. Used for querying historical access control events and role discovery on non-enumerable contracts.',\n        },\n      ],\n    },\n    {\n      id: 'contract-definitions',\n      label: 'Contract Definitions',\n      description: undefined,\n      supportsConnectionTest: false,\n      fields: [\n        // Informational note\n        {\n          id: 'evm-contract-def-note',\n          name: '_note_contract_def',\n          type: 'hidden',\n          label: '',\n          validation: {},\n          isHidden: true,\n          metadata: {\n            hideTestConnection: true,\n            note: {\n              variant: 'info',\n              title: 'Contract Definition Provider',\n              lines: [\n                'Select which provider the builder should try first when loading verified contract definitions. Deep links can override this preference temporarily.',\n              ],\n            },\n          },\n        },\n        // Default provider select\n        {\n          id: 'evm-contract-def-provider',\n          name: 'defaultProvider',\n          type: 'select',\n          label: 'Default Contract Definition Provider',\n          placeholder: 'Select a provider',\n          helperText: 'Used as the first provider to query for contract definitions.',\n          validation: {},\n          options: [\n            { label: 'Etherscan', value: EvmProviderKeys.Etherscan },\n            { label: 'Sourcify', value: EvmProviderKeys.Sourcify },\n          ],\n          // Seed from saved user config or app-config default if present; otherwise empty\n          defaultValue:\n            savedDefaultProvider ||\n            (appConfigService.getGlobalServiceParam('contractdefinition', 'defaultProvider') as\n              | string\n              | undefined) ||\n            '',\n          width: 'full',\n        },\n        // Apply to all networks\n        {\n          id: 'evm-contract-def-apply-all',\n          name: 'applyToAllNetworks',\n          type: 'checkbox',\n          label: 'Apply to all compatible networks',\n          helperText:\n            'Apply this default provider setting to all compatible networks in your project.',\n          validation: {},\n          defaultValue: false,\n          metadata: {\n            nestUnder: 'defaultProvider',\n            disabledWhen: { field: 'defaultProvider', equals: '' },\n          },\n        },\n      ],\n    },\n  ];\n}\n","import type { TypedEvmNetworkConfig } from '@openzeppelin/adapter-evm-core';\nimport {\n  createRelayer as createCoreRelayer,\n  testEvmNetworkServiceConnection,\n  validateEvmNetworkServiceConfig,\n} from '@openzeppelin/adapter-evm-core';\n\nimport { getEvmDefaultServiceConfig, getEvmNetworkServiceForms } from '../configuration';\n\nexport function createRelayer(config: TypedEvmNetworkConfig) {\n  return createCoreRelayer(config, {\n    getDefaultServiceConfig: (networkConfig, serviceId) =>\n      getEvmDefaultServiceConfig(networkConfig, serviceId),\n    getNetworkServiceForms: (networkConfig) => getEvmNetworkServiceForms(networkConfig),\n    testNetworkServiceConnection: (serviceId, values, networkConfig) =>\n      testEvmNetworkServiceConnection(serviceId, values, networkConfig),\n    validateNetworkServiceConfig: validateEvmNetworkServiceConfig,\n  });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,2BACd,eACA,WACgC;AAChC,SAAQ,WAAR;EACE,KAAK;AACH,OAAI,cAAc,OAChB,QAAO,EAAE,QAAQ,cAAc,QAAQ;AAEzC;EACF,KAAK,YAAY;GAIf,MAAM,SAASA,6DADK,cAC0C;AAG9D,OAAI,cAAc,eAAe,OAC/B,QAAO;IACL,aAAa,cAAc;IAC3B,QAAQ,cAAc;IACtB,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;IAC7B;AAEH;;EAEF,KAAK,0BAA0B;GAE7B,MAAM,qBAAqB;AAC3B,OAAI,mBAAmB,wBACrB,QAAO,EAAE,yBAAyB,mBAAmB,yBAAyB;AAEhF,UAAO;;EAET,KAAK,uBAEH,QAAO;;AAEX,QAAO;;;;;;AAOT,SAAgB,0BACd,eACsB;CACtB,MAAM,iBAAiBC,wCAAiB,uBAAuB,cAAc,EAAE;CAG/E,MAAM,mBAAmB,QAAQ,eAAe;CAEhD,MAAM,sBAAsBC,uDAAg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