mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +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 '../../../../wallets/crypto_currency/crypto_currency.dart';
|
||||||
import '../../../../widgets/conditional_parent.dart';
|
import '../../../../widgets/conditional_parent.dart';
|
||||||
import '../../../../widgets/custom_buttons/app_bar_icon_button.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/date_picker/date_picker.dart';
|
||||||
import '../../../../widgets/desktop/desktop_app_bar.dart';
|
import '../../../../widgets/desktop/desktop_app_bar.dart';
|
||||||
import '../../../../widgets/desktop/desktop_scaffold.dart';
|
import '../../../../widgets/desktop/desktop_scaffold.dart';
|
||||||
|
@ -72,6 +73,9 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
|
|
||||||
bool get supportsMnemonicPassphrase => coin.hasMnemonicPassphraseSupport;
|
bool get supportsMnemonicPassphrase => coin.hasMnemonicPassphraseSupport;
|
||||||
|
|
||||||
|
bool enableLelantusScanning = false;
|
||||||
|
bool get supportsLelantus => coin is Firo;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
walletName = widget.walletName;
|
walletName = widget.walletName;
|
||||||
|
@ -107,12 +111,13 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
await Navigator.of(context).pushNamed(
|
await Navigator.of(context).pushNamed(
|
||||||
RestoreWalletView.routeName,
|
RestoreWalletView.routeName,
|
||||||
arguments: Tuple5(
|
arguments: Tuple6(
|
||||||
walletName,
|
walletName,
|
||||||
coin,
|
coin,
|
||||||
ref.read(mnemonicWordCountStateProvider.state).state,
|
ref.read(mnemonicWordCountStateProvider.state).state,
|
||||||
_restoreFromDate,
|
_restoreFromDate,
|
||||||
passwordController.text,
|
passwordController.text,
|
||||||
|
enableLelantusScanning,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -437,6 +442,17 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
CheckboxTextButton(
|
||||||
|
label: "Scan for Lelantus transactions",
|
||||||
|
onChanged: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
enableLelantusScanning = newValue ?? true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 8,
|
||||||
|
),
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius: BorderRadius.circular(
|
borderRadius: BorderRadius.circular(
|
||||||
Constants.size.circularBorderRadius,
|
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_libmonero/wownero/wownero.dart' as libwow;
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
import '../../../notifications/show_flush_bar.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/desktop_home_view.dart';
|
||||||
import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
|
||||||
import '../../../providers/db/main_db_provider.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.dart';
|
||||||
import '../../../widgets/table_view/table_view_cell.dart';
|
import '../../../widgets/table_view/table_view_cell.dart';
|
||||||
import '../../../widgets/table_view/table_view_row.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 {
|
class RestoreWalletView extends ConsumerStatefulWidget {
|
||||||
const RestoreWalletView({
|
const RestoreWalletView({
|
||||||
|
@ -74,6 +75,7 @@ class RestoreWalletView extends ConsumerStatefulWidget {
|
||||||
required this.seedWordsLength,
|
required this.seedWordsLength,
|
||||||
required this.mnemonicPassphrase,
|
required this.mnemonicPassphrase,
|
||||||
required this.restoreFromDate,
|
required this.restoreFromDate,
|
||||||
|
this.enableLelantusScanning = false,
|
||||||
this.barcodeScanner = const BarcodeScannerWrapper(),
|
this.barcodeScanner = const BarcodeScannerWrapper(),
|
||||||
this.clipboard = const ClipboardWrapper(),
|
this.clipboard = const ClipboardWrapper(),
|
||||||
});
|
});
|
||||||
|
@ -85,6 +87,7 @@ class RestoreWalletView extends ConsumerStatefulWidget {
|
||||||
final String mnemonicPassphrase;
|
final String mnemonicPassphrase;
|
||||||
final int seedWordsLength;
|
final int seedWordsLength;
|
||||||
final DateTime restoreFromDate;
|
final DateTime restoreFromDate;
|
||||||
|
final bool enableLelantusScanning;
|
||||||
|
|
||||||
final BarcodeScannerInterface barcodeScanner;
|
final BarcodeScannerInterface barcodeScanner;
|
||||||
final ClipboardInterface clipboard;
|
final ClipboardInterface clipboard;
|
||||||
|
@ -256,6 +259,8 @@ class _RestoreWalletViewState extends ConsumerState<RestoreWalletView> {
|
||||||
otherDataJsonString = jsonEncode(
|
otherDataJsonString = jsonEncode(
|
||||||
{
|
{
|
||||||
WalletInfoKeys.lelantusCoinIsarRescanRequired: false,
|
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/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.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 '../../../../route_generator.dart';
|
||||||
import '../../../../themes/stack_colors.dart';
|
import '../../../../themes/stack_colors.dart';
|
||||||
import '../../../../utilities/constants.dart';
|
import '../../../../utilities/constants.dart';
|
||||||
|
@ -22,6 +20,10 @@ import '../../../../widgets/background.dart';
|
||||||
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
|
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
|
||||||
import '../../../../widgets/rounded_white_container.dart';
|
import '../../../../widgets/rounded_white_container.dart';
|
||||||
import '../../../../widgets/stack_dialog.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 {
|
class WalletSettingsWalletSettingsView extends ConsumerWidget {
|
||||||
const WalletSettingsWalletSettingsView({
|
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/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
import '../../../../../providers/db/main_db_provider.dart';
|
||||||
import '../../../../../providers/global/prefs_provider.dart';
|
import '../../../../../providers/global/prefs_provider.dart';
|
||||||
import '../../../../../providers/global/wallets_provider.dart';
|
import '../../../../../providers/global/wallets_provider.dart';
|
||||||
import '../../../../../themes/stack_colors.dart';
|
import '../../../../../themes/stack_colors.dart';
|
||||||
|
@ -18,10 +22,12 @@ import '../../../../../utilities/assets.dart';
|
||||||
import '../../../../../utilities/text_styles.dart';
|
import '../../../../../utilities/text_styles.dart';
|
||||||
import '../../../../../wallets/crypto_currency/coins/banano.dart';
|
import '../../../../../wallets/crypto_currency/coins/banano.dart';
|
||||||
import '../../../../../wallets/crypto_currency/coins/firo.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/cash_fusion_interface.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_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/ordinals_interface.dart';
|
||||||
import '../../../../../wallets/wallet/wallet_mixin_interfaces/paynym_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.dart';
|
||||||
import '../../../../../widgets/desktop/desktop_dialog_close_button.dart';
|
import '../../../../../widgets/desktop/desktop_dialog_close_button.dart';
|
||||||
import '../../../../../widgets/rounded_container.dart';
|
import '../../../../../widgets/rounded_container.dart';
|
||||||
|
@ -53,6 +59,9 @@ class MoreFeaturesDialog extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
||||||
|
bool _enableLelantusScanning = false;
|
||||||
|
bool _isUpdatingLelantusScanning = false; // Mutex.
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final wallet = ref.watch(
|
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(
|
final coinControlPrefEnabled = ref.watch(
|
||||||
prefsChangeNotifierProvider.select(
|
prefsChangeNotifierProvider.select(
|
||||||
(value) => value.enableCoinControl,
|
(value) => value.enableCoinControl,
|
||||||
|
@ -136,6 +153,65 @@ class _MoreFeaturesDialogState extends ConsumerState<MoreFeaturesDialog> {
|
||||||
iconAsset: Assets.svg.cashFusion,
|
iconAsset: Assets.svg.cashFusion,
|
||||||
onPressed: () => widget.onFusionPressed?.call(),
|
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(
|
const SizedBox(
|
||||||
height: 28,
|
height: 28,
|
||||||
),
|
),
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:isar/isar.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/add_wallet_list_entity.dart';
|
||||||
import 'models/add_wallet_list_entity/sub_classes/eth_token_entity.dart';
|
import 'models/add_wallet_list_entity/sub_classes/eth_token_entity.dart';
|
||||||
import 'models/buy/response_objects/quote.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/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_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/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/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/wallet_settings_wallet_settings_view.dart';
|
||||||
import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_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 'wallets/wallet/wallet.dart';
|
||||||
import 'widgets/choose_coin_view.dart';
|
import 'widgets/choose_coin_view.dart';
|
||||||
import 'widgets/frost_scaffold.dart';
|
import 'widgets/frost_scaffold.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file contains all the routes for the app.
|
* This file contains all the routes for the app.
|
||||||
|
@ -1390,7 +1392,8 @@ class RouteGenerator {
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
||||||
|
|
||||||
case RestoreWalletView.routeName:
|
case RestoreWalletView.routeName:
|
||||||
if (args is Tuple5<String, CryptoCurrency, int, DateTime, String>) {
|
if (args
|
||||||
|
is Tuple6<String, CryptoCurrency, int, DateTime, String, bool>) {
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
builder: (_) => RestoreWalletView(
|
builder: (_) => RestoreWalletView(
|
||||||
|
@ -1399,6 +1402,7 @@ class RouteGenerator {
|
||||||
seedWordsLength: args.item3,
|
seedWordsLength: args.item3,
|
||||||
restoreFromDate: args.item4,
|
restoreFromDate: args.item4,
|
||||||
mnemonicPassphrase: args.item5,
|
mnemonicPassphrase: args.item5,
|
||||||
|
enableLelantusScanning: args.item6 ?? false,
|
||||||
),
|
),
|
||||||
settings: RouteSettings(
|
settings: RouteSettings(
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
|
@ -1950,6 +1954,18 @@ class RouteGenerator {
|
||||||
}
|
}
|
||||||
return _routeError("${settings.name} invalid args: ${args.toString()}");
|
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 ============================================
|
// == Desktop specific routes ============================================
|
||||||
case CreatePasswordView.routeName:
|
case CreatePasswordView.routeName:
|
||||||
if (args is bool) {
|
if (args is bool) {
|
||||||
|
|
|
@ -507,4 +507,5 @@ abstract class WalletInfoKeys {
|
||||||
static const String tezosDerivationPath = "tezosDerivationPathKey";
|
static const String tezosDerivationPath = "tezosDerivationPathKey";
|
||||||
static const String lelantusCoinIsarRescanRequired =
|
static const String lelantusCoinIsarRescanRequired =
|
||||||
"lelantusCoinIsarRescanRequired";
|
"lelantusCoinIsarRescanRequired";
|
||||||
|
static const String enableLelantusScanning = "enableLelantusScanningKey";
|
||||||
}
|
}
|
||||||
|
|
|
@ -610,13 +610,26 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
|
||||||
await mainDB.deleteWalletBlockchainData(walletId);
|
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
|
// lelantus
|
||||||
final latestSetId = await electrumXClient.getLelantusLatestCoinId();
|
int? latestSetId;
|
||||||
final setDataMapFuture = getSetDataMap(latestSetId);
|
Future<Map<int, dynamic>>? setDataMapFuture;
|
||||||
final usedSerialNumbersFuture =
|
Future<List<String>>? usedSerialNumbersFuture;
|
||||||
electrumXCachedClient.getUsedCoinSerials(
|
if (enableLelantusScanning) {
|
||||||
cryptoCurrency: info.coin,
|
latestSetId = await electrumXClient.getLelantusLatestCoinId();
|
||||||
);
|
setDataMapFuture = getSetDataMap(latestSetId);
|
||||||
|
usedSerialNumbersFuture = electrumXCachedClient.getUsedCoinSerials(
|
||||||
|
cryptoCurrency: info.coin,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// spark
|
// spark
|
||||||
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId();
|
||||||
|
@ -736,39 +749,52 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
|
||||||
updateUTXOs(),
|
updateUTXOs(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final futureResults = await Future.wait([
|
List<Future<dynamic>> futures = [];
|
||||||
usedSerialNumbersFuture,
|
|
||||||
setDataMapFuture,
|
futures.add(sparkAnonSetFuture);
|
||||||
sparkAnonSetFuture,
|
futures.add(sparkUsedCoinTagsFuture);
|
||||||
sparkUsedCoinTagsFuture,
|
if (enableLelantusScanning) {
|
||||||
]);
|
futures.add(usedSerialNumbersFuture!);
|
||||||
|
futures.add(setDataMapFuture!);
|
||||||
|
}
|
||||||
|
|
||||||
|
final futureResults = await Future.wait(futures);
|
||||||
|
|
||||||
// lelantus
|
// lelantus
|
||||||
final usedSerialsSet = (futureResults[0] as List<String>).toSet();
|
Set<String>? usedSerialsSet;
|
||||||
final setDataMap = futureResults[1] as Map<dynamic, dynamic>;
|
Map<dynamic, dynamic>? setDataMap;
|
||||||
|
if (enableLelantusScanning) {
|
||||||
|
usedSerialsSet = (futureResults[2] as List<String>).toSet();
|
||||||
|
setDataMap = futureResults[3] as Map<dynamic, dynamic>;
|
||||||
|
}
|
||||||
|
|
||||||
// spark
|
// spark
|
||||||
final sparkAnonymitySet = futureResults[2] as Map<String, dynamic>;
|
final sparkAnonymitySet = futureResults[0] as Map<String, dynamic>;
|
||||||
final sparkSpentCoinTags = futureResults[3] as Set<String>;
|
final sparkSpentCoinTags = futureResults[1] as Set<String>;
|
||||||
|
|
||||||
if (Util.isDesktop) {
|
if (Util.isDesktop) {
|
||||||
await Future.wait([
|
List<Future<dynamic>> futures = [];
|
||||||
recoverLelantusWallet(
|
if (enableLelantusScanning) {
|
||||||
latestSetId: latestSetId,
|
futures.add(recoverLelantusWallet(
|
||||||
usedSerialNumbers: usedSerialsSet,
|
latestSetId: latestSetId!,
|
||||||
setDataMap: setDataMap,
|
usedSerialNumbers: usedSerialsSet!,
|
||||||
),
|
setDataMap: setDataMap!,
|
||||||
recoverSparkWallet(
|
));
|
||||||
anonymitySet: sparkAnonymitySet,
|
}
|
||||||
spentCoinTags: sparkSpentCoinTags,
|
futures.add(recoverSparkWallet(
|
||||||
),
|
anonymitySet: sparkAnonymitySet,
|
||||||
]);
|
spentCoinTags: sparkSpentCoinTags,
|
||||||
|
));
|
||||||
|
|
||||||
|
await Future.wait(futures);
|
||||||
} else {
|
} else {
|
||||||
await recoverLelantusWallet(
|
if (enableLelantusScanning) {
|
||||||
latestSetId: latestSetId,
|
await recoverLelantusWallet(
|
||||||
usedSerialNumbers: usedSerialsSet,
|
latestSetId: latestSetId!,
|
||||||
setDataMap: setDataMap,
|
usedSerialNumbers: usedSerialsSet!,
|
||||||
);
|
setDataMap: setDataMap!,
|
||||||
|
);
|
||||||
|
}
|
||||||
await recoverSparkWallet(
|
await recoverSparkWallet(
|
||||||
anonymitySet: sparkAnonymitySet,
|
anonymitySet: sparkAnonymitySet,
|
||||||
spentCoinTags: sparkSpentCoinTags,
|
spentCoinTags: sparkSpentCoinTags,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:isar/isar.dart';
|
import 'package:isar/isar.dart';
|
||||||
import 'package:meta/meta.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.
|
// TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided.
|
||||||
if (this is LelantusInterface) {
|
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));
|
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.90, walletId));
|
||||||
|
|
||||||
|
|
|
@ -1194,7 +1194,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.0"
|
version: "0.2.0"
|
||||||
monero:
|
monero:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
path: "."
|
path: "."
|
||||||
ref: "6a17a405a1a260fa228b2f4fc94044088a4335ac"
|
ref: "6a17a405a1a260fa228b2f4fc94044088a4335ac"
|
||||||
|
|
Loading…
Reference in a new issue