-
Notifications
You must be signed in to change notification settings - Fork 250
chore(release): v0.9.1 release - Trezor login hot-fix
#2743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79eabfe
1d9dfea
615a22e
c9e9a68
c0cd153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -71,9 +71,12 @@ class PortfolioGrowthRepository { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// The graph cache provider to store the portfolio growth graph data. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final PersistenceProvider<String, GraphCache> _graphCache; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final CoinsRepo _coinsRepository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// The SDK needed for connecting to blockchain nodes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final KomodoDefiSdk _sdk; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// The coins repository for detailed coin info | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final CoinsRepo _coinsRepository; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final _log = Logger('PortfolioGrowthRepository'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| static Future<void> ensureInitialized() async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -514,4 +517,38 @@ class PortfolioGrowthRepository { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Future<void> clearCache() => _graphCache.deleteAll(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Calculate the total 24h change in USD value for a list of coins | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// This method fetches the current prices for all coins and calculates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// the 24h change by multiplying each coin's percentage change by its USD balance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Future<double> calculateTotalChange24h(List<Coin> coins) async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Fetch current prices including 24h change data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final prices = await _coinsRepository.fetchCurrentPrices() ?? {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Calculate the 24h change by summing the change percentage of each coin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // multiplied by its USD balance and divided by 100 (to convert percentage to decimal) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double totalChange = 0.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (final coin in coins) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final price = prices[coin.id.symbol.configSymbol.toUpperCase()]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final change24h = price?.change24h ?? 0.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| final usdBalance = coin.lastKnownUsdBalance(_sdk) ?? 0.0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| totalChange += (change24h * usdBalance / 100); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return totalChange; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+525
to
+538
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
Every call fetches fresh prices, even though -final prices = await _coinsRepository.fetchCurrentPrices() ?? {};
+final prices = _coinsRepository.getCachedPrices() ??
+ await _coinsRepository.fetchCurrentPrices() ?? {};Alternatively pass the already-cached map from the caller. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Get the cached price for a given coin symbol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// This is used to avoid fetching prices for every calculation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CexPrice? getCachedPrice(String symbol) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return _coinsRepository.getCachedPrice(symbol); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Update prices for all coins by fetching from market data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// This method ensures we have up-to-date price data before calculations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Future<void> updatePrices() async { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await _coinsRepository.fetchCurrentPrices(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,16 +19,25 @@ final class PortfolioGrowthChartLoadSuccess extends PortfolioGrowthState { | |
| required this.portfolioGrowth, | ||
| required this.percentageIncrease, | ||
| required super.selectedPeriod, | ||
| required this.totalBalance, | ||
| required this.totalChange24h, | ||
| required this.percentageChange24h, | ||
| }); | ||
|
|
||
| final ChartData portfolioGrowth; | ||
| final double percentageIncrease; | ||
| final double totalBalance; | ||
| final double totalChange24h; | ||
| final double percentageChange24h; | ||
|
|
||
|
Comment on lines
+22
to
32
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid storing money in
🤖 Prompt for AI Agents |
||
| @override | ||
| List<Object> get props => <Object>[ | ||
| portfolioGrowth, | ||
| percentageIncrease, | ||
| selectedPeriod, | ||
| totalBalance, | ||
| totalChange24h, | ||
| percentageChange24h, | ||
| ]; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Un-throttled price polling may flood the CEX API
updatePrices()is executed on every tick ofStream.periodic. Ifevent.updateFrequencyis small (e.g. a few seconds), the wallet will hammer the price endpoint continuously, even when the UI is backgrounded. Consider one of:or move price refreshing to a debounced/background service.
🤖 Prompt for AI Agents