Skip to content

[chainId] --> [chainId, writeContractAsync, publicClient] fixed useMemo to avoid older reference#56

Open
aniket866 wants to merge 1 commit intoStabilityNexus:mainfrom
aniket866:patch-2
Open

[chainId] --> [chainId, writeContractAsync, publicClient] fixed useMemo to avoid older reference#56
aniket866 wants to merge 1 commit intoStabilityNexus:mainfrom
aniket866:patch-2

Conversation

@aniket866
Copy link
Contributor

@aniket866 aniket866 commented Feb 8, 2026

Fixed issue #57
Closes #57

@kaneki003 Please review

Summary by CodeRabbit

  • Bug Fixes
    • Fixed swap interface to properly update when network configuration or contract state changes.

…> [chainId, writeContractAsync, publicClient]
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Updated the useMemo dependency array for ContractClient instantiation in SwapInterface to include writeContractAsync and publicClient alongside chainId, ensuring the contract client instance is properly recreated when any of these values change.

Changes

Cohort / File(s) Summary
ContractClient Dependency Fix
components/swap/swap-interface.tsx
Added writeContractAsync and publicClient to the dependency array of the useMemo hook that creates ContractClient. Previously only chainId triggered recreation, which could result in stale provider references when wallet reconnections occurred.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A wallet reconnects with grace,
but memories old held their place,
One line fixed, dependencies now true,
ContractClient remembers the new! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly references the specific dependency array change that was made in the PR, matching the main objective to fix the useMemo hook dependency issue.
Linked Issues check ✅ Passed The code change adds chainId, writeContractAsync, and publicClient to the useMemo dependency array, directly addressing the requirement in issue #57 to rebuild the contractClient when any of these inputs change.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the useMemo dependency array for contractClient in swap-interface.tsx, which is exactly what issue #57 requires.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

missing array dependency useMemo hook creating contractClient only depends on [chainId] Results in older reference

2 participants