Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/pages/exchange_view/choose_from_stack_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../providers/providers.dart';
import '../../themes/stack_colors.dart';
import '../../utilities/constants.dart';
import '../../utilities/logger.dart';
import '../../utilities/text_styles.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
import '../../wallets/isar/providers/wallet_info_provider.dart';
Expand Down Expand Up @@ -50,7 +51,16 @@ class _ChooseFromStackViewState extends ConsumerState<ChooseFromStackView> {
ref
.watch(pWallets)
.wallets
.where((e) => e.info.coin == coin)
.where((e) {
try {
return e.info.coin == coin;
} catch (ex) {
Logging.instance.e(
"Error while filtering wallets for ${coin.ticker}: $ex",
);
return false;
}
})
.map((e) => e.walletId)
.toList();

Expand Down
13 changes: 12 additions & 1 deletion lib/pages/wallets_view/wallets_overview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import '../../services/event_bus/global_event_bus.dart';
import '../../themes/stack_colors.dart';
import '../../utilities/assets.dart';
import '../../utilities/constants.dart';
import '../../utilities/logger.dart';
import '../../utilities/text_styles.dart';
import '../../utilities/util.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
Expand Down Expand Up @@ -130,7 +131,17 @@ class _EthWalletsOverviewState extends ConsumerState<WalletsOverview> {
void updateWallets() {
final walletsData = ref.read(pAllWalletsInfo);

walletsData.removeWhere((e) => e.coin != widget.coin);
walletsData.removeWhere((e) {
try {
return e.coin != widget.coin;
} catch (ex) {
// Remove wallets with unknown/unsupported coins.
Logging.instance.e(
"Error while filtering wallets for ${e.coin.ticker}: $ex",
);
return true;
}
});

if (widget.coin is Ethereum) {
for (final data in walletsData) {
Expand Down
28 changes: 18 additions & 10 deletions lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import '../../providers/global/prefs_provider.dart';
import '../../providers/global/wallets_provider.dart';
import '../../themes/stack_colors.dart';
import '../../utilities/constants.dart';
import '../../utilities/logger.dart';
import '../../utilities/show_loading.dart';
import '../../utilities/show_node_tor_settings_mismatch.dart';
import '../../utilities/util.dart';
Expand All @@ -27,21 +28,28 @@ import '../../widgets/wallet_info_row/wallet_info_row.dart';
import 'wallet_view/desktop_wallet_view.dart';

class CoinWalletsTable extends ConsumerWidget {
const CoinWalletsTable({
super.key,
required this.coin,
});
const CoinWalletsTable({super.key, required this.coin});

final CryptoCurrency coin;

@override
Widget build(BuildContext context, WidgetRef ref) {
final walletIds = ref
.watch(pWallets)
.wallets
.where((e) => e.info.coin == coin)
.map((e) => e.walletId)
.toList();
final walletIds =
ref
.watch(pWallets)
.wallets
.where((e) {
try {
return e.info.coin == coin;
} catch (ex) {
Logging.instance.e(
"Error while filtering wallets for ${coin.ticker}: $ex",
);
return false;
}
})
.map((e) => e.walletId)
.toList();

return Container(
decoration: BoxDecoration(
Expand Down
8 changes: 7 additions & 1 deletion lib/wallets/isar/models/wallet_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ class WalletInfo implements IsarId {
}

@ignore
CryptoCurrency get coin => AppConfig.getCryptoCurrencyFor(coinName)!;
CryptoCurrency get coin {
final result = AppConfig.getCryptoCurrencyFor(coinName);
if (result == null) {
throw Exception('Unknown cryptocurrency: $coinName for wallet $walletId');
}
return result;
}

@ignore
Balance get cachedBalance {
Expand Down
13 changes: 11 additions & 2 deletions lib/widgets/node_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import '../utilities/assets.dart';
import '../utilities/constants.dart';
import '../utilities/default_nodes.dart';
import '../utilities/enums/sync_type_enum.dart';
import '../utilities/logger.dart';
import '../utilities/test_node_connection.dart';
import '../utilities/text_styles.dart';
import '../utilities/tor_plain_net_option_enum.dart';
Expand Down Expand Up @@ -59,8 +60,16 @@ class _NodeCardState extends ConsumerState<NodeCard> {
bool _advancedIsExpanded = false;

Future<void> _notifyWalletsOfUpdatedNode(WidgetRef ref) async {
final wallets =
ref.read(pWallets).wallets.where((e) => e.info.coin == widget.coin);
final wallets = ref.read(pWallets).wallets.where((e) {
try {
return e.info.coin == widget.coin;
} catch (ex) {
Logging.instance.e(
"Error while filtering wallets for ${widget.coin}: $ex",
);
return false;
}
});
final prefs = ref.read(prefsChangeNotifierProvider);

switch (prefs.syncType) {
Expand Down
13 changes: 11 additions & 2 deletions lib/widgets/node_options_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import '../utilities/assets.dart';
import '../utilities/constants.dart';
import '../utilities/default_nodes.dart';
import '../utilities/enums/sync_type_enum.dart';
import '../utilities/logger.dart';
import '../utilities/test_node_connection.dart';
import '../utilities/text_styles.dart';
import '../utilities/tor_plain_net_option_enum.dart';
Expand All @@ -44,8 +45,16 @@ class NodeOptionsSheet extends ConsumerWidget {
final String popBackToRoute;

Future<void> _notifyWalletsOfUpdatedNode(WidgetRef ref) async {
final wallets =
ref.read(pWallets).wallets.where((e) => e.info.coin == coin);
final wallets = ref.read(pWallets).wallets.where((e) {
try {
return e.info.coin == coin;
} catch (ex) {
Logging.instance.e(
"Error while filtering wallets for ${coin.ticker}: $ex",
);
return false;
}
});
final prefs = ref.read(prefsChangeNotifierProvider);

switch (prefs.syncType) {
Expand Down
Loading