mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
* 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>
76 lines
2.1 KiB
Dart
76 lines
2.1 KiB
Dart
import 'package:cake_wallet/core/payment_uris.dart';
|
|
import 'package:cake_wallet/nano/nano.dart';
|
|
|
|
class PaymentRequest {
|
|
PaymentRequest(this.address, this.amount, this.note, this.scheme, this.pjUri,
|
|
{this.callbackUrl, this.callbackMessage, this.contractAddress});
|
|
|
|
factory PaymentRequest.fromUri(Uri? uri) {
|
|
var address = "";
|
|
var amount = "";
|
|
var note = "";
|
|
var scheme = "";
|
|
String? walletType;
|
|
String? callbackUrl;
|
|
String? callbackMessage;
|
|
String? pjUri;
|
|
String? contractAddress;
|
|
|
|
if (uri != null) {
|
|
if (uri.queryParameters['pj'] != null) {
|
|
pjUri = uri.toString();
|
|
}
|
|
|
|
address = uri.queryParameters['address'] ?? uri.path;
|
|
amount = uri.queryParameters['tx_amount'] ?? uri.queryParameters['amount'] ?? "";
|
|
note = uri.queryParameters['tx_description'] ?? uri.queryParameters['message'] ?? "";
|
|
scheme = uri.scheme;
|
|
callbackUrl = uri.queryParameters['callback'];
|
|
callbackMessage = uri.queryParameters['callbackMessage'];
|
|
walletType = uri.queryParameters['type'];
|
|
|
|
if (scheme == "ethereum") {
|
|
final paymentUri = ERC681URI.fromUri(uri);
|
|
|
|
address = paymentUri.address;
|
|
amount = paymentUri.amount;
|
|
contractAddress = paymentUri.contractAddress;
|
|
}
|
|
}
|
|
|
|
if (scheme == "nano-gpt") {
|
|
scheme = walletType ?? "nano";
|
|
}
|
|
|
|
if (nano != null) {
|
|
if (amount.isNotEmpty) {
|
|
if (address.contains("nano")) {
|
|
amount = nanoUtil!.getRawAsUsableString(amount, nanoUtil!.rawPerNano);
|
|
} else if (address.contains("ban")) {
|
|
amount = nanoUtil!.getRawAsUsableString(amount, nanoUtil!.rawPerBanano);
|
|
}
|
|
}
|
|
}
|
|
|
|
return PaymentRequest(
|
|
address,
|
|
amount,
|
|
note,
|
|
scheme,
|
|
pjUri,
|
|
callbackUrl: callbackUrl,
|
|
callbackMessage: callbackMessage,
|
|
contractAddress: contractAddress,
|
|
);
|
|
}
|
|
|
|
final String address;
|
|
final String amount;
|
|
final String note;
|
|
final String scheme;
|
|
final String? pjUri;
|
|
final String? callbackUrl;
|
|
final String? callbackMessage;
|
|
final String? contractAddress;
|
|
}
|