From 46d1310039b434d6f101ce46206d4a6b54599c77 Mon Sep 17 00:00:00 2001 From: julian Date: Sat, 13 Jan 2024 11:09:37 -0600 Subject: [PATCH] Some todo clean up and re prioritization --- .../send_view/confirm_transaction_view.dart | 2 +- .../sub_widgets/restoring_wallet_card.dart | 25 --------- .../wallet_network_settings_view.dart | 52 +++++++++---------- .../wallet_settings_view.dart | 2 +- .../firo_rescan_recovery_error_dialog.dart | 2 +- .../all_transactions_view.dart | 3 +- .../tx_v2/all_transactions_v2_view.dart | 6 +-- lib/pages/wallet_view/wallet_view.dart | 2 +- .../desktop_attention_delete_wallet.dart | 3 +- .../unlock_wallet_keys_desktop.dart | 6 ++- lib/wallets/wallet/impl/epiccash_wallet.dart | 22 ++------ lib/wallets/wallet/impl/particl_wallet.dart | 6 +-- lib/wallets/wallet/wallet.dart | 2 +- 13 files changed, 46 insertions(+), 87 deletions(-) diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index 1bc5a841f..e9063d328 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -793,7 +793,7 @@ class _ConfirmTransactionViewState height: 2, ), SelectableText( - // TODO: [prio=high] spark transaction specifics - better handling + // TODO: [prio=med] spark transaction specifics - better handling widget.isPaynymTransaction ? widget.txData.paynymAccountLite!.nymName : widget.txData.recipients?.first.address ?? diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart index fab224cfd..36c3d7c81 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart @@ -112,31 +112,6 @@ class _RestoringWalletCardState extends ConsumerState { restoringStatus: StackRestoringStatus.restoring); try { - // TODO: [prio=high] handle non mnemonic based wallets - // final mnemonicList = await (wallet as MnemonicBasedWallet) - // .getMnemonicAsWords(); - // int maxUnusedAddressGap = 20; - // if (coin == Coin.firo) { - // maxUnusedAddressGap = 50; - // } - // const maxNumberOfIndexesToCheck = 1000; - // - // if (mnemonicList.isEmpty) { - // await manager.recoverFromMnemonic( - // mnemonic: ref.read(provider).mnemonic!, - // mnemonicPassphrase: - // ref.read(provider).mnemonicPassphrase!, - // maxUnusedAddressGap: maxUnusedAddressGap, - // maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, - // height: ref.read(provider).height ?? 0, - // ); - // } else { - // await manager.fullRescan( - // maxUnusedAddressGap, - // maxNumberOfIndexesToCheck, - // ); - // } - await wallet.recover(isRescan: true); if (mounted) { diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index 8228ceb1c..6fbf8df93 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -36,6 +36,9 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; +import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; +import 'package:stackwallet/wallets/wallet/impl/monero_wallet.dart'; +import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart'; import 'package:stackwallet/widgets/animated_text.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; @@ -316,33 +319,28 @@ class _WalletNetworkSettingsViewState final coin = ref.watch(pWalletCoin(widget.walletId)); - // TODO: [prio=high] sync percent for certain wallets - // if (coin == Coin.monero) { - // double highestPercent = - // (ref.read(pWallets).getWallet(widget.walletId).wallet as MoneroWallet) - // .highestPercentCached; - // if (_percent < highestPercent) { - // _percent = highestPercent.clamp(0.0, 1.0); - // } - // } else if (coin == Coin.wownero) { - // double highestPercent = (ref - // .watch(pWallets) - // .getWallet(widget.walletId) - // .wallet as WowneroWallet) - // .highestPercentCached; - // if (_percent < highestPercent) { - // _percent = highestPercent.clamp(0.0, 1.0); - // } - // } else if (coin == Coin.epicCash) { - // double highestPercent = (ref - // .watch(pWallets) - // .getWallet(widget.walletId) - // .wallet as EpicCashWallet) - // .highestPercent; - // if (_percent < highestPercent) { - // _percent = highestPercent.clamp(0.0, 1.0); - // } - // } + if (coin == Coin.monero) { + double highestPercent = + (ref.read(pWallets).getWallet(widget.walletId) as MoneroWallet) + .highestPercentCached; + if (_percent < highestPercent) { + _percent = highestPercent.clamp(0.0, 1.0); + } + } else if (coin == Coin.wownero) { + double highestPercent = + (ref.watch(pWallets).getWallet(widget.walletId) as WowneroWallet) + .highestPercentCached; + if (_percent < highestPercent) { + _percent = highestPercent.clamp(0.0, 1.0); + } + } else if (coin == Coin.epicCash) { + double highestPercent = + (ref.watch(pWallets).getWallet(widget.walletId) as EpiccashWallet) + .highestPercent; + if (_percent < highestPercent) { + _percent = highestPercent.clamp(0.0, 1.0); + } + } return ConditionalParent( condition: !isDesktop, diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart index 726010c67..0714528e0 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart @@ -235,7 +235,7 @@ class _WalletSettingsViewState extends ConsumerState { final wallet = ref .read(pWallets) .getWallet(widget.walletId); - // TODO: [prio=high] take wallets that don't have amnemonic into account + // TODO: [prio=frost] take wallets that don't have a mnemonic into account if (wallet is MnemonicInterface) { final mnemonic = await wallet.getMnemonicAsWords(); diff --git a/lib/pages/special/firo_rescan_recovery_error_dialog.dart b/lib/pages/special/firo_rescan_recovery_error_dialog.dart index 2908f1959..d062b62d5 100644 --- a/lib/pages/special/firo_rescan_recovery_error_dialog.dart +++ b/lib/pages/special/firo_rescan_recovery_error_dialog.dart @@ -258,7 +258,7 @@ class _FiroRescanRecoveryErrorViewState } else { final wallet = ref.read(pWallets).getWallet(widget.walletId); - // TODO: [prio=high] take wallets that don't have amnemonic into account + // TODO: [prio=low] take wallets that don't have a mnemonic into account if (wallet is MnemonicInterface) { final mnemonic = await wallet.getMnemonicAsWords(); diff --git a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart index c84e8aa02..658fe8797 100644 --- a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart +++ b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart @@ -493,7 +493,8 @@ class _TransactionDetailsViewState extends ConsumerState { value: [widget.walletId], ) ], - // TODO: [prio=high] add filters to wallet or cryptocurrency class + // TODO: [prio=med] add filters to wallet or cryptocurrency class + // Might not be needed (yet)? // filter: [ // // todo // ], diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart index c3bc64310..6c74ed337 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart @@ -484,9 +484,6 @@ class _AllTransactionsV2ViewState extends ConsumerState { final criteria = ref.watch(transactionFilterProvider.state).state; - //todo: check if print needed - // debugPrint("Consumer build called"); - return FutureBuilder( future: ref .watch(mainDBProvider) @@ -499,7 +496,8 @@ class _AllTransactionsV2ViewState extends ConsumerState { value: [widget.walletId], ) ], - // TODO: [prio=high] add filters to wallet or cryptocurrency class + // TODO: [prio=med] add filters to wallet or cryptocurrency class + // Might not be needed (yet)? // filter: [ // // todo // ], diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 0511f1166..bbb688f01 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -182,7 +182,7 @@ class _WalletViewState extends ConsumerState { _lelantusRescanRecovery = true; _firoRescanRecovery(); // } else if (ref.read(managerProvider).rescanOnOpenVersion == - // TODO: [prio=high] + // TODO: [prio=med] // Constants.rescanV1) { // _rescanningOnOpen = true; // ref.read(managerProvider).fullRescan(20, 1000).then( diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart index ed04dabaf..a5353fffa 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart @@ -113,7 +113,8 @@ class _DesktopAttentionDeleteWallet onPressed: () async { final wallet = ref.read(pWallets).getWallet(widget.walletId); - // TODO: [prio=high] handle other types wallet deletion + // TODO: [prio=med] handle other types wallet deletion + // All wallets currently are mnemonic based if (wallet is MnemonicInterface) { final words = await wallet.getMnemonicAsWords(); diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart index 618c173d7..0a9a5a29e 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart @@ -81,7 +81,8 @@ class _UnlockWalletKeysDesktopState final wallet = ref.read(pWallets).getWallet(widget.walletId); - // TODO: [prio=high] handle wallets that don't have a mnemonic + // TODO: [prio=med] handle wallets that don't have a mnemonic + // All wallets currently are mnemonic based if (wallet is! MnemonicInterface) { throw Exception("FIXME ~= see todo in code"); } @@ -303,7 +304,8 @@ class _UnlockWalletKeysDesktopState final wallet = ref.read(pWallets).getWallet(widget.walletId); - // TODO: [prio=high] handle wallets that don't have a mnemonic + // TODO: [prio=low] handle wallets that don't have a mnemonic + // All wallets currently are mnemonic based if (wallet is! MnemonicInterface) { throw Exception("FIXME ~= see todo in code"); } diff --git a/lib/wallets/wallet/impl/epiccash_wallet.dart b/lib/wallets/wallet/impl/epiccash_wallet.dart index b7ec7754d..147140cac 100644 --- a/lib/wallets/wallet/impl/epiccash_wallet.dart +++ b/lib/wallets/wallet/impl/epiccash_wallet.dart @@ -296,7 +296,7 @@ class EpiccashWallet extends Bip39Wallet { Map txAddressInfo, ) async { try { - var slatesToCommits = await _getSlatesToCommits(); + final slatesToCommits = info.epicData?.slatesToCommits ?? {}; final from = txAddressInfo['from']; final to = txAddressInfo['to']; slatesToCommits[slateData.slateId] = { @@ -318,22 +318,6 @@ class EpiccashWallet extends Bip39Wallet { } } - // TODO: [prio=high] this isn't needed. Condense to `info.epicData?.slatesToCommits ?? {}` where needed - Future> _getSlatesToCommits() async { - try { - var slatesToCommits = info.epicData?.slatesToCommits; - if (slatesToCommits == null) { - slatesToCommits = {}; - } else { - slatesToCommits = slatesToCommits; - } - return slatesToCommits; - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return {}; - } - } - Future _getCurrentIndex() async { try { final int receivingIndex = info.epicData!.receivingIndex; @@ -455,7 +439,7 @@ class EpiccashWallet extends Bip39Wallet { ); } -// TODO: [prio=high] what is the point of this??? + // As opposed to fake config? Future _getRealConfig() async { String? config = await secureStorageInterface.read( key: '${walletId}_config', @@ -954,7 +938,7 @@ class EpiccashWallet extends Bip39Wallet { final List txns = []; - final slatesToCommits = await _getSlatesToCommits(); + final slatesToCommits = info.epicData?.slatesToCommits ?? {}; for (final tx in transactions) { // Logging.instance.log("tx: $tx", level: LogLevel.Info); diff --git a/lib/wallets/wallet/impl/particl_wallet.dart b/lib/wallets/wallet/impl/particl_wallet.dart index 3c31f4454..4018b17e3 100644 --- a/lib/wallets/wallet/impl/particl_wallet.dart +++ b/lib/wallets/wallet/impl/particl_wallet.dart @@ -187,7 +187,7 @@ class ParticlWallet extends Bip39HDWallet (inputTx["vout"] as List).firstWhere((e) => e["n"] == vout) as Map); - final prevOut = fromElectrumXJsonParticl( + final prevOut = _parseOutput( prevOutJson, decimalPlaces: cryptoCurrency.fractionDigits, isFullAmountNotSats: true, @@ -227,7 +227,7 @@ class ParticlWallet extends Bip39HDWallet // Parse outputs. final List outputs = []; for (final outputJson in txData["vout"] as List) { - OutputV2 output = fromElectrumXJsonParticl( + OutputV2 output = _parseOutput( Map.from(outputJson as Map), decimalPlaces: cryptoCurrency.fractionDigits, isFullAmountNotSats: true, @@ -462,7 +462,7 @@ class ParticlWallet extends Bip39HDWallet } /// OutputV2.fromElectrumXJson wrapper for Particl-specific outputs. - static OutputV2 fromElectrumXJsonParticl( + OutputV2 _parseOutput( Map json, { // Other params just passed thru to fromElectrumXJson for transparent outs. required bool walletOwns, diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 037827832..5961a868d 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -206,7 +206,7 @@ abstract class Wallet { ); } - // TODO: [prio=med] refactor to more generalized token rather than eth specific + // TODO: [prio=low] refactor to more generalized token rather than eth specific static Wallet loadTokenWallet({ required EthereumWallet ethWallet, required EthContract contract,