Merge branch 'main' of https://github.com/cake-tech/cake_wallet into secure_storage_fresh_install

This commit is contained in:
Matthew Fosse 2024-11-05 08:37:13 -08:00
commit 1a9f843c0e
6 changed files with 32 additions and 18 deletions

View file

@ -106,8 +106,7 @@ class AddressValidator extends TextValidator {
case CryptoCurrency.wow: case CryptoCurrency.wow:
pattern = '[0-9a-zA-Z]+'; pattern = '[0-9a-zA-Z]+';
case CryptoCurrency.bch: case CryptoCurrency.bch:
pattern = pattern = '^(bitcoincash:)?(q|p)[0-9a-zA-Z]{41,42}';
'(?!bitcoincash:)[0-9a-zA-Z]*|(?!bitcoincash:)q|p[0-9a-zA-Z]{41}|(?!bitcoincash:)q|p[0-9a-zA-Z]{42}|bitcoincash:q|p[0-9a-zA-Z]{41}|bitcoincash:q|p[0-9a-zA-Z]{42}';
case CryptoCurrency.bnb: case CryptoCurrency.bnb:
pattern = '[0-9a-zA-Z]+'; pattern = '[0-9a-zA-Z]+';
case CryptoCurrency.hbar: case CryptoCurrency.hbar:

View file

@ -141,8 +141,8 @@ class ExolixExchangeProvider extends ExchangeProvider {
'coinTo': _normalizeCurrency(request.toCurrency), 'coinTo': _normalizeCurrency(request.toCurrency),
'networkFrom': _networkFor(request.fromCurrency), 'networkFrom': _networkFor(request.fromCurrency),
'networkTo': _networkFor(request.toCurrency), 'networkTo': _networkFor(request.toCurrency),
'withdrawalAddress': request.toAddress, 'withdrawalAddress': _normalizeAddress(request.toAddress),
'refundAddress': request.refundAddress, 'refundAddress': _normalizeAddress(request.refundAddress),
'rateType': _getRateType(isFixedRateMode), 'rateType': _getRateType(isFixedRateMode),
'apiToken': apiKey, 'apiToken': apiKey,
}; };
@ -275,4 +275,7 @@ class ExolixExchangeProvider extends ExchangeProvider {
return tag; return tag;
} }
} }
String _normalizeAddress(String address) =>
address.startsWith('bitcoincash:') ? address.replaceFirst('bitcoincash:', '') : address;
} }

View file

@ -129,8 +129,8 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
"currency_to": _normalizeCurrency(request.toCurrency), "currency_to": _normalizeCurrency(request.toCurrency),
"amount": request.fromAmount, "amount": request.fromAmount,
"fixed": isFixedRateMode, "fixed": isFixedRateMode,
"user_refund_address": request.refundAddress, "user_refund_address": _normalizeAddress(request.refundAddress),
"address_to": request.toAddress "address_to": _normalizeAddress(request.toAddress)
}; };
final uri = Uri.https(apiAuthority, createExchangePath, params); final uri = Uri.https(apiAuthority, createExchangePath, params);
@ -243,4 +243,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
return currency.title.toLowerCase(); return currency.title.toLowerCase();
} }
} }
String _normalizeAddress(String address) =>
address.startsWith('bitcoincash:') ? address.replaceFirst('bitcoincash:', '') : address;
} }

View file

@ -129,8 +129,8 @@ class StealthExExchangeProvider extends ExchangeProvider {
if (isFixedRateMode) 'rate_id': rateId, if (isFixedRateMode) 'rate_id': rateId,
'amount': 'amount':
isFixedRateMode ? double.parse(request.toAmount) : double.parse(request.fromAmount), isFixedRateMode ? double.parse(request.toAmount) : double.parse(request.fromAmount),
'address': request.toAddress, 'address': _normalizeAddress(request.toAddress),
'refund_address': request.refundAddress, 'refund_address': _normalizeAddress(request.refundAddress),
'additional_fee_percent': _additionalFeePercent, 'additional_fee_percent': _additionalFeePercent,
}; };
@ -296,4 +296,7 @@ class StealthExExchangeProvider extends ExchangeProvider {
return currency.tag!.toLowerCase(); return currency.tag!.toLowerCase();
} }
String _normalizeAddress(String address) =>
address.startsWith('bitcoincash:') ? address.replaceFirst('bitcoincash:', '') : address;
} }

View file

@ -116,9 +116,7 @@ class ThorChainExchangeProvider extends ExchangeProvider {
required bool isFixedRateMode, required bool isFixedRateMode,
required bool isSendAll, required bool isSendAll,
}) async { }) async {
String formattedToAddress = request.toAddress.startsWith('bitcoincash:')
? request.toAddress.replaceFirst('bitcoincash:', '')
: request.toAddress;
final formattedFromAmount = double.parse(request.fromAmount); final formattedFromAmount = double.parse(request.fromAmount);
@ -126,11 +124,11 @@ class ThorChainExchangeProvider extends ExchangeProvider {
'from_asset': _normalizeCurrency(request.fromCurrency), 'from_asset': _normalizeCurrency(request.fromCurrency),
'to_asset': _normalizeCurrency(request.toCurrency), 'to_asset': _normalizeCurrency(request.toCurrency),
'amount': _doubleToThorChainString(formattedFromAmount), 'amount': _doubleToThorChainString(formattedFromAmount),
'destination': formattedToAddress, 'destination': _normalizeAddress(request.toAddress),
'affiliate': _affiliateName, 'affiliate': _affiliateName,
'affiliate_bps': _affiliateBps, 'affiliate_bps': _affiliateBps,
'refund_address': 'refund_address':
isRefundAddressSupported.contains(request.fromCurrency) ? request.refundAddress : '', isRefundAddressSupported.contains(request.fromCurrency) ? _normalizeAddress(request.refundAddress) : '',
}; };
final responseJSON = await _getSwapQuote(params); final responseJSON = await _getSwapQuote(params);
@ -288,4 +286,7 @@ class ThorChainExchangeProvider extends ExchangeProvider {
return currentState; return currentState;
} }
String _normalizeAddress(String address) =>
address.startsWith('bitcoincash:') ? address.replaceFirst('bitcoincash:', '') : address;
} }

View file

@ -99,18 +99,23 @@ abstract class ContactListViewModelBase with Store {
Future<void> delete(ContactRecord contact) async => contact.original.delete(); Future<void> delete(ContactRecord contact) async => contact.original.delete();
@computed ObservableList<ContactRecord> get contactsToShow =>
List<ContactRecord> get contactsToShow => ObservableList.of(contacts.where((element) => _isValidForCurrency(element)));
contacts.where((element) => _isValidForCurrency(element)).toList();
@computed @computed
List<WalletContact> get walletContactsToShow => List<WalletContact> get walletContactsToShow =>
walletContacts.where((element) => _isValidForCurrency(element)).toList(); walletContacts.where((element) => _isValidForCurrency(element)).toList();
bool _isValidForCurrency(ContactBase element) { bool _isValidForCurrency(ContactBase element) {
if (element.name.contains('Silent Payments')) return false;
if (element.name.contains('MWEB')) return false;
return _currency == null || return _currency == null ||
element.type == _currency || element.type == _currency ||
element.type.title == _currency!.tag || (element.type.tag != null &&
element.type.tag == _currency!.tag; _currency?.tag != null &&
element.type.tag == _currency?.tag) ||
_currency?.toString() == element.type.tag ||
_currency?.tag == element.type.toString();
} }
} }