diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 26f557dba..1aa8096c3 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -68,7 +68,9 @@ abstract class Wallet { final refreshMutex = Mutex(); - WalletInfo get info => _walletInfo; + late final String _walletId; + WalletInfo get info => + mainDB.isar.walletInfo.where().walletIdEqualTo(walletId).findFirstSync()!; bool get isConnected => _isConnected; bool get shouldAutoSync => _shouldAutoSync; @@ -88,9 +90,6 @@ abstract class Wallet { // ===== private properties =========================================== - late WalletInfo _walletInfo; - late final Stream _walletInfoStream; - Timer? _periodicRefreshTimer; Timer? _networkAliveTimer; @@ -106,7 +105,7 @@ abstract class Wallet { //============================================================================ // ========== Wallet Info Convenience Getters ================================ - String get walletId => info.walletId; + String get walletId => _walletId; /// Attempt to fetch the most recent chain height. /// On failure return the last cached height. @@ -223,9 +222,7 @@ abstract class Wallet { wallet.secureStorageInterface = ethWallet.secureStorageInterface; wallet.mainDB = ethWallet.mainDB; - return wallet - .._walletInfo = ethWallet.info - .._watchWalletInfo(); + return wallet.._walletId = ethWallet.info.walletId; } //============================================================================ @@ -275,8 +272,7 @@ abstract class Wallet { return wallet ..secureStorageInterface = secureStorageInterface ..mainDB = mainDB - .._walletInfo = walletInfo - .._watchWalletInfo(); + .._walletId = walletInfo.walletId; } static Wallet _loadWallet({ @@ -349,19 +345,6 @@ abstract class Wallet { } } - // listen to changes in db and updated wallet info property as required - void _watchWalletInfo() { - _walletInfoStream = mainDB.isar.walletInfo.watchObject( - _walletInfo.id, - fireImmediately: true, - ); - _walletInfoStream.forEach((element) { - if (element != null) { - _walletInfo = element; - } - }); - } - void _startNetworkAlivePinging() { // call once on start right away _periodicPingCheck();