mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-08 19:59:29 +00:00
Merge pull request #878 from cypherstack/firo
Add Lelantus toggle to Firo wallets
This commit is contained in:
commit
62726857f2
10 changed files with 391 additions and 49 deletions
|
@ -25,6 +25,7 @@ import '../../../../utilities/util.dart';
|
|||
import '../../../../wallets/crypto_currency/crypto_currency.dart';
|
||||
import '../../../../widgets/conditional_parent.dart';
|
||||
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import '../../../../widgets/custom_buttons/checkbox_text_button.dart';
|
||||
import '../../../../widgets/date_picker/date_picker.dart';
|
||||
import '../../../../widgets/desktop/desktop_app_bar.dart';
|
||||
import '../../../../widgets/desktop/desktop_scaffold.dart';
|
||||
|
@ -72,6 +73,9 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
|||
|
||||
bool get supportsMnemonicPassphrase => coin.hasMnemonicPassphraseSupport;
|
||||
|
||||
bool enableLelantusScanning = false;
|
||||
bool get supportsLelantus => coin is Firo;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
walletName = widget.walletName;
|
||||
|
@ -107,12 +111,13 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
|||
if (mounted) {
|
||||
await Navigator.of(context).pushNamed(
|
||||
RestoreWalletView.routeName,
|
||||
arguments: Tuple5(
|
||||
arguments: Tuple6(
|
||||
walletName,
|
||||
coin,
|
||||
ref.read(mnemonicWordCountStateProvider.state).state,
|
||||
_restoreFromDate,
|
||||
passwordController.text,
|
||||
enableLelantusScanning,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -437,6 +442,17 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
|||
color: Colors.transparent,
|
||||
child: Column(
|
||||
children: [
|
||||
CheckboxTextButton(
|
||||
label: "Scan for Lelantus transactions",
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
enableLelantusScanning = newValue ?? true;
|
||||
});
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
|
|
|
@ -22,15 +22,9 @@ import 'package:flutter_libmonero/monero/monero.dart' as libxmr;
|
|||
import 'package:flutter_libmonero/wownero/wownero.dart' as libwow;
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
|
||||
import '../../../notifications/show_flush_bar.dart';
|
||||
import '../add_token_view/edit_wallet_tokens_view.dart';
|
||||
import 'confirm_recovery_dialog.dart';
|
||||
import 'sub_widgets/restore_failed_dialog.dart';
|
||||
import 'sub_widgets/restore_succeeded_dialog.dart';
|
||||
import 'sub_widgets/restoring_dialog.dart';
|
||||
import '../select_wallet_for_token_view.dart';
|
||||
import '../verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
||||
import '../../home_view/home_view.dart';
|
||||
import '../../../pages_desktop_specific/desktop_home_view.dart';
|
||||
import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||
import '../../../providers/db/main_db_provider.dart';
|
||||
|
@ -64,7 +58,14 @@ import '../../../widgets/icon_widgets/qrcode_icon.dart';
|
|||
import '../../../widgets/table_view/table_view.dart';
|
||||
import '../../../widgets/table_view/table_view_cell.dart';
|
||||
import '../../../widgets/table_view/table_view_row.dart';
|
||||
import 'package:wakelock/wakelock.dart';
|
||||
import '../../home_view/home_view.dart';
|
||||
import '../add_token_view/edit_wallet_tokens_view.dart';
|
||||
import '../select_wallet_for_token_view.dart';
|
||||
import '../verify_recovery_phrase_view/verify_recovery_phrase_view.dart';
|
||||
import 'confirm_recovery_dialog.dart';
|
||||
import 'sub_widgets/restore_failed_dialog.dart';
|
||||
import 'sub_widgets/restore_succeeded_dialog.dart';
|
||||
import 'sub_widgets/restoring_dialog.dart';
|
||||
|
||||
class RestoreWalletView extends ConsumerStatefulWidget {
|
||||
const RestoreWalletView({
|
||||
|
@ -74,6 +75,7 @@ class RestoreWalletView extends ConsumerStatefulWidget {
|
|||
required this.seedWordsLength,
|
||||
required this.mnemonicPassphrase,
|
||||
required this.restoreFromDate,
|
||||
this.enableLelantusScanning = false,
|
||||
this.barcodeScanner = const BarcodeScannerWrapper(),
|
||||
this.clipboard = const ClipboardWrapper(),
|
||||
});
|
||||
|
@ -85,6 +87,7 @@ class RestoreWalletView extends ConsumerStatefulWidget {
|
|||
final String mnemonicPassphrase;
|
||||
final int seedWordsLength;
|
||||
final DateTime restoreFromDate;
|
||||
final bool enableLelantusScanning;
|
||||
|
||||
final BarcodeScannerInterface barcodeScanner;
|
||||
final ClipboardInterface clipboard;
|
||||
|
@ -256,6 +259,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
|||
otherDataJsonString = jsonEncode(
|
||||
{
|
||||
WalletInfoKeys.lelantusCoinIsarRescanRequired: false,
|
||||
WalletInfoKeys.enableLelantusScanning:
|
||||
widget.enableLelantusScanning,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* This file is part of Stack Wallet.
|
||||
*
|
||||
* Copyright (c) 2023 Cypher Stack
|
||||
* All Rights Reserved.
|
||||
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
||||
* Generated by Cypher Stack on 2023-05-26
|
||||
*
|
||||
*/
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../../../providers/db/main_db_provider.dart';
|
||||
import '../../../../providers/global/wallets_provider.dart';
|
||||
import '../../../../themes/stack_colors.dart';
|
||||
import '../../../../utilities/text_styles.dart';
|
||||
import '../../../../wallets/crypto_currency/crypto_currency.dart';
|
||||
import '../../../../wallets/isar/models/wallet_info.dart';
|
||||
import '../../../../wallets/wallet/wallet.dart';
|
||||
import '../../../../widgets/background.dart';
|
||||
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import '../../../../widgets/custom_buttons/draggable_switch_button.dart';
|
||||
|
||||
class LelantusSettingsView extends ConsumerStatefulWidget {
|
||||
const LelantusSettingsView({
|
||||
super.key,
|
||||
required this.walletId,
|
||||
});
|
||||
|
||||
static const String routeName = "/lelantusSettings";
|
||||
|
||||
final String walletId;
|
||||
|
||||
@override
|
||||
ConsumerState<LelantusSettingsView> createState() =>
|
||||
_LelantusSettingsViewState();
|
||||
}
|
||||
|
||||
class _LelantusSettingsViewState extends ConsumerState<LelantusSettingsView> {
|
||||
late final TextEditingController _controller;
|
||||
late final String walletId;
|
||||
|
||||
final _focusNode = FocusNode();
|
||||
|
||||
bool _isInitialized = false;
|
||||
Wallet<CryptoCurrency>? wallet;
|
||||
bool _enableLelantusScanning = false;
|
||||
bool _isUpdatingLelantusScanning = false;
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
if (!_isInitialized) {
|
||||
// Get the wallet.
|
||||
wallet = ref.watch(
|
||||
pWallets.select(
|
||||
(value) => value.getWallet(widget.walletId),
|
||||
),
|
||||
);
|
||||
|
||||
// Parse otherDataJsonString to get the enableLelantusScanning value.
|
||||
if (wallet?.info.otherDataJsonString != null) {
|
||||
final otherDataJson = json.decode(wallet!.info.otherDataJsonString!);
|
||||
_enableLelantusScanning =
|
||||
otherDataJson[WalletInfoKeys.enableLelantusScanning] as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
_isInitialized = true; // Ensure this logic runs only once
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
_focusNode.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Background(
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
|
||||
appBar: AppBar(
|
||||
leading: AppBarBackButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
title: Text(
|
||||
"Lelantus settings",
|
||||
style: STextStyles.navBarTitle(context),
|
||||
),
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
width: 40,
|
||||
child: DraggableSwitchButton(
|
||||
isOn: _enableLelantusScanning,
|
||||
onValueChanged: (newValue) async {
|
||||
if (_isUpdatingLelantusScanning) return;
|
||||
_isUpdatingLelantusScanning = true; // Lock mutex.
|
||||
|
||||
// Toggle enableLelantusScanning in wallet info.
|
||||
await wallet?.info.updateOtherData(
|
||||
newEntries: {
|
||||
WalletInfoKeys.enableLelantusScanning:
|
||||
!_enableLelantusScanning,
|
||||
},
|
||||
isar: ref.read(mainDBProvider).isar,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
_enableLelantusScanning = !_enableLelantusScanning;
|
||||
_isUpdatingLelantusScanning = false; // Free mutex.
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Scan for Lelantus transactions",
|
||||
style: STextStyles.smallMed12(context),
|
||||
),
|
||||
// Text(
|
||||
// detail,
|
||||
// style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
|
@ -10,9 +10,7 @@
|
|||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../../pinpad_views/lock_screen_view.dart';
|
||||
import 'delete_wallet_warning_view.dart';
|
||||
import 'rename_wallet_view.dart';
|
||||
|
||||
import '../../../../route_generator.dart';
|
||||
import '../../../../themes/stack_colors.dart';
|
||||
import '../../../../utilities/constants.dart';
|
||||
|
@ -22,6 +20,10 @@ import '../../../../widgets/background.dart';
|
|||
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import '../../../../widgets/rounded_white_container.dart';
|
||||
import '../../../../widgets/stack_dialog.dart';
|
||||
import '../../../pinpad_views/lock_screen_view.dart';
|
||||
import 'delete_wallet_warning_view.dart';
|
||||
import 'lelantus_settings_view.dart';
|
||||
import 'rename_wallet_view.dart';
|
||||
|
||||
class WalletSettingsWalletSettingsView extends ConsumerWidget {
|
||||
const WalletSettingsWalletSettingsView({
|
||||
|
@ -180,6 +182,40 @@ class WalletSettingsWalletSettingsView extends ConsumerWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
RoundedWhiteContainer(
|
||||
padding: const EdgeInsets.all(0),
|
||||
child: RawMaterialButton(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pushNamed(
|
||||
LelantusSettingsView.routeName,
|
||||
arguments: walletId,
|
||||
);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12.0,
|
||||
vertical: 20,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
"Lelantus settings",
|
||||
style: STextStyles.titleBold12(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -8,9 +8,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../../../providers/db/main_db_provider.dart';
|
||||
import '../../../../../providers/global/prefs_provider.dart';
|
||||
import '../../../../../providers/global/wallets_provider.dart';
|
||||
import '../../../../../themes/stack_colors.dart';
|
||||
|
@ -18,10 +22,12 @@ import '../../../../../utilities/assets.dart';
|
|||
import '../../../../../utilities/text_styles.dart';
|
||||
import '../../../../../wallets/crypto_currency/coins/banano.dart';
|
||||
import '../../../../../wallets/crypto_currency/coins/firo.dart';
|
||||
import '../../../../../wallets/isar/models/wallet_info.dart';
|
||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart';
|
||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart';
|
||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart';
|
||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart';
|
||||
import '../../../../../widgets/custom_buttons/draggable_switch_button.dart';
|
||||
import '../../../../../widgets/desktop/desktop_dialog.dart';
|
||||
import '../../../../../widgets/desktop/desktop_dialog_close_button.dart';
|
||||
import '../../../../../widgets/rounded_container.dart';
|
||||
|
@ -53,6 +59,9 @@ class MoreFeaturesDialog extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
||||
bool _enableLelantusScanning = false;
|
||||
bool _isUpdatingLelantusScanning = false; // Mutex.
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final wallet = ref.watch(
|
||||
|
@ -61,6 +70,14 @@ class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
|||
),
|
||||
);
|
||||
|
||||
// Parse otherDataJsonString to get the enableLelantusScanning value.
|
||||
if (wallet.info.otherDataJsonString != null) {
|
||||
final otherDataJson = json.decode(wallet.info.otherDataJsonString!);
|
||||
_enableLelantusScanning =
|
||||
otherDataJson[WalletInfoKeys.enableLelantusScanning] as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
final coinControlPrefEnabled = ref.watch(
|
||||
prefsChangeNotifierProvider.select(
|
||||
(value) => value.enableCoinControl,
|
||||
|
@ -136,6 +153,65 @@ class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
|||
iconAsset: Assets.svg.cashFusion,
|
||||
onPressed: () => widget.onFusionPressed?.call(),
|
||||
),
|
||||
if (wallet.info.coin is Firo)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 6,
|
||||
horizontal: 32,
|
||||
),
|
||||
child: RoundedContainer(
|
||||
color: Colors.transparent,
|
||||
borderColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 3),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
width: 40,
|
||||
child: DraggableSwitchButton(
|
||||
isOn: _enableLelantusScanning,
|
||||
onValueChanged: (newValue) async {
|
||||
if (_isUpdatingLelantusScanning) return;
|
||||
_isUpdatingLelantusScanning = true; // Lock mutex.
|
||||
|
||||
// Toggle enableLelantusScanning in wallet info.
|
||||
await wallet.info.updateOtherData(
|
||||
newEntries: {
|
||||
WalletInfoKeys.enableLelantusScanning:
|
||||
!_enableLelantusScanning,
|
||||
},
|
||||
isar: ref.read(mainDBProvider).isar,
|
||||
);
|
||||
|
||||
setState(() {
|
||||
_enableLelantusScanning = !_enableLelantusScanning;
|
||||
_isUpdatingLelantusScanning = false; // Free mutex.
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Scan for Lelantus transactions",
|
||||
style: STextStyles.w600_20(context),
|
||||
),
|
||||
// Text(
|
||||
// detail,
|
||||
// style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 28,
|
||||
),
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
import 'models/add_wallet_list_entity/add_wallet_list_entity.dart';
|
||||
import 'models/add_wallet_list_entity/sub_classes/eth_token_entity.dart';
|
||||
import 'models/buy/response_objects/quote.dart';
|
||||
|
@ -127,6 +129,7 @@ import 'pages/settings_views/wallet_settings_view/wallet_settings_view.dart';
|
|||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart';
|
||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart';
|
||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart';
|
||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart';
|
||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart';
|
||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart';
|
||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart';
|
||||
|
@ -194,7 +197,6 @@ import 'wallets/models/tx_data.dart';
|
|||
import 'wallets/wallet/wallet.dart';
|
||||
import 'widgets/choose_coin_view.dart';
|
||||
import 'widgets/frost_scaffold.dart';
|
||||
import 'package:tuple/tuple.dart';
|
||||
|
||||
/*
|
||||
* This file contains all the routes for the app.
|
||||
|
@ -1390,7 +1392,8 @@ class RouteGenerator {
|
|||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case RestoreWalletView.routeName:
|
||||
if (args is Tuple5<String, CryptoCurrency, int, DateTime, String>) {
|
||||
if (args
|
||||
is Tuple6<String, CryptoCurrency, int, DateTime, String, bool>) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => RestoreWalletView(
|
||||
|
@ -1399,6 +1402,7 @@ class RouteGenerator {
|
|||
seedWordsLength: args.item3,
|
||||
restoreFromDate: args.item4,
|
||||
mnemonicPassphrase: args.item5,
|
||||
enableLelantusScanning: args.item6 ?? false,
|
||||
),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
|
@ -1950,6 +1954,18 @@ class RouteGenerator {
|
|||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
case LelantusSettingsView.routeName:
|
||||
if (args is String) {
|
||||
return getRoute(
|
||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||
builder: (_) => LelantusSettingsView(walletId: args),
|
||||
settings: RouteSettings(
|
||||
name: settings.name,
|
||||
),
|
||||
);
|
||||
}
|
||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||
|
||||
// == Desktop specific routes ============================================
|
||||
case CreatePasswordView.routeName:
|
||||
if (args is bool) {
|
||||
|
|
|
@ -507,4 +507,5 @@ abstract class WalletInfoKeys {
|
|||
static const String tezosDerivationPath = "tezosDerivationPathKey";
|
||||
static const String lelantusCoinIsarRescanRequired =
|
||||
"lelantusCoinIsarRescanRequired";
|
||||
static const String enableLelantusScanning = "enableLelantusScanningKey";
|
||||
}
|
||||
|
|
|
@ -610,13 +610,26 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
|
|||
await mainDB.deleteWalletBlockchainData(walletId);
|
||||
}
|
||||
|
||||
// Parse otherDataJsonString to get the enableLelantusScanning value.
|
||||
bool? enableLelantusScanning = false;
|
||||
if (info.otherDataJsonString != null) {
|
||||
final otherDataJson = json.decode(info.otherDataJsonString!);
|
||||
enableLelantusScanning =
|
||||
otherDataJson[WalletInfoKeys.enableLelantusScanning] as bool? ??
|
||||
false;
|
||||
}
|
||||
|
||||
// lelantus
|
||||
final latestSetId = await electrumXClient.getLelantusLatestCoinId();
|
||||
final setDataMapFuture = getSetDataMap(latestSetId);
|
||||
final usedSerialNumbersFuture =
|
||||
electrumXCachedClient.getUsedCoinSerials(
|
||||
cryptoCurrency: info.coin,
|
||||
);
|
||||
int? latestSetId;
|
||||
Future<Map<int, dynamic>>? setDataMapFuture;
|
||||
Future<List<String>>? usedSerialNumbersFuture;
|
||||
if (enableLelantusScanning) {
|
||||
latestSetId = await electrumXClient.getLelantusLatestCoinId();
|
||||
setDataMapFuture = getSetDataMap(latestSetId);
|
||||
usedSerialNumbersFuture = electrumXCachedClient.getUsedCoinSerials(
|
||||
cryptoCurrency: info.coin,
|
||||
);
|
||||
}
|
||||
|
||||
// spark
|
||||
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
||||
|
@ -736,39 +749,52 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
|
|||
updateUTXOs(),
|
||||
]);
|
||||
|
||||
final futureResults = await Future.wait([
|
||||
usedSerialNumbersFuture,
|
||||
setDataMapFuture,
|
||||
sparkAnonSetFuture,
|
||||
sparkUsedCoinTagsFuture,
|
||||
]);
|
||||
List<Future<dynamic>> futures = [];
|
||||
|
||||
futures.add(sparkAnonSetFuture);
|
||||
futures.add(sparkUsedCoinTagsFuture);
|
||||
if (enableLelantusScanning) {
|
||||
futures.add(usedSerialNumbersFuture!);
|
||||
futures.add(setDataMapFuture!);
|
||||
}
|
||||
|
||||
final futureResults = await Future.wait(futures);
|
||||
|
||||
// lelantus
|
||||
final usedSerialsSet = (futureResults[0] as List<String>).toSet();
|
||||
final setDataMap = futureResults[1] as Map<dynamic, dynamic>;
|
||||
Set<String>? usedSerialsSet;
|
||||
Map<dynamic, dynamic>? setDataMap;
|
||||
if (enableLelantusScanning) {
|
||||
usedSerialsSet = (futureResults[2] as List<String>).toSet();
|
||||
setDataMap = futureResults[3] as Map<dynamic, dynamic>;
|
||||
}
|
||||
|
||||
// spark
|
||||
final sparkAnonymitySet = futureResults[2] as Map<String, dynamic>;
|
||||
final sparkSpentCoinTags = futureResults[3] as Set<String>;
|
||||
final sparkAnonymitySet = futureResults[0] as Map<String, dynamic>;
|
||||
final sparkSpentCoinTags = futureResults[1] as Set<String>;
|
||||
|
||||
if (Util.isDesktop) {
|
||||
await Future.wait([
|
||||
recoverLelantusWallet(
|
||||
latestSetId: latestSetId,
|
||||
usedSerialNumbers: usedSerialsSet,
|
||||
setDataMap: setDataMap,
|
||||
),
|
||||
recoverSparkWallet(
|
||||
anonymitySet: sparkAnonymitySet,
|
||||
spentCoinTags: sparkSpentCoinTags,
|
||||
),
|
||||
]);
|
||||
List<Future<dynamic>> futures = [];
|
||||
if (enableLelantusScanning) {
|
||||
futures.add(recoverLelantusWallet(
|
||||
latestSetId: latestSetId!,
|
||||
usedSerialNumbers: usedSerialsSet!,
|
||||
setDataMap: setDataMap!,
|
||||
));
|
||||
}
|
||||
futures.add(recoverSparkWallet(
|
||||
anonymitySet: sparkAnonymitySet,
|
||||
spentCoinTags: sparkSpentCoinTags,
|
||||
));
|
||||
|
||||
await Future.wait(futures);
|
||||
} else {
|
||||
await recoverLelantusWallet(
|
||||
latestSetId: latestSetId,
|
||||
usedSerialNumbers: usedSerialsSet,
|
||||
setDataMap: setDataMap,
|
||||
);
|
||||
if (enableLelantusScanning) {
|
||||
await recoverLelantusWallet(
|
||||
latestSetId: latestSetId!,
|
||||
usedSerialNumbers: usedSerialsSet!,
|
||||
setDataMap: setDataMap!,
|
||||
);
|
||||
}
|
||||
await recoverSparkWallet(
|
||||
anonymitySet: sparkAnonymitySet,
|
||||
spentCoinTags: sparkSpentCoinTags,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
@ -558,7 +559,17 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
|
||||
// TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided.
|
||||
if (this is LelantusInterface) {
|
||||
await (this as LelantusInterface).refreshLelantusData();
|
||||
// Parse otherDataJsonString to get the enableLelantusScanning value.
|
||||
bool enableLelantusScanning = false;
|
||||
if (this.info.otherDataJsonString != null) {
|
||||
final otherDataJson = json.decode(this.info.otherDataJsonString!);
|
||||
enableLelantusScanning =
|
||||
otherDataJson[WalletInfoKeys.enableLelantusScanning] as bool? ??
|
||||
false;
|
||||
}
|
||||
if (enableLelantusScanning) {
|
||||
await (this as LelantusInterface).refreshLelantusData();
|
||||
}
|
||||
}
|
||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId));
|
||||
|
||||
|
|
|
@ -1194,7 +1194,7 @@ packages:
|
|||
source: hosted
|
||||
version: "0.2.0"
|
||||
monero:
|
||||
dependency: "direct main"
|
||||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: "6a17a405a1a260fa228b2f4fc94044088a4335ac"
|
||||
|
|
Loading…
Reference in a new issue