Merge branch 'main' into wownero

This commit is contained in:
cyan 2024-06-29 10:48:32 +02:00 committed by GitHub
commit 5553c4f477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 46 additions and 3 deletions

View file

@ -166,6 +166,7 @@ jobs:
echo "const quantexExchangeMarkup = '${{ secrets.QUANTEX_EXCHANGE_MARKUP }}';" >> lib/.secrets.g.dart
echo "const nano2ApiKey = '${{ secrets.NANO2_API_KEY }}';" >> cw_nano/lib/.secrets.g.dart
echo "const tronGridApiKey = '${{ secrets.TRON_GRID_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
echo "const tronNowNodesApiKey = '${{ secrets.TRON_NOW_NODES_API_KEY }}';" >> cw_tron/lib/.secrets.g.dart
- name: Rename app
run: |

View file

@ -4,5 +4,9 @@
useSSL: true
-
uri: api.trongrid.io
is_default: false
useSSL: true
-
uri: trx.nownodes.io
is_default: true
useSSL: true

View file

@ -20,6 +20,7 @@ class TronHTTPProvider implements TronServiceProvider {
final response = await client.get(Uri.parse(params.url(url)), headers: {
'Content-Type': 'application/json',
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
if (url.contains("nownodes")) 'api-key': secrets.tronNowNodesApiKey,
}).timeout(timeout ?? defaultRequestTimeout);
final data = json.decode(response.body) as Map<String, dynamic>;
return data;
@ -32,6 +33,7 @@ class TronHTTPProvider implements TronServiceProvider {
headers: {
'Content-Type': 'application/json',
if (url.contains("trongrid")) 'TRON-PRO-API-KEY': secrets.tronGridApiKey,
if (url.contains("nownodes")) 'api-key': secrets.tronNowNodesApiKey,
},
body: params.toRequestBody())
.timeout(timeout ?? defaultRequestTimeout);

1
devtools_options.yaml Normal file
View file

@ -0,0 +1 @@
extensions:

View file

@ -37,7 +37,7 @@ const cakeWalletBitcoinCashDefaultNodeUri = 'bitcoincash.stackwallet.com:50002';
const nanoDefaultNodeUri = 'rpc.nano.to';
const nanoDefaultPowNodeUri = 'rpc.nano.to';
const solanaDefaultNodeUri = 'rpc.ankr.com';
const tronDefaultNodeUri = 'api.trongrid.io';
const tronDefaultNodeUri = 'trx.nownodes.io';
const newCakeWalletBitcoinUri = 'btc-electrum.cakewallet.com:50002';
const wowneroDefaultNodeUri = 'node3.monerodevs.org:34568';
@ -236,7 +236,11 @@ Future<void> defaultSettingsMigration(
await changeWowneroCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
break;
case 37:
await replaceTronDefaultNode(sharedPreferences: sharedPreferences, nodes: nodes);
break;
case 38:
await fixBtcDerivationPaths(walletInfoSource);
break;
default:
break;
}
@ -1189,3 +1193,29 @@ Future<void> changeTronCurrentNodeToDefault(
await sharedPreferences.setInt(PreferencesKey.currentTronNodeIdKey, nodeId);
}
Future<void> replaceTronDefaultNode({
required SharedPreferences sharedPreferences,
required Box<Node> nodes,
}) async {
// Get the currently active node
final currentTronNodeId = sharedPreferences.getInt(PreferencesKey.currentTronNodeIdKey);
final currentTronNode =
nodes.values.firstWhereOrNull((Node node) => node.key == currentTronNodeId);
//Confirm if this node is part of the default nodes from CakeWallet
final tronDefaultNodeList = [
'tron-rpc.publicnode.com:443',
'api.trongrid.io',
];
bool needsToBeReplaced =
currentTronNode == null ? true : tronDefaultNodeList.contains(currentTronNode.uriRaw);
// If it's a custom node, return. We don't want to switch users from their custom nodes
if (!needsToBeReplaced) {
return;
}
// If it's not, we switch user to the new default node: NowNodes
await changeTronCurrentNodeToDefault(sharedPreferences: sharedPreferences, nodes: nodes);
}

View file

@ -203,7 +203,7 @@ Future<void> initializeAppConfigs() async {
transactionDescriptions: transactionDescriptions,
secureStorage: secureStorage,
anonpayInvoiceInfo: anonpayInvoiceInfo,
initialMigrationVersion: 37,
initialMigrationVersion: 38,
);
}

View file

@ -39,6 +39,10 @@ class SecretKey {
SecretKey('moralisApiKey', () => ''),
SecretKey('ankrApiKey', () => ''),
SecretKey('quantexExchangeMarkup', () => ''),
SecretKey('testCakePayApiKey', () => ''),
SecretKey('cakePayApiKey', () => ''),
SecretKey('CSRFToken', () => ''),
SecretKey('authorization', () => ''),
];
static final evmChainsSecrets = [
@ -54,9 +58,10 @@ class SecretKey {
static final nanoSecrets = [
SecretKey('nano2ApiKey', () => ''),
];
static final tronSecrets = [
SecretKey('tronGridApiKey', () => ''),
SecretKey('tronNowNodesApiKey', () => ''),
];
final String name;