cake_wallet/lib/store/secret_store.dart

30 lines
966 B
Dart
Raw Normal View History

2021-01-13 16:43:34 +00:00
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:flutter/foundation.dart';
import 'package:cake_wallet/core/secure_storage.dart';
2021-01-13 16:43:34 +00:00
import 'package:mobx/mobx.dart';
part 'secret_store.g.dart';
class SecretStore = SecretStoreBase with _$SecretStore;
abstract class SecretStoreBase with Store {
static Future<SecretStore> load(SecureStorage storage) async {
2021-01-13 16:43:34 +00:00
final secretStore = SecretStore();
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
final backupPassword = await storage.read(key: backupPasswordKey);
2022-10-12 17:09:57 +00:00
// FIX-ME: backupPassword ?? '' ???
secretStore.write(key: backupPasswordKey, value: backupPassword ?? '');
2021-01-13 16:43:34 +00:00
return secretStore;
}
SecretStoreBase() : values = ObservableMap<String, String>();
ObservableMap values;
String read(String key) => values[key] as String;
2022-10-12 17:09:57 +00:00
String write({required String key, required String value}) =>
2021-01-13 16:43:34 +00:00
values[key] = value;
}