mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
make service api use proxy wrapper
This commit is contained in:
parent
08eb54b3b3
commit
46ff2706d9
2 changed files with 13 additions and 4 deletions
|
@ -392,6 +392,7 @@ Future<void> setup({
|
|||
keyService: getIt.get<KeyService>(),
|
||||
torViewModel: getIt.get<TorViewModel>(),
|
||||
sharedPreferences: getIt.get<SharedPreferences>(),
|
||||
proxyWrapper: getIt.get<ProxyWrapper>(),
|
||||
));
|
||||
|
||||
getIt.registerFactory<AuthService>(
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
|||
|
||||
import 'package:cake_wallet/buy/buy_provider.dart';
|
||||
import 'package:cake_wallet/core/key_service.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
||||
import 'package:cake_wallet/entities/balance_display_mode.dart';
|
||||
import 'package:cake_wallet/entities/preferences_key.dart';
|
||||
|
@ -20,6 +21,7 @@ import 'package:cake_wallet/store/dashboard/transaction_filter_store.dart';
|
|||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/store/yat/yat_store.dart';
|
||||
import 'package:cake_wallet/utils/mobx.dart';
|
||||
import 'package:cake_wallet/utils/proxy_wrapper.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/action_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart';
|
||||
|
@ -68,6 +70,7 @@ abstract class DashboardViewModelBase with Store {
|
|||
required this.anonpayTransactionsStore,
|
||||
required this.keyService,
|
||||
required this.torViewModel,
|
||||
required this.proxyWrapper,
|
||||
required this.sharedPreferences,
|
||||
}) : hasSellAction = false,
|
||||
hasBuyAction = false,
|
||||
|
@ -299,6 +302,8 @@ abstract class DashboardViewModelBase with Store {
|
|||
|
||||
TorViewModel torViewModel;
|
||||
|
||||
ProxyWrapper proxyWrapper;
|
||||
|
||||
AppStore appStore;
|
||||
|
||||
SettingsStore settingsStore;
|
||||
|
@ -523,21 +528,24 @@ abstract class DashboardViewModelBase with Store {
|
|||
|
||||
Future<ServicesResponse> getServicesStatus() async {
|
||||
try {
|
||||
final res = await http.get(Uri.parse("https://service-api.cakewallet.com/v1/active-notices"));
|
||||
final res = await proxyWrapper.get(
|
||||
clearnetUri: Uri.parse("https://service-api.cakewallet.com/v1/active-notices"),
|
||||
);
|
||||
final responseBody = await utf8.decodeStream(res);
|
||||
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw res.body;
|
||||
throw responseBody;
|
||||
}
|
||||
|
||||
final oldSha = sharedPreferences.getString(PreferencesKey.serviceStatusShaKey);
|
||||
|
||||
final hash = await Cryptography.instance.sha256().hash(utf8.encode(res.body));
|
||||
final hash = await Cryptography.instance.sha256().hash(utf8.encode(responseBody));
|
||||
final currentSha = bytesToHex(hash.bytes);
|
||||
|
||||
final hasUpdates = oldSha != currentSha;
|
||||
|
||||
return ServicesResponse.fromJson(
|
||||
json.decode(res.body) as Map<String, dynamic>,
|
||||
json.decode(responseBody) as Map<String, dynamic>,
|
||||
hasUpdates,
|
||||
currentSha,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue