Refactor: Extract duplicate code, add TDD test coverage, standardize on pnpm - #2
Merged
Merged
Conversation
…on pnpm Extract duplicate code into centralized utilities: - decimal-converter.js: P3D decimal multiplier handling (44 lines removed from BridgeForm) - error-parser.js: transaction error categorization (177 lines removed from Expatriation/Repatriation) - network-switcher.js: MetaMask network switching (111 lines removed from BridgeForm/AssistantsList) Add comprehensive test coverage using TDD methodology: - 27 tests for decimal-converter - 32 tests for error-parser - 16 tests for network-switcher - All tests passing (88/88) Fix pre-existing test failures: - Export ProviderManager class for settings-consistency tests - Correct health status expectation in retry-with-fallback tests Standardize on pnpm package manager: - Add .mise.toml for Node 18 + pnpm - Add .npmrc with hoisting config for React compatibility - Update all docs (README, CLAUDE.md) to use pnpm commands - Add Makefile with test target - Add packageManager field to package.json - Resolve ESLint plugin conflict with .eslintrc.json 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Resolve merge conflicts: - Makefile: Keep main's comprehensive version, replace npm with pnpm - retry-with-fallback.test.js: Keep both test scenarios (rate limiting + degraded state) - provider-manager.js: Accept main's grammatically correct comment All 89 tests passing.
…ageManager The pnpm/action-setup@v4 action auto-detects version from package.json's packageManager field. Having both causes ERR_PNPM_BAD_PM_VERSION conflict.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors the codebase to eliminate duplicate code, adds comprehensive test coverage using TDD methodology, and standardizes the project on pnpm package manager.
Code Duplication Eliminated
decimal-converter.js: Extracted P3D decimal multiplier handling
error-parser.js: Centralized transaction error categorization
network-switcher.js: Extracted MetaMask network switching logic
Test Coverage
Package Manager Migration
Test Plan
make testpnpm installcompletes successfullypnpm startruns without ESLint conflictspnpm testruns all tests successfullyChanges
New Files:
src/utils/decimal-converter.js+ testssrc/utils/error-parser.js+ testssrc/utils/network-switcher.js+ tests.mise.toml(Node + pnpm config).npmrc(pnpm config).eslintrc.json(ESLint config)Makefile(test target)CLAUDE.md(developer documentation)Modified Files:
src/components/BridgeForm.js(-112 lines of duplicate code)src/components/AssistantsList.js(-43 lines of duplicate code)src/components/Expatriation.js(-101 lines of duplicate code)src/components/Repatriation.js(-76 lines of duplicate code)src/utils/provider-manager.js(exported ProviderManager class)src/utils/__tests__/retry-with-fallback.test.js(fixed expectation)README.md(updated to pnpm)package.json(added packageManager field, removed eslintConfig).gitignore(added package-lock.json)Total Impact:
🤖 Generated with Claude Code