Skip to content

fix(coin-details): display fiat balance for addresses#3049

Merged
CharlVS merged 5 commits intodevfrom
codex/replace-_balance-with-coinbalance
Aug 12, 2025
Merged

fix(coin-details): display fiat balance for addresses#3049
CharlVS merged 5 commits intodevfrom
codex/replace-_balance-with-coinbalance

Conversation

@takenagain
Copy link
Copy Markdown
Contributor

@takenagain takenagain commented Aug 5, 2025

Update AddressCard to show the fiat value for the address balance instead of showing the balance twice.

Before

image

After

image

Summary by CodeRabbit

  • New Features

    • The coin balance display now includes the equivalent USD value alongside the coin amount and ticker for improved clarity.
  • Style

    • Simplified formatting in the coin balance widget for a cleaner codebase.
    • Removed redundant spacing in the address card on mobile layouts.

Copilot AI review requested due to automatic review settings August 5, 2025 10:45
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 5, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes update formatting and display logic in two widget files. In coin_balance.dart, multi-line widget and parameter declarations are consolidated into single lines for conciseness, with no logic changes. In coin_addresses.dart, the balance display now includes a USD value, and a redundant spacing widget is removed.

Changes

Cohort / File(s) Change Summary
Widget Formatting Simplification
lib/shared/widgets/coin_balance.dart
Consolidated multi-line widget and parameter declarations into single lines; no logic or control flow changes.
Balance Display Logic & Layout Update
lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
Added USD value to balance display using SDK price data; removed redundant vertical spacing widget.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CoinAddressesWidget
    participant SDK

    User->>CoinAddressesWidget: View coin address details
    CoinAddressesWidget->>SDK: Fetch last known USD price for coin
    SDK-->>CoinAddressesWidget: Return USD price
    CoinAddressesWidget->>User: Display balance with ticker and USD equivalent
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Suggested labels

QA

Suggested reviewers

  • AndrewDelaney
  • smk762
  • CharlVS

Poem

Coins and widgets, neat and bright,
Formatting trimmed for coder’s delight.
Balances now in dollars gleam,
No more clutter in the theme!
A rabbit hops through tidy code—
Efficiency is the golden road. 🪙🐇

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/replace-_balance-with-coinbalance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@takenagain takenagain marked this pull request as draft August 5, 2025 10:45
@takenagain takenagain changed the title fix: display fiat balance for addresses fix(coin-details): display fiat balance for addresses Aug 5, 2025
@takenagain takenagain added the bug Something isn't working label Aug 5, 2025
@takenagain takenagain self-assigned this Aug 5, 2025
@takenagain takenagain added this to the v0.10.0 Release milestone Aug 5, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request replaces a local balance widget with the reusable CoinBalance component to display both asset balance and fiat equivalent for addresses. The changes improve code reuse and provide consistent balance display across the application.

  • Removes the local _Balance widget and replaces it with the existing CoinBalance component
  • Refactors the CoinBalance widget to improve code organization and formatting
  • Adds import for formatters.dart to support balance formatting functionality

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart Replaces local _Balance widget with CoinBalance component and adds necessary import
lib/shared/widgets/coin_balance.dart Refactors code organization, removes unused parameters, and adds formatters import

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 5, 2025

Visit the preview URL for this PR (updated for commit 95a9c56):

https://walletrc--pull-3049-merge-kt98qyrq.web.app

