mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-05-05 08:42:14 +00:00
- Fix reloading settings store
- Revert changes to backup_service.dart
This commit is contained in:
parent
d961a4645e
commit
c235df8935
4 changed files with 31 additions and 53 deletions
lib
|
@ -1,7 +1,6 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:cake_wallet/store/settings_store.dart';
|
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
@ -21,7 +20,7 @@ import 'package:cake_backup/backup.dart' as cake_backup;
|
||||||
|
|
||||||
class BackupService {
|
class BackupService {
|
||||||
BackupService(this._flutterSecureStorage, this._walletInfoSource,
|
BackupService(this._flutterSecureStorage, this._walletInfoSource,
|
||||||
this._keyService, this._sharedPreferences, this._settingsStore)
|
this._keyService, this._sharedPreferences)
|
||||||
: _cipher = Cryptography.instance.chacha20Poly1305Aead(),
|
: _cipher = Cryptography.instance.chacha20Poly1305Aead(),
|
||||||
_correctWallets = <WalletInfo>[];
|
_correctWallets = <WalletInfo>[];
|
||||||
|
|
||||||
|
@ -34,7 +33,6 @@ class BackupService {
|
||||||
final FlutterSecureStorage _flutterSecureStorage;
|
final FlutterSecureStorage _flutterSecureStorage;
|
||||||
final SharedPreferences _sharedPreferences;
|
final SharedPreferences _sharedPreferences;
|
||||||
final Box<WalletInfo> _walletInfoSource;
|
final Box<WalletInfo> _walletInfoSource;
|
||||||
final SettingsStore _settingsStore;
|
|
||||||
final KeyService _keyService;
|
final KeyService _keyService;
|
||||||
List<WalletInfo> _correctWallets;
|
List<WalletInfo> _correctWallets;
|
||||||
|
|
||||||
|
@ -303,7 +301,6 @@ class BackupService {
|
||||||
as Map<String, dynamic>;
|
as Map<String, dynamic>;
|
||||||
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
||||||
final decodedPin = keychainJSON['pin'] as String;
|
final decodedPin = keychainJSON['pin'] as String;
|
||||||
_settingsStore.pinCodeLength = decodedPin.length;
|
|
||||||
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||||
final backupPasswordKey =
|
final backupPasswordKey =
|
||||||
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
|
@ -334,7 +331,6 @@ class BackupService {
|
||||||
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
||||||
final decodedPin = keychainJSON['pin'] as String;
|
final decodedPin = keychainJSON['pin'] as String;
|
||||||
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||||
_settingsStore.pinCodeLength = decodedPin.length;
|
|
||||||
final backupPasswordKey =
|
final backupPasswordKey =
|
||||||
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
||||||
|
|
|
@ -606,9 +606,7 @@ Future setup(
|
||||||
getIt.get<FlutterSecureStorage>(),
|
getIt.get<FlutterSecureStorage>(),
|
||||||
_walletInfoSource,
|
_walletInfoSource,
|
||||||
getIt.get<KeyService>(),
|
getIt.get<KeyService>(),
|
||||||
getIt.get<SharedPreferences>(),
|
getIt.get<SharedPreferences>()));
|
||||||
getIt.get<SettingsStore>(),
|
|
||||||
));
|
|
||||||
|
|
||||||
getIt.registerFactory(() => BackupViewModel(getIt.get<FlutterSecureStorage>(),
|
getIt.registerFactory(() => BackupViewModel(getIt.get<FlutterSecureStorage>(),
|
||||||
getIt.get<SecretStore>(), getIt.get<BackupService>()));
|
getIt.get<SecretStore>(), getIt.get<BackupService>()));
|
||||||
|
|
|
@ -3,7 +3,6 @@ import 'package:cake_wallet/entities/preferences_key.dart';
|
||||||
import 'package:cw_core/transaction_priority.dart';
|
import 'package:cw_core/transaction_priority.dart';
|
||||||
import 'package:cake_wallet/themes/theme_base.dart';
|
import 'package:cake_wallet/themes/theme_base.dart';
|
||||||
import 'package:cake_wallet/themes/theme_list.dart';
|
import 'package:cake_wallet/themes/theme_list.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
|
@ -234,8 +233,7 @@ abstract class SettingsStoreBase with Store {
|
||||||
: ThemeType.bright.index;
|
: ThemeType.bright.index;
|
||||||
final savedTheme = ThemeList.deserialize(
|
final savedTheme = ThemeList.deserialize(
|
||||||
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ??
|
raw: sharedPreferences.getInt(PreferencesKey.currentTheme) ??
|
||||||
legacyTheme ??
|
legacyTheme);
|
||||||
0);
|
|
||||||
final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
|
final actionListDisplayMode = ObservableList<ActionListDisplayMode>();
|
||||||
actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
|
actionListDisplayMode.addAll(deserializeActionlistDisplayModes(
|
||||||
sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ??
|
sharedPreferences.getInt(PreferencesKey.displayActionListModeKey) ??
|
||||||
|
@ -281,7 +279,7 @@ abstract class SettingsStoreBase with Store {
|
||||||
if (havenNode != null) {
|
if (havenNode != null) {
|
||||||
nodes[WalletType.haven] = havenNode;
|
nodes[WalletType.haven] = havenNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SettingsStore(
|
return SettingsStore(
|
||||||
sharedPreferences: sharedPreferences,
|
sharedPreferences: sharedPreferences,
|
||||||
nodes: nodes,
|
nodes: nodes,
|
||||||
|
@ -301,48 +299,35 @@ abstract class SettingsStoreBase with Store {
|
||||||
shouldShowYatPopup: shouldShowYatPopup);
|
shouldShowYatPopup: shouldShowYatPopup);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIX-ME: Dead code
|
Future<void> reload(
|
||||||
|
{required Box<Node> nodeSource,
|
||||||
|
FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
||||||
|
TransactionPriority? initialMoneroTransactionPriority,
|
||||||
|
TransactionPriority? initialBitcoinTransactionPriority,
|
||||||
|
BalanceDisplayMode initialBalanceDisplayMode = BalanceDisplayMode.availableBalance}) async {
|
||||||
|
if (initialBitcoinTransactionPriority == null) {
|
||||||
|
initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority();
|
||||||
|
}
|
||||||
|
|
||||||
//Future<void> reload(
|
if (initialMoneroTransactionPriority == null) {
|
||||||
// {required Box<Node> nodeSource,
|
initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority();
|
||||||
// FiatCurrency initialFiatCurrency = FiatCurrency.usd,
|
}
|
||||||
// TransactionPriority? initialMoneroTransactionPriority,
|
|
||||||
// TransactionPriority? initialBitcoinTransactionPriority,
|
|
||||||
// BalanceDisplayMode initialBalanceDisplayMode =
|
|
||||||
// BalanceDisplayMode.availableBalance}) async {
|
|
||||||
|
|
||||||
// if (initialBitcoinTransactionPriority == null) {
|
|
||||||
// initialBitcoinTransactionPriority = bitcoin?.getMediumTransactionPriority();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (initialMoneroTransactionPriority == null) {
|
final isBitcoinBuyEnabled = (secrets.wyreSecretKey.isNotEmpty) &&
|
||||||
// initialMoneroTransactionPriority = monero?.getDefaultTransactionPriority();
|
(secrets.wyreApiKey.isNotEmpty) &&
|
||||||
// }
|
(secrets.wyreAccountId.isNotEmpty);
|
||||||
|
|
||||||
// final isBitcoinBuyEnabled = (secrets.wyreSecretKey?.isNotEmpty ?? false) &&
|
final settings = await SettingsStoreBase.load(
|
||||||
// (secrets.wyreApiKey?.isNotEmpty ?? false) &&
|
nodeSource: nodeSource,
|
||||||
// (secrets.wyreAccountId?.isNotEmpty ?? false);
|
isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
||||||
|
initialBalanceDisplayMode: initialBalanceDisplayMode,
|
||||||
|
initialFiatCurrency: initialFiatCurrency,
|
||||||
|
initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
||||||
|
initialBitcoinTransactionPriority: initialBitcoinTransactionPriority);
|
||||||
|
|
||||||
// final settings = await SettingsStoreBase.load(
|
getIt.unregister<SettingsStore>();
|
||||||
// nodeSource: nodeSource,
|
getIt.registerSingleton<SettingsStore>(settings);
|
||||||
// isBitcoinBuyEnabled: isBitcoinBuyEnabled,
|
}
|
||||||
// initialBalanceDisplayMode: initialBalanceDisplayMode,
|
|
||||||
// initialFiatCurrency: initialFiatCurrency,
|
|
||||||
// initialMoneroTransactionPriority: initialMoneroTransactionPriority,
|
|
||||||
// initialBitcoinTransactionPriority: initialBitcoinTransactionPriority);
|
|
||||||
// fiatCurrency = settings.fiatCurrency;
|
|
||||||
// actionlistDisplayMode = settings.actionlistDisplayMode;
|
|
||||||
// priority[WalletType.monero] = initialMoneroTransactionPriority;
|
|
||||||
// priority[WalletType.bitcoin] = initialBitcoinTransactionPriority;
|
|
||||||
// balanceDisplayMode = settings.balanceDisplayMode;
|
|
||||||
// shouldSaveRecipientAddress = settings.shouldSaveRecipientAddress;
|
|
||||||
// allowBiometricalAuthentication = settings.allowBiometricalAuthentication;
|
|
||||||
// currentTheme = settings.currentTheme;
|
|
||||||
// pinCodeLength = settings.pinCodeLength;
|
|
||||||
// languageCode = settings.languageCode;
|
|
||||||
// appVersion = settings.appVersion;
|
|
||||||
// shouldShowYatPopup = settings.shouldShowYatPopup;
|
|
||||||
//}
|
|
||||||
|
|
||||||
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
Future<void> _saveCurrentNode(Node node, WalletType walletType) async {
|
||||||
switch (walletType) {
|
switch (walletType) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
||||||
try {
|
try {
|
||||||
state = IsExecutingState();
|
state = IsExecutingState();
|
||||||
|
|
||||||
if (filePath?.isEmpty ?? true) {
|
if (filePath.isEmpty) {
|
||||||
state = FailureState('Backup file is not selected.');
|
state = FailureState('Backup file is not selected.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +48,7 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
||||||
|
|
||||||
final store = getIt.get<AppStore>();
|
final store = getIt.get<AppStore>();
|
||||||
ReactionDisposer? reaction;
|
ReactionDisposer? reaction;
|
||||||
// FIX-ME: SettingsStore reload
|
await store.settingsStore.reload(nodeSource: getIt.get<Box<Node>>());
|
||||||
// await store.settingsStore.reload(nodeSource: getIt.get<Box<Node>>());
|
|
||||||
|
|
||||||
reaction = autorun((_) {
|
reaction = autorun((_) {
|
||||||
final wallet = store.wallet;
|
final wallet = store.wallet;
|
||||||
|
|
Loading…
Reference in a new issue