change default tron node to nowNodes if not already
Some checks failed
Cache Dependencies / test (push) Has been cancelled

This commit is contained in:
OmarHatem 2024-11-27 02:20:08 +02:00
parent 765ae87712
commit 9706243c81

View file

@ -273,7 +273,19 @@ Future<void> defaultSettingsMigration(
newDefaultUri: newCakeWalletBitcoinUri, newDefaultUri: newCakeWalletBitcoinUri,
currentNodePreferenceKey: PreferencesKey.currentBitcoinElectrumSererIdKey, currentNodePreferenceKey: PreferencesKey.currentBitcoinElectrumSererIdKey,
useSSL: true, 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; break;
@ -300,11 +312,11 @@ Future<void> _changeDefaultNode({
required String newDefaultUri, required String newDefaultUri,
required String currentNodePreferenceKey, required String currentNodePreferenceKey,
required bool useSSL, 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<String> oldUri, // leave empty if you want to force replace the node regardless of the user's current node
}) async { }) async {
final currentNodeId = sharedPreferences.getInt(currentNodePreferenceKey); final currentNodeId = sharedPreferences.getInt(currentNodePreferenceKey);
final currentNode = nodes.values.firstWhere((node) => node.key == currentNodeId); 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) { if (shouldReplace) {
var newNodeId = var newNodeId =