Skip to content

fix: batch sell value in currency sometimes missing#8928

Merged
infiniteflower merged 4 commits into
mainfrom
fix/batchSell-marketData
May 29, 2026
Merged

fix: batch sell value in currency sometimes missing#8928
infiniteflower merged 4 commits into
mainfrom
fix/batchSell-marketData

Conversation

@infiniteflower
Copy link
Copy Markdown
Contributor

@infiniteflower infiniteflower commented May 28, 2026

Explanation

selectExchangeRateByAssetId previously looked up EVM token marketData using only the address casing extracted from the provided asset ID. Batch Sell fee assets can arrive from obtainGaslessBatch with a lowercase ERC-20 address, while Mobile provides token rates keyed by checksummed addresses. That mismatch caused selectBatchSellTrades(...).totalNetworkFee.amount to be present while valueInCurrency and usd were null.

This updates the EVM token exchange-rate lookup to try the checksummed address first and then fall back to the lowercase address. That keeps existing checksummed quote metadata behavior working while allowing Batch Sell fee asset IDs with lowercase addresses to resolve against checksummed marketData keys.

Regression tests cover both the low-level selectExchangeRateByAssetId casing behavior and the full selectBatchSellTrades path for Batch Sell network fee fiat values.

Screen.Recording.2026-05-28.at.7.06.05.PM.mov

References

Related to MetaMask/metamask-mobile#30710

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Small selector lookup fix with new tests; no auth, persistence, or API contract changes.

Overview
Fixes Batch Sell network fee fiat display when the fee token’s ERC-20 address in the asset ID is lowercase but marketData is keyed by checksummed addresses.

selectExchangeRateByAssetId now resolves EVM token rates via a shared helper that looks up getAddress(address) first, then lowercase, and returns safely on invalid hex instead of failing the lookup. That restores selectBatchSellTrades totalNetworkFee valueInCurrency and usd when rates were previously missing. Regression tests cover the selector and the full Batch Sell fee path; the package changelog records the fix.

Reviewed by Cursor Bugbot for commit 156b42c. Bugbot is set up for automated code reviews on this repo. Configure here.

@infiniteflower infiniteflower marked this pull request as ready for review May 28, 2026 23:13
@infiniteflower infiniteflower requested review from a team as code owners May 28, 2026 23:13
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 b8fc768. Configure here.

Comment thread packages/bridge-controller/src/selectors.ts Outdated
micaelae
micaelae previously approved these changes May 29, 2026
@infiniteflower infiniteflower added this pull request to the merge queue May 29, 2026
@infiniteflower infiniteflower removed this pull request from the merge queue due to a manual request May 29, 2026
@infiniteflower infiniteflower added this pull request to the merge queue May 29, 2026
Merged via the queue into main with commit bdc6c51 May 29, 2026
649 of 733 checks passed
@infiniteflower infiniteflower deleted the fix/batchSell-marketData branch May 29, 2026 15:13
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.

3 participants