Skip to content

Add ENS utility library for mainnet address resolution#156

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1754241429-ens-utility-library
Open

Add ENS utility library for mainnet address resolution#156
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1754241429-ens-utility-library

Conversation

@devin-ai-integration
Copy link
Contributor

Add ENS utility library for mainnet address resolution

Summary

This PR introduces a standalone ENS (Ethereum Name Service) utility library for resolving ENS names to Ethereum addresses on mainnet. The implementation follows the established patterns from the existing ArbiScan utilities and includes:

  • ENSClient class for performing ENS operations with configurable RPC providers
  • Pydantic models (ENSResolution, ReverseENSResolution) for structured data handling
  • Utility functions for both forward (name → address) and reverse (address → name) resolution
  • Input validation using the existing sanitize_user_input pattern
  • web3.py dependency added for onchain ENS lookups

The library supports custom RPC providers via environment variables (INFURA_PROJECT_ID) with fallback to public endpoints.

Review & Testing Checklist for Human

  • Test ENS resolution with various real ENS names (vitalik.eth, ens.eth, etc.) to verify functionality
  • Verify error handling with invalid inputs (non-.eth names, malformed addresses, non-existent names)
  • Test network failure scenarios by temporarily blocking network access or using invalid provider URLs
  • Check reverse resolution works correctly for addresses that do/don't have ENS names
  • Verify web3 dependency doesn't conflict with existing code and installs correctly in clean environment

Recommended test plan: Run the included test_ens_utility.py script and verify it handles both successful resolutions and graceful error handling for network issues.


Diagram

%%{ init : { "theme" : "default" }}%%
flowchart TD
    pyproject["pyproject.toml<br/>+web3 dependency"]:::minor-edit
    
    ens_models["src/talos/models/ens.py<br/>ENSResolution models"]:::major-edit
    ens_utils["src/talos/utils/ens.py<br/>ENSClient + utilities"]:::major-edit
    
    arbiscan_utils["src/talos/utils/arbiscan.py<br/>ArbiScanClient pattern"]:::context
    arbiscan_models["src/talos/models/arbiscan.py<br/>Pydantic models pattern"]:::context
    validation["src/talos/utils/validation.py<br/>sanitize_user_input"]:::context
    
    ens_utils --> ens_models
    ens_utils --> validation
    ens_models -.-> arbiscan_models
    ens_utils -.-> arbiscan_utils
    pyproject --> ens_utils
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB  
    classDef context fill:#F5F5F5
Loading

Notes

  • Network dependency risk: The utility relies on external RPC providers which could be rate-limited or fail. Consider implementing retry logic and better fallback mechanisms for production use.
  • Type safety: Had to use type: ignore[union-attr] comments for web3.py's complex union types - this is a known limitation of web3.py's type annotations.
  • Testing limitations: Only basic manual testing was performed. Consider adding comprehensive unit tests with mocked network calls for better reliability.

Session details: Requested by @talos-agent
Link to Devin run: https://app.devin.ai/sessions/ade086eff99240beb646051dfe16da92

- Add ENSClient class for resolving ENS names to Ethereum addresses
- Add ENSResolution and ReverseENSResolution Pydantic models
- Support both forward and reverse ENS resolution
- Include input validation and error handling
- Add web3.py dependency for onchain ENS lookups
- Follow established patterns from ArbiScan utilities

Co-Authored-By: talosgma@gmail.com <talosgma@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration
Copy link
Contributor Author

Devin is archived and cannot be woken up. Please unarchive Devin if you want to continue using it.

@johnny-emp johnny-emp force-pushed the main branch 3 times, most recently from ccf2936 to 015ec79 Compare September 10, 2025 04:44
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.

0 participants