cake_wallet/lib/view_model/rescan_view_model.dart
Serhii 02fd12f5f8
CW-214-Monero-wallet-rescan-bug (#945)
* clear transactionHistory before rescan

* move the clear method to the abstract class
2023-07-11 20:56:01 +03:00

30 lines
No EOL
742 B
Dart

import 'package:cw_core/wallet_base.dart';
import 'package:mobx/mobx.dart';
part 'rescan_view_model.g.dart';
class RescanViewModel = RescanViewModelBase with _$RescanViewModel;
enum RescanWalletState { rescaning, none }
abstract class RescanViewModelBase with Store {
RescanViewModelBase(this._wallet)
: state = RescanWalletState.none,
isButtonEnabled = false;
final WalletBase _wallet;
@observable
RescanWalletState state;
@observable
bool isButtonEnabled;
@action
Future<void> rescanCurrentWallet({required int restoreHeight}) async {
state = RescanWalletState.rescaning;
await _wallet.rescan(height: restoreHeight);
_wallet.transactionHistory.clear();
state = RescanWalletState.none;
}
}