Pay Anything Flow Enhancements (#2564)

* fix: update Bitcoin and Litecoin Bech32 address patterns for improved detection for pay anything flow

* feat: add Litecoin MWEB address detection patterns for pay anything flow

* feat: Add support for ERC-681 payment scheme to QR and link to exchange send from external QR

* feat: Introduce TokenUtilities to centralize token management across viewmodels

- Added TokenUtilities class to centralize token-related operations for EVM, Solana, and Tron tokens.
- Refactored existing methods in ExchangeTradeViewModel and SendViewModel to utilize TokenUtilities.
- Updated PaymentRequest to include contractAddress.
- Enhanced payment QR scanning to fetch token details for QRs with contract addresses - ERC-681 QR scheme

* fix: Prefill amount with other data when app is brought up via payment deeplink on QR scan

* fix: Reduce trade not created errors WIP

* feat: Add exchange provider logging functionality

* feat: Enhance ERC681URI with amount normalization, prevents parsing issues with various input formats for amounts

* - Use regex from address validator for btc/ltc manual checks
- Add check for solana addresses
- Handle failures in normalizeToInteger method
- fix issue with address only being added when there's an amount

* feat: Trigger pay anything flow when address is pasted via ctrl v or paste input

* fix: remove duplicate registration

* fix: disable text selection in SendCard address field

* feat: Prevent swap option from showing for Mweb and Silent Payment addresses in Pay Anything flow

* refactor: remove notes widget and controllers from swap confirmation bottomsheet

* fix: Issue with tap send all button not responsive, and updateing fiat amount, after wallet syncing is complete if it was previously tapped while wallet was syncing

* fix: Resolve excessive decimal places error with input sanitization and formatting for amount entry

* fix: Add check for already usable amount format to prevent errors with Nano QR scanning

* fix: Improve fiat input handling by preventing unnecessary updates during user input

* fix: Handle potential null case for setReceiveAmountFromFiat

* Update lib/src/widgets/bottom_sheet/payment_confirmation_bottom_sheet.dart

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
David Adegoke
2025-10-11 04:20:09 +03:00
committed by GitHub
co-authored by Omar Hatem
parent a56ae8e4ab
commit 025fc9154c
7 changed files with 179 additions and 55 deletions
@@ -43,6 +43,7 @@ import 'package:cake_wallet/utils/token_utilities.dart';
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:cake_wallet/view_model/send/fees_view_model.dart';
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_list_view_model.dart';
import 'package:cw_core/crypto_amount_format.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/erc20_token.dart';
import 'package:cw_core/spl_token.dart';
@@ -452,10 +453,13 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
@action
void setReceiveAmountFromFiat({required String fiatAmount}) {
final _enteredAmount = double.tryParse(fiatAmount.replaceAll(',', '.')) ?? 0.0;
final crypto = _enteredAmount / fiatConversionStore.prices[receiveCurrency]!;
final price = fiatConversionStore.prices[receiveCurrency];
if (price == null || price == 0.0) return;
final crypto = _enteredAmount / price;
final receiveAmountTmp = _cryptoNumberFormat.format(crypto);
if (receiveAmount != receiveAmountTmp) {
changeReceiveAmount(amount: receiveAmountTmp);
changeReceiveAmount(amount: receiveAmountTmp.withMaxDecimals(receiveCurrency.decimals));
}
}
+1
View File
@@ -241,6 +241,7 @@ abstract class OutputBase with Store {
void setSendAll(String fullBalance) {
cryptoFullBalance = fullBalance;
sendAll = true;
_updateFiatAmount();
}
@action