From cf336529b001366acb3c40a92ce6bc3051ee6188 Mon Sep 17 00:00:00 2001 From: cygnet Date: Thu, 4 Jul 2024 19:19:58 +0200 Subject: [PATCH] WIP add create wallet use case --- lib/main.dart | 32 ++++--- lib/src/data/models/sp_receiver_model.dart | 6 +- .../data/providers/wallet_secure_storage.dart | 38 --------- .../data/repositories/wallet_repository.dart | 4 +- .../notifiers/wallet_notifier.dart | 35 ++++++-- .../screens/setupwallet_screen.dart | 85 +++++++++---------- .../presentation/screens/spend_screen.dart | 20 ++--- .../presentation/screens/wallet_screen.dart | 1 + lib/src/utils/global_functions.dart | 1 + 9 files changed, 105 insertions(+), 117 deletions(-) delete mode 100644 lib/src/data/providers/wallet_secure_storage.dart diff --git a/lib/main.dart b/lib/main.dart index 2bce434..923fcbc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,8 @@ import 'package:donationwallet/src/data/providers/chain_api.dart'; -import 'package:donationwallet/src/data/providers/wallet_secure_storage.dart'; +import 'package:donationwallet/src/data/providers/secure_storage.dart'; import 'package:donationwallet/src/data/repositories/chain_repository.dart'; import 'package:donationwallet/src/data/repositories/wallet_repository.dart'; +import 'package:donationwallet/src/domain/usecases/create_wallet_usecase.dart'; import 'package:donationwallet/src/domain/usecases/delete_wallet_usecase.dart'; import 'package:donationwallet/src/domain/usecases/get_chain_tip_usecase.dart'; import 'package:donationwallet/src/domain/usecases/load_wallet_usecase.dart'; @@ -29,21 +30,26 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { AndroidOptions getAndroidOptions() => const AndroidOptions( - encryptedSharedPreferences: true, - ); + encryptedSharedPreferences: true, + ); final storage = FlutterSecureStorage(aOptions: getAndroidOptions()); return MultiProvider( providers: [ - ChangeNotifierProvider(create: (_) => WalletNotifier( - SaveWalletUseCase(WalletRepository(WalletSecureStorageProvider(storage))), - LoadWalletUseCase(WalletRepository(WalletSecureStorageProvider(storage))), - DeleteWalletUseCase(WalletRepository(WalletSecureStorageProvider(storage))), - UpdateWalletUseCase(ChainRepository(ChainApiProvider())), - )), - ChangeNotifierProvider(create: (_) => ChainNotifier( - GetChainTipUseCase(ChainRepository(ChainApiProvider())) - ) - ) + ChangeNotifierProvider( + create: (_) => WalletNotifier( + SaveWalletUseCase( + WalletRepository(SecureStorageProvider(storage))), + LoadWalletUseCase( + WalletRepository(SecureStorageProvider(storage))), + DeleteWalletUseCase( + WalletRepository(SecureStorageProvider(storage))), + UpdateWalletUseCase(ChainRepository(ChainApiProvider())), + CreateWalletUseCase( + WalletRepository(SecureStorageProvider(storage))), + )), + ChangeNotifierProvider( + create: (_) => ChainNotifier( + GetChainTipUseCase(ChainRepository(ChainApiProvider())))) ], child: const SilentPaymentApp(), ); diff --git a/lib/src/data/models/sp_receiver_model.dart b/lib/src/data/models/sp_receiver_model.dart index 92cb494..ea03bed 100644 --- a/lib/src/data/models/sp_receiver_model.dart +++ b/lib/src/data/models/sp_receiver_model.dart @@ -19,7 +19,11 @@ class SPReceiver { factory SPReceiver.fromJson(Map json) { var labelsList = json['labels'] as List; - List