diff --git a/lib/_pkg/wallet/lwk/create.dart b/lib/_pkg/wallet/lwk/create.dart index 4b1d3e8e..c53cb99e 100644 --- a/lib/_pkg/wallet/lwk/create.dart +++ b/lib/_pkg/wallet/lwk/create.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:bb_mobile/_model/wallet.dart'; import 'package:bb_mobile/_pkg/error.dart'; import 'package:lwk_dart/lwk_dart.dart' as lwk; @@ -28,6 +30,29 @@ class LWKCreate { return (w, null); } catch (e) { + try { + if (e.toString().contains( + 'LwkError(msg: UpdateOnDifferentStatus { wollet_status: ', + )) { + final appDocDir = await getApplicationDocumentsDirectory(); + final String dbDir = + '${appDocDir.path}/${wallet.getWalletStorageString()}'; + // delete dbDir + final Directory dbDirect = Directory(dbDir); + if (dbDirect.existsSync()) { + await dbDirect.delete(recursive: true); + } + } + } catch (e) { + return ( + null, + Err( + e.toString(), + title: 'Error occurred while creating wallet', + solution: 'Please try again.', + ) + ); + } return ( null, Err( diff --git a/lib/_pkg/wallet/sync.dart b/lib/_pkg/wallet/sync.dart index 226728b7..46a3ef82 100644 --- a/lib/_pkg/wallet/sync.dart +++ b/lib/_pkg/wallet/sync.dart @@ -64,6 +64,14 @@ class WalletSync implements IWalletSync { .deleteWalletFile(wallet.id); // create db file or restart app } + if (errSyncing.message.contains( + 'LwkError(msg: UpdateOnDifferentStatus { wollet_status: ', + )) { + locator + .get() + .deleteWalletFile(wallet.id); + // create db file or restart app + } throw errSyncing; } final err = diff --git a/lib/locator.dart b/lib/locator.dart index 17a53c62..03ad95d2 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -55,7 +55,7 @@ import 'package:flutter_animate/flutter_animate.dart'; import 'package:get_it/get_it.dart'; import 'package:go_router/go_router.dart'; -const bbVersion = '0.3.10'; +const bbVersion = '0.3.16'; GetIt locator = GetIt.instance; diff --git a/lib/wallet/bloc/wallet_bloc.dart b/lib/wallet/bloc/wallet_bloc.dart index d290177b..821411fd 100644 --- a/lib/wallet/bloc/wallet_bloc.dart +++ b/lib/wallet/bloc/wallet_bloc.dart @@ -136,7 +136,11 @@ class WalletBloc extends Bloc { Future _syncWallet(SyncWallet event, Emitter emit) async { if (state.wallet == null) return; if (state.syncing) return; - + if (state.errLoadingWallet.isNotEmpty) { + add(LoadWallet(state.wallet!.getWalletStorageString())); + return; + } + // if (walletIsLoaded) // final (wallet, _) = await _walletsStorageRepository.readWallet( // walletHashId: state.wallet!.id, // ); diff --git a/pubspec.yaml b/pubspec.yaml index 5ed2c12e..32847fee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: bb_mobile description: Bull Bitcoin Mobile Wallet publish_to: "none" -version: 0.3.10+23 +version: 0.3.16+23 environment: sdk: ">=3.3.0 <4.0.0"