Skip to content

Conversation

@VaitaR
Copy link
Owner

@VaitaR VaitaR commented Oct 9, 2025

This PR implements optional scanner_version parameter with smart defaults:

🎯 Key Changes

1. Optional scanner_version Parameter

  • New signature:
  • Smart defaults:
    • Etherscan → 'v2' (recommended version with full features)
    • All other scanners → 'v1' (base version)

2. Cleaner API Usage

# Before (verbose)
client = ChainscanClient.from_config('etherscan', 'v2', 'ethereum')
client = ChainscanClient.from_config('blockscout', 'v1', 'eth')

# After (clean)
client = ChainscanClient.from_config('etherscan', 'ethereum')     # v2 default
client = ChainscanClient.from_config('blockscout', 'eth')         # v1 default

3. Updated Documentation & Examples

  • ✅ README.md - updated examples and parameter order
  • ✅ AGENTS.md - updated examples and parameter order
  • ✅ All example files - use new cleaner API
  • ✅ Tests - updated to use correct parameter order

4. Backward Compatibility

  • ✅ Old explicit version specification still works
  • ✅ No breaking changes for existing code

🔧 Technical Details

Parameter Order Change

  • Before:
  • After:

Default Version Logic

if scanner_version is None:
    scanner_version = 'v2' if scanner_name == 'etherscan' else 'v1'

📋 Files Modified

  • Core client implementation
  • Documentation and examples
  • Integration tests
  • Type annotations and signatures

This change makes the API more intuitive while maintaining full backward compatibility.

- Make scanner_version parameter optional with smart defaults
- Etherscan defaults to 'v2' (recommended version)
- All other scanners default to 'v1' (base version)
- Update all examples and documentation to use cleaner API
- Add tests for default version behavior
- Maintain backward compatibility with explicit version specification
@VaitaR VaitaR merged commit e9c3f07 into main Oct 9, 2025
@chatgpt-codex-connector
Copy link

💡 Codex Review

def from_config(
cls,
scanner_name: str,
network: str | int,
scanner_version: str | None = None,
loop: AbstractEventLoop | None = None,
timeout: ClientTimeout | None = None,
proxy: str | None = None,
throttler: AbstractAsyncContextManager[Any] | None = None,
retry_options: RetryOptionsBase | None = None,
) -> 'ChainscanClient':
"""
Create client using unified chain-based configuration.
Args:
scanner_name: Scanner implementation ('etherscan', 'blockscout')
network: Chain name/ID ('ethereum', 'base', 1, 8453)
scanner_version: Scanner version ('v1', 'v2'). If None, uses default:
- 'v2' for etherscan (recommended)
- 'v1' for all other scanners
loop: Event loop instance
timeout: Request timeout configuration
proxy: Proxy URL
throttler: Rate limiting throttler
retry_options: Retry configuration
Returns:
Configured ChainscanClient instance
Example:
```python
# Etherscan v2 for Ethereum (version defaults to 'v2')
client = ChainscanClient.from_config('etherscan', 'ethereum')
# BlockScout v1 for Polygon (version defaults to 'v1')
client = ChainscanClient.from_config('blockscout', 'polygon')
# Explicit version specification
client = ChainscanClient.from_config('moralis', 'ethereum', 'v1')
# Works with chain_id too
client = ChainscanClient.from_config('etherscan', 8453)
```
"""
# Determine default scanner version if not provided
if scanner_version is None:
scanner_version = 'v2' if scanner_name == 'etherscan' else 'v1'

P1 Badge Changing positional argument order breaks existing call sites

The new signature places network before scanner_version and defaults the version to v2/v1. Any existing positional invocations that still pass (scanner_name, version, network) now treat strings like 'v1' or 'v2' as the network and fail in resolve_chain_id. For example, tests/test_blockscout_ethereum_flow.py and several example scripts still call ChainscanClient.from_config('blockscout', 'v1', 'ethereum'), which now raises ValueError and causes those tests/scripts to skip or crash. Unless backward compatibility is preserved, this change will also break user code in the wild. Consider detecting the old calling convention or forcing keyword-only arguments so legacy calls keep working.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

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.

2 participants