Skip to content

Introduce Money class and refactor currency handling#3157

Open
konstantinullrich wants to merge 60 commits into
devfrom
amount-refactor
Open

Introduce Money class and refactor currency handling#3157
konstantinullrich wants to merge 60 commits into
devfrom
amount-refactor

Conversation

@konstantinullrich
Copy link
Copy Markdown
Contributor

Description

This pull request introduces a new Money class for fixed-point currency handling, improving precision and consistency across various balance and transaction logic. Key changes include:

  • Refactored Bitcoin, lightning, dEuro, Solana, Tron, Zcash, Decred, EVM, and other wallet transaction logic to utilize the Money class for consistent currency precision and improved accuracy.
  • Removed legacy Decred amount formatting in favor of Money.
  • Standardized balance handling across all supported wallets using Money.
  • Enhanced the Money class with new factories and optimized string formatting.
  • Added extensive unit tests for the Money class to ensure reliability and correctness.

Pull Request - Checklist

  • Initial Manual Tests Passed
  • Double check modified code and verify it with the feature/task requirements
  • Format code
  • Look for code duplication
  • Clear naming for variables and methods
  • Manual tests in accessibility mode (TalkBack on Android) passed

- Introduced `Money` class for handling money values with fixed-point precision.
- Added parsing and comparison methods to `CryptoCurrency` and `FiatCurrency` interfaces.
- Implemented `smartAmountSanitizer` for format normalization.

Includes extensive unit tests for validation.
…`Money` for consistent and precise currency handling
…ney.zero` and refine `Balance` class for consistency
# Conflicts:
#	cw_evm/lib/evm_chain_wallet.dart
#	lib/evm/cw_evm.dart
@konstantinullrich konstantinullrich marked this pull request as ready for review April 9, 2026 12:49
Copy link
Copy Markdown
Contributor

@OmarHatem28 OmarHatem28 left a comment

Choose a reason for hiding this comment

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

3 files left, but here are the comments so far.
please check them, along with the previous ones

Comment thread cw_bitcoin/lib/electrum_balance.dart Outdated
Comment thread cw_bitcoin/lib/electrum_transaction_info.dart Outdated
Comment thread cw_evm/lib/evm_erc20_currency.dart Outdated
Comment thread lib/view_model/send/output.dart Outdated
Comment thread cw_bitcoin/lib/electrum_wallet.dart Outdated
Comment thread cw_solana/lib/default_spl_tokens.dart
Comment thread cw_tron/lib/tron_client.dart Outdated
Comment thread lib/new-ui/widgets/send_page/send_confirm_sheet.dart Outdated
Comment thread lib/solana/cw_solana.dart Outdated
Comment thread cw_zcash/lib/src/zcash_balance.dart Outdated
konstantinullrich and others added 3 commits May 6, 2026 16:29
* disallow SP and MWEB for swaps

* Simplify address selection in addressForExchange

Refactor addressForExchange method to simplify address selection logic.

* validate refund and receive address types

* localize address validation messages

* minor ui fix [skip ci]

* minor fix [skip ci]

* Revert "localize address validation messages"

* fix translations

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
…sion across the codebase, add unit tests for `AmountSanitizer`
Comment thread cw_solana/lib/solana_client.dart Outdated
Comment thread lib/view_model/dashboard/balance_view_model.dart Outdated
Comment thread lib/view_model/dashboard/balance_view_model.dart
Comment thread lib/view_model/exchange/exchange_view_model.dart Outdated
Comment thread lib/view_model/exchange/exchange_view_model.dart Outdated
konstantinullrich and others added 14 commits May 11, 2026 13:39
…th inherited properties, update references accordingly
…ansaction signing methods to avoid inconsistency
… transaction methods for consistency and precision
# Conflicts:
#	cw_bitcoin/lib/lightning/lightning_wallet.dart
#	cw_core/lib/crypto_currency.dart
#	lib/new-ui/widgets/coins_page/assets_history/history_section.dart
#	lib/new-ui/widgets/coins_page/assets_history/transaction_details_modal.dart
#	lib/view_model/bridge/bridge_view_model.dart
#	lib/view_model/dashboard/balance_view_model.dart
#	lib/view_model/exchange/exchange_view_model.dart
…prove balance calculation consistency across view models
…ity and hashCode overrides to `ERC20Currency` for object comparison
…e string handling, and streamline address validation logic
…Balance.fromRawString` for safer balance parsing
…nd remove unused `evm_erc20_currency.dart` file
…timize balance handling in `zano_wallet`, update Breez SDK to v0.14.0, and implement equality/hashCode for `Currency`
… `Image.asset` with `CakeImageWidget` in swap address modal
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