refactor: extract various business logic into separate utilities#26678
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| isExpired, | ||
| blockaidError, | ||
| shouldShowPriceImpactWarning, | ||
| validQuotes, |
There was a problem hiding this comment.
validQuotes is exported here but never imported/used anywhere in the app. Why export it? (and also, why even have it at all? Dead code? 🤔 )
| } | ||
|
|
||
| const QuoteDetailsCard: React.FC<QuoteDetailsCardProps> = ({ | ||
| hasInsufficientBalance, |
There was a problem hiding this comment.
We import hasInsufficientBalance here intentionally to minimize use of useLatestBalance, which is RPC expensive and soon to be deprecated (hopefully 🙏 ).
We should keep this hasInsufficientBalance param and pass it into useShouldRenderGasSponsoredBanner so the hook can use that directly.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
SmokeTrade is selected because:
SmokeConfirmations is selected because:
The changes are primarily refactoring with comprehensive unit tests added, but the shared Performance Test Selection: |
Description
Extract various logic into separate pure functions and hooks.
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4188
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Mostly refactoring with broad surface-area touch in Bridge quoting/fee display and validation filtering; moderate risk of UI regressions around fee formatting and when quote sections render/clear on expiry.
Overview
Refactors Bridge quote presentation logic into reusable utilities/hooks. Network-fee formatting is extracted to
formatNetworkFee+useFormattedNetworkFee, and gas-sponsorship logic is moved intouseIsNetworkGasSponsored+useShouldRenderGasSponsoredBanner, with gasless detection centralized inisGaslessQuote.Hardens quote-driven UI and data selection.
BridgeViewnow avoids rendering the bottom action section when there’s noactiveQuote(fixing an expiry/redirect edge case), anduseBridgeQuoteDataaddsvalidQuotesby filtering sorted quotes to those matching the selected destination token and non-expired state.Consolidates fiat formatting. The existing
useFiatFormatterhook is simplified to delegate to a new sharedutil/formatFiathelper, with extensive new unit tests added across the new hooks/utilities.Written by Cursor Bugbot for commit 9096d32. This will update automatically on new commits. Configure here.