diff --git a/lib/main.dart b/lib/main.dart index 10067ac19..5aeb89508 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -589,9 +589,16 @@ class _MaterialAppWithThemeState extends ConsumerState _loadChangeNowData(); } - return const LockscreenView( + String? startupWalletId; + if (ref.read(prefsChangeNotifierProvider).gotoWalletOnStartup) { + startupWalletId = + ref.read(prefsChangeNotifierProvider).startupWalletId; + } + + return LockscreenView( isInitialAppLogin: true, routeOnSuccess: HomeView.routeName, + routeOnSuccessArguments: startupWalletId, biometricsAuthenticationTitle: "Unlock Stack", biometricsLocalizedReason: "Unlock your stack wallet using biometrics", diff --git a/lib/pages/exchange_view/exchange_loading_overlay.dart b/lib/pages/exchange_view/exchange_loading_overlay.dart index 9b8e07d7c..28484022a 100644 --- a/lib/pages/exchange_view/exchange_loading_overlay.dart +++ b/lib/pages/exchange_view/exchange_loading_overlay.dart @@ -1,20 +1,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/exchange/available_currencies_state_provider.dart'; -import 'package:stackwallet/providers/exchange/available_floating_rate_pairs_state_provider.dart'; -import 'package:stackwallet/providers/exchange/change_now_provider.dart'; import 'package:stackwallet/providers/exchange/changenow_initial_load_status.dart'; -import 'package:stackwallet/providers/exchange/estimate_rate_exchange_form_provider.dart'; -import 'package:stackwallet/providers/exchange/fixed_rate_exchange_form_provider.dart'; -import 'package:stackwallet/providers/exchange/fixed_rate_market_pairs_provider.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; -import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class ExchangeLoadingOverlayView extends ConsumerStatefulWidget { - const ExchangeLoadingOverlayView({Key? key}) : super(key: key); + const ExchangeLoadingOverlayView({ + Key? key, + required this.unawaitedLoad, + }) : super(key: key); + + final VoidCallback unawaitedLoad; @override ConsumerState createState() => @@ -28,103 +26,6 @@ class _ExchangeLoadingOverlayViewState bool userReloaded = false; - Future _loadFixedRateMarkets() async { - if (ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state == - ChangeNowLoadStatus.loading) { - // already in progress so just - return; - } - - ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.loading; - - final response3 = - await ref.read(changeNowProvider).getAvailableFixedRateMarkets(); - if (response3.value != null) { - ref.read(fixedRateMarketPairsStateProvider.state).state = - response3.value!; - - if (ref.read(fixedRateExchangeFormProvider).market == null) { - final matchingMarkets = - response3.value!.where((e) => e.to == "doge" && e.from == "btc"); - if (matchingMarkets.isNotEmpty) { - await ref - .read(fixedRateExchangeFormProvider) - .updateMarket(matchingMarkets.first, true); - } - } - } else { - Logging.instance.log( - "Failed to load changeNOW fixed rate markets: ${response3.exception?.errorMessage}", - level: LogLevel.Error); - - ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.failed; - return; - } - - ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.success; - } - - Future _loadChangeNowStandardCurrencies() async { - if (ref - .read(changeNowEstimatedInitialLoadStatusStateProvider.state) - .state == - ChangeNowLoadStatus.loading) { - // already in progress so just - return; - } - - ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.loading; - - final response = await ref.read(changeNowProvider).getAvailableCurrencies(); - final response2 = - await ref.read(changeNowProvider).getAvailableFloatingRatePairs(); - if (response.value != null) { - ref.read(availableChangeNowCurrenciesStateProvider.state).state = - response.value!; - if (response2.value != null) { - ref.read(availableFloatingRatePairsStateProvider.state).state = - response2.value!; - - if (response.value!.length > 1) { - if (ref.read(estimatedRateExchangeFormProvider).from == null) { - if (response.value!.where((e) => e.ticker == "btc").isNotEmpty) { - await ref.read(estimatedRateExchangeFormProvider).updateFrom( - response.value!.firstWhere((e) => e.ticker == "btc"), false); - } - } - if (ref.read(estimatedRateExchangeFormProvider).to == null) { - if (response.value!.where((e) => e.ticker == "doge").isNotEmpty) { - await ref.read(estimatedRateExchangeFormProvider).updateTo( - response.value!.firstWhere((e) => e.ticker == "doge"), false); - } - } - } - } else { - Logging.instance.log( - "Failed to load changeNOW available floating rate pairs: ${response2.exception?.errorMessage}", - level: LogLevel.Error); - ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.failed; - return; - } - } else { - Logging.instance.log( - "Failed to load changeNOW currencies: ${response.exception?.errorMessage}", - level: LogLevel.Error); - await Future.delayed(const Duration(seconds: 3)); - ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.failed; - return; - } - - ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = - ChangeNowLoadStatus.success; - } - @override void initState() { _statusEst = @@ -168,8 +69,10 @@ class _ExchangeLoadingOverlayViewState child: const CustomLoadingOverlay( message: "Loading ChangeNOW data", eventBus: null), ), - if (_statusEst == ChangeNowLoadStatus.failed || - _statusFixed == ChangeNowLoadStatus.failed) + if ((_statusEst == ChangeNowLoadStatus.failed || + _statusFixed == ChangeNowLoadStatus.failed) && + _statusEst != ChangeNowLoadStatus.loading && + _statusFixed != ChangeNowLoadStatus.loading) Container( color: CFColors.stackAccent.withOpacity(0.7), child: Column( @@ -186,13 +89,8 @@ class _ExchangeLoadingOverlayViewState .copyWith(color: CFColors.stackAccent), ), onPressed: () { - if (_statusEst == ChangeNowLoadStatus.failed) { - _loadChangeNowStandardCurrencies(); - } - if (_statusFixed == ChangeNowLoadStatus.failed) { - userReloaded = true; - _loadFixedRateMarkets(); - } + userReloaded = true; + widget.unawaitedLoad(); }, ), ), diff --git a/lib/pages/exchange_view/wallet_initiated_exchange_view.dart b/lib/pages/exchange_view/wallet_initiated_exchange_view.dart index 74519e379..551f8b5d9 100644 --- a/lib/pages/exchange_view/wallet_initiated_exchange_view.dart +++ b/lib/pages/exchange_view/wallet_initiated_exchange_view.dart @@ -29,7 +29,6 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; -import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart'; @@ -1272,55 +1271,55 @@ class _WalletInitiatedExchangeViewState .read(estimatedRateExchangeFormProvider) .fromAmountString); - if (ft.toLowerCase() == - coin.ticker.toLowerCase()) { - bool shouldPop = false; - bool wasPopped = false; - unawaited(showDialog( - context: context, - builder: (_) => WillPopScope( - onWillPop: () async { - if (shouldPop) { - wasPopped = true; - } - return shouldPop; - }, - child: const CustomLoadingOverlay( - message: "Checking available balance", - eventBus: null, - ), - ), - )); - - final availableBalance = - await manager.availableBalance; - - final feeObject = await manager.fees; - - final fee = await manager.estimateFeeFor( - Format.decimalAmountToSatoshis( - sendAmount), - feeObject.medium); - - shouldPop = true; - if (!wasPopped && mounted) { - Navigator.of(context).pop(); - } - - if (availableBalance < - sendAmount + - Format.satoshisToAmount(fee)) { - unawaited(showDialog( - context: context, - builder: (_) => StackOkDialog( - title: "Insufficient balance", - message: - "Current ${coin.prettyName} wallet does not have enough ${coin.ticker} for this trade", - ), - )); - return; - } - } + // if (ft.toLowerCase() == + // coin.ticker.toLowerCase()) { + // bool shouldPop = false; + // bool wasPopped = false; + // unawaited(showDialog( + // context: context, + // builder: (_) => WillPopScope( + // onWillPop: () async { + // if (shouldPop) { + // wasPopped = true; + // } + // return shouldPop; + // }, + // child: const CustomLoadingOverlay( + // message: "Checking available balance", + // eventBus: null, + // ), + // ), + // )); + // + // final availableBalance = + // await manager.availableBalance; + // + // final feeObject = await manager.fees; + // + // final fee = await manager.estimateFeeFor( + // Format.decimalAmountToSatoshis( + // sendAmount), + // feeObject.medium); + // + // shouldPop = true; + // if (!wasPopped && mounted) { + // Navigator.of(context).pop(); + // } + // + // if (availableBalance < + // sendAmount + + // Format.satoshisToAmount(fee)) { + // unawaited(showDialog( + // context: context, + // builder: (_) => StackOkDialog( + // title: "Insufficient balance", + // message: + // "Current ${coin.prettyName} wallet does not have enough ${coin.ticker} for this trade", + // ), + // )); + // return; + // } + // } if (isEstimated) { final fromTicker = ref diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index 32388e07c..669561adf 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -13,6 +13,7 @@ import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; import 'package:stackwallet/providers/global/notifications_provider.dart'; import 'package:stackwallet/providers/ui/home_view_index_provider.dart'; import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; +import 'package:stackwallet/services/change_now/change_now_loading_service.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/cfcolors.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -40,7 +41,16 @@ class _HomeViewState extends ConsumerState { bool _exitEnabled = false; + final _cnLoadingService = ChangeNowLoadingService(); + Future _onWillPop() async { + + // go to home view when tapping back on the main exchange view + if (ref.read(homeViewPageIndexStateProvider.state).state == 1) { + ref.read(homeViewPageIndexStateProvider.state).state = 0; + return false; + } + if (_exitEnabled) { return true; } @@ -70,6 +80,11 @@ class _HomeViewState extends ConsumerState { return _exitEnabled; } + void _loadCNData() { + // unawaited future + _cnLoadingService.loadAll(ref); + } + @override void initState() { _pageController = PageController(); @@ -77,9 +92,11 @@ class _HomeViewState extends ConsumerState { const WalletsView(), if (Constants.enableExchange) Stack( - children: const [ - ExchangeView(), - ExchangeLoadingOverlayView(), + children: [ + const ExchangeView(), + ExchangeLoadingOverlayView( + unawaitedLoad: _loadCNData, + ), ], ), // const BuyView(), diff --git a/lib/pages/pinpad_views/lock_screen_view.dart b/lib/pages/pinpad_views/lock_screen_view.dart index b22cebb9b..03dd5bb26 100644 --- a/lib/pages/pinpad_views/lock_screen_view.dart +++ b/lib/pages/pinpad_views/lock_screen_view.dart @@ -1,9 +1,14 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; +import 'package:stackwallet/pages/home_view/home_view.dart'; +import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; // import 'package:stackwallet/providers/global/has_authenticated_start_state_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/providers/global/wallets_provider.dart'; // import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/biometrics.dart'; @@ -15,6 +20,7 @@ import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; import 'package:stackwallet/widgets/shake/shake.dart'; +import 'package:tuple/tuple.dart'; class LockscreenView extends ConsumerStatefulWidget { const LockscreenView({ @@ -75,10 +81,20 @@ class _LockscreenViewState extends ConsumerState { if (widget.popOnSuccess) { Navigator.of(context).pop(widget.routeOnSuccessArguments); } else { - Navigator.of(context).pushReplacementNamed( + unawaited(Navigator.of(context).pushReplacementNamed( widget.routeOnSuccess, arguments: widget.routeOnSuccessArguments, - ); + )); + if (widget.routeOnSuccess == HomeView.routeName && + widget.routeOnSuccessArguments is String) { + final walletId = widget.routeOnSuccessArguments as String; + unawaited(Navigator.of(context).pushNamed(WalletView.routeName, + arguments: Tuple2( + walletId, + ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(walletId)))); + } } } @@ -105,7 +121,7 @@ class _LockscreenViewState extends ConsumerState { // await walletsService.getWalletId(currentWalletName)); // } - _onUnlock(); + unawaited(_onUnlock()); } // leave this commented to enable pin fall back should biometrics not work properly // else { @@ -250,10 +266,10 @@ class _LockscreenViewState extends ConsumerState { _timeout = const Duration(minutes: 60); } - Future.delayed(_timeout).then((_) { + unawaited(Future.delayed(_timeout).then((_) { _attemptLock = false; _attempts = 0; - }); + })); } if (_attemptLock) { @@ -264,13 +280,13 @@ class _LockscreenViewState extends ConsumerState { prettyTime += "${_timeout.inSeconds} seconds"; } - showFloatingFlushBar( + unawaited(showFloatingFlushBar( type: FlushBarType.warning, message: "Incorrect PIN entered too many times. Please wait $prettyTime", context: context, iconAsset: Assets.svg.alertCircle, - ); + )); await Future.delayed( const Duration(milliseconds: 100)); @@ -286,15 +302,15 @@ class _LockscreenViewState extends ConsumerState { if (storedPin == pin) { await Future.delayed( const Duration(milliseconds: 200)); - _onUnlock(); + unawaited(_onUnlock()); } else { - _shakeController.shake(); - showFloatingFlushBar( + unawaited(_shakeController.shake()); + unawaited(showFloatingFlushBar( type: FlushBarType.warning, message: "Incorrect PIN. Please try again", context: context, iconAsset: Assets.svg.alertCircle, - ); + )); await Future.delayed( const Duration(milliseconds: 100)); diff --git a/lib/pages/settings_views/global_settings_view/global_settings_view.dart b/lib/pages/settings_views/global_settings_view/global_settings_view.dart index 8c739ac00..2f52b9c37 100644 --- a/lib/pages/settings_views/global_settings_view/global_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/global_settings_view.dart @@ -9,6 +9,7 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/language_v import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/security_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; import 'package:stackwallet/pages/settings_views/sub_widgets/settings_list_button.dart'; @@ -166,6 +167,18 @@ class GlobalSettingsView extends StatelessWidget { const SizedBox( height: 8, ), + SettingsListButton( + iconAssetName: Assets.svg.arrowUpRight, + iconSize: 16, + title: "Startup", + onPressed: () { + Navigator.of(context).pushNamed( + StartupPreferencesView.routeName); + }, + ), + const SizedBox( + height: 8, + ), SettingsListButton( iconAssetName: Assets.svg.sun, iconSize: 18, diff --git a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart new file mode 100644 index 000000000..861886625 --- /dev/null +++ b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart @@ -0,0 +1,269 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart'; +import 'package:stackwallet/providers/global/prefs_provider.dart'; +import 'package:stackwallet/utilities/cfcolors.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class StartupPreferencesView extends ConsumerStatefulWidget { + const StartupPreferencesView({Key? key}) : super(key: key); + + static const String routeName = "/startupPreferences"; + + @override + ConsumerState createState() => + _StartupPreferencesViewState(); +} + +class _StartupPreferencesViewState + extends ConsumerState { + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: CFColors.almostWhite, + appBar: AppBar( + leading: AppBarBackButton( + onPressed: () async { + Navigator.of(context).pop(); + }, + ), + title: Text( + "Startup preferences", + style: STextStyles.navBarTitle, + ), + ), + body: Padding( + padding: const EdgeInsets.all(16), + child: LayoutBuilder( + builder: (context, constraints) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: constraints.maxHeight, + ), + child: IntrinsicHeight( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.all(4.0), + child: RawMaterialButton( + // splashColor: CFColors.splashLight, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + onPressed: () { + ref + .read(prefsChangeNotifierProvider) + .gotoWalletOnStartup = false; + }, + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + SizedBox( + width: 20, + height: 20, + child: Radio( + activeColor: CFColors.link2, + value: false, + groupValue: ref.watch( + prefsChangeNotifierProvider + .select((value) => value + .gotoWalletOnStartup), + ), + onChanged: (value) { + if (value is bool) { + ref + .read( + prefsChangeNotifierProvider) + .gotoWalletOnStartup = value; + } + }, + ), + ), + const SizedBox( + width: 12, + ), + Flexible( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Home screen", + style: STextStyles.titleBold12, + textAlign: TextAlign.left, + ), + Text( + "Stack Wallet home screen", + style: STextStyles.itemSubtitle, + textAlign: TextAlign.left, + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + Padding( + padding: const EdgeInsets.all(4), + child: RawMaterialButton( + // splashColor: CFColors.splashLight, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + onPressed: () { + ref + .read(prefsChangeNotifierProvider) + .gotoWalletOnStartup = true; + }, + child: Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.all(8), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + SizedBox( + width: 20, + height: 20, + child: Radio( + activeColor: CFColors.link2, + value: true, + groupValue: ref.watch( + prefsChangeNotifierProvider + .select((value) => value + .gotoWalletOnStartup), + ), + onChanged: (value) { + if (value is bool) { + ref + .read( + prefsChangeNotifierProvider) + .gotoWalletOnStartup = value; + } + }, + ), + ), + const SizedBox( + width: 12, + ), + Flexible( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Specific wallet", + style: STextStyles.titleBold12, + textAlign: TextAlign.left, + ), + Text( + "Select a specific wallet to load into on startup", + style: STextStyles.itemSubtitle, + textAlign: TextAlign.left, + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + if (!ref.watch(prefsChangeNotifierProvider + .select((value) => value.gotoWalletOnStartup))) + const SizedBox( + height: 12, + ), + if (ref.watch(prefsChangeNotifierProvider + .select((value) => value.gotoWalletOnStartup))) + Container( + color: Colors.transparent, + child: Padding( + padding: const EdgeInsets.only( + left: 12.0, + right: 12, + bottom: 12, + ), + child: Row( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + const SizedBox( + width: 12 + 20, + height: 12, + ), + Flexible( + child: RawMaterialButton( + // splashColor: CFColors.splashLight, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants + .size.circularBorderRadius, + ), + ), + onPressed: () { + Navigator.of(context).pushNamed( + StartupWalletSelectionView + .routeName); + }, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Select wallet...", + style: STextStyles.link2, + textAlign: TextAlign.left, + ), + ], + ), + ), + ), + ], + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ); + }, + ), + ), + ); + } +} diff --git a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart new file mode 100644 index 000000000..9569419e5 --- /dev/null +++ b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart @@ -0,0 +1,197 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/svg.dart'; +import 'package:stackwallet/providers/providers.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/cfcolors.dart'; +import 'package:stackwallet/utilities/constants.dart'; +import 'package:stackwallet/utilities/text_styles.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class StartupWalletSelectionView extends ConsumerStatefulWidget { + const StartupWalletSelectionView({Key? key}) : super(key: key); + + static const String routeName = "/startupWalletSelection"; + @override + ConsumerState createState() => + _StartupWalletSelectionViewState(); +} + +class _StartupWalletSelectionViewState + extends ConsumerState { + final Map _controllers = {}; + + @override + Widget build(BuildContext context) { + final managers = ref + .watch(walletsChangeNotifierProvider.select((value) => value.managers)); + + _controllers.clear(); + for (final manager in managers) { + _controllers[manager.walletId] = DSBController(); + } + + return Scaffold( + backgroundColor: CFColors.almostWhite, + appBar: AppBar( + leading: AppBarBackButton( + onPressed: () async { + Navigator.of(context).pop(); + }, + ), + title: FittedBox( + fit: BoxFit.scaleDown, + child: Text( + "Select startup wallet", + style: STextStyles.navBarTitle, + ), + ), + ), + body: LayoutBuilder(builder: (context, constraints) { + return Padding( + padding: const EdgeInsets.only( + left: 12, + top: 12, + right: 12, + ), + child: SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: constraints.maxHeight - 24, + ), + child: IntrinsicHeight( + child: Padding( + padding: const EdgeInsets.all(4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 4, + ), + Text( + "Select a wallet to load into immediately on startup", + style: STextStyles.smallMed12, + ), + const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: Column( + children: [ + ...managers.map( + (manager) => Padding( + padding: const EdgeInsets.all(12), + child: Row( + key: Key( + "startupWalletSelectionGroupKey_${manager.walletId}"), + children: [ + Container( + decoration: BoxDecoration( + color: CFColors.coin + .forCoin(manager.coin) + .withOpacity(0.5), + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + child: Padding( + padding: const EdgeInsets.all(4), + child: SvgPicture.asset( + Assets.svg + .iconFor(coin: manager.coin), + width: 20, + height: 20, + ), + ), + ), + const SizedBox( + width: 12, + ), + Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + manager.walletName, + style: STextStyles.titleBold12, + ), + // const SizedBox( + // height: 2, + // ), + // FutureBuilder( + // future: manager.totalBalance, + // builder: (builderContext, + // AsyncSnapshot snapshot) { + // if (snapshot.connectionState == + // ConnectionState.done && + // snapshot.hasData) { + // return Text( + // "${Format.localizedStringAsFixed( + // value: snapshot.data!, + // locale: ref.watch( + // localeServiceChangeNotifierProvider + // .select((value) => + // value.locale)), + // decimalPlaces: 8, + // )} ${manager.coin.ticker}", + // style: STextStyles.itemSubtitle, + // ); + // } else { + // return AnimatedText( + // stringsToLoopThrough: const [ + // "Loading balance", + // "Loading balance.", + // "Loading balance..", + // "Loading balance..." + // ], + // style: STextStyles.itemSubtitle, + // ); + // } + // }, + // ), + ], + ), + const Spacer(), + SizedBox( + height: 20, + width: 20, + child: Radio( + activeColor: CFColors.link2, + value: manager.walletId, + groupValue: ref.watch( + prefsChangeNotifierProvider.select( + (value) => value.startupWalletId), + ), + onChanged: (value) { + if (value is String) { + ref + .read( + prefsChangeNotifierProvider) + .startupWalletId = value; + } + }, + ), + ), + ], + ), + ), + ), + ], + ), + ), + ], + ), + ), + ), + ), + ), + ); + }), + ); + } +} diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 94228bee7..01b2f4ad8 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -24,6 +24,9 @@ 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/providers/ui/unread_notifications_provider.dart'; +import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; +import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart'; +import 'package:stackwallet/services/change_now/change_now_loading_service.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; @@ -35,6 +38,7 @@ import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; +import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; @@ -42,10 +46,6 @@ import 'package:stackwallet/widgets/custom_loading_overlay.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; -import '../../providers/wallet/public_private_balance_state_provider.dart'; -import '../../providers/wallet/wallet_balance_toggle_state_provider.dart'; -import '../../utilities/enums/wallet_balance_toggle_state.dart'; - /// [eventBus] should only be set during testing class WalletView extends ConsumerStatefulWidget { const WalletView({ @@ -79,6 +79,8 @@ class _WalletViewState extends ConsumerState { late StreamSubscription _syncStatusSubscription; late StreamSubscription _nodeStatusSubscription; + final _cnLoadingService = ChangeNowLoadingService(); + @override void initState() { walletId = widget.walletId; @@ -272,9 +274,10 @@ class _WalletViewState extends ConsumerState { unawaited(Navigator.of(context).pushNamed( WalletInitiatedExchangeView.routeName, - arguments: Tuple2( + arguments: Tuple3( walletId, coin, + _loadCNData, ), )); } @@ -346,6 +349,11 @@ class _WalletViewState extends ConsumerState { } } + void _loadCNData() { + // unawaited future + _cnLoadingService.loadAll(ref, coin: ref.read(managerProvider).coin); + } + @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 001c21b0d..df15f65fe 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -56,6 +56,8 @@ import 'package:stackwallet/pages/settings_views/global_settings_view/stack_back import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart'; +import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; @@ -224,6 +226,18 @@ class RouteGenerator { builder: (_) => const SyncingPreferencesView(), settings: RouteSettings(name: settings.name)); + case StartupPreferencesView.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const StartupPreferencesView(), + settings: RouteSettings(name: settings.name)); + + case StartupWalletSelectionView.routeName: + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const StartupWalletSelectionView(), + settings: RouteSettings(name: settings.name)); + case ManageNodesView.routeName: return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, @@ -719,7 +733,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case WalletInitiatedExchangeView.routeName: - if (args is Tuple2) { + if (args is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => Stack( @@ -728,7 +742,9 @@ class RouteGenerator { walletId: args.item1, coin: args.item2, ), - const ExchangeLoadingOverlayView(), + ExchangeLoadingOverlayView( + unawaitedLoad: args.item3, + ), ], ), settings: RouteSettings( diff --git a/lib/services/change_now/change_now_loading_service.dart b/lib/services/change_now/change_now_loading_service.dart new file mode 100644 index 000000000..51cd12d21 --- /dev/null +++ b/lib/services/change_now/change_now_loading_service.dart @@ -0,0 +1,140 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/providers/exchange/available_currencies_state_provider.dart'; +import 'package:stackwallet/providers/exchange/available_floating_rate_pairs_state_provider.dart'; +import 'package:stackwallet/providers/exchange/change_now_provider.dart'; +import 'package:stackwallet/providers/exchange/changenow_initial_load_status.dart'; +import 'package:stackwallet/providers/exchange/estimate_rate_exchange_form_provider.dart'; +import 'package:stackwallet/providers/exchange/fixed_rate_exchange_form_provider.dart'; +import 'package:stackwallet/providers/exchange/fixed_rate_market_pairs_provider.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/logger.dart'; + +class ChangeNowLoadingService { + Future loadAll(WidgetRef ref, {Coin? coin}) async { + try { + await Future.wait([ + _loadFixedRateMarkets(ref, coin: coin), + _loadChangeNowStandardCurrencies(ref, coin: coin), + ]); + } catch (e, s) { + Logging.instance.log("ChangeNowLoadingService.loadAll failed: $e\n$s", + level: LogLevel.Error); + } + } + + Future _loadFixedRateMarkets(WidgetRef ref, {Coin? coin}) async { + if (ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state == + ChangeNowLoadStatus.loading) { + // already in progress so just + return; + } + + ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.loading; + + final response3 = + await ref.read(changeNowProvider).getAvailableFixedRateMarkets(); + if (response3.value != null) { + ref.read(fixedRateMarketPairsStateProvider.state).state = + response3.value!; + + if (ref.read(fixedRateExchangeFormProvider).market == null) { + String fromTicker = "btc"; + String toTicker = "xmr"; + + if (coin != null) { + fromTicker = coin.ticker.toLowerCase(); + } + + final matchingMarkets = response3.value! + .where((e) => e.to == toTicker && e.from == fromTicker); + if (matchingMarkets.isNotEmpty) { + await ref + .read(fixedRateExchangeFormProvider) + .updateMarket(matchingMarkets.first, true); + } + } + } else { + Logging.instance.log( + "Failed to load changeNOW fixed rate markets: ${response3.exception?.errorMessage}", + level: LogLevel.Error); + + ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.failed; + return; + } + + ref.read(changeNowFixedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.success; + } + + Future _loadChangeNowStandardCurrencies(WidgetRef ref, + {Coin? coin}) async { + if (ref + .read(changeNowEstimatedInitialLoadStatusStateProvider.state) + .state == + ChangeNowLoadStatus.loading) { + // already in progress so just + return; + } + + ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.loading; + + final response = await ref.read(changeNowProvider).getAvailableCurrencies(); + final response2 = + await ref.read(changeNowProvider).getAvailableFloatingRatePairs(); + if (response.value != null) { + ref.read(availableChangeNowCurrenciesStateProvider.state).state = + response.value!; + if (response2.value != null) { + ref.read(availableFloatingRatePairsStateProvider.state).state = + response2.value!; + + String fromTicker = "btc"; + String toTicker = "xmr"; + + if (coin != null) { + fromTicker = coin.ticker.toLowerCase(); + } + + if (response.value!.length > 1) { + if (ref.read(estimatedRateExchangeFormProvider).from == null) { + if (response.value! + .where((e) => e.ticker == fromTicker) + .isNotEmpty) { + await ref.read(estimatedRateExchangeFormProvider).updateFrom( + response.value!.firstWhere((e) => e.ticker == fromTicker), + false); + } + } + if (ref.read(estimatedRateExchangeFormProvider).to == null) { + if (response.value!.where((e) => e.ticker == toTicker).isNotEmpty) { + await ref.read(estimatedRateExchangeFormProvider).updateTo( + response.value!.firstWhere((e) => e.ticker == toTicker), + false); + } + } + } + } else { + Logging.instance.log( + "Failed to load changeNOW available floating rate pairs: ${response2.exception?.errorMessage}", + level: LogLevel.Error); + ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.failed; + return; + } + } else { + Logging.instance.log( + "Failed to load changeNOW currencies: ${response.exception?.errorMessage}", + level: LogLevel.Error); + await Future.delayed(const Duration(seconds: 3)); + ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.failed; + return; + } + + ref.read(changeNowEstimatedInitialLoadStatusStateProvider.state).state = + ChangeNowLoadStatus.success; + } +} diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 69e3ea82e..ae6d7b70a 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -418,7 +418,7 @@ class BitcoinWallet extends CoinServiceAPI { "index: $index, \t GapCounter $account ${type.name}: $gapCounter", level: LogLevel.Info); - final ID = "k_$index"; + final _id = "k_$index"; Map txCountCallArgs = {}; final Map receivingNodes = {}; @@ -463,13 +463,13 @@ class BitcoinWallet extends CoinServiceAPI { throw Exception("No Path type $type exists"); } receivingNodes.addAll({ - "${ID}_$j": { + "${_id}_$j": { "node": node, "address": address, } }); txCountCallArgs.addAll({ - "${ID}_$j": address, + "${_id}_$j": address, }); } @@ -478,9 +478,9 @@ class BitcoinWallet extends CoinServiceAPI { // check and add appropriate addresses for (int k = 0; k < txCountBatchSize; k++) { - int count = counts["${ID}_$k"]!; + int count = counts["${_id}_$k"]!; if (count > 0) { - final node = receivingNodes["${ID}_$k"]; + final node = receivingNodes["${_id}_$k"]; // add address to array addressArray.add(node["address"] as String); iterationsAddressArray.add(node["address"] as String); @@ -526,7 +526,7 @@ class BitcoinWallet extends CoinServiceAPI { continue; } } - } catch (e, s) { + } catch (e) { // } } @@ -568,25 +568,25 @@ class BitcoinWallet extends CoinServiceAPI { // receiving addresses Logging.instance .log("checking receiving addresses...", level: LogLevel.Info); - Future resultReceive44 = _checkGaps(maxNumberOfIndexesToCheck, + final resultReceive44 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 0); - Future resultReceive49 = _checkGaps(maxNumberOfIndexesToCheck, + final resultReceive49 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip49, 0); - Future resultReceive84 = _checkGaps(maxNumberOfIndexesToCheck, + final resultReceive84 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip84, 0); Logging.instance .log("checking change addresses...", level: LogLevel.Info); // change addresses - Future resultChange44 = _checkGaps(maxNumberOfIndexesToCheck, + final resultChange44 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 1); - Future resultChange49 = _checkGaps(maxNumberOfIndexesToCheck, + final resultChange49 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip49, 1); - Future resultChange84 = _checkGaps(maxNumberOfIndexesToCheck, + final resultChange84 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip84, 1); await Future.wait([ @@ -851,7 +851,7 @@ class BitcoinWallet extends CoinServiceAPI { // notify on unconfirmed transactions for (final tx in unconfirmedTxnsToNotifyPending) { if (tx.txType == "Received") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, @@ -862,10 +862,10 @@ class BitcoinWallet extends CoinServiceAPI { txid: tx.txid, confirmations: tx.confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, - ); + )); await txTracker.addNotifiedPending(tx.txid); } else if (tx.txType == "Sent") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, @@ -876,7 +876,7 @@ class BitcoinWallet extends CoinServiceAPI { txid: tx.txid, confirmations: tx.confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, - ); + )); await txTracker.addNotifiedPending(tx.txid); } } @@ -884,7 +884,7 @@ class BitcoinWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { if (tx.txType == "Received") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, walletId: walletId, @@ -892,10 +892,10 @@ class BitcoinWallet extends CoinServiceAPI { date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), shouldWatchForUpdates: false, coinName: coin.name, - ); + )); await txTracker.addNotifiedConfirmed(tx.txid); } else if (tx.txType == "Sent") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, walletId: walletId, @@ -903,7 +903,7 @@ class BitcoinWallet extends CoinServiceAPI { date: DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000), shouldWatchForUpdates: false, coinName: coin.name, - ); + )); await txTracker.addNotifiedConfirmed(tx.txid); } } @@ -970,15 +970,15 @@ class BitcoinWallet extends CoinServiceAPI { if (currentHeight != storedHeight) { if (currentHeight != -1) { // -1 failed to fetch current height - updateStoredChainHeight(newHeight: currentHeight); + unawaited(updateStoredChainHeight(newHeight: currentHeight)); } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); - Future changeAddressForTransactions = + final changeAddressForTransactions = _checkChangeAddressForTransactions(DerivePathType.bip84); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.3, walletId)); - Future currentReceivingAddressesForTransactions = + final currentReceivingAddressesForTransactions = _checkCurrentReceivingAddressesForTransactions(); final newTxData = _fetchTransactionData(); @@ -999,7 +999,7 @@ class BitcoinWallet extends CoinServiceAPI { GlobalEventBus.instance .fire(RefreshPercentChangedEvent(0.80, walletId)); - Future allTxsToWatch = getAllTxsToWatch(await newTxData); + final allTxsToWatch = getAllTxsToWatch(await newTxData); await Future.wait([ newTxData, changeAddressForTransactions, @@ -1358,7 +1358,7 @@ class BitcoinWallet extends CoinServiceAPI { ); if (shouldRefresh) { - refresh(); + unawaited(refresh()); } } diff --git a/lib/services/coins/dogecoin/dogecoin_wallet.dart b/lib/services/coins/dogecoin/dogecoin_wallet.dart index 9e1892690..c5a3ed8ac 100644 --- a/lib/services/coins/dogecoin/dogecoin_wallet.dart +++ b/lib/services/coins/dogecoin/dogecoin_wallet.dart @@ -251,7 +251,7 @@ class DogecoinWallet extends CoinServiceAPI { } Future updateStoredChainHeight({required int newHeight}) async { - DB.instance.put( + await DB.instance.put( boxName: walletId, key: "storedChainHeight", value: newHeight); } @@ -365,7 +365,7 @@ class DogecoinWallet extends CoinServiceAPI { "index: $index, \t GapCounter $account ${type.name}: $gapCounter", level: LogLevel.Info); - final ID = "k_$index"; + final _id = "k_$index"; Map txCountCallArgs = {}; final Map receivingNodes = {}; @@ -392,13 +392,13 @@ class DogecoinWallet extends CoinServiceAPI { throw Exception("No Path type $type exists"); } receivingNodes.addAll({ - "${ID}_$j": { + "${_id}_$j": { "node": node, "address": address, } }); txCountCallArgs.addAll({ - "${ID}_$j": address, + "${_id}_$j": address, }); } @@ -407,9 +407,9 @@ class DogecoinWallet extends CoinServiceAPI { // check and add appropriate addresses for (int k = 0; k < txCountBatchSize; k++) { - int count = counts["${ID}_$k"]!; + int count = counts["${_id}_$k"]!; if (count > 0) { - final node = receivingNodes["${ID}_$k"]; + final node = receivingNodes["${_id}_$k"]; // add address to array addressArray.add(node["address"] as String); iterationsAddressArray.add(node["address"] as String); @@ -455,7 +455,7 @@ class DogecoinWallet extends CoinServiceAPI { continue; } } - } catch (e, s) { + } catch (e) { // } } @@ -485,13 +485,13 @@ class DogecoinWallet extends CoinServiceAPI { // receiving addresses Logging.instance .log("checking receiving addresses...", level: LogLevel.Info); - Future resultReceive44 = _checkGaps(maxNumberOfIndexesToCheck, + final resultReceive44 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 0); Logging.instance .log("checking change addresses...", level: LogLevel.Info); // change addresses - Future resultChange44 = _checkGaps(maxNumberOfIndexesToCheck, + final resultChange44 = _checkGaps(maxNumberOfIndexesToCheck, maxUnusedAddressGap, txCountBatchSize, root, DerivePathType.bip44, 1); await Future.wait([ @@ -653,7 +653,7 @@ class DogecoinWallet extends CoinServiceAPI { // notify on new incoming transaction for (final tx in unconfirmedTxnsToNotifyPending) { if (tx.txType == "Received") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Incoming transaction", body: walletName, walletId: walletId, @@ -664,10 +664,10 @@ class DogecoinWallet extends CoinServiceAPI { txid: tx.txid, confirmations: tx.confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, - ); + )); await txTracker.addNotifiedPending(tx.txid); } else if (tx.txType == "Sent") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Sending transaction", body: walletName, walletId: walletId, @@ -678,7 +678,7 @@ class DogecoinWallet extends CoinServiceAPI { txid: tx.txid, confirmations: tx.confirmations, requiredConfirmations: MINIMUM_CONFIRMATIONS, - ); + )); await txTracker.addNotifiedPending(tx.txid); } } @@ -686,7 +686,7 @@ class DogecoinWallet extends CoinServiceAPI { // notify on confirmed for (final tx in unconfirmedTxnsToNotifyConfirmed) { if (tx.txType == "Received") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Incoming transaction confirmed", body: walletName, walletId: walletId, @@ -694,11 +694,11 @@ class DogecoinWallet extends CoinServiceAPI { date: DateTime.now(), shouldWatchForUpdates: false, coinName: coin.name, - ); + )); await txTracker.addNotifiedConfirmed(tx.txid); } else if (tx.txType == "Sent") { - NotificationApi.showNotification( + unawaited(NotificationApi.showNotification( title: "Outgoing transaction confirmed", body: walletName, walletId: walletId, @@ -706,7 +706,7 @@ class DogecoinWallet extends CoinServiceAPI { date: DateTime.now(), shouldWatchForUpdates: false, coinName: coin.name, - ); + )); await txTracker.addNotifiedConfirmed(tx.txid); } } @@ -770,7 +770,7 @@ class DogecoinWallet extends CoinServiceAPI { if (currentHeight != storedHeight) { if (currentHeight != -1) { // -1 failed to fetch current height - updateStoredChainHeight(newHeight: currentHeight); + unawaited(updateStoredChainHeight(newHeight: currentHeight)); } GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId)); @@ -1127,7 +1127,7 @@ class DogecoinWallet extends CoinServiceAPI { ); if (shouldRefresh) { - refresh(); + unawaited(refresh()); } } @@ -2796,7 +2796,7 @@ class DogecoinWallet extends CoinServiceAPI { ); // clear cache - _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); + await _cachedElectrumXClient.clearSharedTransactionCache(coin: coin); // back up data await _rescanBackup(); @@ -3062,6 +3062,7 @@ class DogecoinWallet extends CoinServiceAPI { return available - estimatedFee; } + @override Future generateNewAddress() async { try { await _incrementAddressIndexForChain( diff --git a/lib/services/coins/epiccash/epiccash_wallet.dart b/lib/services/coins/epiccash/epiccash_wallet.dart index 514ddb79f..2e0d20e5c 100644 --- a/lib/services/coins/epiccash/epiccash_wallet.dart +++ b/lib/services/coins/epiccash/epiccash_wallet.dart @@ -225,7 +225,7 @@ Future executeNative(Map arguments) async { sendPort .send("Error An error was thrown in this isolate $function: $e\n$s"); } finally { - Logging.instance.isar?.close(); + await Logging.instance.isar?.close(); } } @@ -539,7 +539,7 @@ class EpicCashWallet extends CoinServiceAPI { // TODO notify ui/ fire event for node changed? if (shouldRefresh) { - refresh(); + unawaited(refresh()); } } @@ -705,7 +705,7 @@ class EpicCashWallet extends CoinServiceAPI { try { result = await cancelPendingTransaction(tx_slate_id); Logging.instance.log("result?: $result", level: LogLevel.Info); - if (result != null && !(result.toLowerCase().contains("error"))) { + if (!(result.toLowerCase().contains("error"))) { await postCancel( receiveAddress, tx_slate_id, signature, sendersAddress); } @@ -1180,10 +1180,10 @@ class EpicCashWallet extends CoinServiceAPI { transactionFees = message['result'] as String; }); debugPrint(transactionFees); - var decodeData; + dynamic decodeData; try { decodeData = json.decode(transactionFees!); - } catch (e, s) { + } catch (e) { if (ifErrorEstimateFee) { //Error Not enough funds. Required: 0.56500000, Available: 0.56200000 if (transactionFees!.contains("Required")) { @@ -1705,7 +1705,7 @@ class EpicCashWallet extends CoinServiceAPI { try { final String response = message['result'] as String; - if (response == null || response == "") { + if (response == "") { Logging.instance.log("response: ${response.runtimeType}", level: LogLevel.Info); await deleteSlate(currentAddress, @@ -1921,7 +1921,7 @@ class EpicCashWallet extends CoinServiceAPI { if (currentHeight != storedHeight) { if (currentHeight != -1) { // -1 failed to fetch current height - updateStoredChainHeight(newHeight: currentHeight); + unawaited(updateStoredChainHeight(newHeight: currentHeight)); } final newTxData = _fetchTransactionData(); @@ -2288,7 +2288,7 @@ class EpicCashWallet extends CoinServiceAPI { timer?.cancel(); timer = null; if (isActive) { - startSync(); + unawaited(startSync()); } else { for (final isolate in isolates.values) { isolate.kill(priority: Isolate.immediate); diff --git a/lib/services/coins/firo/firo_wallet.dart b/lib/services/coins/firo/firo_wallet.dart index b6f7574b6..ea21721f5 100644 --- a/lib/services/coins/firo/firo_wallet.dart +++ b/lib/services/coins/firo/firo_wallet.dart @@ -1127,7 +1127,7 @@ class FiroWallet extends CoinServiceAPI { final balance = Format.decimalAmountToSatoshis(await availablePrivateBalance()); if (satoshiAmount == balance) { - print("is send all"); + // print("is send all"); isSendAll = true; } dynamic txHexOrError = @@ -2796,18 +2796,18 @@ class FiroWallet extends CoinServiceAPI { final listTxData = txData.getAllTransactions(); listTxData.forEach((key, value) { // ignore change addresses - bool hasAtLeastOneReceive = false; + // bool hasAtLeastOneReceive = false; // int howManyReceiveInputs = 0; - for (var element in value.inputs) { - if (listLelantusTxData.containsKey(element.txid) && - listLelantusTxData[element.txid]!.txType == "Received" - // && - // listLelantusTxData[element.txid].subType != "mint" - ) { - hasAtLeastOneReceive = true; - // howManyReceiveInputs++; - } - } + // for (var element in value.inputs) { + // if (listLelantusTxData.containsKey(element.txid) && + // listLelantusTxData[element.txid]!.txType == "Received" + // // && + // // listLelantusTxData[element.txid].subType != "mint" + // ) { + // // hasAtLeastOneReceive = true; + // // howManyReceiveInputs++; + // } + // } if (value.txType == "Received" && value.subType != "mint") { // Every receive other than a mint should be shown. Mints will be collected and shown from the send side @@ -4238,7 +4238,7 @@ class FiroWallet extends CoinServiceAPI { Future _restore(int latestSetId, Map setDataMap, dynamic usedSerialNumbers) async { final mnemonic = await _secureStore.read(key: '${_walletId}_mnemonic'); - Future data = _txnData; + final dataFuture = _txnData; final String currency = _prefs.currency; final Decimal currentPrice = await firoPrice; @@ -4252,7 +4252,7 @@ class FiroWallet extends CoinServiceAPI { "network": _network, }); - await Future.wait([data]); + await Future.wait([dataFuture]); var result = await receivePort.first; if (result is String) { Logging.instance @@ -4263,8 +4263,7 @@ class FiroWallet extends CoinServiceAPI { stop(receivePort); final message = await staticProcessRestore( - (await data) as models.TransactionData, - result as Map); + (await dataFuture), result as Map); await DB.instance.put( boxName: walletId, key: 'mintIndex', value: message['mintIndex']); @@ -4305,7 +4304,7 @@ class FiroWallet extends CoinServiceAPI { final latestSetId = await getLatestSetId(); final List> sets = []; - List anonFutures = []; + List>> anonFutures = []; for (int i = 1; i <= latestSetId; i++) { final set = cachedElectrumXClient.getAnonymitySet( groupId: "$i", @@ -4315,8 +4314,7 @@ class FiroWallet extends CoinServiceAPI { } await Future.wait(anonFutures); for (int i = 1; i <= latestSetId; i++) { - Map set = - (await anonFutures[i - 1]) as Map; + Map set = (await anonFutures[i - 1]); set["setId"] = i; sets.add(set); } diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index cd297f121..578cf35a4 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -34,6 +34,8 @@ class Prefs extends ChangeNotifier { _backupFrequencyType = await _getBackupFrequencyType(); _lastAutoBackup = await _getLastAutoBackup(); _hideBlockExplorerWarning = await _getHideBlockExplorerWarning(); + _gotoWalletOnStartup = await _getGotoWalletOnStartup(); + _startupWalletId = await _getStartupWalletId(); _initialized = true; } @@ -468,8 +470,6 @@ class Prefs extends ChangeNotifier { boxName: DB.boxNamePrefs, key: "autoBackupFileUri") as DateTime?; } - - // auto backup bool _hideBlockExplorerWarning = false; @@ -480,9 +480,9 @@ class Prefs extends ChangeNotifier { if (_hideBlockExplorerWarning != hideBlockExplorerWarning) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "hideBlockExplorerWarning", - value: hideBlockExplorerWarning) + boxName: DB.boxNamePrefs, + key: "hideBlockExplorerWarning", + value: hideBlockExplorerWarning) .then((_) { _hideBlockExplorerWarning = hideBlockExplorerWarning; notifyListeners(); @@ -492,7 +492,56 @@ class Prefs extends ChangeNotifier { Future _getHideBlockExplorerWarning() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "hideBlockExplorerWarning") as bool? ?? + boxName: DB.boxNamePrefs, + key: "hideBlockExplorerWarning") as bool? ?? false; } + + // auto backup + + bool _gotoWalletOnStartup = false; + + bool get gotoWalletOnStartup => _gotoWalletOnStartup; + + set gotoWalletOnStartup(bool gotoWalletOnStartup) { + if (_gotoWalletOnStartup != gotoWalletOnStartup) { + DB.instance + .put( + boxName: DB.boxNamePrefs, + key: "gotoWalletOnStartup", + value: gotoWalletOnStartup) + .then((_) { + _gotoWalletOnStartup = gotoWalletOnStartup; + notifyListeners(); + }); + } + } + + Future _getGotoWalletOnStartup() async { + return await DB.instance.get( + boxName: DB.boxNamePrefs, key: "gotoWalletOnStartup") as bool? ?? + false; + } + + // startup wallet id + + String? _startupWalletId; + + String? get startupWalletId => _startupWalletId; + + set startupWalletId(String? startupWalletId) { + if (this.startupWalletId != startupWalletId) { + DB.instance.put( + boxName: DB.boxNamePrefs, + key: "startupWalletId", + value: startupWalletId); + _startupWalletId = startupWalletId; + notifyListeners(); + } + } + + Future _getStartupWalletId() async { + return await DB.instance.get( + boxName: DB.boxNamePrefs, key: "startupWalletId") as String?; + } } diff --git a/test/cached_electrumx_test.mocks.dart b/test/cached_electrumx_test.mocks.dart index 1c72d43c2..ce37c93d1 100644 --- a/test/cached_electrumx_test.mocks.dart +++ b/test/cached_electrumx_test.mocks.dart @@ -358,6 +358,28 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { super.noSuchMethod(Invocation.setter(#lastAutoBackup, lastAutoBackup), returnValueForMissingStub: null); @override + bool get hideBlockExplorerWarning => + (super.noSuchMethod(Invocation.getter(#hideBlockExplorerWarning), + returnValue: false) as bool); + @override + set hideBlockExplorerWarning(bool? hideBlockExplorerWarning) => + super.noSuchMethod( + Invocation.setter( + #hideBlockExplorerWarning, hideBlockExplorerWarning), + returnValueForMissingStub: null); + @override + bool get gotoWalletOnStartup => + (super.noSuchMethod(Invocation.getter(#gotoWalletOnStartup), + returnValue: false) as bool); + @override + set gotoWalletOnStartup(bool? gotoWalletOnStartup) => super.noSuchMethod( + Invocation.setter(#gotoWalletOnStartup, gotoWalletOnStartup), + returnValueForMissingStub: null); + @override + set startupWalletId(String? startupWalletId) => + super.noSuchMethod(Invocation.setter(#startupWalletId, startupWalletId), + returnValueForMissingStub: null); + @override bool get hasListeners => (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); diff --git a/test/electrumx_test.mocks.dart b/test/electrumx_test.mocks.dart index 4ef0b01ec..fb115f9ab 100644 --- a/test/electrumx_test.mocks.dart +++ b/test/electrumx_test.mocks.dart @@ -207,6 +207,28 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { super.noSuchMethod(Invocation.setter(#lastAutoBackup, lastAutoBackup), returnValueForMissingStub: null); @override + bool get hideBlockExplorerWarning => + (super.noSuchMethod(Invocation.getter(#hideBlockExplorerWarning), + returnValue: false) as bool); + @override + set hideBlockExplorerWarning(bool? hideBlockExplorerWarning) => + super.noSuchMethod( + Invocation.setter( + #hideBlockExplorerWarning, hideBlockExplorerWarning), + returnValueForMissingStub: null); + @override + bool get gotoWalletOnStartup => + (super.noSuchMethod(Invocation.getter(#gotoWalletOnStartup), + returnValue: false) as bool); + @override + set gotoWalletOnStartup(bool? gotoWalletOnStartup) => super.noSuchMethod( + Invocation.setter(#gotoWalletOnStartup, gotoWalletOnStartup), + returnValueForMissingStub: null); + @override + set startupWalletId(String? startupWalletId) => + super.noSuchMethod(Invocation.setter(#startupWalletId, startupWalletId), + returnValueForMissingStub: null); + @override bool get hasListeners => (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); diff --git a/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart b/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart index 27aa1a772..2e496569f 100644 --- a/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart +++ b/test/models/exchange/estimated_rate_exchange_form_state_test.mocks.dart @@ -8,18 +8,20 @@ import 'package:decimal/decimal.dart' as _i7; import 'package:http/http.dart' as _i4; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/exchange/change_now/available_floating_rate_pair.dart' - as _i12; + as _i13; import 'package:stackwallet/models/exchange/change_now/change_now_response.dart' as _i2; +import 'package:stackwallet/models/exchange/change_now/cn_exchange_estimate.dart' + as _i9; import 'package:stackwallet/models/exchange/change_now/currency.dart' as _i6; import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart' as _i8; import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart' - as _i10; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart' as _i11; +import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart' + as _i12; import 'package:stackwallet/models/exchange/change_now/fixed_rate_market.dart' - as _i9; + as _i10; import 'package:stackwallet/services/change_now/change_now.dart' as _i3; // ignore_for_file: type=lint @@ -98,38 +100,42 @@ class MockChangeNow extends _i1.Mock implements _i3.ChangeNow { as _i5 .Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>>); @override - _i5.Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>> - getEstimatedFixedRateExchangeAmount( + _i5.Future<_i2.ChangeNowResponse<_i9.CNExchangeEstimate>> + getEstimatedExchangeAmountV2( {String? fromTicker, String? toTicker, - _i7.Decimal? fromAmount, - bool? useRateId = true, + _i9.CNEstimateType? fromOrTo, + _i7.Decimal? amount, + String? fromNetwork, + String? toNetwork, + _i9.CNFlowType? flow = _i9.CNFlowType.standard, String? apiKey}) => (super.noSuchMethod( - Invocation.method(#getEstimatedFixedRateExchangeAmount, [], { + Invocation.method(#getEstimatedExchangeAmountV2, [], { #fromTicker: fromTicker, #toTicker: toTicker, - #fromAmount: fromAmount, - #useRateId: useRateId, + #fromOrTo: fromOrTo, + #amount: amount, + #fromNetwork: fromNetwork, + #toNetwork: toNetwork, + #flow: flow, #apiKey: apiKey }), returnValue: Future< - _i2.ChangeNowResponse< - _i8.EstimatedExchangeAmount>>.value( - _FakeChangeNowResponse_0<_i8.EstimatedExchangeAmount>())) - as _i5 - .Future<_i2.ChangeNowResponse<_i8.EstimatedExchangeAmount>>); + _i2.ChangeNowResponse<_i9.CNExchangeEstimate>>.value( + _FakeChangeNowResponse_0<_i9.CNExchangeEstimate>())) + as _i5.Future<_i2.ChangeNowResponse<_i9.CNExchangeEstimate>>); @override - _i5.Future<_i2.ChangeNowResponse>> + _i5.Future<_i2.ChangeNowResponse>> getAvailableFixedRateMarkets({String? apiKey}) => (super.noSuchMethod( Invocation.method( #getAvailableFixedRateMarkets, [], {#apiKey: apiKey}), returnValue: - Future<_i2.ChangeNowResponse>>.value( - _FakeChangeNowResponse_0>())) as _i5 - .Future<_i2.ChangeNowResponse>>); + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i5 + .Future<_i2.ChangeNowResponse>>); @override - _i5.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> + _i5.Future<_i2.ChangeNowResponse<_i11.ExchangeTransaction>> createStandardExchangeTransaction( {String? fromTicker, String? toTicker, @@ -155,11 +161,11 @@ class MockChangeNow extends _i1.Mock implements _i3.ChangeNow { #apiKey: apiKey }), returnValue: Future< - _i2.ChangeNowResponse<_i10.ExchangeTransaction>>.value( - _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i5 - .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); + _i2.ChangeNowResponse<_i11.ExchangeTransaction>>.value( + _FakeChangeNowResponse_0<_i11.ExchangeTransaction>())) as _i5 + .Future<_i2.ChangeNowResponse<_i11.ExchangeTransaction>>); @override - _i5.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> + _i5.Future<_i2.ChangeNowResponse<_i11.ExchangeTransaction>> createFixedRateExchangeTransaction( {String? fromTicker, String? toTicker, @@ -187,26 +193,26 @@ class MockChangeNow extends _i1.Mock implements _i3.ChangeNow { #apiKey: apiKey }), returnValue: Future< - _i2.ChangeNowResponse<_i10.ExchangeTransaction>>.value( - _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i5 - .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); + _i2.ChangeNowResponse<_i11.ExchangeTransaction>>.value( + _FakeChangeNowResponse_0<_i11.ExchangeTransaction>())) as _i5 + .Future<_i2.ChangeNowResponse<_i11.ExchangeTransaction>>); @override - _i5.Future<_i2.ChangeNowResponse<_i11.ExchangeTransactionStatus>> + _i5.Future<_i2.ChangeNowResponse<_i12.ExchangeTransactionStatus>> getTransactionStatus({String? id, String? apiKey}) => (super.noSuchMethod( Invocation.method( #getTransactionStatus, [], {#id: id, #apiKey: apiKey}), returnValue: - Future<_i2.ChangeNowResponse<_i11.ExchangeTransactionStatus>>.value( - _FakeChangeNowResponse_0<_i11.ExchangeTransactionStatus>())) as _i5 - .Future<_i2.ChangeNowResponse<_i11.ExchangeTransactionStatus>>); + Future<_i2.ChangeNowResponse<_i12.ExchangeTransactionStatus>>.value( + _FakeChangeNowResponse_0<_i12.ExchangeTransactionStatus>())) as _i5 + .Future<_i2.ChangeNowResponse<_i12.ExchangeTransactionStatus>>); @override - _i5.Future<_i2.ChangeNowResponse>> + _i5.Future<_i2.ChangeNowResponse>> getAvailableFloatingRatePairs({bool? includePartners = false}) => (super .noSuchMethod( Invocation.method(#getAvailableFloatingRatePairs, [], {#includePartners: includePartners}), returnValue: - Future<_i2.ChangeNowResponse>>.value( - _FakeChangeNowResponse_0>())) as _i5 - .Future<_i2.ChangeNowResponse>>); + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i5 + .Future<_i2.ChangeNowResponse>>); } diff --git a/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart b/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart index 31130ec28..c28b76d74 100644 --- a/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart +++ b/test/screen_tests/address_book_view/subviews/add_address_book_view_screen_test.mocks.dart @@ -334,6 +334,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i8.Future); @override + _i8.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i8.Future); + @override void addListener(_i10.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart b/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart index 618cef5d8..7829cd299 100644 --- a/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart +++ b/test/screen_tests/address_book_view/subviews/address_book_entry_details_view_screen_test.mocks.dart @@ -315,6 +315,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart b/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart index 034e4edf8..0aa30d54f 100644 --- a/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart +++ b/test/screen_tests/address_book_view/subviews/edit_address_book_entry_view_screen_test.mocks.dart @@ -313,6 +313,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/exchange/exchange_view_test.mocks.dart b/test/screen_tests/exchange/exchange_view_test.mocks.dart index aa517d09b..0295bfaed 100644 --- a/test/screen_tests/exchange/exchange_view_test.mocks.dart +++ b/test/screen_tests/exchange/exchange_view_test.mocks.dart @@ -9,18 +9,20 @@ import 'package:decimal/decimal.dart' as _i15; import 'package:http/http.dart' as _i13; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/exchange/change_now/available_floating_rate_pair.dart' - as _i19; + as _i20; import 'package:stackwallet/models/exchange/change_now/change_now_response.dart' as _i2; +import 'package:stackwallet/models/exchange/change_now/cn_exchange_estimate.dart' + as _i17; import 'package:stackwallet/models/exchange/change_now/currency.dart' as _i14; import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart' as _i16; import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart' as _i10; import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart' - as _i18; + as _i19; import 'package:stackwallet/models/exchange/change_now/fixed_rate_market.dart' - as _i17; + as _i18; import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart' as _i5; import 'package:stackwallet/services/change_now/change_now.dart' as _i12; @@ -183,6 +185,28 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { super.noSuchMethod(Invocation.setter(#lastAutoBackup, lastAutoBackup), returnValueForMissingStub: null); @override + bool get hideBlockExplorerWarning => + (super.noSuchMethod(Invocation.getter(#hideBlockExplorerWarning), + returnValue: false) as bool); + @override + set hideBlockExplorerWarning(bool? hideBlockExplorerWarning) => + super.noSuchMethod( + Invocation.setter( + #hideBlockExplorerWarning, hideBlockExplorerWarning), + returnValueForMissingStub: null); + @override + bool get gotoWalletOnStartup => + (super.noSuchMethod(Invocation.getter(#gotoWalletOnStartup), + returnValue: false) as bool); + @override + set gotoWalletOnStartup(bool? gotoWalletOnStartup) => super.noSuchMethod( + Invocation.setter(#gotoWalletOnStartup, gotoWalletOnStartup), + returnValueForMissingStub: null); + @override + set startupWalletId(String? startupWalletId) => + super.noSuchMethod(Invocation.setter(#startupWalletId, startupWalletId), + returnValueForMissingStub: null); + @override bool get hasListeners => (super.noSuchMethod(Invocation.getter(#hasListeners), returnValue: false) as bool); @@ -386,36 +410,40 @@ class MockChangeNow extends _i1.Mock implements _i12.ChangeNow { as _i7 .Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>>); @override - _i7.Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>> - getEstimatedFixedRateExchangeAmount( + _i7.Future<_i2.ChangeNowResponse<_i17.CNExchangeEstimate>> + getEstimatedExchangeAmountV2( {String? fromTicker, String? toTicker, - _i15.Decimal? fromAmount, - bool? useRateId = true, + _i17.CNEstimateType? fromOrTo, + _i15.Decimal? amount, + String? fromNetwork, + String? toNetwork, + _i17.CNFlowType? flow = _i17.CNFlowType.standard, String? apiKey}) => (super.noSuchMethod( - Invocation.method(#getEstimatedFixedRateExchangeAmount, [], { + Invocation.method(#getEstimatedExchangeAmountV2, [], { #fromTicker: fromTicker, #toTicker: toTicker, - #fromAmount: fromAmount, - #useRateId: useRateId, + #fromOrTo: fromOrTo, + #amount: amount, + #fromNetwork: fromNetwork, + #toNetwork: toNetwork, + #flow: flow, #apiKey: apiKey }), returnValue: Future< - _i2.ChangeNowResponse< - _i16.EstimatedExchangeAmount>>.value( - _FakeChangeNowResponse_0<_i16.EstimatedExchangeAmount>())) - as _i7 - .Future<_i2.ChangeNowResponse<_i16.EstimatedExchangeAmount>>); + _i2.ChangeNowResponse<_i17.CNExchangeEstimate>>.value( + _FakeChangeNowResponse_0<_i17.CNExchangeEstimate>())) + as _i7.Future<_i2.ChangeNowResponse<_i17.CNExchangeEstimate>>); @override - _i7.Future<_i2.ChangeNowResponse>> + _i7.Future<_i2.ChangeNowResponse>> getAvailableFixedRateMarkets({String? apiKey}) => (super.noSuchMethod( Invocation.method( #getAvailableFixedRateMarkets, [], {#apiKey: apiKey}), returnValue: - Future<_i2.ChangeNowResponse>>.value( - _FakeChangeNowResponse_0>())) as _i7 - .Future<_i2.ChangeNowResponse>>); + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i7 + .Future<_i2.ChangeNowResponse>>); @override _i7.Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>> createStandardExchangeTransaction( @@ -479,22 +507,22 @@ class MockChangeNow extends _i1.Mock implements _i12.ChangeNow { _FakeChangeNowResponse_0<_i10.ExchangeTransaction>())) as _i7 .Future<_i2.ChangeNowResponse<_i10.ExchangeTransaction>>); @override - _i7.Future<_i2.ChangeNowResponse<_i18.ExchangeTransactionStatus>> + _i7.Future<_i2.ChangeNowResponse<_i19.ExchangeTransactionStatus>> getTransactionStatus({String? id, String? apiKey}) => (super.noSuchMethod( Invocation.method( #getTransactionStatus, [], {#id: id, #apiKey: apiKey}), returnValue: - Future<_i2.ChangeNowResponse<_i18.ExchangeTransactionStatus>>.value( - _FakeChangeNowResponse_0<_i18.ExchangeTransactionStatus>())) as _i7 - .Future<_i2.ChangeNowResponse<_i18.ExchangeTransactionStatus>>); + Future<_i2.ChangeNowResponse<_i19.ExchangeTransactionStatus>>.value( + _FakeChangeNowResponse_0<_i19.ExchangeTransactionStatus>())) as _i7 + .Future<_i2.ChangeNowResponse<_i19.ExchangeTransactionStatus>>); @override - _i7.Future<_i2.ChangeNowResponse>> + _i7.Future<_i2.ChangeNowResponse>> getAvailableFloatingRatePairs({bool? includePartners = false}) => (super .noSuchMethod( Invocation.method(#getAvailableFloatingRatePairs, [], {#includePartners: includePartners}), returnValue: - Future<_i2.ChangeNowResponse>>.value( - _FakeChangeNowResponse_0>())) as _i7 - .Future<_i2.ChangeNowResponse>>); + Future<_i2.ChangeNowResponse>>.value( + _FakeChangeNowResponse_0>())) as _i7 + .Future<_i2.ChangeNowResponse>>); } diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 81369cdf1..d7d0e193c 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -483,6 +483,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i9.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart b/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart index 910b5404b..5d1ac1f5d 100644 --- a/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart +++ b/test/screen_tests/main_view_tests/main_view_screen_testA_test.mocks.dart @@ -373,6 +373,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i6.Future); @override + _i6.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i6.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart b/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart index 1c298aa7e..c2ac8447a 100644 --- a/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart +++ b/test/screen_tests/main_view_tests/main_view_screen_testB_test.mocks.dart @@ -373,6 +373,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i6.Future); @override + _i6.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i6.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart b/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart index 4f00f5f8e..04a0dac53 100644 --- a/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart +++ b/test/screen_tests/main_view_tests/main_view_screen_testC_test.mocks.dart @@ -373,6 +373,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i6.Future); @override + _i6.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i6.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart b/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart index bab971459..80c9677f1 100644 --- a/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/backup_key_view_screen_test.mocks.dart @@ -248,6 +248,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart b/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart index da239f761..c34ced0de 100644 --- a/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/backup_key_warning_view_screen_test.mocks.dart @@ -371,6 +371,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i6.Future); @override + _i6.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i6.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart index 429b5b6b6..f37383e4b 100644 --- a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart @@ -483,6 +483,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i9.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart index 7f0d56002..48de40a42 100644 --- a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart @@ -399,6 +399,10 @@ class MockManager extends _i1.Mock implements _i12.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i8.Future); @override + _i8.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i8.Future); + @override void addListener(_i11.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart b/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart index 769a9263f..e93ed2ce7 100644 --- a/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/verify_backup_key_view_screen_test.mocks.dart @@ -248,6 +248,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart index ec7ea5959..b95f2cc22 100644 --- a/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/currency_view_screen_test.mocks.dart @@ -248,6 +248,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart index b12808703..17fb394ac 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart @@ -360,6 +360,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i8.Future); @override + _i8.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i8.Future); + @override void addListener(_i10.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart index ca45f0303..5c08dc466 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart @@ -360,6 +360,10 @@ class MockManager extends _i1.Mock implements _i11.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i8.Future); @override + _i8.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i8.Future); + @override void addListener(_i10.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart index 6f6475108..10d20aa58 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_backup_view_screen_test.mocks.dart @@ -248,6 +248,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart index 3c9a86351..d5760cd45 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/rescan_warning_view_screen_test.mocks.dart @@ -248,6 +248,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart index c3301a326..969da34a1 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_subviews/wallet_delete_mnemonic_view_screen_test.mocks.dart @@ -371,6 +371,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i6.Future); @override + _i6.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i6.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart index c5645ad09..336bb7222 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart @@ -527,6 +527,10 @@ class MockManager extends _i1.Mock implements _i15.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i8.Future); @override + _i8.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i8.Future); + @override void addListener(_i14.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart index 379ceacd1..f74cec132 100644 --- a/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_view_screen_test.mocks.dart @@ -371,6 +371,10 @@ class MockManager extends _i1.Mock implements _i9.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i6.Future); @override + _i6.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i6.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart b/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart index d26dfc10c..337f73285 100644 --- a/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart +++ b/test/screen_tests/transaction_subviews/transaction_search_results_view_screen_test.mocks.dart @@ -250,6 +250,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart index 623613b53..0fa3baaa5 100644 --- a/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/confirm_send_view_screen_test.mocks.dart @@ -249,6 +249,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart index 86b635747..745dab4f3 100644 --- a/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/receive_view_screen_test.mocks.dart @@ -248,6 +248,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart index c7e4bbe9a..72eb2f746 100644 --- a/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/send_view_screen_test.mocks.dart @@ -270,6 +270,10 @@ class MockManager extends _i1.Mock implements _i8.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i10.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart b/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart index 0ca83f21e..8cbf518ee 100644 --- a/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart +++ b/test/screen_tests/wallet_view/wallet_view_screen_test.mocks.dart @@ -250,6 +250,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null); diff --git a/test/services/coins/manager_test.mocks.dart b/test/services/coins/manager_test.mocks.dart index 600707e90..8baae2d1b 100644 --- a/test/services/coins/manager_test.mocks.dart +++ b/test/services/coins/manager_test.mocks.dart @@ -232,6 +232,22 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { super.noSuchMethod(Invocation.method(#stopNetworkAlivePinging, []), returnValueForMissingStub: null); @override + _i8.Future> prepareSendPublic( + {String? address, int? satoshiAmount, Map? args}) => + (super.noSuchMethod( + Invocation.method(#prepareSendPublic, [], { + #address: address, + #satoshiAmount: satoshiAmount, + #args: args + }), + returnValue: + Future>.value({})) + as _i8.Future>); + @override + _i8.Future confirmSendPublic({dynamic txData}) => (super.noSuchMethod( + Invocation.method(#confirmSendPublic, [], {#txData: txData}), + returnValue: Future.value('')) as _i8.Future); + @override _i8.Future> prepareSend( {String? address, int? satoshiAmount, Map? args}) => (super.noSuchMethod( @@ -257,6 +273,47 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { #send, [], {#toAddress: toAddress, #amount: amount, #args: args}), returnValue: Future.value('')) as _i8.Future); @override + int estimateTxFee({int? vSize, int? feeRatePerKB}) => (super.noSuchMethod( + Invocation.method( + #estimateTxFee, [], {#vSize: vSize, #feeRatePerKB: feeRatePerKB}), + returnValue: 0) as int); + @override + dynamic coinSelection(int? satoshiAmountToSend, int? selectedTxFeeRate, + String? _recipientAddress, bool? isSendAll, + {int? additionalOutputs = 0, List<_i4.UtxoObject>? utxos}) => + super.noSuchMethod(Invocation.method(#coinSelection, [ + satoshiAmountToSend, + selectedTxFeeRate, + _recipientAddress, + isSendAll + ], { + #additionalOutputs: additionalOutputs, + #utxos: utxos + })); + @override + _i8.Future> fetchBuildTxData( + List<_i4.UtxoObject>? utxosToUse) => + (super.noSuchMethod(Invocation.method(#fetchBuildTxData, [utxosToUse]), + returnValue: + Future>.value({})) + as _i8.Future>); + @override + _i8.Future> buildTransaction( + {List<_i4.UtxoObject>? utxosToUse, + Map? utxoSigningData, + List? recipients, + List? satoshiAmounts}) => + (super.noSuchMethod( + Invocation.method(#buildTransaction, [], { + #utxosToUse: utxosToUse, + #utxoSigningData: utxoSigningData, + #recipients: recipients, + #satoshiAmounts: satoshiAmounts + }), + returnValue: + Future>.value({})) + as _i8.Future>); + @override _i8.Future updateNode(bool? shouldRefresh) => (super.noSuchMethod(Invocation.method(#updateNode, [shouldRefresh]), returnValue: Future.value(), @@ -293,8 +350,8 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: >[]) as List>); @override - _i8.Future autoMint() => - (super.noSuchMethod(Invocation.method(#autoMint, []), + _i8.Future anonymizeAllPublicFunds() => + (super.noSuchMethod(Invocation.method(#anonymizeAllPublicFunds, []), returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i8.Future); @override @@ -325,6 +382,11 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i8.Future); @override + _i8.Future checkChangeAddressForTransactions() => (super.noSuchMethod( + Invocation.method(#checkChangeAddressForTransactions, []), + returnValue: Future.value(), + returnValueForMissingStub: Future.value()) as _i8.Future); + @override _i8.Future fillAddresses(String? suppliedMnemonic, {int? perBatch = 50, int? numberOfThreads = 4}) => (super.noSuchMethod( @@ -367,6 +429,11 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: Future.value(), returnValueForMissingStub: Future.value()) as _i8.Future); @override + _i8.Future> getSetDataMap(int? latestSetId) => + (super.noSuchMethod(Invocation.method(#getSetDataMap, [latestSetId]), + returnValue: Future>.value({})) + as _i8.Future>); + @override _i8.Future>> fetchAnonymitySets() => (super.noSuchMethod(Invocation.method(#fetchAnonymitySets, []), returnValue: Future>>.value( @@ -387,11 +454,11 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValueForMissingStub: Future.value()) as _i8.Future); @override _i8.Future getCoinsToJoinSplit(int? required) => - (super.noSuchMethod(Invocation.method(#GetCoinsToJoinSplit, [required]), + (super.noSuchMethod(Invocation.method(#getCoinsToJoinSplit, [required]), returnValue: Future.value()) as _i8.Future); @override _i8.Future estimateJoinSplitFee(int? spendAmount) => (super.noSuchMethod( - Invocation.method(#EstimateJoinSplitFee, [spendAmount]), + Invocation.method(#estimateJoinSplitFee, [spendAmount]), returnValue: Future.value(0)) as _i8.Future); @override _i8.Future estimateFeeFor(int? satoshiAmount, int? feeRate) => @@ -399,6 +466,27 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i8.Future); @override + _i8.Future estimateFeeForPublic(int? satoshiAmount, int? feeRate) => + (super.noSuchMethod( + Invocation.method(#estimateFeeForPublic, [satoshiAmount, feeRate]), + returnValue: Future.value(0)) as _i8.Future); + @override + int roughFeeEstimate(int? inputCount, int? outputCount, int? feeRatePerKB) => + (super.noSuchMethod( + Invocation.method( + #roughFeeEstimate, [inputCount, outputCount, feeRatePerKB]), + returnValue: 0) as int); + @override + int sweepAllEstimate(int? feeRate) => + (super.noSuchMethod(Invocation.method(#sweepAllEstimate, [feeRate]), + returnValue: 0) as int); + @override + _i8.Future>> fastFetch(List? allTxHashes) => + (super.noSuchMethod(Invocation.method(#fastFetch, [allTxHashes]), + returnValue: Future>>.value( + >[])) + as _i8.Future>>); + @override _i8.Future> getJMintTransactions( _i6.CachedElectrumX? cachedClient, List? transactions, @@ -418,6 +506,20 @@ class MockFiroWallet extends _i1.Mock implements _i7.FiroWallet { returnValue: Future>.value(<_i4.Transaction>[])) as _i8.Future>); + @override + _i8.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i8.Future); + @override + _i8.Future<_i3.Decimal> availablePrivateBalance() => + (super.noSuchMethod(Invocation.method(#availablePrivateBalance, []), + returnValue: Future<_i3.Decimal>.value(_FakeDecimal_1())) + as _i8.Future<_i3.Decimal>); + @override + _i8.Future<_i3.Decimal> availablePublicBalance() => + (super.noSuchMethod(Invocation.method(#availablePublicBalance, []), + returnValue: Future<_i3.Decimal>.value(_FakeDecimal_1())) + as _i8.Future<_i3.Decimal>); } /// A class which mocks [ElectrumX]. diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index 5757ab5dd..012df8061 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -250,6 +250,10 @@ class MockManager extends _i1.Mock implements _i5.Manager { Invocation.method(#estimateFeeFor, [satoshiAmount, feeRate]), returnValue: Future.value(0)) as _i7.Future); @override + _i7.Future generateNewAddress() => + (super.noSuchMethod(Invocation.method(#generateNewAddress, []), + returnValue: Future.value(false)) as _i7.Future); + @override void addListener(_i8.VoidCallback? listener) => super.noSuchMethod(Invocation.method(#addListener, [listener]), returnValueForMissingStub: null);