2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/di.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:cake_wallet/store/app_store.dart';
|
|
|
|
import 'package:cake_wallet/core/key_service.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/wallet_service.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
2021-12-24 12:37:24 +00:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2020-09-21 11:50:26 +00:00
|
|
|
|
|
|
|
Future<void> loadCurrentWallet() async {
|
|
|
|
final appStore = getIt.get<AppStore>();
|
|
|
|
final name = getIt
|
|
|
|
.get<SharedPreferences>()
|
|
|
|
.getString(PreferencesKey.currentWalletName);
|
|
|
|
final typeRaw =
|
|
|
|
getIt.get<SharedPreferences>().getInt(PreferencesKey.currentWalletType) ??
|
|
|
|
0;
|
|
|
|
final type = deserializeFromInt(typeRaw);
|
|
|
|
final password =
|
|
|
|
await getIt.get<KeyService>().getWalletPassword(walletName: name);
|
|
|
|
final _service = getIt.get<WalletService>(param1: type);
|
|
|
|
final wallet = await _service.openWallet(name, password);
|
2020-12-15 16:29:10 +00:00
|
|
|
appStore.changeCurrentWallet(wallet);
|
2020-09-21 11:50:26 +00:00
|
|
|
}
|