cake_wallet/lib/view_model/rescan_view_model.dart

29 lines
694 B
Dart
Raw Permalink Normal View History

2021-12-24 12:37:24 +00:00
import 'package:cw_core/wallet_base.dart';
2020-09-21 11:50:26 +00:00
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;
2020-09-21 11:50:26 +00:00
}
@observable
RescanWalletState state;
final WalletBase _wallet;
@observable
bool isButtonEnabled;
2020-09-21 11:50:26 +00:00
@action
Future<void> rescanCurrentWallet({int restoreHeight}) async {
state = RescanWalletState.rescaning;
await _wallet.rescan(height: restoreHeight);
state = RescanWalletState.none;
}
}