mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
Node Auto-reconnect and connectivity enhancements (#1513)
* Add auto-reconnect Enhance connectivity issues * minor enhancement [skip ci] * minor: remove core secrets since it's empty * pending transactions fix * temporary fix for RBF * remove unused hashes from cache key * fix minimum limits check * Add authentication to services api * update polyseed * override hashlib package
This commit is contained in:
parent
0335702aa9
commit
f902a644db
19 changed files with 131 additions and 222 deletions
|
@ -48,6 +48,7 @@ import 'package:mobx/mobx.dart';
|
|||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||
|
||||
part 'dashboard_view_model.g.dart';
|
||||
|
||||
|
@ -375,7 +376,8 @@ abstract class DashboardViewModelBase with Store {
|
|||
.toList();
|
||||
}
|
||||
|
||||
bool get hasSellProviders => ProvidersHelper.getAvailableSellProviderTypes(wallet.type).isNotEmpty;
|
||||
bool get hasSellProviders =>
|
||||
ProvidersHelper.getAvailableSellProviderTypes(wallet.type).isNotEmpty;
|
||||
|
||||
bool get shouldShowYatPopup => settingsStore.shouldShowYatPopup;
|
||||
|
||||
|
@ -534,8 +536,11 @@ abstract class DashboardViewModelBase with Store {
|
|||
void setSyncAll(bool value) => settingsStore.currentSyncAll = value;
|
||||
|
||||
Future<List<String>> checkForHavenWallets() async {
|
||||
final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||
return walletInfoSource.values.where((element) => element.type == WalletType.haven).map((e) => e.name).toList();
|
||||
final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||
return walletInfoSource.values
|
||||
.where((element) => element.type == WalletType.haven)
|
||||
.map((e) => e.name)
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<List<String>> checkAffectedWallets() async {
|
||||
|
@ -576,29 +581,34 @@ abstract class DashboardViewModelBase with Store {
|
|||
Future<ServicesResponse> getServicesStatus() async {
|
||||
try {
|
||||
if (isEnabledBulletinAction) {
|
||||
final res = await http.get(Uri.parse("https://service-api.cakewallet.com/v1/active-notices"));
|
||||
final uri = Uri.https(
|
||||
"service-api.cakewallet.com",
|
||||
"/v1/active-notices",
|
||||
{'key': secrets.fiatApiKey},
|
||||
);
|
||||
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw res.body;
|
||||
}
|
||||
final res = await http.get(uri);
|
||||
|
||||
final oldSha = sharedPreferences.getString(PreferencesKey.serviceStatusShaKey);
|
||||
|
||||
final hash = await Cryptography.instance.sha256().hash(utf8.encode(res.body));
|
||||
final currentSha = bytesToHex(hash.bytes);
|
||||
|
||||
final hasUpdates = oldSha != currentSha;
|
||||
|
||||
return ServicesResponse.fromJson(
|
||||
json.decode(res.body) as Map<String, dynamic>,
|
||||
hasUpdates,
|
||||
currentSha,
|
||||
);
|
||||
}
|
||||
else {
|
||||
return ServicesResponse([], false, '');
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw res.body;
|
||||
}
|
||||
} catch (_) {
|
||||
|
||||
final oldSha = sharedPreferences.getString(PreferencesKey.serviceStatusShaKey);
|
||||
|
||||
final hash = await Cryptography.instance.sha256().hash(utf8.encode(res.body));
|
||||
final currentSha = bytesToHex(hash.bytes);
|
||||
|
||||
final hasUpdates = oldSha != currentSha;
|
||||
|
||||
return ServicesResponse.fromJson(
|
||||
json.decode(res.body) as Map<String, dynamic>,
|
||||
hasUpdates,
|
||||
currentSha,
|
||||
);
|
||||
} else {
|
||||
return ServicesResponse([], false, '');
|
||||
}
|
||||
} catch (e) {
|
||||
return ServicesResponse([], false, '');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue