fix: handle BTC quote when BTC quote has missing or non-positive network fee data#30313
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. |
0d46ab0 to
bd1cace
Compare
bd1cace to
4027284
Compare
4027284 to
7a67c3e
Compare
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.
Reviewed by Cursor Bugbot for commit 7a67c3e. Configure here.
7a67c3e to
797bf0f
Compare
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use |
|
@metamaskbot update-mobile-fixture |
|
🔄 Fixture update started. Running workflow from branch |
|
❌ E2E fixture update failed.\n\nCommon causes:\n- CI workflow is still running — wait for 'Build iOS Apps' to complete\n- CI workflow was skipped — ensure your PR has iOS-impacting changes or use |
daa8400 to
d4be510
Compare
…ration into an independent statement
d4be510 to
30e4c63
Compare
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: The PR introduces a new
The changes are focused on Bitcoin bridge edge cases but modify core bridge UI logic (button states, labels) that runs for all bridge/swap flows. Risk is medium because the logic changes are well-scoped but touch critical user-facing confirm button behavior. Performance Test Selection: |
|




Description
This pull request improves how the Bridge UI handles and displays cases where the network fee is unavailable, especially for Bitcoin (BTC) bridges. It introduces a new hook to detect unavailable network fees, updates the logic for disabling/enabling the confirm button, and adjusts messaging and analytics accordingly. The changes also include comprehensive tests for these scenarios.
Key changes:
1. Handling Network Fee Unavailability in the UI
useIsNetworkFeeUnavailablehook to detect when the network fee (especially for BTC) is unavailable and integrated it into bothBridgeViewandSwapsConfirmButtoncomponents. This disables the confirm button and updates the label to "Insufficient funds" when the fee is unavailable.2. Analytics and Event Tracking
useBridgeQuoteEventshook and its consumers to track when the network fee is unavailable, emitting a newnetwork_fee_unavailablewarning instead of the generic insufficient gas warning.3. Gas Fee Calculation Logic
useHasSufficientGasto usetotalNetworkFee.amountfor BTC quotes instead ofgasFee.effective.amount, ensuring correct balance validation for Bitcoin transactions.4. Testing and Coverage
SwapsConfirmButtonanduseBridgeQuoteEvents, and additional BTC-specific tests foruseHasSufficientGas.These updates ensure that users are clearly informed when a bridge transaction cannot proceed due to unavailable network fees, especially for Bitcoin, and that analytics accurately reflect this state.
Changelog
CHANGELOG entry: fixed BTC quote when BTC quote has missing or non-positive network fee data
Related issues
Fixes: Bridging BTC is failing at the transaction crafting in certain cases
Manual testing steps
BTC quote with unavailable fee
Screenshots/Recordings
Before
After
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Updates bridge confirmation disablement, labeling, and analytics around fee/gas validation, which can block submissions and alter event warnings; impact is mostly limited to BTC and UI state handling but affects core swap/bridge CTA logic.
Overview
Improves BTC quote handling when network fee data is missing/invalid. Adds
useIsNetworkFeeUnavailableto detect BTC quotes with missing, non-finite, or non-positivetotalNetworkFee.amount, and uses it to disable submission and show Insufficient funds (instead of Insufficient gas) inBridgeView,SwapsConfirmButton, and Quick Buy.Adjusts fee validation + analytics.
useHasSufficientGasnow preferstotalNetworkFee.amountfor BTC when checking gas sufficiency, anduseBridgeQuoteEventsemits a newnetwork_fee_unavailablewarning (taking precedence over insufficient gas).Expands test coverage. Adds/updates unit tests to cover BTC network-fee-unavailable cases across confirm button states, “Get new quote” enablement, quote warnings, Quick Buy button errors, and BTC gas validation.
Reviewed by Cursor Bugbot for commit 30e4c63. Bugbot is set up for automated code reviews on this repo. Configure here.