fix: catch error in newly added fetchTransactions call (#2265)

fix: null handling in cw_monero
This commit is contained in:
cyan 2025-05-15 01:07:17 +02:00 committed by GitHub
parent ca8dbf3c81
commit 40084ec532
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 6 deletions

View file

@ -139,16 +139,16 @@ String getAddress({int accountIndex = 0, int addressIndex = 0}) {
} }
int getFullBalance({int accountIndex = 0}) => int getFullBalance({int accountIndex = 0}) =>
currentWallet!.balance(accountIndex: accountIndex); currentWallet?.balance(accountIndex: accountIndex) ?? 0;
int getUnlockedBalance({int accountIndex = 0}) => int getUnlockedBalance({int accountIndex = 0}) =>
currentWallet!.unlockedBalance(accountIndex: accountIndex); currentWallet?.unlockedBalance(accountIndex: accountIndex) ?? 0;
int getCurrentHeight() => currentWallet!.blockChainHeight(); int getCurrentHeight() => currentWallet?.blockChainHeight() ?? 0;
int getNodeHeightSync() => currentWallet!.daemonBlockChainHeight(); int getNodeHeightSync() => currentWallet?.daemonBlockChainHeight() ?? 0;
bool isConnectedSync() => currentWallet!.connected() != 0; bool isConnectedSync() => currentWallet?.connected() != 0;
Future<bool> setupNodeSync( Future<bool> setupNodeSync(
{required String address, {required String address,

View file

@ -593,7 +593,13 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
} }
final sharedPreferences = await SharedPreferences.getInstance(); final sharedPreferences = await SharedPreferences.getInstance();
await sharedPreferences.setString(PreferencesKey.backgroundSyncLastTrigger(wallet.name), DateTime.now().add(Duration(minutes: 1)).toIso8601String()); await sharedPreferences.setString(PreferencesKey.backgroundSyncLastTrigger(wallet.name), DateTime.now().add(Duration(minutes: 1)).toIso8601String());
unawaited(wallet.fetchTransactions()); unawaited(() {
try {
wallet.fetchTransactions();
} catch (e) {
printV(e);
}
}());
state = TransactionCommitted(); state = TransactionCommitted();
} catch (e) { } catch (e) {
state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency)); state = FailureState(translateErrorMessage(e, wallet.type, wallet.currency));