Skip to content

feat(chains): add ethereum monitoring integration#193

Merged
mijinummi merged 2 commits into
MD-Creative-Production:mainfrom
omolobamoyinoluwa-max:feat/136-ethereum-monitoring
Jun 22, 2026
Merged

feat(chains): add ethereum monitoring integration#193
mijinummi merged 2 commits into
MD-Creative-Production:mainfrom
omolobamoyinoluwa-max:feat/136-ethereum-monitoring

Conversation

@omolobamoyinoluwa-max

Copy link
Copy Markdown
Contributor

Summary

Extends Sentinel monitoring capabilities to Ethereum by implementing an EthereumChainMonitor that polls the Ethereum JSON-RPC for new blocks, extracts transactions, and normalizes them into the shared NormalizedChainEvent format.

Changes

New Files

  • apps/backend/src/modules/chains/monitors/ethereum.chain-monitor.ts — Ethereum chain monitor implementing IChainMonitor

    • Connects to Ethereum via ethers v6 JsonRpcProvider
    • Polls for new blocks every 15s (configurable via ETHEREUM_POLL_INTERVAL_MS)
    • Normalizes transactions with event classification: contract_deploy > contract_call > transfer
    • Converts BigInt values to strings for JSON compatibility
    • Health check via getBlockNumber()
    • Duplicate subscription guard
  • apps/backend/src/modules/chains/monitors/ethereum.chain-monitor.spec.ts — 12 tests covering:

    • Normalization of native ETH transfers, contract calls, and contract deployments
    • Timestamp handling (string, number, missing)
    • Graceful handling of missing fields
    • Block polling and event emission
    • Duplicate subscribe rejection
    • Health check (healthy, RPC error, negative block number)

Modified Files

  • apps/backend/src/modules/chains/chains.module.ts — Registers EthereumChainMonitor in the CHAIN_MONITORS provider array, gated behind the ETHEREUM_RPC_URL environment variable

Environment Variables

Variable Default Description
ETHEREUM_RPC_URL http://localhost:8545 Ethereum JSON-RPC endpoint (required to activate)
ETHEREUM_POLL_INTERVAL_MS 15000 Polling interval in milliseconds

Verification

  • ✅ All 180 backend tests pass
  • ✅ TypeScript typecheck passes with no errors
  • ✅ ESLint/Prettier passes with no errors
  • ✅ Follows existing StellarChainMonitor pattern
  • ✅ Integrates with ChainRegistryService for unified event delivery

Related

Closes #136

- Implement EthereumChainMonitor implementing IChainMonitor
- Poll Ethereum JSON-RPC for new blocks and normalize transactions
- Support transfer, contract_call, and contract_deploy event types
- Register monitor in ChainsModule behind ETHEREUM_RPC_URL env var
- Add comprehensive test suite for normalization, polling, and health

Closes MD-Creative-Production#136
- Replace jest.clearAllMocks() with targeted mockReset() calls
to properly clear mockResolvedValueOnce queues between tests
- Simplify ethers jest.mock to avoid recursive ethers.ethers reference
- Use eslint-disable-next-line instead of tslint directive
@mijinummi mijinummi merged commit 8ba92d9 into MD-Creative-Production:main Jun 22, 2026
11 checks passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 22, 2026
3 tasks
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.

Add Ethereum Monitoring Integration

2 participants