Merge remote-tracking branch 'origin/staging' into tor

This commit is contained in:
sneurlax 2023-08-14 12:32:41 -05:00
commit c88320a59e
5 changed files with 66 additions and 9 deletions

View file

@ -9,6 +9,7 @@
*/ */
import 'dart:convert'; import 'dart:convert';
import 'dart:math';
import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/electrumx_rpc/electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart';
@ -157,7 +158,6 @@ class CachedElectrumX {
Future<List<String>> getUsedCoinSerials({ Future<List<String>> getUsedCoinSerials({
required Coin coin, required Coin coin,
int startNumber = 0,
}) async { }) async {
try { try {
final box = await DB.instance.getUsedSerialsCacheBox(coin: coin); final box = await DB.instance.getUsedSerialsCacheBox(coin: coin);
@ -168,7 +168,7 @@ class CachedElectrumX {
_list == null ? {} : List<String>.from(_list).toSet(); _list == null ? {} : List<String>.from(_list).toSet();
final startNumber = 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( final serials = await electrumXClient.getUsedCoinSerials(
startNumber: startNumber, startNumber: startNumber,

View file

@ -13,6 +13,7 @@ import 'dart:async';
import 'package:event_bus/event_bus.dart'; import 'package:event_bus/event_bus.dart';
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:stackwallet/db/hive/db.dart';
import 'package:stackwallet/models/epicbox_config_model.dart'; import 'package:stackwallet/models/epicbox_config_model.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/address_book_views/address_book_view.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/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/enums/coin_enum.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/text_styles.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.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/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
/// [eventBus] should only be set during testing /// [eventBus] should only be set during testing
@ -306,6 +310,61 @@ class _WalletSettingsViewState extends ConsumerState<WalletSettingsView> {
); );
}, },
), ),
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<void>(
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<void>(
[
Future.delayed(
const Duration(
milliseconds: 1500,
),
),
DB.instance
.clearSharedTransactionCache(
coin: coin,
),
],
),
context: context,
message: "Clearing cache...",
);
}
},
);
},
),
if (coin == Coin.nano || coin == Coin.banano) if (coin == Coin.nano || coin == Coin.banano)
const SizedBox( const SizedBox(
height: 8, height: 8,

View file

@ -35,6 +35,7 @@ class TxIcon extends ConsumerWidget {
String _getAssetName( String _getAssetName(
bool isCancelled, bool isReceived, bool isPending, IThemeAssets assets) { bool isCancelled, bool isReceived, bool isPending, IThemeAssets assets) {
if (!isReceived && transaction.subType == TransactionSubType.mint) { if (!isReceived && transaction.subType == TransactionSubType.mint) {
if (isCancelled) { if (isCancelled) {
return Assets.svg.anonymizeFailed; return Assets.svg.anonymizeFailed;
@ -47,7 +48,7 @@ class TxIcon extends ConsumerWidget {
if (isReceived) { if (isReceived) {
if (isCancelled) { if (isCancelled) {
return assets.receive; return assets.receiveCancelled;
} }
if (isPending) { if (isPending) {
return assets.receivePending; return assets.receivePending;

View file

@ -358,8 +358,6 @@ class _TransactionDetailsViewState
final currentHeight = ref.watch(walletsChangeNotifierProvider final currentHeight = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(walletId).currentHeight)); .select((value) => value.getManager(walletId).currentHeight));
print("THIS TRANSACTION IS $_transaction");
return ConditionalParent( return ConditionalParent(
condition: !isDesktop, condition: !isDesktop,
builder: (child) => Background( builder: (child) => Background(
@ -1584,8 +1582,7 @@ class _TransactionDetailsViewState
coin.requiredConfirmations, coin.requiredConfirmations,
) == ) ==
false && false &&
_transaction.isCancelled == false && _transaction.isCancelled == false)
_transaction.type == TransactionType.outgoing)
? ConditionalParent( ? ConditionalParent(
condition: isDesktop, condition: isDesktop,
builder: (child) => Padding( builder: (child) => Padding(

View file

@ -2286,8 +2286,8 @@ void main() {
when(cachedClient.getAnonymitySet( when(cachedClient.getAnonymitySet(
groupId: "1", blockhash: "", coin: Coin.firo)) groupId: "1", blockhash: "", coin: Coin.firo))
.thenAnswer((_) async => GetAnonymitySetSampleData.data); .thenAnswer((_) async => GetAnonymitySetSampleData.data);
when(cachedClient.getUsedCoinSerials(startNumber: 0, coin: Coin.firo)) when(cachedClient.getUsedCoinSerials(coin: Coin.firo)).thenAnswer(
.thenAnswer((_) async => List<String>.from( (_) async => List<String>.from(
GetUsedSerialsSampleData.serials['serials'] as List)); GetUsedSerialsSampleData.serials['serials'] as List));
final firo = FiroWallet( final firo = FiroWallet(