CW-653-Migrate-Tron-And-Solana-To-NowNodes (#1492)
* chore: Setup * feat: Add NowNodes for Tron Wallet and switch it to be the default node for Tron * feat: Add NowNodes for Solana Wallet and switch it to be the default node for Solana * fix: Add nownodes entry to secrets * fix: Remove pubspec.lock in shared external * fix conflicts with main * change secrets names * feat: Remove Solana NowNodes config * feat: Remove Solana NowNodes config * feat: Revert commented out code --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
Adegoke David committed
Jun 28, 2024 at 22:36 UTC
a319e101564ec9023b4807ccafa3e61bb602549f
9 files changed
+51
-8
.github/workflows/pr_test_build.yml
+1
@@ -158,6 +158,7 @@ jobs:
158
echo "const quantexExchangeMarkup = '${{ secrets.QUANTEX_EXCHANGE_MARKUP }}';" >> lib/.secrets.g.dart
159
echo "const nano2ApiKey = '${{ secrets.NANO2_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart
160
echo "const tronGridApiKey = '${{ secrets.TRON_GRID_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
161
+ echo "const tronNowNodesApiKey = '${{ secrets.TRON_NOW_NODES_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
162
163
- name: Rename app
164
run: |
assets/tron_node_list.yml
+4
@@ -4,5 +4,9 @@
4
useSSL: true
5
-
6
uri: api.trongrid.io
7
+ is_default: false
8
+ useSSL: true
9
+-
10
+ uri: trx.nownodes.io
11
is_default: true
12
useSSL: true
\ No newline at end of file
cw_tron/lib/tron_http_provider.dart
+2
@@ -20,6 +20,7 @@ class TronHTTPProvider implements TronServiceProvider {
20
final response = await client.get(Uri.parse(params.url(url)), headers: {
21
'Content-Type': 'application/json',
22
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
23
+ if (url.contains("nownodes")) 'api-key': secrets.tronNowNodesApiKey,
24
}).timeout(timeout ?? defaultRequestTimeout);
25
final data = json.decode(response.body) as Map<String, dynamic>;
26
return data;
@@ -32,6 +33,7 @@ class TronHTTPProvider implements TronServiceProvider {
33
headers: {
34
'Content-Type': 'application/json',
35
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
36
+ if (url.contains("nownodes")) 'api-key': secrets.tronNowNodesApiKey,
37
},
38
body: params.toRequestBody())
39
.timeout(timeout ?? defaultRequestTimeout);
devtools_options.yaml
new
+1
@@ -0,0 +1 @@
1
+extensions:
ios/Runner.xcodeproj/project.pbxproj
+4
-4
@@ -164,7 +164,7 @@
164
97C146E61CF9000F007C117D /* Project object */ = {
165
isa = PBXProject;
166
attributes = {
167
- LastUpgradeCheck = 1300;
167
+ LastUpgradeCheck = 1510;
168
ORGANIZATIONNAME = "";
169
TargetAttributes = {
170
97C146ED1CF9000F007C117D = {
@@ -355,7 +355,7 @@
355
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
356
GCC_WARN_UNUSED_FUNCTION = YES;
357
GCC_WARN_UNUSED_VARIABLE = YES;
358
- IPHONEOS_DEPLOYMENT_TARGET = 11.0;
358
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
359
MTL_ENABLE_DEBUG_INFO = NO;
360
SDKROOT = iphoneos;
361
SUPPORTED_PLATFORMS = iphoneos;
@@ -449,7 +449,7 @@
449
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
450
GCC_WARN_UNUSED_FUNCTION = YES;
451
GCC_WARN_UNUSED_VARIABLE = YES;
452
- IPHONEOS_DEPLOYMENT_TARGET = 11.0;
452
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
453
MTL_ENABLE_DEBUG_INFO = YES;
454
ONLY_ACTIVE_ARCH = YES;
455
SDKROOT = iphoneos;
@@ -499,7 +499,7 @@
499
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
500
GCC_WARN_UNUSED_FUNCTION = YES;
501
GCC_WARN_UNUSED_VARIABLE = YES;
502
- IPHONEOS_DEPLOYMENT_TARGET = 11.0;
502
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
503
MTL_ENABLE_DEBUG_INFO = NO;
504
SDKROOT = iphoneos;
505
SUPPORTED_PLATFORMS = iphoneos;
ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+1
-1
@@ -1,6 +1,6 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<Scheme
3
- LastUpgradeVersion = "1300"
3
+ LastUpgradeVersion = "1510"
4
version = "1.3">
5
<BuildAction
6
parallelizeBuildables = "YES"
lib/entities/default_settings_migration.dart
+31
-1
@@ -37,7 +37,7 @@ const cakeWalletBitcoinCashDefaultNodeUri = 'bitcoincash.stackwallet.com:50002';
37
const nanoDefaultNodeUri = 'rpc.nano.to';
38
const nanoDefaultPowNodeUri = 'rpc.nano.to';
39
const solanaDefaultNodeUri = 'rpc.ankr.com';
40
-const tronDefaultNodeUri = 'api.trongrid.io';
40
+const tronDefaultNodeUri = 'trx.nownodes.io';
41
const newCakeWalletBitcoinUri = 'btc-electrum.cakewallet.com:50002';
42
43
Future<void> defaultSettingsMigration(
@@ -234,7 +234,11 @@ Future<void> defaultSettingsMigration(
234
await changeTronCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
235
break;
236
case 37:
237
+ await replaceTronDefaultNode(sharedPreferences: sharedPreferences, nodes: nodes);
238
+ break;
239
+ case 38:
240
await fixBtcDerivationPaths(walletInfoSource);
241
+ break;
242
default:
243
break;
244
}
@@ -1142,3 +1146,29 @@ Future<void> changeTronCurrentNodeToDefault(
1146
1147
await sharedPreferences.setInt(PreferencesKey.currentTronNodeIdKey, nodeId);
1148
}
1149
+
1150
+Future<void> replaceTronDefaultNode({
1151
+ required SharedPreferences sharedPreferences,
1152
+ required Box<Node> nodes,
1153
+}) async {
1154
+ // Get the currently active node
1155
+ final currentTronNodeId = sharedPreferences.getInt(PreferencesKey.currentTronNodeIdKey);
1156
+ final currentTronNode =
1157
+ nodes.values.firstWhereOrNull((Node node) => node.key == currentTronNodeId);
1158
+
1159
+ //Confirm if this node is part of the default nodes from CakeWallet
1160
+ final tronDefaultNodeList = [
1161
+ 'tron-rpc.publicnode.com:443',
1162
+ 'api.trongrid.io',
1163
+ ];
1164
+ bool needsToBeReplaced =
1165
+ currentTronNode == null ? true : tronDefaultNodeList.contains(currentTronNode.uriRaw);
1166
+
1167
+ // If it's a custom node, return. We don't want to switch users from their custom nodes
1168
+ if (!needsToBeReplaced) {
1169
+ return;
1170
+ }
1171
+
1172
+ // If it's not, we switch user to the new default node: NowNodes
1173
+ await changeTronCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
1174
+}
\ No newline at end of file
lib/main.dart
+1
-1
@@ -202,7 +202,7 @@ Future<void> initializeAppConfigs() async {
202
transactionDescriptions: transactionDescriptions,
203
secureStorage: secureStorage,
204
anonpayInvoiceInfo: anonpayInvoiceInfo,
205
- initialMigrationVersion: 37,
205
+ initialMigrationVersion: 38,
206
);
207
}
208
tool/utils/secret_key.dart
+6
-1
@@ -39,6 +39,10 @@ class SecretKey {
39
SecretKey('moralisApiKey', () => ''),
40
SecretKey('ankrApiKey', () => ''),
41
SecretKey('quantexExchangeMarkup', () => ''),
42
+ SecretKey('testCakePayApiKey', () => ''),
43
+ SecretKey('cakePayApiKey', () => ''),
44
+ SecretKey('CSRFToken', () => ''),
45
+ SecretKey('authorization', () => ''),
46
];
47
48
static final evmChainsSecrets = [
@@ -54,9 +58,10 @@ class SecretKey {
58
static final nanoSecrets = [
59
SecretKey('nano2ApiKey', () => ''),
60
];
57
-
61
+
62
static final tronSecrets = [
63
SecretKey('tronGridApiKey', () => ''),
64
+ SecretKey('tronNowNodesApiKey', () => ''),
65
];
66
67
final String name;