2021-01-05 18:31:03 +00:00
|
|
|
import 'package:cake_wallet/bitcoin/bitcoin_amount_format.dart';
|
2021-01-27 13:51:51 +00:00
|
|
|
import 'package:cake_wallet/bitcoin/bitcoin_transaction_priority.dart';
|
2021-01-05 18:31:03 +00:00
|
|
|
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
2020-07-31 15:29:21 +00:00
|
|
|
import 'package:cake_wallet/core/wallet_base.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/crypto_currency.dart';
|
2020-11-02 11:33:45 +00:00
|
|
|
import 'package:cake_wallet/entities/sync_status.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/wallet_type.dart';
|
|
|
|
import 'package:cake_wallet/exchange/exchange_provider.dart';
|
|
|
|
import 'package:cake_wallet/exchange/limits.dart';
|
|
|
|
import 'package:cake_wallet/exchange/trade.dart';
|
|
|
|
import 'package:cake_wallet/exchange/limits_state.dart';
|
2020-08-26 17:31:23 +00:00
|
|
|
import 'package:cake_wallet/store/dashboard/trades_store.dart';
|
2021-01-05 18:31:03 +00:00
|
|
|
import 'package:cake_wallet/store/settings_store.dart';
|
2020-07-31 15:29:21 +00:00
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
|
|
import 'package:hive/hive.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/exchange/exchange_trade_state.dart';
|
|
|
|
import 'package:cake_wallet/exchange/changenow/changenow_exchange_provider.dart';
|
|
|
|
import 'package:cake_wallet/exchange/changenow/changenow_request.dart';
|
|
|
|
import 'package:cake_wallet/exchange/trade_request.dart';
|
|
|
|
import 'package:cake_wallet/exchange/xmrto/xmrto_exchange_provider.dart';
|
|
|
|
import 'package:cake_wallet/exchange/xmrto/xmrto_trade_request.dart';
|
|
|
|
import 'package:cake_wallet/exchange/morphtoken/morphtoken_exchange_provider.dart';
|
|
|
|
import 'package:cake_wallet/exchange/morphtoken/morphtoken_request.dart';
|
2020-07-31 15:29:21 +00:00
|
|
|
import 'package:cake_wallet/store/templates/exchange_template_store.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/exchange/exchange_template.dart';
|
2020-07-31 15:29:21 +00:00
|
|
|
|
|
|
|
part 'exchange_view_model.g.dart';
|
|
|
|
|
|
|
|
class ExchangeViewModel = ExchangeViewModelBase with _$ExchangeViewModel;
|
|
|
|
|
|
|
|
abstract class ExchangeViewModelBase with Store {
|
2021-01-05 18:31:03 +00:00
|
|
|
ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore,
|
|
|
|
this.tradesStore, this._settingsStore) {
|
2021-05-10 16:51:13 +00:00
|
|
|
const excludeCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp, CryptoCurrency.bnb];
|
2021-05-07 07:36:38 +00:00
|
|
|
providerList = [ChangeNowExchangeProvider()];
|
2020-09-02 08:47:41 +00:00
|
|
|
_initialPairBasedOnWallet();
|
2020-07-31 15:29:21 +00:00
|
|
|
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
|
|
|
|
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
|
|
|
|
depositAmount = '';
|
|
|
|
receiveAmount = '';
|
|
|
|
receiveAddress = '';
|
2020-11-10 14:58:40 +00:00
|
|
|
depositAddress = depositCurrency == wallet.currency ? wallet.address : '';
|
2020-07-31 15:29:21 +00:00
|
|
|
limitsState = LimitsInitialState();
|
|
|
|
tradeState = ExchangeTradeStateInitial();
|
|
|
|
_cryptoNumberFormat = NumberFormat()..maximumFractionDigits = 12;
|
2020-09-02 08:47:41 +00:00
|
|
|
provider = providersForCurrentPair().first;
|
2020-11-10 14:58:40 +00:00
|
|
|
final initialProvider = provider;
|
|
|
|
provider.checkIsAvailable().then((bool isAvailable) {
|
|
|
|
if (!isAvailable && provider == initialProvider) {
|
|
|
|
provider = providerList.firstWhere(
|
|
|
|
(provider) => provider is ChangeNowExchangeProvider,
|
|
|
|
orElse: () => providerList.last);
|
|
|
|
_onPairChange();
|
|
|
|
}
|
|
|
|
});
|
2021-05-07 07:36:38 +00:00
|
|
|
receiveCurrencies = CryptoCurrency.all
|
2021-05-10 16:51:13 +00:00
|
|
|
.where((cryptoCurrency) => !excludeCurrencies.contains(cryptoCurrency))
|
|
|
|
.toList();
|
2021-02-23 17:36:03 +00:00
|
|
|
_defineIsReceiveAmountEditable();
|
2021-02-16 19:06:23 +00:00
|
|
|
isFixedRateMode = false;
|
2020-09-25 19:55:41 +00:00
|
|
|
isReceiveAmountEntered = false;
|
2020-07-31 15:29:21 +00:00
|
|
|
loadLimits();
|
|
|
|
}
|
|
|
|
|
|
|
|
final WalletBase wallet;
|
|
|
|
final Box<Trade> trades;
|
2020-10-07 05:58:22 +00:00
|
|
|
final ExchangeTemplateStore _exchangeTemplateStore;
|
2020-08-26 17:31:23 +00:00
|
|
|
final TradesStore tradesStore;
|
2020-07-31 15:29:21 +00:00
|
|
|
|
|
|
|
@observable
|
|
|
|
ExchangeProvider provider;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
List<ExchangeProvider> providerList;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
CryptoCurrency depositCurrency;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
CryptoCurrency receiveCurrency;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
LimitsState limitsState;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
ExchangeTradeState tradeState;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
String depositAmount;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
String receiveAmount;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
String depositAddress;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
String receiveAddress;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool isDepositAddressEnabled;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool isReceiveAddressEnabled;
|
|
|
|
|
2020-10-12 16:47:01 +00:00
|
|
|
@observable
|
2020-09-25 19:55:41 +00:00
|
|
|
bool isReceiveAmountEntered;
|
|
|
|
|
2021-02-16 19:06:23 +00:00
|
|
|
@observable
|
|
|
|
bool isReceiveAmountEditable;
|
|
|
|
|
|
|
|
@observable
|
|
|
|
bool isFixedRateMode;
|
|
|
|
|
2020-11-02 11:33:45 +00:00
|
|
|
@computed
|
|
|
|
SyncStatus get status => wallet.syncStatus;
|
|
|
|
|
2020-07-31 15:29:21 +00:00
|
|
|
@computed
|
|
|
|
ObservableList<ExchangeTemplate> get templates =>
|
2020-10-07 05:58:22 +00:00
|
|
|
_exchangeTemplateStore.templates;
|
2020-07-31 15:29:21 +00:00
|
|
|
|
2021-01-05 18:31:03 +00:00
|
|
|
bool get hasAllAmount =>
|
|
|
|
wallet.type == WalletType.bitcoin && depositCurrency == wallet.currency;
|
|
|
|
|
2021-04-06 17:11:26 +00:00
|
|
|
List<CryptoCurrency> receiveCurrencies;
|
|
|
|
|
2021-01-05 18:31:03 +00:00
|
|
|
Limits limits;
|
|
|
|
|
|
|
|
NumberFormat _cryptoNumberFormat;
|
|
|
|
|
|
|
|
SettingsStore _settingsStore;
|
|
|
|
|
2020-07-31 15:29:21 +00:00
|
|
|
@action
|
|
|
|
void changeProvider({ExchangeProvider provider}) {
|
|
|
|
this.provider = provider;
|
|
|
|
depositAmount = '';
|
|
|
|
receiveAmount = '';
|
2021-02-18 19:08:52 +00:00
|
|
|
isFixedRateMode = false;
|
2021-02-23 17:36:03 +00:00
|
|
|
_defineIsReceiveAmountEditable();
|
2020-07-31 15:29:21 +00:00
|
|
|
loadLimits();
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
void changeDepositCurrency({CryptoCurrency currency}) {
|
|
|
|
depositCurrency = currency;
|
2021-02-18 19:08:52 +00:00
|
|
|
isFixedRateMode = false;
|
2020-07-31 15:29:21 +00:00
|
|
|
_onPairChange();
|
|
|
|
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
|
|
|
|
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
void changeReceiveCurrency({CryptoCurrency currency}) {
|
|
|
|
receiveCurrency = currency;
|
2021-02-18 19:08:52 +00:00
|
|
|
isFixedRateMode = false;
|
2020-07-31 15:29:21 +00:00
|
|
|
_onPairChange();
|
|
|
|
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
|
|
|
|
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
void changeReceiveAmount({String amount}) {
|
|
|
|
receiveAmount = amount;
|
|
|
|
|
|
|
|
if (amount == null || amount.isEmpty) {
|
|
|
|
depositAmount = '';
|
|
|
|
receiveAmount = '';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-24 12:55:24 +00:00
|
|
|
final _amount = double.parse(amount.replaceAll(',', '.')) ?? 0;
|
2020-07-31 15:29:21 +00:00
|
|
|
|
|
|
|
provider
|
|
|
|
.calculateAmount(
|
2021-02-16 19:06:23 +00:00
|
|
|
from: receiveCurrency,
|
|
|
|
to: depositCurrency,
|
2020-11-10 14:58:40 +00:00
|
|
|
amount: _amount,
|
2021-02-18 19:08:52 +00:00
|
|
|
isFixedRateMode: isFixedRateMode,
|
2020-09-25 19:55:41 +00:00
|
|
|
isReceiveAmount: true)
|
2020-09-02 08:47:41 +00:00
|
|
|
.then((amount) => _cryptoNumberFormat
|
|
|
|
.format(amount)
|
|
|
|
.toString()
|
|
|
|
.replaceAll(RegExp('\\,'), ''))
|
2020-07-31 15:29:21 +00:00
|
|
|
.then((amount) => depositAmount = amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
void changeDepositAmount({String amount}) {
|
|
|
|
depositAmount = amount;
|
|
|
|
|
|
|
|
if (amount == null || amount.isEmpty) {
|
|
|
|
depositAmount = '';
|
|
|
|
receiveAmount = '';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-24 12:42:26 +00:00
|
|
|
final _amount = double.parse(amount.replaceAll(',', '.')) ?? 0;
|
2020-07-31 15:29:21 +00:00
|
|
|
provider
|
|
|
|
.calculateAmount(
|
2020-11-10 14:58:40 +00:00
|
|
|
from: depositCurrency,
|
|
|
|
to: receiveCurrency,
|
|
|
|
amount: _amount,
|
2021-02-18 19:08:52 +00:00
|
|
|
isFixedRateMode: isFixedRateMode,
|
2020-09-25 19:55:41 +00:00
|
|
|
isReceiveAmount: false)
|
2020-09-02 08:47:41 +00:00
|
|
|
.then((amount) => _cryptoNumberFormat
|
|
|
|
.format(amount)
|
|
|
|
.toString()
|
|
|
|
.replaceAll(RegExp('\\,'), ''))
|
2020-07-31 15:29:21 +00:00
|
|
|
.then((amount) => receiveAmount = amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
Future loadLimits() async {
|
|
|
|
limitsState = LimitsIsLoading();
|
|
|
|
|
|
|
|
try {
|
2021-05-07 07:36:38 +00:00
|
|
|
limits = await provider.fetchLimits(
|
|
|
|
from: depositCurrency,
|
|
|
|
to: receiveCurrency,
|
|
|
|
isFixedRateMode: isFixedRateMode);
|
2020-07-31 15:29:21 +00:00
|
|
|
limitsState = LimitsLoadedSuccessfully(limits: limits);
|
|
|
|
} catch (e) {
|
|
|
|
limitsState = LimitsLoadedFailure(error: e.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
Future createTrade() async {
|
|
|
|
TradeRequest request;
|
|
|
|
String amount;
|
|
|
|
CryptoCurrency currency;
|
|
|
|
|
|
|
|
if (provider is XMRTOExchangeProvider) {
|
|
|
|
request = XMRTOTradeRequest(
|
|
|
|
from: depositCurrency,
|
|
|
|
to: receiveCurrency,
|
2020-11-10 11:46:58 +00:00
|
|
|
amount: depositAmount?.replaceAll(',', '.'),
|
|
|
|
receiveAmount: receiveAmount?.replaceAll(',', '.'),
|
2020-07-31 15:29:21 +00:00
|
|
|
address: receiveAddress,
|
2020-09-25 19:55:41 +00:00
|
|
|
refundAddress: depositAddress,
|
|
|
|
isBTCRequest: isReceiveAmountEntered);
|
2020-07-31 15:29:21 +00:00
|
|
|
amount = depositAmount;
|
|
|
|
currency = depositCurrency;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (provider is ChangeNowExchangeProvider) {
|
|
|
|
request = ChangeNowRequest(
|
|
|
|
from: depositCurrency,
|
|
|
|
to: receiveCurrency,
|
2020-11-10 11:46:58 +00:00
|
|
|
amount: depositAmount?.replaceAll(',', '.'),
|
2020-07-31 15:29:21 +00:00
|
|
|
refundAddress: depositAddress,
|
|
|
|
address: receiveAddress);
|
|
|
|
amount = depositAmount;
|
|
|
|
currency = depositCurrency;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (provider is MorphTokenExchangeProvider) {
|
|
|
|
request = MorphTokenRequest(
|
|
|
|
from: depositCurrency,
|
|
|
|
to: receiveCurrency,
|
2020-11-10 11:46:58 +00:00
|
|
|
amount: depositAmount?.replaceAll(',', '.'),
|
2020-07-31 15:29:21 +00:00
|
|
|
refundAddress: depositAddress,
|
|
|
|
address: receiveAddress);
|
|
|
|
amount = depositAmount;
|
|
|
|
currency = depositCurrency;
|
|
|
|
}
|
|
|
|
|
2020-10-30 10:39:07 +00:00
|
|
|
amount = amount.replaceAll(',', '.');
|
|
|
|
|
2020-07-31 15:29:21 +00:00
|
|
|
if (limitsState is LimitsLoadedSuccessfully && amount != null) {
|
|
|
|
if (double.parse(amount) < limits.min) {
|
2020-09-02 08:47:41 +00:00
|
|
|
tradeState = TradeIsCreatedFailure(
|
2020-12-02 19:51:06 +00:00
|
|
|
title: provider.title,
|
2020-09-02 08:47:41 +00:00
|
|
|
error: S.current.error_text_minimal_limit('${provider.description}',
|
|
|
|
'${limits.min}', currency.toString()));
|
2020-07-31 15:29:21 +00:00
|
|
|
} else if (limits.max != null && double.parse(amount) > limits.max) {
|
2020-09-02 08:47:41 +00:00
|
|
|
tradeState = TradeIsCreatedFailure(
|
2020-12-02 19:51:06 +00:00
|
|
|
title: provider.title,
|
2020-09-02 08:47:41 +00:00
|
|
|
error: S.current.error_text_maximum_limit('${provider.description}',
|
|
|
|
'${limits.max}', currency.toString()));
|
2020-07-31 15:29:21 +00:00
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
tradeState = TradeIsCreating();
|
2021-05-07 07:36:38 +00:00
|
|
|
final trade = await provider.createTrade(
|
|
|
|
request: request, isFixedRateMode: isFixedRateMode);
|
2020-07-31 15:29:21 +00:00
|
|
|
trade.walletId = wallet.id;
|
2020-08-26 17:31:23 +00:00
|
|
|
tradesStore.setTrade(trade);
|
2020-07-31 15:29:21 +00:00
|
|
|
await trades.add(trade);
|
|
|
|
tradeState = TradeIsCreatedSuccessfully(trade: trade);
|
|
|
|
} catch (e) {
|
2021-01-05 18:31:03 +00:00
|
|
|
tradeState =
|
|
|
|
TradeIsCreatedFailure(title: provider.title, error: e.toString());
|
2020-07-31 15:29:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2020-09-02 08:47:41 +00:00
|
|
|
tradeState = TradeIsCreatedFailure(
|
2020-12-02 19:51:06 +00:00
|
|
|
title: provider.title,
|
2020-09-02 08:47:41 +00:00
|
|
|
error: S.current
|
|
|
|
.error_text_limits_loading_failed('${provider.description}'));
|
2020-07-31 15:29:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
void reset() {
|
2021-02-19 08:37:30 +00:00
|
|
|
_initialPairBasedOnWallet();
|
2020-10-12 16:47:01 +00:00
|
|
|
isReceiveAmountEntered = false;
|
2020-07-31 15:29:21 +00:00
|
|
|
depositAmount = '';
|
|
|
|
receiveAmount = '';
|
|
|
|
depositAddress = depositCurrency == wallet.currency ? wallet.address : '';
|
|
|
|
receiveAddress = receiveCurrency == wallet.currency ? wallet.address : '';
|
|
|
|
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
|
|
|
|
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
|
2021-02-18 19:08:52 +00:00
|
|
|
isFixedRateMode = false;
|
2020-07-31 15:29:21 +00:00
|
|
|
_onPairChange();
|
|
|
|
}
|
|
|
|
|
2021-01-05 18:31:03 +00:00
|
|
|
@action
|
|
|
|
void calculateDepositAllAmount() {
|
|
|
|
if (wallet is BitcoinWallet) {
|
2021-01-11 17:15:27 +00:00
|
|
|
final availableBalance = wallet.balance.available;
|
2021-05-07 07:36:38 +00:00
|
|
|
final priority =
|
|
|
|
_settingsStore.priority[wallet.type] as BitcoinTransactionPriority;
|
2021-01-27 13:51:51 +00:00
|
|
|
final fee = wallet.calculateEstimatedFee(priority, null);
|
2021-01-05 18:31:03 +00:00
|
|
|
|
|
|
|
if (availableBalance < fee || availableBalance == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
final amount = availableBalance - fee;
|
2021-01-06 20:53:59 +00:00
|
|
|
changeDepositAmount(amount: bitcoinAmountToString(amount: amount));
|
2021-01-05 18:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 05:58:22 +00:00
|
|
|
void updateTemplate() => _exchangeTemplateStore.update();
|
|
|
|
|
2020-11-10 14:58:40 +00:00
|
|
|
void addTemplate(
|
|
|
|
{String amount,
|
|
|
|
String depositCurrency,
|
|
|
|
String receiveCurrency,
|
|
|
|
String provider,
|
|
|
|
String depositAddress,
|
|
|
|
String receiveAddress}) =>
|
|
|
|
_exchangeTemplateStore.addTemplate(
|
|
|
|
amount: amount,
|
|
|
|
depositCurrency: depositCurrency,
|
|
|
|
receiveCurrency: receiveCurrency,
|
|
|
|
provider: provider,
|
|
|
|
depositAddress: depositAddress,
|
|
|
|
receiveAddress: receiveAddress);
|
2020-10-07 05:58:22 +00:00
|
|
|
|
|
|
|
void removeTemplate({ExchangeTemplate template}) =>
|
2020-11-10 14:58:40 +00:00
|
|
|
_exchangeTemplateStore.remove(template: template);
|
2020-10-07 05:58:22 +00:00
|
|
|
|
2020-07-31 15:29:21 +00:00
|
|
|
List<ExchangeProvider> providersForCurrentPair() {
|
|
|
|
return _providersForPair(from: depositCurrency, to: receiveCurrency);
|
|
|
|
}
|
|
|
|
|
|
|
|
List<ExchangeProvider> _providersForPair(
|
|
|
|
{CryptoCurrency from, CryptoCurrency to}) {
|
|
|
|
final providers = providerList
|
|
|
|
.where((provider) => provider.pairList
|
2020-09-02 08:47:41 +00:00
|
|
|
.where((pair) =>
|
|
|
|
pair.from == depositCurrency && pair.to == receiveCurrency)
|
|
|
|
.isNotEmpty)
|
2020-07-31 15:29:21 +00:00
|
|
|
.toList();
|
|
|
|
|
|
|
|
return providers;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _onPairChange() {
|
|
|
|
final isPairExist = provider.pairList
|
|
|
|
.where((pair) =>
|
2020-09-02 08:47:41 +00:00
|
|
|
pair.from == depositCurrency && pair.to == receiveCurrency)
|
2020-07-31 15:29:21 +00:00
|
|
|
.isNotEmpty;
|
|
|
|
|
2021-04-01 18:08:11 +00:00
|
|
|
if (isPairExist) {
|
2020-07-31 15:29:21 +00:00
|
|
|
final provider =
|
2020-09-02 08:47:41 +00:00
|
|
|
_providerForPair(from: depositCurrency, to: receiveCurrency);
|
2020-07-31 15:29:21 +00:00
|
|
|
|
|
|
|
if (provider != null) {
|
|
|
|
changeProvider(provider: provider);
|
|
|
|
}
|
2021-04-01 18:08:11 +00:00
|
|
|
} else {
|
|
|
|
depositAmount = '';
|
|
|
|
receiveAmount = '';
|
2020-07-31 15:29:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ExchangeProvider _providerForPair({CryptoCurrency from, CryptoCurrency to}) {
|
|
|
|
final providers = _providersForPair(from: from, to: to);
|
|
|
|
return providers.isNotEmpty ? providers[0] : null;
|
|
|
|
}
|
|
|
|
|
2020-09-02 08:47:41 +00:00
|
|
|
void _initialPairBasedOnWallet() {
|
|
|
|
switch (wallet.type) {
|
|
|
|
case WalletType.monero:
|
|
|
|
depositCurrency = CryptoCurrency.xmr;
|
|
|
|
receiveCurrency = CryptoCurrency.btc;
|
|
|
|
break;
|
|
|
|
case WalletType.bitcoin:
|
|
|
|
depositCurrency = CryptoCurrency.btc;
|
|
|
|
receiveCurrency = CryptoCurrency.xmr;
|
|
|
|
break;
|
2021-05-07 07:36:38 +00:00
|
|
|
case WalletType.litecoin:
|
|
|
|
depositCurrency = CryptoCurrency.ltc;
|
|
|
|
receiveCurrency = CryptoCurrency.xmr;
|
|
|
|
break;
|
2020-09-02 08:47:41 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-02-23 17:36:03 +00:00
|
|
|
|
|
|
|
void _defineIsReceiveAmountEditable() {
|
2021-03-15 17:54:04 +00:00
|
|
|
/*if ((provider is ChangeNowExchangeProvider)
|
2021-02-23 17:36:03 +00:00
|
|
|
&&(depositCurrency == CryptoCurrency.xmr)
|
|
|
|
&&(receiveCurrency == CryptoCurrency.btc)) {
|
|
|
|
isReceiveAmountEditable = true;
|
|
|
|
} else {
|
|
|
|
isReceiveAmountEditable = false;
|
2021-03-15 17:54:04 +00:00
|
|
|
}*/
|
|
|
|
isReceiveAmountEditable = false;
|
2021-02-23 17:36:03 +00:00
|
|
|
}
|
2020-09-02 08:47:41 +00:00
|
|
|
}
|