Skip to content

refactor: Extract duplicate code into reusable utilities with TDD#3

Merged
fedosov merged 1 commit into
mainfrom
refactor-phase1-duplicate-code
Oct 28, 2025
Merged

refactor: Extract duplicate code into reusable utilities with TDD#3
fedosov merged 1 commit into
mainfrom
refactor-phase1-duplicate-code

Conversation

@fedosov
Copy link
Copy Markdown
Contributor

@fedosov fedosov commented Oct 28, 2025

Summary

  • Created bridge-filter.js - Extracts ~100 lines of duplicate bridge filtering logic from fetch-claims.js and fetch-last-transfers.js
  • Created data-normalizer.js - Extracts ~80 lines of duplicate amount/BigNumber normalization from aggregate-claims-transfers.js and fetch-last-transfers.js
  • Created event-parser.js - Eliminates magic array indices when parsing event args, improving type safety
  • Added 32 comprehensive tests following strict RED-GREEN-REFACTOR TDD cycle (8 + 15 + 9 tests)
  • Fixed syntax errors caught by new fetch-last-transfers.test.js import validation test
  • Updated documentation in CLAUDE.md with new utilities and usage examples

Test plan

  • All 122 tests passing (increased from 97 tests)
  • Test coverage: bridge-filter.js, data-normalizer.js, event-parser.js
  • Integration verified: fetch-claims.js, fetch-last-transfers.js, aggregate-claims-transfers.js use new utilities
  • Import validation test catches syntax errors
  • Full test suite: pnpm test -- --no-watch --passWithNoTests --watchAll=false
  • No regressions - all existing functionality preserved
  • Code reduction: ~200+ lines eliminated

🤖 Generated with Claude Code

Phase 1 refactoring eliminates ~200 lines of duplicate code by extracting bridge filtering, data normalization, and event parsing logic into tested utility modules. Adds 32 tests following strict RED-GREEN-REFACTOR cycle. All 122 tests passing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@fedosov fedosov merged commit 3b0d506 into main Oct 28, 2025
1 check passed
@fedosov fedosov deleted the refactor-phase1-duplicate-code branch October 28, 2025 14:56
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.

1 participant