From ea47e41d9097632a8fab190950eeeff4b61310dc Mon Sep 17 00:00:00 2001 From: likho Date: Wed, 2 Aug 2023 13:30:06 +0200 Subject: [PATCH 1/3] Allow cancelling incoming txs for Epiccash --- lib/pages/wallet_view/sub_widgets/tx_icon.dart | 3 ++- .../transaction_views/transaction_details_view.dart | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index d86ad6e8d..46972c49b 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -35,6 +35,7 @@ class TxIcon extends ConsumerWidget { String _getAssetName( bool isCancelled, bool isReceived, bool isPending, IThemeAssets assets) { + if (!isReceived && transaction.subType == TransactionSubType.mint) { if (isCancelled) { return Assets.svg.anonymizeFailed; @@ -47,7 +48,7 @@ class TxIcon extends ConsumerWidget { if (isReceived) { if (isCancelled) { - return assets.receive; + return assets.receiveCancelled; } if (isPending) { return assets.receivePending; diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index 2b1ba62c4..88d0d8b1a 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -358,8 +358,6 @@ class _TransactionDetailsViewState final currentHeight = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId).currentHeight)); - print("THIS TRANSACTION IS $_transaction"); - return ConditionalParent( condition: !isDesktop, builder: (child) => Background( @@ -1584,8 +1582,7 @@ class _TransactionDetailsViewState coin.requiredConfirmations, ) == false && - _transaction.isCancelled == false && - _transaction.type == TransactionType.outgoing) + _transaction.isCancelled == false) ? ConditionalParent( condition: isDesktop, builder: (child) => Padding( From 0d701a51b782256e1c5c567f3a160ca2bc684105 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 14 Aug 2023 09:21:27 -0600 Subject: [PATCH 2/3] clear electrumx cache option for firo wallets --- lib/electrumx_rpc/cached_electrumx.dart | 4 +- .../wallet_settings_view.dart | 59 +++++++++++++++++++ .../services/coins/firo/firo_wallet_test.dart | 4 +- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/lib/electrumx_rpc/cached_electrumx.dart b/lib/electrumx_rpc/cached_electrumx.dart index 8366e259f..cb5237bab 100644 --- a/lib/electrumx_rpc/cached_electrumx.dart +++ b/lib/electrumx_rpc/cached_electrumx.dart @@ -9,6 +9,7 @@ */ import 'dart:convert'; +import 'dart:math'; import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; @@ -157,7 +158,6 @@ class CachedElectrumX { Future> getUsedCoinSerials({ required Coin coin, - int startNumber = 0, }) async { try { final box = await DB.instance.getUsedSerialsCacheBox(coin: coin); @@ -168,7 +168,7 @@ class CachedElectrumX { _list == null ? {} : List.from(_list).toSet(); final startNumber = - cachedSerials.length - 10; // 10 being some arbitrary buffer + max(0, cachedSerials.length - 100); // 100 being some arbitrary buffer final serials = await electrumXClient.getUsedCoinSerials( startNumber: startNumber, 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 fcacc60d4..6b7e57bef 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 @@ -13,6 +13,7 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/models/epicbox_config_model.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; @@ -36,11 +37,14 @@ import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/utilities/show_loading.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; /// [eventBus] should only be set during testing @@ -306,6 +310,61 @@ class _WalletSettingsViewState extends ConsumerState { ); }, ), + if (coin == Coin.firo) + const SizedBox( + height: 8, + ), + if (coin == Coin.firo) + Consumer( + builder: (_, ref, __) { + return SettingsListButton( + iconAssetName: Assets.svg.eye, + title: "Clear electrumx cache", + onPressed: () async { + String? result; + await showDialog( + useSafeArea: false, + barrierDismissible: true, + context: context, + builder: (_) => StackOkDialog( + title: + "Are you sure you want to clear " + "${coin.prettyName} electrumx cache?", + onOkPressed: (value) { + result = value; + }, + leftButton: SecondaryButton( + label: "Cancel", + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ), + ); + + if (result == "OK" && mounted) { + await showLoading( + whileFuture: Future.wait( + [ + Future.delayed( + const Duration( + milliseconds: 1500, + ), + ), + DB.instance + .clearSharedTransactionCache( + coin: coin, + ), + ], + ), + context: context, + message: "Clearing cache...", + ); + } + }, + ); + }, + ), if (coin == Coin.nano || coin == Coin.banano) const SizedBox( height: 8, diff --git a/test/services/coins/firo/firo_wallet_test.dart b/test/services/coins/firo/firo_wallet_test.dart index 05b4aeeff..2bda494fc 100644 --- a/test/services/coins/firo/firo_wallet_test.dart +++ b/test/services/coins/firo/firo_wallet_test.dart @@ -2286,8 +2286,8 @@ void main() { when(cachedClient.getAnonymitySet( groupId: "1", blockhash: "", coin: Coin.firo)) .thenAnswer((_) async => GetAnonymitySetSampleData.data); - when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) - .thenAnswer((_) async => List.from( + when(cachedClient.getUsedCoinSerials(coin: Coin.firo)).thenAnswer( + (_) async => List.from( GetUsedSerialsSampleData.serials['serials'] as List)); final firo = FiroWallet( From 27e33f4deaecedca61200871937199d290ff3e97 Mon Sep 17 00:00:00 2001 From: Diego Salazar Date: Mon, 14 Aug 2023 11:49:20 -0600 Subject: [PATCH 3/3] Bump version (build 1.7.18, build 186) --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 9d9e842cf..bca5686c4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Stack Wallet # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.7.17+185 +version: 1.7.18+186 environment: sdk: ">=3.0.2 <4.0.0"