Enable exchange for haven wallets. (#495)
mkyq committed
Sep 1, 2022 at 19:46 UTC
04be884357bd8a2e71a415a082295fbbff2ef20b
5 files changed
+14
-23
lib/exchange/changenow/changenow_exchange_provider.dart
+2
@@ -19,7 +19,9 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
19
: _lastUsedRateId = '',
20
super(
21
pairList: CryptoCurrency.all
22
+ .where((i) => i != CryptoCurrency.xhv)
23
.map((i) => CryptoCurrency.all
24
+ .where((i) => i != CryptoCurrency.xhv)
25
.map((k) => ExchangePair(from: i, to: k, reverse: true))
26
.where((c) => c != null))
27
.expand((i) => i)
lib/exchange/sideshift/sideshift_exchange_provider.dart
+2
@@ -19,7 +19,9 @@ class SideShiftExchangeProvider extends ExchangeProvider {
19
SideShiftExchangeProvider()
20
: super(
21
pairList: CryptoCurrency.all
22
+ .where((i) => i != CryptoCurrency.xhv)
23
.map((i) => CryptoCurrency.all
24
+ .where((i) => i != CryptoCurrency.xhv)
25
.map((k) => ExchangePair(from: i, to: k, reverse: true))
26
.where((c) => c != null))
27
.expand((i) => i)
lib/src/screens/dashboard/dashboard_page.dart
+1
-17
@@ -314,22 +314,6 @@ class DashboardPage extends BasePage {
314
}
315
316
Future<void> _onClickExchangeButton(BuildContext context) async {
317
- final walletType = walletViewModel.type;
318
-
319
- switch (walletType) {
320
- case WalletType.haven:
321
- await showPopUp<void>(
322
- context: context,
323
- builder: (BuildContext context) {
324
- return AlertWithOneAction(
325
- alertTitle: 'Exchange',
326
- alertContent: 'Exchange for this asset is not supported yet.',
327
- buttonText: S.of(context).ok,
328
- buttonAction: () => Navigator.of(context).pop());
329
- });
330
- break;
331
- default:
332
- await Navigator.of(context).pushNamed(Routes.exchange);
333
- }
317
+ await Navigator.of(context).pushNamed(Routes.exchange);
318
}
319
}
lib/view_model/dashboard/dashboard_view_model.dart
+1
-1
@@ -337,7 +337,7 @@ abstract class DashboardViewModelBase with Store {
337
}
338
339
void updateActions() {
340
- isEnabledExchangeAction = wallet.type != WalletType.haven;
340
+ isEnabledExchangeAction = true;
341
hasExchangeAction = !isHaven;
342
isEnabledBuyAction = wallet.type != WalletType.haven
343
&& wallet.type != WalletType.monero;
lib/view_model/exchange/exchange_view_model.dart
+8
-5
@@ -40,10 +40,10 @@ class ExchangeViewModel = ExchangeViewModelBase with _$ExchangeViewModel;
40
abstract class ExchangeViewModelBase with Store {
41
ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore,
42
this.tradesStore, this._settingsStore, this.sharedPreferences) {
43
- const excludeDepositCurrencies = [CryptoCurrency.xhv];
44
- const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp, CryptoCurrency.bnb, CryptoCurrency.xhv];
43
+ const excludeDepositCurrencies = <CryptoCurrency>[];
44
+ const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp, CryptoCurrency.bnb];
45
providerList = [ChangeNowExchangeProvider(), SideShiftExchangeProvider(), SimpleSwapExchangeProvider()];
46
-
46
+ _initialPairBasedOnWallet();
47
currentTradeAvailableProviders = SplayTreeMap<double, ExchangeProvider>();
48
49
final Map<String, dynamic> exchangeProvidersSelection = json
@@ -51,13 +51,12 @@ abstract class ExchangeViewModelBase with Store {
51
52
/// if the provider is not in the user settings (user's first time or newly added provider)
53
/// then use its default value decided by us
54
- selectedProviders = ObservableList.of(providerList.where(
54
+ selectedProviders = ObservableList.of(providersForCurrentPair().where(
55
(element) => exchangeProvidersSelection[element.title] == null
56
? element.isEnabled
57
: (exchangeProvidersSelection[element.title] as bool))
58
.toList());
59
60
- _initialPairBasedOnWallet();
60
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
61
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
62
depositAmount = '';
@@ -532,6 +531,10 @@ abstract class ExchangeViewModelBase with Store {
531
depositCurrency = CryptoCurrency.ltc;
532
receiveCurrency = CryptoCurrency.xmr;
533
break;
534
+ case WalletType.haven:
535
+ depositCurrency = CryptoCurrency.xhv;
536
+ receiveCurrency = CryptoCurrency.btc;
537
+ break;
538
default:
539
break;
540
}