-
Notifications
You must be signed in to change notification settings - Fork 4
feat(adapter-evm): plat-6846 Add support for Etherscan V2 API #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(adapter-evm): plat-6846 Add support for Etherscan V2 API #56
Conversation
👷 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 →
|
There was a problem hiding this 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 extendEvmNetworkConfig
loses the previousOmit<'viemChain'>
override and may break the expectedviemChain
typing. Please restore the Omit pattern or explicitly re-declareviemChain
with the correct type.
export interface TypedEvmNetworkConfig extends EvmNetworkConfig {
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.
…lorer-api-keys-for-all
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:
adapter-evm
andtypes
packages to support the new Etherscan V2 configuration and API responses.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.