fix(cw_monero): transaction not appearing after send (#2268)

* fix: catch error in newly added fetchTransactions call fix: null handling in cw_monero * fix(cw_monero): transaction not appearing after send

cyan committed May 15, 2025 at 18:48 UTC bc52cf485e52733f95bad6b187820a5bbcf4a825
3 files changed +7 -9
cw_monero/lib/monero_wallet.dart
+1 -1
@@ -446,7 +446,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
446
447 // final status = monero.PendingTransaction_status(pendingTransactionDescription);
448
449 - return PendingMoneroTransaction(pendingTransactionDescription);
449 + return PendingMoneroTransaction(pendingTransactionDescription, this);
450 }
451
452 @override
cw_monero/lib/pending_monero_transaction.dart
+6 -1
@@ -7,6 +7,7 @@ import 'package:cw_core/amount_converter.dart';
7
8 import 'package:cw_core/pending_transaction.dart';
9 import 'package:cw_monero/api/wallet.dart';
10 +import 'package:cw_monero/monero_wallet.dart';
11
12 class DoubleSpendException implements Exception {
13 DoubleSpendException();
@@ -17,9 +18,10 @@ class DoubleSpendException implements Exception {
18 }
19
20 class PendingMoneroTransaction with PendingTransaction {
20 - PendingMoneroTransaction(this.pendingTransactionDescription);
21 + PendingMoneroTransaction(this.pendingTransactionDescription, this.wallet);
22
23 final PendingTransactionDescription pendingTransactionDescription;
24 + final MoneroWalletBase wallet;
25
26 @override
27 String get id => pendingTransactionDescription.hash;
@@ -54,6 +56,7 @@ class PendingMoneroTransaction with PendingTransaction {
56
57 rethrow;
58 }
59 + await wallet.fetchTransactions();
60 storeSync(force: true);
61 }
62
@@ -63,6 +66,8 @@ class PendingMoneroTransaction with PendingTransaction {
66 final ret = monero_transaction_history.commitTransactionFromPointerAddress(
67 address: pendingTransactionDescription.pointerAddress,
68 useUR: true);
69 + await wallet.fetchTransactions();
70 + storeSync(force: true);
71 return ret;
72 } catch (e) {
73 final message = e.toString();
lib/view_model/send/send_view_model.dart
-7
@@ -593,13 +593,6 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
593 }
594 final sharedPreferences = await SharedPreferences.getInstance();
595 await sharedPreferences.setString(PreferencesKey.backgroundSyncLastTrigger(wallet.name), DateTime.now().add(Duration(minutes: 1)).toIso8601String());
596 - unawaited(() {
597 - try {
598 - wallet.fetchTransactions();
599 - } catch (e) {
600 - printV(e);
601 - }
602 - }());
596 state = TransactionCommitted();
597 } catch (e) {
598 state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));