mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-03 12:24:19 +01:00
Pay Anything Enhancements (#2529)
* 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 * wrap in try/catch just in case [skip ci] * Update lib/utils/token_utilities.dart --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Omar Hatem
parent
a84c563f89
commit
c51c2dc105
@@ -0,0 +1,84 @@
|
||||
import 'package:cake_wallet/utils/exchange_provider_logger.dart';
|
||||
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'exchange_provider_logs_view_model.g.dart';
|
||||
|
||||
enum LogFilter { all, success, error }
|
||||
|
||||
class ExchangeProviderLogsViewModel = ExchangeProviderLogsViewModelBase with _$ExchangeProviderLogsViewModel;
|
||||
|
||||
abstract class ExchangeProviderLogsViewModelBase with Store {
|
||||
@observable
|
||||
bool isLoading = false;
|
||||
|
||||
@observable
|
||||
String? error;
|
||||
|
||||
@observable
|
||||
ObservableList<ExchangeProviderLogEntry> logs = ObservableList<ExchangeProviderLogEntry>();
|
||||
|
||||
@observable
|
||||
LogFilter currentFilter = LogFilter.all;
|
||||
|
||||
@computed
|
||||
ObservableList<ExchangeProviderLogEntry> get filteredLogs {
|
||||
switch (currentFilter) {
|
||||
case LogFilter.all:
|
||||
return logs;
|
||||
case LogFilter.success:
|
||||
return ObservableList.of(logs.where((log) => log.isSuccess).toList());
|
||||
case LogFilter.error:
|
||||
return ObservableList.of(logs.where((log) => !log.isSuccess).toList());
|
||||
}
|
||||
}
|
||||
|
||||
@computed
|
||||
int get totalLogs => logs.length;
|
||||
|
||||
@computed
|
||||
int get successLogs => logs.where((log) => log.isSuccess).length;
|
||||
|
||||
@computed
|
||||
int get errorLogs => logs.where((log) => !log.isSuccess).length;
|
||||
|
||||
@computed
|
||||
Map<ExchangeProviderDescription, int> get logsByProvider {
|
||||
final Map<ExchangeProviderDescription, int> counts = {};
|
||||
for (final log in logs) {
|
||||
counts[log.provider] = (counts[log.provider] ?? 0) + 1;
|
||||
}
|
||||
return counts;
|
||||
}
|
||||
|
||||
String getLogsAsText() => ExchangeProviderLogger.getLogsAsText();
|
||||
|
||||
String getLogsAsJson() => ExchangeProviderLogger.getLogsAsJson();
|
||||
|
||||
@action
|
||||
void loadLogs() {
|
||||
isLoading = true;
|
||||
error = null;
|
||||
|
||||
try {
|
||||
logs.clear();
|
||||
logs.addAll(ExchangeProviderLogger.logs);
|
||||
} catch (e) {
|
||||
error = e.toString();
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
void clearLogs() {
|
||||
ExchangeProviderLogger.clearLogs();
|
||||
logs.clear();
|
||||
}
|
||||
|
||||
@action
|
||||
void refreshLogs() => loadLogs();
|
||||
|
||||
@action
|
||||
void setFilter(LogFilter filter) => currentFilter = filter;
|
||||
}
|
||||
Reference in New Issue
Block a user