* hv
* Change build version
This commit is contained in:
mkyq
2022-03-30 17:57:04 +02:00
committed by GitHub
parent e7e419bc83
commit 01150ef2a7
213 changed files with 23972 additions and 672 deletions
+18 -5
View File
@@ -2,7 +2,9 @@ import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/calculate_fiat_amount_raw.dart';
import 'package:cake_wallet/entities/parse_address_from_domain.dart';
import 'package:cake_wallet/entities/parsed_address.dart';
import 'package:cake_wallet/haven/haven.dart';
import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:mobx/mobx.dart';
@@ -22,7 +24,7 @@ const String cryptoNumberPattern = '0.0';
class Output = OutputBase with _$Output;
abstract class OutputBase with Store {
OutputBase(this._wallet, this._settingsStore, this._fiatConversationStore)
OutputBase(this._wallet, this._settingsStore, this._fiatConversationStore, this.cryptoCurrencyHandler)
: _cryptoNumberFormat = NumberFormat(cryptoNumberPattern) {
reset();
_setCryptoNumMaximumFractionDigits();
@@ -77,6 +79,9 @@ abstract class OutputBase with Store {
_amount =
bitcoin.formatterStringDoubleToBitcoinAmount(_cryptoAmount);
break;
case WalletType.haven:
_amount = haven.formatterMoneroParseAmount(amount: _cryptoAmount);
break;
default:
break;
}
@@ -106,6 +111,10 @@ abstract class OutputBase with Store {
if (_wallet.type == WalletType.monero) {
return monero.formatterMoneroAmountToDouble(amount: fee);
}
if (_wallet.type == WalletType.haven) {
return haven.formatterMoneroAmountToDouble(amount: fee);
}
} catch (e) {
print(e.toString());
}
@@ -117,7 +126,7 @@ abstract class OutputBase with Store {
String get estimatedFeeFiatAmount {
try {
final fiat = calculateFiatAmountRaw(
price: _fiatConversationStore.prices[_wallet.currency],
price: _fiatConversationStore.prices[cryptoCurrencyHandler()],
cryptoAmount: estimatedFee);
return fiat;
} catch (_) {
@@ -126,6 +135,7 @@ abstract class OutputBase with Store {
}
WalletType get walletType => _wallet.type;
final CryptoCurrency Function() cryptoCurrencyHandler;
final WalletBase _wallet;
final SettingsStore _settingsStore;
final FiatConversionStore _fiatConversationStore;
@@ -169,7 +179,7 @@ abstract class OutputBase with Store {
void _updateFiatAmount() {
try {
final fiat = calculateFiatAmount(
price: _fiatConversationStore.prices[_wallet.currency],
price: _fiatConversationStore.prices[cryptoCurrencyHandler()],
cryptoAmount: cryptoAmount.replaceAll(',', '.'));
if (fiatAmount != fiat) {
fiatAmount = fiat;
@@ -183,7 +193,7 @@ abstract class OutputBase with Store {
void _updateCryptoAmount() {
try {
final crypto = double.parse(fiatAmount.replaceAll(',', '.')) /
_fiatConversationStore.prices[_wallet.currency];
_fiatConversationStore.prices[cryptoCurrencyHandler()];
final cryptoAmountTmp = _cryptoNumberFormat.format(crypto);
if (cryptoAmount != cryptoAmountTmp) {
@@ -207,6 +217,9 @@ abstract class OutputBase with Store {
case WalletType.litecoin:
maximumFractionDigits = 8;
break;
case WalletType.haven:
maximumFractionDigits = 12;
break;
default:
break;
}
@@ -216,7 +229,7 @@ abstract class OutputBase with Store {
Future<void> fetchParsedAddress(BuildContext context) async {
final domain = address;
final ticker = _wallet.currency.title.toLowerCase();
final ticker = cryptoCurrencyHandler().title.toLowerCase();
parsedAddress = await getIt.get<AddressResolver>().resolve(domain, ticker);
extractedAddress = await extractAddressFromParsed(context, parsedAddress);
note = parsedAddress.description;
@@ -21,7 +21,7 @@ abstract class SendTemplateViewModelBase with Store {
SendTemplateViewModelBase(this._wallet, this._settingsStore,
this._sendTemplateStore, this._fiatConversationStore) {
output = Output(_wallet, _settingsStore, _fiatConversationStore);
output = Output(_wallet, _settingsStore, _fiatConversationStore, () => currency);
}
Output output;
+24 -11
View File
@@ -24,6 +24,7 @@ import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
import 'package:cake_wallet/entities/parsed_address.dart';
import 'package:cake_wallet/bitcoin/bitcoin.dart';
import 'package:cake_wallet/haven/haven.dart';
part 'send_view_model.g.dart';
@@ -39,13 +40,15 @@ abstract class SendViewModelBase with Store {
: state = InitialExecutionState() {
final priority = _settingsStore.priority[_wallet.type];
final priorities = priorityForWalletType(_wallet.type);
selectedCryptoCurrency = _wallet.currency;
currencies = _wallet.balance.keys.toList();
if (!priorityForWalletType(_wallet.type).contains(priority)) {
_settingsStore.priority[_wallet.type] = priorities.first;
}
outputs = ObservableList<Output>()
..add(Output(_wallet, _settingsStore, _fiatConversationStore));
..add(Output(_wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency));
}
@observable
@@ -55,7 +58,7 @@ abstract class SendViewModelBase with Store {
@action
void addOutput() {
outputs.add(Output(_wallet, _settingsStore, _fiatConversationStore));
outputs.add(Output(_wallet, _settingsStore, _fiatConversationStore, () => selectedCryptoCurrency));
}
@action
@@ -79,7 +82,7 @@ abstract class SendViewModelBase with Store {
try {
if (pendingTransaction != null) {
final fiat = calculateFiatAmount(
price: _fiatConversationStore.prices[_wallet.currency],
price: _fiatConversationStore.prices[selectedCryptoCurrency],
cryptoAmount: pendingTransaction.amountFormatted);
return fiat;
} else {
@@ -95,7 +98,7 @@ abstract class SendViewModelBase with Store {
try {
if (pendingTransaction != null) {
final fiat = calculateFiatAmount(
price: _fiatConversationStore.prices[_wallet.currency],
price: _fiatConversationStore.prices[selectedCryptoCurrency],
cryptoAmount: pendingTransaction.feeFormatted);
return fiat;
} else {
@@ -117,7 +120,7 @@ abstract class SendViewModelBase with Store {
Validator get allAmountValidator => AllAmountValidator();
Validator get addressValidator => AddressValidator(type: _wallet.currency);
Validator get addressValidator => AddressValidator(type: selectedCryptoCurrency);
Validator get textValidator => TextValidator();
@@ -125,12 +128,7 @@ abstract class SendViewModelBase with Store {
PendingTransaction pendingTransaction;
@computed
String get balance {
if(_settingsStore.balanceDisplayMode == BalanceDisplayMode.hiddenBalance){
return '---';
}
return _wallet.balance.formattedAvailableBalance ?? '0.0' ;
}
String get balance => _wallet.balance[selectedCryptoCurrency].formattedAvailableBalance ?? '0.0';
@computed
bool get isReadyForSend => _wallet.syncStatus is SyncedSyncStatus;
@@ -144,11 +142,21 @@ abstract class SendViewModelBase with Store {
bool get isElectrumWallet =>
_wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin;
@observable
CryptoCurrency selectedCryptoCurrency;
List<CryptoCurrency> currencies;
bool get hasMultiRecipient => _wallet.type != WalletType.haven;
bool get hasYat => outputs.any((out) =>
out.isParsedAddress &&
out.parsedAddress.parseFrom == ParseFrom.yatRecord);
WalletType get walletType => _wallet.type;
bool get hasCurrecyChanger => walletType == WalletType.haven;
final WalletBase _wallet;
final SettingsStore _settingsStore;
final SendTemplateViewModel sendTemplateViewModel;
@@ -221,6 +229,11 @@ abstract class SendViewModelBase with Store {
return monero.createMoneroTransactionCreationCredentials(
outputs: outputs, priority: priority);
case WalletType.haven:
final priority = _settingsStore.priority[_wallet.type];
return haven.createHavenTransactionCreationCredentials(
outputs: outputs, priority: priority, assetType: selectedCryptoCurrency.title);
default:
return null;
}