Charts: fix 'Cannot compare money in different currencies' crash (#3713)
What changed, and why it matters
This commit fixes a non-security crash in the app's price charts. The chart screen could mix cached and freshly downloaded price rows that were tagged with slightly different currency names (for example, 'usdterc20' versus plain 'usdt'), causing a 'Cannot compare money in different currencies' error. The fix makes the chart request prices using the same currency tag that the cache uses, so the two sources line up. It also adds a missing nickname mapping for the AVAX token. There is no indication this was a security vulnerability or that it could be exploited.
No security action required. Treat as a routine bug fix. If reviewing for release stability, verify that chart price loading still works for tagged assets such as usdterc20/usdttrc20 and avax/avaxc.
Security signals we found
No security-relevant signals observed in the diff
Fix is a UI/data-consistency crash, not a vulnerability
No untrusted input handling, parsing, or boundary changes
No changes to authentication, encryption, wallet, or transaction logic
Evidence from the diff
The patch addresses a consistency bug in ChartsBloc. PriceData cache keys are based on CryptoCurrency.apiString (‘crypto.$title’, no chain tag), so cached entries for assets like usdterc20 are stored under generic usdt. The bloc previously requested fresh prices using the original curr object, whose internal currency tag differed from the cached one. When both sets of PriceData were merged, ChartsLoaded.changeDataFor threw because Money values carried different Currency objects. The fix round-trips curr through currencyFromApiString(curr.apiString) before calling priceStore.getPrices, aligning API and cached rows. A secondary change maps the title ‘avax’ to avaxc in CryptoCurrency.fromString, and a follow-up commit removes the now-unnecessary fallback. The diff is small, localized to chart display logic, and contains no input validation, cryptographic, or authorization changes.
Changed components
lib/new-ui/viewmodels/charts/charts_bloc.dartcw_core/lib/crypto_currency.dartInspect captured patch +3 / −1
### cw_core/lib/crypto_currency.dart
@@ -1032,6 +1032,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
'secret': scrt,
'stellar': xlm,
'avalanche': avaxc,
+ 'avax': avaxc,
'binance': bnb,
'tether': usdt,
'usdcoin': usdc,
### lib/new-ui/viewmodels/charts/charts_bloc.dart
@@ -77,7 +77,8 @@ class ChartsBloc extends Bloc<ChartsEvent, ChartsState> {
final currencies = s.currencies.toList();
final range = s.range;
for (final curr in currencies) {
- data[curr] = await priceStore.getPrices(appStore.settingsStore.fiatCurrency, curr, range);
+ data[curr] = await priceStore.getPrices(
+ appStore.settingsStore.fiatCurrency, currencyFromApiString(curr.apiString), range);
}
emit(
ChartsLoaded(Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.