Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jul 25, 2025

Conversation

Blazebrain
Copy link
Contributor

Issue Number (if Applicable): Fixes #

Description

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

Pull Request - Checklist

  • Initial Manual Tests Passed
  • Double check modified code and verify it with the feature/task requirements
  • Format code
  • Look for code duplication
  • Clear naming for variables and methods
  • Manual tests in accessibility mode (TalkBack on Android) passed

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
@Blazebrain Blazebrain self-assigned this Jul 4, 2025
@Blazebrain Blazebrain requested a review from OmarHatem28 July 4, 2025 14:08
Blazebrain and others added 15 commits July 4, 2025 15:41
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
This change adds additional checks for token balance in EVM, Solana and Tron Wallets in checkNodeHealth.
This change:
- Enables more nodes across wallet types for auto switching
- Modifies CTA for checkbox
- Renames flags to fit
value: nodeViewModel.isTrustedNodeForSwitching,
borderColor: Theme.of(context).colorScheme.surfaceContainerHighest,
iconColor: Theme.of(context).colorScheme.primary,
onChanged: (value) => nodeViewModel.isTrustedNodeForSwitching = value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use the setter as well and make the variable private

@@ -828,6 +858,7 @@ abstract class EVMChainWalletBase
_transactionsUpdateTimer = Timer.periodic(const Duration(seconds: 15), (_) {
_updateTransactions();
_updateBalance();
_updateEstimatedGasFeeParams();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previously it was called every 30 seconds, which I believe is sufficient for this function, now that I see our daily usage, I believe we should check which functions needs to be called frequently and which should be called less frequently so we can decide better and put periodic time accordingly

break;
break;
case 50:
await migrateExistingNodesToUseAutoSwitching(nodes: nodes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be async, no need to be awaited

Suggested change
await migrateExistingNodesToUseAutoSwitching(nodes: nodes);
migrateExistingNodesToUseAutoSwitching(nodes: nodes);

@Blazebrain Blazebrain requested a review from OmarHatem28 July 25, 2025 09:39
@OmarHatem28 OmarHatem28 merged commit 4b2af63 into main Jul 25, 2025
5 checks passed
@OmarHatem28 OmarHatem28 deleted the Allow-Automatic-Node-Switching branch July 25, 2025 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants