From 27777d49184b2a784fe9a67476242c75101dcfc3 Mon Sep 17 00:00:00 2001 From: fosse Date: Tue, 8 Aug 2023 08:58:08 -0400 Subject: [PATCH] save --- cw_nano/lib/nano_wallet.dart | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cw_nano/lib/nano_wallet.dart b/cw_nano/lib/nano_wallet.dart index 4ff372138..8256e82f8 100644 --- a/cw_nano/lib/nano_wallet.dart +++ b/cw_nano/lib/nano_wallet.dart @@ -119,11 +119,17 @@ abstract class NanoWalletBase throw Exception("Nano Node connection failed"); } + if (_publicAddress == null) { + await Future.delayed(Duration(seconds: 1)); + } + try { await _updateBalance(); await _updateRep(); await _receiveAll(); - } catch (e) {} + } catch (e) { + print(e); + } syncStatus = ConnectedSyncStatus(); } catch (e) { @@ -349,7 +355,12 @@ abstract class NanoWalletBase Future _updateRep() async { try { final accountInfo = await _client.getAccountInfo(_publicAddress!); - _representativeAddress = accountInfo["representative"] as String; + if (accountInfo["error"] != null) { + // account not found: + _representativeAddress = NanoClient.DEFAULT_REPRESENTATIVE; + } else { + _representativeAddress = accountInfo["representative"] as String; + } } catch (e) { throw Exception("Failed to get representative address $e"); }