mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-22 02:24:30 +00:00
sync getter
This commit is contained in:
parent
748d70e34f
commit
21e0113439
1 changed files with 23 additions and 0 deletions
|
@ -140,6 +140,29 @@ class WalletsService extends ChangeNotifier {
|
|||
name, WalletInfo.fromJson(Map<String, dynamic>.from(dyn as Map))));
|
||||
}
|
||||
|
||||
Map<String, WalletInfo> fetchWalletsData() {
|
||||
final names = DB.instance.get<dynamic>(
|
||||
boxName: DB.boxNameAllWalletsData, key: 'names') as Map? ??
|
||||
{};
|
||||
|
||||
Logging.instance.log("Fetched wallet names: $names", level: LogLevel.Info);
|
||||
final mapped = Map<String, dynamic>.from(names);
|
||||
mapped.removeWhere((name, dyn) {
|
||||
final jsonObject = Map<String, dynamic>.from(dyn as Map);
|
||||
try {
|
||||
Coin.values.byName(jsonObject["coin"] as String);
|
||||
return false;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log("Error, ${jsonObject["coin"]} does not exist",
|
||||
level: LogLevel.Error);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return mapped.map((name, dyn) => MapEntry(
|
||||
name, WalletInfo.fromJson(Map<String, dynamic>.from(dyn as Map))));
|
||||
}
|
||||
|
||||
Future<void> addExistingStackWallet({
|
||||
required String name,
|
||||
required String walletId,
|
||||
|
|
Loading…
Reference in a new issue