Skip to content

Conversation

pasevin
Copy link
Collaborator

@pasevin pasevin commented Jul 17, 2025

Description

This pull request introduces support for the Etherscan V2 API to fetch contract ABIs, enhancing the reliability and performance of ABI retrieval. The changes are structured to ensure backward compatibility while providing a more robust integration with Etherscan's services.

Key Changes:

  • New Etherscan V2 Client: A new, self-contained client has been implemented to handle interactions with the Etherscan V2 API, including dedicated logic and tests.
  • Updated Type Definitions: Core types have been extended across adapter-evm and types packages to support the new Etherscan V2 configuration and API responses.
  • Seamless Integration: The existing ABI loading mechanism in adapter-evm has been refactored to prioritize the Etherscan V2 client when an API key is provided, gracefully falling back to the legacy API otherwise.
  • Network Configuration: Etherscan V2 has been enabled by default for mainnet and testnet networks, with example configurations provided to guide users.
  • UI Enhancements: The Explorer Settings UI has been updated to allow users to save their Etherscan API key, improving the user experience for developers who rely on this feature.

Copy link

netlify bot commented Jul 17, 2025

👷 Deploy request for transaction-form-builder pending review.

A Netlify team Owner will need to approve the deploy before you can run your build.

Are you a team Owner? Visit the deploys page to approve it

Need more help? Learn more in the Netlify docs

Name Link
🔨 Latest commit 455ff20

@pasevin pasevin requested a review from Copilot July 17, 2025 14:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds unified support for Etherscan V2 API in the EVM adapter, updating configuration, types, service logic, and UI to prioritize the new V2 client with a fallback to the legacy V1 endpoints.

  • Introduces a new Etherscan V2 client and refactors resolveExplorerConfig to use a global V2 API key when available
  • Extends types and configuration services to handle global vs network-specific explorer settings
  • Enhances the Explorer Settings UI to toggle V2 mode and apply settings across networks

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/utils/src/UserExplorerConfigService.ts Added global override logic and getConfiguredNetworkIds method
packages/utils/src/AppConfigService.ts Exposed getGlobalServiceConfig for global service parameters
packages/ui/src/components/ui/accordion.tsx Tweaked accordion animation durations and CSS properties
packages/ui/src/components/explorer/ExplorerSettingsPanel.tsx Added V2 API toggle, global-apply option, and advanced settings UI
packages/types/src/networks/config.ts Added supportsEtherscanV2 and requiresExplorerApiKey flags
packages/types/src/config/app-config.ts Extended UserExplorerConfig with applyToAllNetworks fields
packages/styles/global.css Synchronized accordion animation keyframes and durations
packages/adapter-evm/src/types.ts Adjusted TypedEvmNetworkConfig definition
packages/adapter-evm/src/networks/* Switched all explorer endpoints to the unified V2 API and enabled V2 support
packages/adapter-evm/src/configuration/explorer.ts Refactored explorer resolution to favor V2, then V1 and defaults
packages/adapter-evm/src/abi/* Added etherscan-v2 loader, updated ABI loading and barrel exports
packages/adapter-evm/src/configuration/tests/explorer.test.ts Updated error-message expectation
packages/adapter-evm/src/abi/tests/etherscan-v2.test.ts Added V2 connection tests
packages/adapter-evm/example.env Example for unified V2 API key
packages/adapter-evm/example.app.config.json Example global and legacy service configs
.changeset Recorded minor bump and notes for V2 support
Comments suppressed due to low confidence (6)

packages/types/src/networks/config.ts:103

  • The JSDoc indicates a default of true, but the code treats an undefined supportsEtherscanV2 as false. Please align the comment or adjust the logic to reflect the intended default behavior.
   * Whether this network supports Etherscan V2 API (default: true for all Etherscan-compatible explorers)

packages/utils/src/AppConfigService.ts:284

  • The new getGlobalServiceConfig method doesn’t have unit tests. Adding tests would help ensure it behaves correctly when global configs are present or missing.
  public getGlobalServiceConfig(serviceName: string): ServiceParameterConfig | undefined {

packages/adapter-evm/src/configuration/explorer.ts:23

  • [nitpick] resolveExplorerConfig bypasses any feature flag (e.g., enable_v2_api) when deciding to use V2. Consider integrating a flag check so feature toggles are honored.
export function resolveExplorerConfig(networkConfig: TypedEvmNetworkConfig): UserExplorerConfig {

packages/adapter-evm/src/abi/etherscan-v2.ts:52

  • loadAbiFromEtherscanV2 is not covered by any unit tests. Please add tests for successful fetch, missing API key, and error conditions to validate query construction and error handling.
export async function loadAbiFromEtherscanV2(

packages/adapter-evm/src/configuration/explorer.ts:36

  • [nitpick] The service key 'etherscanv2' (no hyphen) differs from the primaryExplorerApiIdentifier 'etherscan-v2'. For clarity, consider aligning these identifiers or documenting the mapping.
    const globalV2ApiKey = appConfigService.getGlobalServiceConfig('etherscanv2')?.apiKey as

packages/adapter-evm/src/types.ts:13

  • Changing TypedEvmNetworkConfig to extend EvmNetworkConfig loses the previous Omit<'viemChain'> override and may break the expected viemChain typing. Please restore the Omit pattern or explicitly re-declare viemChain with the correct type.
export interface TypedEvmNetworkConfig extends EvmNetworkConfig {

pasevin and others added 4 commits July 17, 2025 17:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ngsPanel

Set useV2Api based on saved applyToAllNetworks preference to prevent
the second useEffect from overriding user's saved configuration.
@pasevin pasevin merged commit 26ea9b9 into main Jul 18, 2025
9 of 10 checks passed
@github-actions github-actions bot mentioned this pull request Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant