Skip to content

60 update network connectors - #85

Merged
MatiasOS merged 14 commits into
openscan-explorer:devfrom
MatiasOS:60-update-network-connectors
Dec 10, 2025
Merged

MatiasOS merged 14 commits into
openscan-explorer:devfrom
MatiasOS:60-update-network-connectors

Conversation

@MatiasOS

@MatiasOS MatiasOS commented Dec 9, 2025 •

Copy link
Copy Markdown
Member

Summary

This PR introduces the network connectors architecture - a major refactoring that extracts blockchain data fetching logic into a modular adapter system with the new explorer-network-connectors package. This enables better maintainability, easier network additions, and cleaner separation of concerns.

Key Changes

Network Connectors Architecture

Code Removal (Replaced by network connectors)

Total Removed: ~2,120 lines of legacy fetcher/adapter code

🔧 Service Layer Updates

  • DataService.ts: Simplified from ~1,500 to ~780 lines (-48%)
    • Removed network-specific fetcher instantiation logic
    • Integrated adapter factory pattern
    • Cleaner method implementations delegating to adapters
  • useDataService.ts: Updated to initialize adapters via factory
  • NetworkBlockIndicator.tsx: Now uses RpcClient from explorer-network-connectors

⚙️ Configuration

  • biome.json: Disabled automatic import sorting (prevents conflicts with manual organization)
  • tsconfig.json: Updated module resolution for new package structure

Architecture Benefits

Advantages:

  • ✅ Single Responsibility: Each adapter handles one network type
  • ✅ DRY Principle: Shared logic in NetworkAdapter base class
  • ✅ Easy Extensions: Add new networks by creating new adapter
  • ✅ Reusability: Connectors package can be used in other projects
  • ✅ Type Safety: Consistent interfaces across all networks

Technical Details

Adapter Structure:
Each adapter extends NetworkAdapter and implements:

  • getBlock(blockNumber) - Fetch block data
  • getTransaction(txHash) - Fetch transaction with receipt
  • getAddress(address) - Fetch address data, balance, code
  • getNetworkStats() - Gas price, latest block, sync status

Network-Specific Customizations:

  • Arbitrum: Adds l1BlockNumber, sendCount, requestId fields
  • OP Stack (Optimism, Base): Adds L1 fee breakdown (l1Fee, l1GasPrice, l1GasUsed)
  • Generic EVM: Standard Ethereum fields only

RPC Strategy Support:

  • Both fallback and parallel RPC strategies work with new connectors
  • Metadata generation and provider comparison maintained
  • Inconsistency detection preserved

Breaking Changes

None - this is an internal refactoring that maintains full API compatibility.

File Statistics

  • 59 files changed
  • +2,892 insertions
  • -2,958 deletions
  • Net: -66 lines (code consolidation)

@MatiasOS
MatiasOS requested a review from AugustoL December 9, 2025 11:38
@github-actions

github-actions Bot commented Dec 9, 2025 •

Copy link
Copy Markdown

🚀 Preview: https://pr-85--openscan.netlify.app
📝 Commit: 8e606843699e0df53bf7f41f9a8b16026c5d7a89

@MatiasOS
MatiasOS force-pushed the 60-update-network-connectors branch from ae2621b to 8e60684 Compare December 10, 2025 13:16
@MatiasOS MatiasOS changed the title [WIP] 60 update network connectors 60 update network connectors Dec 10, 2025

@AugustoL AugustoL left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🍻

@MatiasOS
MatiasOS merged commit f6a3748 into openscan-explorer:dev Dec 10, 2025
2 checks passed
@MatiasOS
MatiasOS deleted the 60-update-network-connectors branch December 10, 2025 13:49
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