fix: Add proper state reporting [skip ci]

This commit is contained in:
Blazebrain 2023-07-11 10:55:03 +01:00
parent 245e52792f
commit 857e355ee6

View file

@ -68,7 +68,6 @@ abstract class WalletCreationVMBase with Store {
bool typeExists(WalletType type) => walletCreationService.typeExists(type); bool typeExists(WalletType type) => walletCreationService.typeExists(type);
Future<void> create({dynamic options, RestoredWallet? restoreWallet}) async { Future<void> create({dynamic options, RestoredWallet? restoreWallet}) async {
// if (restoreWallet != null && // if (restoreWallet != null &&
// restoreWallet.restoreMode == WalletRestoreMode.txids) { // restoreWallet.restoreMode == WalletRestoreMode.txids) {
await _createFlowForSweepAll(options, restoreWallet); await _createFlowForSweepAll(options, restoreWallet);
@ -109,6 +108,7 @@ abstract class WalletCreationVMBase with Store {
dynamic options, dynamic options,
RestoredWallet? restoreWallet, RestoredWallet? restoreWallet,
) async { ) async {
state = IsExecutingState();
final type = restoreWallet?.type ?? this.type; final type = restoreWallet?.type ?? this.type;
try { try {
@ -145,7 +145,7 @@ abstract class WalletCreationVMBase with Store {
await restoredWallet.startSync(); await restoredWallet.startSync();
await syncCompleter.future; await syncCompleter.future;
// * Sweep all funds from restoredWallet to newWallet // * Sweep all funds from restoredWallet to newWallet
await _sweepAllFundsToNewWallet( await _sweepAllFundsToNewWallet(
restoredWallet, restoredWallet,
@ -153,7 +153,6 @@ abstract class WalletCreationVMBase with Store {
type, type,
restoreWallet?.txId ?? '', restoreWallet?.txId ?? '',
); );
} catch (e) { } catch (e) {
print( print(
'Error occurred while creating a new wallet from Scan QR using sweep all', 'Error occurred while creating a new wallet from Scan QR using sweep all',
@ -215,17 +214,18 @@ abstract class WalletCreationVMBase with Store {
} }
Future<void> _sweepAllFundsToNewWallet( Future<void> _sweepAllFundsToNewWallet(
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
TransactionInfo> TransactionInfo>
wallet, wallet,
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
TransactionInfo> TransactionInfo>
newWallet, newWallet,
WalletType type, WalletType type,
String paymentId, String paymentId,
) async { ) async {
final output = Output(
final output = Output(wallet, _appStore.settingsStore, wallet,
_appStore.settingsStore,
_fiatConversationStore, _fiatConversationStore,
() => wallet.currency, () => wallet.currency,
); );
@ -308,14 +308,10 @@ abstract class WalletCreationVMBase with Store {
} }
} }
Future<void> _createTransaction(WalletBase wallet, Object credentials) async { Future<void> _createTransaction(WalletBase wallet, Object credentials) async {
try { try {
print('in here');
state = IsExecutingState();
print('about to enter wallet create transaction function'); print('about to enter wallet create transaction function');
pendingTransaction = await wallet.createTransaction(credentials); pendingTransaction = await wallet.createTransaction(credentials);
state = ExecutedSuccessfullyState();
} catch (e) { } catch (e) {
state = FailureState(e.toString()); state = FailureState(e.toString());
} }