mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
apply lelantus rescan on desktop
This commit is contained in:
parent
bd090a3e92
commit
64d946e752
2 changed files with 213 additions and 87 deletions
|
@ -4,6 +4,8 @@ import 'package:flutter_svg/flutter_svg.dart';
|
|||
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
|
||||
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart';
|
||||
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart';
|
||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart';
|
||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||
import 'package:stackwallet/route_generator.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
|
@ -13,6 +15,9 @@ import 'package:stackwallet/utilities/util.dart';
|
|||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
@ -48,7 +53,47 @@ class _FiroRescanRecoveryErrorViewState
|
|||
child: ConditionalParent(
|
||||
condition: Util.isDesktop,
|
||||
builder: (child) {
|
||||
return child;
|
||||
return DesktopScaffold(
|
||||
appBar: DesktopAppBar(
|
||||
background: Theme.of(context).extension<StackColors>()!.popupBG,
|
||||
isCompactHeight: true,
|
||||
// useSpacers: false,
|
||||
trailing: Padding(
|
||||
padding: const EdgeInsets.only(right: 16),
|
||||
child: CustomTextButton(
|
||||
text: "Delete wallet",
|
||||
onTap: () async {
|
||||
final result = await showDialog<bool?>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => Navigator(
|
||||
initialRoute: DesktopDeleteWalletDialog.routeName,
|
||||
onGenerateRoute: RouteGenerator.generateRoute,
|
||||
onGenerateInitialRoutes: (_, __) {
|
||||
return [
|
||||
RouteGenerator.generateRoute(
|
||||
RouteSettings(
|
||||
name: DesktopDeleteWalletDialog.routeName,
|
||||
arguments: widget.walletId,
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (result == true) {
|
||||
if (context.mounted) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
body: SizedBox(width: 328, child: child),
|
||||
);
|
||||
},
|
||||
child: ConditionalParent(
|
||||
condition: !Util.isDesktop,
|
||||
|
@ -164,13 +209,50 @@ class _FiroRescanRecoveryErrorViewState
|
|||
"Failed to rescan firo wallet",
|
||||
style: STextStyles.pageTitleH2(context),
|
||||
),
|
||||
if (!Util.isDesktop) const Spacer(),
|
||||
Row(
|
||||
Util.isDesktop
|
||||
? const SizedBox(
|
||||
height: 60,
|
||||
)
|
||||
: const Spacer(),
|
||||
BranchedParent(
|
||||
condition: Util.isDesktop,
|
||||
conditionBranchBuilder: (children) => Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: children,
|
||||
),
|
||||
otherBranchBuilder: (children) => Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: SecondaryButton(
|
||||
Expanded(child: children[0]),
|
||||
children[1],
|
||||
Expanded(child: children[2]),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
SecondaryButton(
|
||||
label: "Show mnemonic",
|
||||
buttonHeight: Util.isDesktop ? ButtonHeight.l : null,
|
||||
onPressed: () async {
|
||||
if (Util.isDesktop) {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => Navigator(
|
||||
initialRoute: UnlockWalletKeysDesktop.routeName,
|
||||
onGenerateRoute: RouteGenerator.generateRoute,
|
||||
onGenerateInitialRoutes: (_, __) {
|
||||
return [
|
||||
RouteGenerator.generateRoute(
|
||||
RouteSettings(
|
||||
name: UnlockWalletKeysDesktop.routeName,
|
||||
arguments: widget.walletId,
|
||||
),
|
||||
)
|
||||
];
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final mnemonic = await ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
|
@ -198,24 +280,24 @@ class _FiroRescanRecoveryErrorViewState
|
|||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
PrimaryButton(
|
||||
label: "Retry",
|
||||
buttonHeight: Util.isDesktop ? ButtonHeight.l : null,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(
|
||||
true,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -17,6 +17,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart';
|
||||
import 'package:stackwallet/pages/special/firo_rescan_recovery_error_dialog.dart';
|
||||
import 'package:stackwallet/pages/token_view/my_tokens_view.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/sub_widgets/transactions_list.dart';
|
||||
import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart';
|
||||
|
@ -30,6 +31,7 @@ import 'package:stackwallet/providers/global/auto_swb_service_provider.dart';
|
|||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/providers/ui/transaction_filter_provider.dart';
|
||||
import 'package:stackwallet/services/coins/banano/banano_wallet.dart';
|
||||
import 'package:stackwallet/services/coins/firo/firo_wallet.dart';
|
||||
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
|
||||
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
|
||||
import 'package:stackwallet/themes/coin_icon_provider.dart';
|
||||
|
@ -78,6 +80,7 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
|
||||
late final bool _shouldDisableAutoSyncOnLogOut;
|
||||
bool _rescanningOnOpen = false;
|
||||
bool _lelantusRescanRecovery = false;
|
||||
|
||||
Future<void> onBackPressed() async {
|
||||
await _logout();
|
||||
|
@ -103,6 +106,38 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
ref.read(managerProvider.notifier).isActiveWallet = false;
|
||||
}
|
||||
|
||||
Future<void> _firoRescanRecovery() async {
|
||||
final success = await (ref
|
||||
.read(walletsChangeNotifierProvider)
|
||||
.getManager(widget.walletId)
|
||||
.wallet as FiroWallet)
|
||||
.firoRescanRecovery();
|
||||
|
||||
if (success) {
|
||||
// go into wallet
|
||||
WidgetsBinding.instance.addPostFrameCallback(
|
||||
(_) => setState(() {
|
||||
_rescanningOnOpen = false;
|
||||
_lelantusRescanRecovery = false;
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
// show error message dialog w/ options
|
||||
if (mounted) {
|
||||
final shouldRetry = await Navigator.of(context).pushNamed(
|
||||
FiroRescanRecoveryErrorView.routeName,
|
||||
arguments: widget.walletId,
|
||||
);
|
||||
|
||||
if (shouldRetry is bool && shouldRetry) {
|
||||
await _firoRescanRecovery();
|
||||
}
|
||||
} else {
|
||||
return await _firoRescanRecovery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
controller = TextEditingController();
|
||||
|
@ -124,7 +159,13 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
_shouldDisableAutoSyncOnLogOut = false;
|
||||
}
|
||||
|
||||
if (ref.read(managerProvider).coin != Coin.ethereum &&
|
||||
if (ref.read(managerProvider).coin == Coin.firo &&
|
||||
(ref.read(managerProvider).wallet as FiroWallet)
|
||||
.lelantusCoinIsarRescanRequired) {
|
||||
_rescanningOnOpen = true;
|
||||
_lelantusRescanRecovery = true;
|
||||
_firoRescanRecovery();
|
||||
} else if (ref.read(managerProvider).coin != Coin.ethereum &&
|
||||
ref.read(managerProvider).rescanOnOpenVersion == Constants.rescanV1) {
|
||||
_rescanningOnOpen = true;
|
||||
ref.read(managerProvider).fullRescan(20, 1000).then(
|
||||
|
@ -172,7 +213,9 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
subMessage: "This only needs to run once per wallet",
|
||||
eventBus: null,
|
||||
textColor: Theme.of(context).extension<StackColors>()!.textDark,
|
||||
actionButton: SecondaryButton(
|
||||
actionButton: _lelantusRescanRecovery
|
||||
? null
|
||||
: SecondaryButton(
|
||||
label: "Skip",
|
||||
buttonHeight: ButtonHeight.l,
|
||||
onPressed: () async {
|
||||
|
@ -198,14 +241,15 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 32),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 32),
|
||||
child: Text(
|
||||
"Skipping this process can completely"
|
||||
" break your wallet. It is only meant to be done in"
|
||||
" emergency situations where the migration fails"
|
||||
" and will not let you continue. Still skip?",
|
||||
style: STextStyles.desktopTextSmall(context),
|
||||
style:
|
||||
STextStyles.desktopTextSmall(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
@ -235,8 +279,8 @@ class _DesktopWalletViewState extends ConsumerState<DesktopWalletView> {
|
|||
Navigator.of(context,
|
||||
rootNavigator: true)
|
||||
.pop();
|
||||
setState(
|
||||
() => _rescanningOnOpen = false);
|
||||
setState(() =>
|
||||
_rescanningOnOpen = false);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue