Skip to content

feat: add etherscan 2.0 api - #429

Merged
mkflow27 merged 7 commits into
mainfrom
feat-add-etherscan-2-dot-0
Jul 28, 2025
Merged

feat: add etherscan 2.0 api#429
mkflow27 merged 7 commits into
mainfrom
feat-add-etherscan-2-dot-0

Conversation

@mkflow27

@mkflow27 mkflow27 commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

Also closes: #427 See erc4626 pr: balancer/balancer-v3-erc4626-tests#74

@mkflow27 mkflow27 self-assigned this Jul 28, 2025
@mkflow27
mkflow27 requested a review from Copilot July 28, 2025 11:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Etherscan API 2.0, upgrading from the previous implementation to use the new API endpoint structure with chain ID-based URLs.

  • Updates EtherscanApi service to use the new v2 API endpoint format
  • Adds comprehensive test coverage for multiple blockchain networks
  • Includes a custom chain definition for HyperEVM

Reviewed Changes

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

File Description
src/services/etherscanApi.ts Updates API URL generation to use Etherscan v2 format and removes hardcoded delays
test/typescript/etherscanApi.test.ts Adds comprehensive test suite covering multiple chains and API functionality
src/utils/customChains.ts Defines HyperEVM custom chain configuration
package.json Adds Jest testing dependencies
Comments suppressed due to low confidence (2)

test/typescript/etherscanApi.test.ts:53

  • The test uses '0x' as a fallback address when multicall3 is not defined, which would result in an invalid Ethereum address and likely cause the API call to fail. Consider either ensuring all test chains have multicall3 defined or using a valid fallback address.
                    etherscanApi.chain.contracts?.multicall3?.address || '0x',

test/typescript/etherscanApi.test.ts:65

  • Same issue as above - using '0x' as a fallback address could cause test failures due to invalid address format.
                    etherscanApi.chain.contracts?.multicall3?.address || '0x',

Comment on lines +19 to +20
// TODO: Validate chain is supported by EtherscanAPI.
return `https://api.etherscan.io/v2/api?chainid=${this.chain.id}`

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

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

The TODO comment indicates missing validation for supported chains. This could lead to runtime errors when using unsupported chains. Consider implementing validation against a list of supported chain IDs or adding error handling for unsupported chains.

Suggested change
// TODO: Validate chain is supported by EtherscanAPI.
return `https://api.etherscan.io/v2/api?chainid=${this.chain.id}`
const supportedChains = [1, 3, 4, 5, 42, 56, 137, 250, 43114]; // Example chain IDs from Etherscan documentation
if (!supportedChains.includes(this.chain.id)) {
throw new Error(`Unsupported chain ID: ${this.chain.id}. Please use a supported chain.`);
}
return `https://api.etherscan.io/v2/api?chainid=${this.chain.id}`;

Copilot uses AI. Check for mistakes.
Comment thread src/utils/customChains.ts
default: {
name: 'HyperEVM Explorer',
url: 'https://hyperevmscan.com',
apiUrl: 'https://api.etherscan.io/v2/api?chainid=999',

Copilot AI Jul 28, 2025

Copy link

Choose a reason for hiding this comment

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

The apiUrl in the block explorer configuration is inconsistent with the new API URL generation logic in EtherscanApi. Since the service now constructs URLs dynamically, this hardcoded apiUrl may cause confusion or conflicts.

Suggested change
apiUrl: 'https://api.etherscan.io/v2/api?chainid=999',
apiUrl: generateEtherscanApiUrl(999),

Copilot uses AI. Check for mistakes.
@mkflow27
mkflow27 merged commit bc0bd55 into main Jul 28, 2025
1 check passed
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.

HYPE on Hyperlend 4626 Rate Provider

2 participants