Fix issues from code review

This commit is contained in:
Godwin Asuquo 2023-03-02 17:13:25 +02:00
parent d4b5f24d5e
commit 15237d5f79
9 changed files with 18 additions and 17 deletions

View file

@ -217,7 +217,7 @@ class BackupService {
final fiatApiMode = data[PreferencesKey.currentFiatApiModeKey] as int?;
final currentPinLength = data[PreferencesKey.currentPinLength] as int?;
final currentTheme = data[PreferencesKey.currentTheme] as int?;
final disableExchange = data[PreferencesKey.disableExchangeKey] as bool?;
final exchangeStatus = data[PreferencesKey.exchangeStatusKey] as bool?;
final currentDefaultSettingsMigrationVersion = data[PreferencesKey.currentDefaultSettingsMigrationVersion] as int?;
final moneroTransactionPriority = data[PreferencesKey.moneroTransactionPriority] as int?;
final bitcoinTransactionPriority = data[PreferencesKey.bitcoinTransactionPriority] as int?;
@ -280,9 +280,9 @@ class BackupService {
await _sharedPreferences.setInt(
PreferencesKey.currentTheme, currentTheme);
if (disableExchange != null)
if (exchangeStatus != null)
await _sharedPreferences.setBool(
PreferencesKey.disableExchangeKey, disableExchange);
PreferencesKey.exchangeStatusKey, exchangeStatus);
if (currentDefaultSettingsMigrationVersion != null)
await _sharedPreferences.setInt(
@ -431,8 +431,8 @@ class BackupService {
_sharedPreferences.getInt(PreferencesKey.displayActionListModeKey),
PreferencesKey.currentTheme:
_sharedPreferences.getInt(PreferencesKey.currentTheme),
PreferencesKey.disableExchangeKey:
_sharedPreferences.getBool(PreferencesKey.disableExchangeKey),
PreferencesKey.exchangeStatusKey:
_sharedPreferences.getBool(PreferencesKey.exchangeStatusKey),
PreferencesKey.currentDefaultSettingsMigrationVersion: _sharedPreferences
.getInt(PreferencesKey.currentDefaultSettingsMigrationVersion),
PreferencesKey.bitcoinTransactionPriority:

View file

@ -308,7 +308,7 @@ class TrocadorExchangeProvider extends ExchangeProvider {
return onionApiAuthority;
}
final uri = Uri.https(onionApiAuthority, '/api/trade');
final uri = Uri.https(onionApiAuthority, tradePath);
await get(uri);
return onionApiAuthority;

View file

@ -70,7 +70,7 @@ class _AdvancedPrivacySettingsBodyState extends State<AdvancedPrivacySettingsBod
items: ExchangeApiMode.all,
selectedItem: widget.privacySettingsViewModel.exchangeStatus,
onItemSelected: (ExchangeApiMode mode) =>
widget.privacySettingsViewModel.setEnableExchange(mode),
widget.privacySettingsViewModel.setExchangeApiMode(mode),
),
);
}

View file

@ -36,7 +36,7 @@ class PrivacyPage extends BasePage {
title: S.current.exchange,
items: ExchangeApiMode.all,
selectedItem: _privacySettingsViewModel.exchangeStatus,
onItemSelected: (ExchangeApiMode mode) => _privacySettingsViewModel.setEnableExchange(mode),
onItemSelected: (ExchangeApiMode mode) => _privacySettingsViewModel.setExchangeApiMode(mode),
),
),
SettingsSwitcherCell(

View file

@ -38,7 +38,7 @@ abstract class AdvancedPrivacySettingsViewModelBase with Store {
}
@action
void setEnableExchange(ExchangeApiMode value) {
void setExchangeApiMode(ExchangeApiMode value) {
_settingsStore.exchangeStatus = value;
}

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/wallet_type_utils.dart';
import 'package:cw_core/transaction_history.dart';
@ -274,7 +275,7 @@ abstract class DashboardViewModelBase with Store {
settingsStore.shouldShowYatPopup = shouldShow;
@computed
bool get isEnabledExchangeAction => settingsStore.exchangeStatus != FiatApiMode.disabled;
bool get isEnabledExchangeAction => settingsStore.exchangeStatus != ExchangeApiMode.disabled;
@observable
bool hasExchangeAction;

View file

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:collection';
import 'dart:convert';
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:cake_wallet/entities/preferences_key.dart';
import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart';
@ -56,7 +57,7 @@ abstract class ExchangeViewModelBase with Store {
isDepositAddressEnabled = false,
isReceiveAddressEnabled = false,
isReceiveAmountEditable = false,
_providerUseTorOnly = false,
_useTorOnly = false,
receiveCurrencies = <CryptoCurrency>[],
depositCurrencies = <CryptoCurrency>[],
limits = Limits(min: 0, max: 0),
@ -66,7 +67,7 @@ abstract class ExchangeViewModelBase with Store {
depositCurrency = wallet.currency,
providerList = [],
selectedProviders = ObservableList<ExchangeProvider>() {
_providerUseTorOnly = _settingsStore.exchangeStatus == FiatApiMode.torOnly;
_useTorOnly = _settingsStore.exchangeStatus == ExchangeApiMode.torOnly;
_setProviders();
const excludeDepositCurrencies = [CryptoCurrency.btt, CryptoCurrency.nano];
const excludeReceiveCurrencies = [CryptoCurrency.xlm, CryptoCurrency.xrp,
@ -123,7 +124,7 @@ abstract class ExchangeViewModelBase with Store {
_calculateBestRate();
});
}
bool _providerUseTorOnly;
bool _useTorOnly;
final WalletBase wallet;
final Box<Trade> trades;
final ExchangeTemplateStore _exchangeTemplateStore;
@ -134,7 +135,7 @@ abstract class ExchangeViewModelBase with Store {
ChangeNowExchangeProvider(),
SideShiftExchangeProvider(),
SimpleSwapExchangeProvider(),
TrocadorExchangeProvider(useTorOnly: _providerUseTorOnly),
TrocadorExchangeProvider(useTorOnly: _useTorOnly),
];
@observable
@ -696,7 +697,7 @@ abstract class ExchangeViewModelBase with Store {
}
void _setProviders(){
if (_settingsStore.exchangeStatus == FiatApiMode.torOnly) {
if (_settingsStore.exchangeStatus == ExchangeApiMode.torOnly) {
providerList = _allProviders.where((provider) => provider.supportsOnionAddress).toList();
} else {
providerList = _allProviders;

View file

@ -25,7 +25,7 @@ abstract class PrivacySettingsViewModelBase with Store {
void setShouldSaveRecipientAddress(bool value) => _settingsStore.shouldSaveRecipientAddress = value;
@action
void setEnableExchange(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
void setExchangeApiMode(ExchangeApiMode value) => _settingsStore.exchangeStatus = value;
@action
void setFiatMode(bool value) {

View file

@ -56,7 +56,6 @@ dependencies:
archive: ^3.3.0
cryptography: ^2.0.5
file_picker: ^4.6.1
file: ^6.1.4
unorm_dart: ^0.2.0
# check unorm_dart for usage and for replace
permission_handler: ^10.0.0