info dialog if node settings and current TOR status will cause sync issues on wallet open

This commit is contained in:
julian 2024-11-26 12:46:18 -06:00
parent b548386097
commit 3fb18bf2db
7 changed files with 190 additions and 0 deletions

View file

@ -16,6 +16,7 @@ import 'package:mutex/mutex.dart';
import '../../notifications/show_flush_bar.dart';
// import 'package:stackwallet/providers/global/has_authenticated_start_state_provider.dart';
import '../../providers/global/node_service_provider.dart';
import '../../providers/global/prefs_provider.dart';
import '../../providers/global/secure_store_provider.dart';
import '../../providers/global/wallets_provider.dart';
@ -25,7 +26,9 @@ import '../../utilities/assets.dart';
import '../../utilities/biometrics.dart';
import '../../utilities/flutter_secure_storage_interface.dart';
import '../../utilities/show_loading.dart';
import '../../utilities/show_node_tor_settings_mismatch.dart';
import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../wallets/wallet/intermediate/lib_monero_wallet.dart';
import '../../widgets/background.dart';
import '../../widgets/custom_buttons/app_bar_icon_button.dart';
@ -101,6 +104,20 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
final walletId = widget.routeOnSuccessArguments as String;
final wallet = ref.read(pWallets).getWallet(walletId);
final canContinue = await checkShowNodeTorSettingsMismatch(
context: context,
currency: wallet.cryptoCurrency,
prefs: ref.read(prefsChangeNotifierProvider),
nodeService: ref.read(nodeServiceChangeNotifierProvider),
allowCancel: false,
rootNavigator: Util.isDesktop,
);
if (!canContinue) {
return;
}
final Future<void> loadFuture;
if (wallet is LibMoneroWallet) {
loadFuture =

View file

@ -22,6 +22,7 @@ import '../../../utilities/amount/amount.dart';
import '../../../utilities/amount/amount_formatter.dart';
import '../../../utilities/constants.dart';
import '../../../utilities/show_loading.dart';
import '../../../utilities/show_node_tor_settings_mismatch.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
import '../../../wallets/crypto_currency/coins/firo.dart';
@ -117,6 +118,19 @@ class _FavoriteCardState extends ConsumerState<FavoriteCard> {
onTap: () async {
final wallet = ref.read(pWallets).getWallet(walletId);
final canContinue = await checkShowNodeTorSettingsMismatch(
context: context,
currency: coin,
prefs: ref.read(prefsChangeNotifierProvider),
nodeService: ref.read(nodeServiceChangeNotifierProvider),
allowCancel: true,
rootNavigator: Util.isDesktop,
);
if (!canContinue) {
return;
}
final Future<void> loadFuture;
if (wallet is LibMoneroWallet) {
loadFuture =

View file

@ -21,6 +21,7 @@ import '../../../themes/stack_colors.dart';
import '../../../utilities/amount/amount.dart';
import '../../../utilities/constants.dart';
import '../../../utilities/show_loading.dart';
import '../../../utilities/show_node_tor_settings_mismatch.dart';
import '../../../utilities/text_styles.dart';
import '../../../utilities/util.dart';
import '../../../wallets/crypto_currency/crypto_currency.dart';
@ -83,6 +84,20 @@ class WalletListItem extends ConsumerWidget {
.read(pWallets)
.wallets
.firstWhere((e) => e.info.coin == coin);
final canContinue = await checkShowNodeTorSettingsMismatch(
context: context,
currency: coin,
prefs: ref.read(prefsChangeNotifierProvider),
nodeService: ref.read(nodeServiceChangeNotifierProvider),
allowCancel: true,
rootNavigator: Util.isDesktop,
);
if (!canContinue) {
return;
}
final Future<void> loadFuture;
if (wallet is LibMoneroWallet) {
loadFuture =

View file

@ -12,10 +12,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../providers/global/active_wallet_provider.dart';
import '../../providers/global/node_service_provider.dart';
import '../../providers/global/prefs_provider.dart';
import '../../providers/global/wallets_provider.dart';
import '../../themes/stack_colors.dart';
import '../../utilities/constants.dart';
import '../../utilities/show_loading.dart';
import '../../utilities/show_node_tor_settings_mismatch.dart';
import '../../utilities/util.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
import '../../wallets/wallet/intermediate/lib_monero_wallet.dart';
@ -81,6 +84,22 @@ class CoinWalletsTable extends ConsumerWidget {
final wallet =
ref.read(pWallets).getWallet(walletIds[i]);
final canContinue =
await checkShowNodeTorSettingsMismatch(
context: context,
currency: coin,
prefs: ref.read(prefsChangeNotifierProvider),
nodeService:
ref.read(nodeServiceChangeNotifierProvider),
allowCancel: true,
rootNavigator: Util.isDesktop,
);
if (!canContinue) {
return;
}
final Future<void> loadFuture;
if (wallet is LibMoneroWallet) {
loadFuture = wallet

View file

@ -20,6 +20,7 @@ import '../../themes/coin_icon_provider.dart';
import '../../themes/stack_colors.dart';
import '../../utilities/amount/amount.dart';
import '../../utilities/show_loading.dart';
import '../../utilities/show_node_tor_settings_mismatch.dart';
import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
@ -123,6 +124,19 @@ class _DesktopWalletSummaryRowState
final wallet = ref.read(pWallets).wallets.firstWhere(
(e) => e.cryptoCurrency.identifier == widget.coin.identifier);
final canContinue = await checkShowNodeTorSettingsMismatch(
context: context,
currency: wallet.cryptoCurrency,
prefs: ref.read(prefsChangeNotifierProvider),
nodeService: ref.read(nodeServiceChangeNotifierProvider),
allowCancel: true,
rootNavigator: Util.isDesktop,
);
if (!canContinue) {
return;
}
final Future<void> loadFuture;
if (wallet is LibMoneroWallet) {
loadFuture =

View file

@ -0,0 +1,97 @@
import 'package:flutter/material.dart';
import '../services/node_service.dart';
import '../wallets/crypto_currency/crypto_currency.dart';
import '../widgets/conditional_parent.dart';
import '../widgets/desktop/desktop_dialog.dart';
import '../widgets/desktop/primary_button.dart';
import '../widgets/desktop/secondary_button.dart';
import '../widgets/stack_dialog.dart';
import 'prefs.dart';
import 'text_styles.dart';
import 'util.dart';
Future<bool> checkShowNodeTorSettingsMismatch({
required BuildContext context,
required CryptoCurrency currency,
required Prefs prefs,
required NodeService nodeService,
required bool allowCancel,
bool rootNavigator = false,
}) async {
final node =
nodeService.getPrimaryNodeFor(currency: currency) ?? currency.defaultNode;
if (prefs.useTor) {
if (node.torEnabled) {
return true;
}
} else {
if (node.clearnetEnabled) {
return true;
}
}
final result = await showDialog<bool>(
context: context,
barrierDismissible: false,
builder: (context) => ConditionalParent(
condition: Util.isDesktop,
builder: (child) => DesktopDialog(
maxHeight: double.infinity,
child: Padding(
padding: const EdgeInsets.all(32),
child: child,
),
),
child: ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => StackDialogBase(
child: child,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
"Attention! Node connection issue detected. "
"The current node will not sync due to its connectivity settings. "
"Please adjust the node settings or enable/disable TOR.",
style: STextStyles.w600_16(context),
),
SizedBox(
height: Util.isDesktop ? 32 : 24,
),
Row(
children: [
allowCancel
? Expanded(
child: SecondaryButton(
buttonHeight: Util.isDesktop ? ButtonHeight.l : null,
label: "Cancel",
onPressed: () {
Navigator.of(context).pop(false);
},
),
)
: const Spacer(),
SizedBox(
width: Util.isDesktop ? 24 : 16,
),
Expanded(
child: PrimaryButton(
buttonHeight: Util.isDesktop ? ButtonHeight.l : null,
label: "Continue",
onPressed: () {
Navigator.of(context).pop(true);
},
),
),
],
),
],
),
),
),
);
return result ?? true;
}

View file

@ -23,6 +23,7 @@ import '../providers/providers.dart';
import '../utilities/constants.dart';
import '../utilities/logger.dart';
import '../utilities/show_loading.dart';
import '../utilities/show_node_tor_settings_mismatch.dart';
import '../utilities/util.dart';
import '../wallets/isar/providers/eth/current_token_wallet_provider.dart';
import '../wallets/wallet/impl/ethereum_wallet.dart';
@ -95,6 +96,19 @@ class SimpleWalletCard extends ConsumerWidget {
final wallet = ref.read(pWallets).getWallet(walletId);
final canContinue = await checkShowNodeTorSettingsMismatch(
context: context,
currency: wallet.cryptoCurrency,
prefs: ref.read(prefsChangeNotifierProvider),
nodeService: ref.read(nodeServiceChangeNotifierProvider),
allowCancel: true,
rootNavigator: Util.isDesktop,
);
if (!canContinue) {
return;
}
if (context.mounted) {
final Future<void> loadFuture;
if (wallet is LibMoneroWallet) {