From 1eb9e65617e85ef2d70d7c324865c8cde8137565 Mon Sep 17 00:00:00 2001
From: OmarHatem <omarh.ismail1@gmail.com>
Date: Thu, 20 Oct 2022 20:24:01 +0200
Subject: [PATCH] Set trusted daemon after node connection

---
 cw_haven/lib/haven_wallet.dart                             | 6 ++----
 cw_monero/lib/monero_wallet.dart                           | 6 ++----
 .../node_list/node_create_or_edit_view_model.dart          | 7 -------
 3 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/cw_haven/lib/haven_wallet.dart b/cw_haven/lib/haven_wallet.dart
index 00d37ee08..14ff2f88e 100644
--- a/cw_haven/lib/haven_wallet.dart
+++ b/cw_haven/lib/haven_wallet.dart
@@ -121,6 +121,8 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
           password: node.password,
           useSSL: node.useSSL ?? false,
           isLightWallet: false); // FIXME: hardcoded value
+
+      haven_wallet.setTrustedDaemon(node.trusted);
       syncStatus = ConnectedSyncStatus();
     } catch (e) {
       syncStatus = FailedSyncStatus();
@@ -394,8 +396,4 @@ abstract class HavenWalletBase extends WalletBase<MoneroBalance,
       print(e.toString());
     }
   }
-
-  void setTrustedDaemon(bool arg) => haven_wallet.setTrustedDaemon(arg);
-
-  Future<bool> trustedDaemon() async => haven_wallet.trustedDaemon();
 }
diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart
index ff0104015..86a0358f0 100644
--- a/cw_monero/lib/monero_wallet.dart
+++ b/cw_monero/lib/monero_wallet.dart
@@ -136,6 +136,8 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
           password: node.password,
           useSSL: node.isSSL,
           isLightWallet: false); // FIXME: hardcoded value
+
+      monero_wallet.setTrustedDaemon(node.trusted);
       syncStatus = ConnectedSyncStatus();
     } catch (e) {
       syncStatus = FailedSyncStatus();
@@ -432,8 +434,4 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
       print(e.toString());
     }
   }
-
-  void setTrustedDaemon(bool arg) => monero_wallet.setTrustedDaemon(arg);
-
-  Future<bool> trustedDaemon() async => monero_wallet.trustedDaemon();
 }
diff --git a/lib/view_model/node_list/node_create_or_edit_view_model.dart b/lib/view_model/node_list/node_create_or_edit_view_model.dart
index 7b481f356..e24692059 100644
--- a/lib/view_model/node_list/node_create_or_edit_view_model.dart
+++ b/lib/view_model/node_list/node_create_or_edit_view_model.dart
@@ -1,6 +1,4 @@
 import 'package:cake_wallet/core/execution_state.dart';
-import 'package:cw_haven/haven_wallet.dart';
-import 'package:cw_monero/monero_wallet.dart';
 import 'package:hive/hive.dart';
 import 'package:mobx/mobx.dart';
 import 'package:cw_core/wallet_base.dart';
@@ -84,11 +82,6 @@ abstract class NodeCreateOrEditViewModelBase with Store {
       final node =
           Node(uri: uri, type: _wallet.type, login: login, password: password,
               useSSL: useSSL, trusted: trusted);
-      if (_wallet.type == WalletType.monero) {
-        (_wallet as MoneroWallet).setTrustedDaemon(trusted);
-      } else if (_wallet.type == WalletType.haven) {
-        (_wallet as HavenWallet).setTrustedDaemon(trusted);
-      }
       await _nodeSource.add(node);
       state = ExecutedSuccessfullyState();
     } catch (e) {