CW-974: Add support for automatic node switching. (#2361)

* feat: Add support for automatic node switching.

This change:
- Adds isTrustedNodeForSwitching property to Node class.
- Adds UI Checkbox to mark a node as trusted for automatic switching in Node create or edit form.
- Implements checkNodeHealth method in wallet classes to verify node connectivity.
- Adds NodeSwitchingService for managing automatic node switching based on health checks.
- Adds setting option for user to enable/disable automated node switching

* fix(automatic-node-switch): Set node health check interval to 5 minutes in NodeSwitchingService

* refactor: Update handler method

* feat: Automatic Node Switching Improvements

This change:
- Moves enable automatic node switch to the Manage Nodes Page
- Adds check to verify node health before attempting to sync in EVM, Sol and Tron Wallets.
- Modifies trusted ndoes list for monero
- Adds trigger for Node Health Check when app resumes from background

* fix: Increase default request timeout for Tron and update health check interval for node switch

* feat: Enhance Node health check functionality.

This change adds additional checks for token balance in EVM, Solana and Tron Wallets in checkNodeHealth.

* fix: Update health check interval to 30 seconds in NodeSwitchingService

* Update bitcoin_electrum_server_list.yml

* fix: Electru wallet not connecting to new node after switching

* fix: Automated Node Switch not working on Decred Wallet

* fix: Add more nodes for AutoSwitching

This change:
- Enables more nodes across wallet types for auto switching
- Modifies CTA for checkbox
- Renames flags to fit

* fix: Add migration function for setting up default nodes for autoswitching

* fix: Review and testing fixes

* chore: Adjust balance and history fetch timer
This commit is contained in:
David Adegoke
2025-07-25 16:42:59 +03:00
committed by GitHub
parent 8f4eed4d9b
commit 4b2af63fa5
73 changed files with 639 additions and 68 deletions
+6 -1
View File
@@ -26,6 +26,7 @@ class Node extends HiveObject with Keyable {
this.trusted = false,
this.socksProxyAddress,
this.path = '',
this.isEnabledForAutoSwitching = false,
String? uri,
WalletType? type,
}) {
@@ -44,7 +45,8 @@ class Node extends HiveObject with Keyable {
password = map['password'] as String?,
useSSL = map['useSSL'] as bool?,
trusted = map['trusted'] as bool? ?? false,
socksProxyAddress = map['socksProxyPort'] as String?;
socksProxyAddress = map['socksProxyPort'] as String?,
isEnabledForAutoSwitching = map['isEnabledForAutoSwitching'] as bool? ?? false;
static const typeId = NODE_TYPE_ID;
static const boxName = 'Nodes';
@@ -82,6 +84,9 @@ class Node extends HiveObject with Keyable {
@HiveField(10)
bool? supportsMweb;
@HiveField(11, defaultValue: false)
bool isEnabledForAutoSwitching;
bool get isSSL => useSSL ?? false;
bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty;
+5
View File
@@ -112,4 +112,9 @@ abstract class WalletBase<BalanceType extends Balance, HistoryType extends Trans
bool isTestnet = false;
bool canSend() => true;
/// This is used to check if the current node is healthy by making a lightweight RPC call
/// Each wallet implementation should override this to make a single, efficient call
/// Returns true if the node is healthy, false otherwise
Future<bool> checkNodeHealth();
}