mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 19:26:27 +00:00
Enable exchange for haven wallets. (#495)
This commit is contained in:
parent
0931696fa1
commit
04be884357
5 changed files with 14 additions and 23 deletions
|
@ -19,7 +19,9 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||||
: _lastUsedRateId = '',
|
: _lastUsedRateId = '',
|
||||||
super(
|
super(
|
||||||
pairList: CryptoCurrency.all
|
pairList: CryptoCurrency.all
|
||||||
|
.where((i) => i != CryptoCurrency.xhv)
|
||||||
.map((i) => CryptoCurrency.all
|
.map((i) => CryptoCurrency.all
|
||||||
|
.where((i) => i != CryptoCurrency.xhv)
|
||||||
.map((k) => ExchangePair(from: i, to: k, reverse: true))
|
.map((k) => ExchangePair(from: i, to: k, reverse: true))
|
||||||
.where((c) => c != null))
|
.where((c) => c != null))
|
||||||
.expand((i) => i)
|
.expand((i) => i)
|
||||||
|
|
|
@ -19,7 +19,9 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
||||||
SideShiftExchangeProvider()
|
SideShiftExchangeProvider()
|
||||||
: super(
|
: super(
|
||||||
pairList: CryptoCurrency.all
|
pairList: CryptoCurrency.all
|
||||||
|
.where((i) => i != CryptoCurrency.xhv)
|
||||||
.map((i) => CryptoCurrency.all
|
.map((i) => CryptoCurrency.all
|
||||||
|
.where((i) => i != CryptoCurrency.xhv)
|
||||||
.map((k) => ExchangePair(from: i, to: k, reverse: true))
|
.map((k) => ExchangePair(from: i, to: k, reverse: true))
|
||||||
.where((c) => c != null))
|
.where((c) => c != null))
|
||||||
.expand((i) => i)
|
.expand((i) => i)
|
||||||
|
|
|
@ -314,22 +314,6 @@ class DashboardPage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _onClickExchangeButton(BuildContext context) async {
|
Future<void> _onClickExchangeButton(BuildContext context) async {
|
||||||
final walletType = walletViewModel.type;
|
await Navigator.of(context).pushNamed(Routes.exchange);
|
||||||
|
|
||||||
switch (walletType) {
|
|
||||||
case WalletType.haven:
|
|
||||||
await showPopUp<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (BuildContext context) {
|
|
||||||
return AlertWithOneAction(
|
|
||||||
alertTitle: 'Exchange',
|
|
||||||
alertContent: 'Exchange for this asset is not supported yet.',
|
|
||||||
buttonText: S.of(context).ok,
|
|
||||||
buttonAction: () => Navigator.of(context).pop());
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
await Navigator.of(context).pushNamed(Routes.exchange);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -337,7 +337,7 @@ abstract class DashboardViewModelBase with Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateActions() {
|
void updateActions() {
|
||||||
isEnabledExchangeAction = wallet.type != WalletType.haven;
|
isEnabledExchangeAction = true;
|
||||||
hasExchangeAction = !isHaven;
|
hasExchangeAction = !isHaven;
|
||||||
isEnabledBuyAction = wallet.type != WalletType.haven
|
isEnabledBuyAction = wallet.type != WalletType.haven
|
||||||
&& wallet.type != WalletType.monero;
|
&& wallet.type != WalletType.monero;
|
||||||
|
|
|
@ -40,10 +40,10 @@ class ExchangeViewModel = ExchangeViewModelBase with _$ExchangeViewModel;
|
||||||
abstract class ExchangeViewModelBase with Store {
|
abstract class ExchangeViewModelBase with Store {
|
||||||
ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore,
|
ExchangeViewModelBase(this.wallet, this.trades, this._exchangeTemplateStore,
|
||||||
this.tradesStore, this._settingsStore, this.sharedPreferences) {
|
this.tradesStore, this._settingsStore, this.sharedPreferences) {
|
||||||
const excludeDepositCurrencies = [CryptoCurrency.xhv];
|
const excludeDepositCurrencies = <CryptoCurrency>[];
|
||||||
const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp, CryptoCurrency.bnb, CryptoCurrency.xhv];
|
const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp, CryptoCurrency.bnb];
|
||||||
providerList = [ChangeNowExchangeProvider(), SideShiftExchangeProvider(), SimpleSwapExchangeProvider()];
|
providerList = [ChangeNowExchangeProvider(), SideShiftExchangeProvider(), SimpleSwapExchangeProvider()];
|
||||||
|
_initialPairBasedOnWallet();
|
||||||
currentTradeAvailableProviders = SplayTreeMap<double, ExchangeProvider>();
|
currentTradeAvailableProviders = SplayTreeMap<double, ExchangeProvider>();
|
||||||
|
|
||||||
final Map<String, dynamic> exchangeProvidersSelection = json
|
final Map<String, dynamic> exchangeProvidersSelection = json
|
||||||
|
@ -51,13 +51,12 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
|
|
||||||
/// if the provider is not in the user settings (user's first time or newly added provider)
|
/// if the provider is not in the user settings (user's first time or newly added provider)
|
||||||
/// then use its default value decided by us
|
/// then use its default value decided by us
|
||||||
selectedProviders = ObservableList.of(providerList.where(
|
selectedProviders = ObservableList.of(providersForCurrentPair().where(
|
||||||
(element) => exchangeProvidersSelection[element.title] == null
|
(element) => exchangeProvidersSelection[element.title] == null
|
||||||
? element.isEnabled
|
? element.isEnabled
|
||||||
: (exchangeProvidersSelection[element.title] as bool))
|
: (exchangeProvidersSelection[element.title] as bool))
|
||||||
.toList());
|
.toList());
|
||||||
|
|
||||||
_initialPairBasedOnWallet();
|
|
||||||
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
|
isDepositAddressEnabled = !(depositCurrency == wallet.currency);
|
||||||
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
|
isReceiveAddressEnabled = !(receiveCurrency == wallet.currency);
|
||||||
depositAmount = '';
|
depositAmount = '';
|
||||||
|
@ -532,6 +531,10 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
depositCurrency = CryptoCurrency.ltc;
|
depositCurrency = CryptoCurrency.ltc;
|
||||||
receiveCurrency = CryptoCurrency.xmr;
|
receiveCurrency = CryptoCurrency.xmr;
|
||||||
break;
|
break;
|
||||||
|
case WalletType.haven:
|
||||||
|
depositCurrency = CryptoCurrency.xhv;
|
||||||
|
receiveCurrency = CryptoCurrency.btc;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue