From 9706243c81d4c6d0888846a09c5ef5874c5cd53f Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 27 Nov 2024 02:20:08 +0200 Subject: [PATCH] change default tron node to nowNodes if not already --- lib/entities/default_settings_migration.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 9e0e3457d..7f0679625 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -273,7 +273,19 @@ Future defaultSettingsMigration( newDefaultUri: newCakeWalletBitcoinUri, currentNodePreferenceKey: PreferencesKey.currentBitcoinElectrumSererIdKey, useSSL: true, - oldUri: 'cakewallet.com', + oldUri: ['cakewallet.com'], + ); + _changeDefaultNode( + nodes: nodes, + sharedPreferences: sharedPreferences, + type: WalletType.tron, + newDefaultUri: tronDefaultNodeUri, + currentNodePreferenceKey: PreferencesKey.currentTronNodeIdKey, + useSSL: true, + oldUri: [ + 'tron-rpc.publicnode.com:443', + 'api.trongrid.io', + ], ); break; @@ -300,11 +312,11 @@ Future _changeDefaultNode({ required String newDefaultUri, required String currentNodePreferenceKey, required bool useSSL, - required String oldUri, // leave empty if you want to force replace the node regardless of the user's current node + required List oldUri, // leave empty if you want to force replace the node regardless of the user's current node }) async { final currentNodeId = sharedPreferences.getInt(currentNodePreferenceKey); final currentNode = nodes.values.firstWhere((node) => node.key == currentNodeId); - final shouldReplace = currentNode.uriRaw.contains(oldUri); + final shouldReplace = oldUri.any((e) => currentNode.uriRaw.contains(e)); if (shouldReplace) { var newNodeId =