(expires Tue, 12 Aug 2025 11:41:14 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

takenagain and others added 2 commits August 5, 2025 12:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@takenagain
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Aug 5, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart (1)

743-743: Address deprecation warning for QR code styling.

The foregroundColor property is deprecated. Update the QrImageView to use the newer color properties.

-            foregroundColor: theme.custom.dexPageTheme.emptyPlace,
+            eyeStyle: QrEyeStyle(
+              eyeShape: QrEyeShape.square,
+              color: theme.custom.dexPageTheme.emptyPlace,
+            ),
+            dataModuleStyle: QrDataModuleStyle(
+              dataModuleShape: QrDataModuleShape.square,
+              color: theme.custom.dexPageTheme.emptyPlace,
+            ),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 976943a and 95a9c56.

📒 Files selected for processing (2)
  • lib/shared/widgets/coin_balance.dart (2 hunks)
  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart (2 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2570
File: lib/views/fiat/fiat_inputs.dart:198-212
Timestamp: 2025-03-25T18:39:03.280Z
Learning: The `showBalanceIndicator` parameter for the `SourceAddressField` widget will be added in a future SDK update, as noted by the developer.
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2566
File: lib/bloc/coins_bloc/coins_bloc.dart:10-10
Timestamp: 2025-04-01T15:51:37.060Z
Learning: In the Komodo Wallet project, part files share imports with their parent files. The import for `app_config.dart` in `coins_bloc.dart` is necessary because the part file `coins_state.dart` uses `excludedAssetList` from that package.
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2566
File: lib/bloc/coins_bloc/coins_bloc.dart:10-10
Timestamp: 2025-04-01T15:51:37.060Z
Learning: The `excludedAssetList` from `app_config.dart` is used in the `_filterExcludedAssets` method in `coins_state.dart`. Since `coins_state.dart` is a part file of `coins_bloc.dart`, the import needs to be in the parent file even though it's not directly used there. In Dart, part files share the namespace and imports of their parent files.
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2976
File: lib/bloc/coins_manager/coins_manager_bloc.dart:82-83
Timestamp: 2025-07-23T09:31:17.738Z
Learning: In the CoinsManagerBloc, `state.selectedCoins` is used separately from `state.coins` to indicate whether a coin is enabled or not in the UI. The order of Set deduplication when merging coin lists doesn't affect UI behavior because selection state is tracked independently from the coin list used for filtering and sorting.
📚 Learning: in the komodo wallet project, part files share imports with their parent files. the import for `app_...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2566
File: lib/bloc/coins_bloc/coins_bloc.dart:10-10
Timestamp: 2025-04-01T15:51:37.060Z
Learning: In the Komodo Wallet project, part files share imports with their parent files. The import for `app_config.dart` in `coins_bloc.dart` is necessary because the part file `coins_state.dart` uses `excludedAssetList` from that package.

Applied to files:

  • lib/shared/widgets/coin_balance.dart
  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
📚 Learning: the `excludedassetlist` from `app_config.dart` is used in the `_filterexcludedassets` method in `coi...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2566
File: lib/bloc/coins_bloc/coins_bloc.dart:10-10
Timestamp: 2025-04-01T15:51:37.060Z
Learning: The `excludedAssetList` from `app_config.dart` is used in the `_filterExcludedAssets` method in `coins_state.dart`. Since `coins_state.dart` is a part file of `coins_bloc.dart`, the import needs to be in the parent file even though it's not directly used there. In Dart, part files share the namespace and imports of their parent files.

Applied to files:

  • lib/shared/widgets/coin_balance.dart
  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
📚 Learning: it's acceptable to use unconditional `dart:io` imports in the komodo wallet codebase when the usage ...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2608
File: lib/bloc/fiat/fiat_onramp_form/fiat_form_bloc.dart:2-3
Timestamp: 2025-05-01T21:00:36.970Z
Learning: It's acceptable to use unconditional `dart:io` imports in the Komodo wallet codebase when the usage is guarded by `!kIsWeb` conditional checks that prevent the platform-specific code from being executed in web environments.

Applied to files:

  • lib/shared/widgets/coin_balance.dart
  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
📚 Learning: the `showbalanceindicator` parameter for the `sourceaddressfield` widget will be added in a future s...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2570
File: lib/views/fiat/fiat_inputs.dart:198-212
Timestamp: 2025-03-25T18:39:03.280Z
Learning: The `showBalanceIndicator` parameter for the `SourceAddressField` widget will be added in a future SDK update, as noted by the developer.

Applied to files:

  • lib/shared/widgets/coin_balance.dart
  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
📚 Learning: in the coinsmanagerbloc, `state.selectedcoins` is used separately from `state.coins` to indicate whe...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2976
File: lib/bloc/coins_manager/coins_manager_bloc.dart:82-83
Timestamp: 2025-07-23T09:31:17.738Z
Learning: In the CoinsManagerBloc, `state.selectedCoins` is used separately from `state.coins` to indicate whether a coin is enabled or not in the UI. The order of Set deduplication when merging coin lists doesn't affect UI behavior because selection state is tracked independently from the coin list used for filtering and sorting.

Applied to files:

  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
📚 Learning: in the komodo wallet project, test files are structured to define test functions that are called fro...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2611
File: test_units/tests/system_health/system_clock_repository_test.dart:7-8
Timestamp: 2025-05-08T19:07:13.442Z
Learning: In the Komodo Wallet project, test files are structured to define test functions that are called from a central test runner in test_units/main.dart, rather than each test file having its own main() function.

Applied to files:

  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
📚 Learning: in the komodo wallet project, test functions are defined in individual files under `test_units/tests...
Learnt from: takenagain
PR: KomodoPlatform/komodo-wallet#2611
File: test_units/tests/system_health/http_head_time_provider_test.dart:8-24
Timestamp: 2025-05-08T19:05:13.083Z
Learning: In the Komodo Wallet project, test functions are defined in individual files under `test_units/tests/` but are executed through the central entry point in `test_units/main.dart`, so individual test files don't need their own `main()` function.

Applied to files:

  • lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart
🪛 GitHub Actions: takenagain is validating code guidelines 🚀
lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart

[info] 743-743: 'foregroundColor' is deprecated. Use colors in eyeStyle and dataModuleStyle instead.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Desktop (windows)
  • GitHub Check: Build Mobile (Android)
  • GitHub Check: Build Mobile (iOS)
🔇 Additional comments (3)
lib/views/wallet/coin_details/coin_details_info/coin_addresses.dart (2)

17-18: LGTM! New imports are properly utilized.

The new imports are correctly added to support the fiat balance display feature:

  • formatters.dart provides formatUsdValue for USD formatting
  • legacy_coin_migration_extensions.dart provides abbr2Ticker for ticker conversion

290-299: Excellent implementation of fiat balance display!

The updated balance display logic correctly:

  • Calculates USD value using the coin's last known price
  • Handles null price scenarios gracefully with formatUsdValue
  • Shows clear format: "balance TICKER ($fiat)"
  • Uses the appropriate address.balance.total for individual address balances

This perfectly addresses the PR objective of displaying fiat values instead of redundant balance information.

lib/shared/widgets/coin_balance.dart (1)

10-10: LGTM! Clean formatting improvements.

The consolidation of multi-line expressions into single lines improves code readability while maintaining identical functionality. These formatting changes align well with the overall code style.

Also applies to: 18-18, 35-35, 39-39, 43-43

@takenagain takenagain marked this pull request as ready for review August 5, 2025 11:54
@takenagain takenagain added the QA Ready for QA Testing label Aug 5, 2025
@takenagain takenagain requested review from CharlVS and smk762 August 5, 2025 11:54
Comment on lines +290 to +293
final balance = address.balance.total.toDouble();
final price = coin.lastKnownUsdPrice(context.sdk);
final usdValue = price == null ? null : price * balance;
final fiat = formatUsdValue(usdValue);
Copy link
Copy Markdown
Collaborator

@CharlVS CharlVS Aug 5, 2025

Choose a reason for hiding this comment

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

Consider using a stream-based approach so that we're resilient to edge cases where the user is on the page before the prices are loaded or if they have a momentary dip in their connection.

I generally avoid using stream builders because they clutter up the UI and suggest that the state is modelled correctly incorrectly, but all fiat-display UI code is going to be overhauled in the near future when we add the UX enhancement for multiple fiat currency options.

EDIT: strike out and replace a word which changes the meaning of the entire comment (@smk762 @takenagain)

@smk762
Copy link
Copy Markdown
Collaborator

smk762 commented Aug 6, 2025

Confirmed fiat display in the wallet page
image

There is some time prior to data being available, during while the display is suboptimal.
image

As mentioned previously, when there is nothing inside the brackets, use a spinner. The current UI in this state is bad UX.

There is also a state where there is something between the brackets, but it's a default (0.00) briefly before the actual price arrives (e.g. in LTC above). For the duration of this state, we are transmitting incorrect information to the user. It would be better to maintain the spinner - but this may put coins with no price data into an eternal spin. IMO the simplest solution here is to hide both the brackets and the fiat value unless a non-zero, non-null value is present.

This should be applied in all places where a fiat value is shown. I've received some negative user feedback where their experience was diminished by the implication that their favorite low cap coin was worthless because we lacked price info, so it value was shown as $0.00.

I'll move this commentary into an issue, as the scope of this PR was already fulfilled and its merge should not be delayed.

Copy link
Copy Markdown
Collaborator

@smk762 smk762 left a comment

Choose a reason for hiding this comment

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

lgtm

@CharlVS CharlVS merged commit 26fe733 into dev Aug 12, 2025
2 of 13 checks passed
@CharlVS CharlVS deleted the codex/replace-_balance-with-coinbalance branch August 12, 2025 16:26
cursor bot pushed a commit that referenced this pull request Aug 20, 2025
* refactor: drop balance override from CoinBalance

* chore: remove unused import

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(address-card): revert change to coinbalance and use extensions

* feat(coin-addresses): migrate to stream-based pubkey watch function

TODO: bump SDK version once merged

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codex QA Ready for QA Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants