Generic fixes (#1320)

* New price API

* Fix test app package id

* Fix workflow

* change environment variable to use pr number [skip ci]

* Fix un-needed padding

* Fix raw value for usdtSol

* Remove duplicate fetching for balance and transactions at start [skip ci]

* Fix address validation of spl tokens

* Add Service Status

* Update lib/src/widgets/service_status_tile.dart

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>

* Update lib/src/widgets/services_updates_widget.dart

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>

* Update monero version

* update sodium script

* Change automatic priority fee rate

---------

Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
This commit is contained in:
Omar Hatem
2024-03-10 04:02:30 +02:00
committed by GitHub
co-authored by Konstantin Ullrich
parent c7deeaea9b
commit 6414364602
20 changed files with 285 additions and 33 deletions
@@ -4,8 +4,10 @@ import 'package:cake_wallet/buy/buy_provider.dart';
import 'package:cake_wallet/core/key_service.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';
import 'package:cake_wallet/entities/provider_types.dart';
import 'package:cake_wallet/entities/exchange_api_mode.dart';
import 'package:cake_wallet/entities/service_status.dart';
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/monero/monero.dart';
@@ -42,7 +44,8 @@ import 'package:cw_core/wallet_type.dart';
import 'package:eth_sig_util/util/utils.dart';
import 'package:flutter/services.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/entities/provider_types.dart';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
part 'dashboard_view_model.g.dart';
@@ -59,6 +62,7 @@ abstract class DashboardViewModelBase with Store {
required this.yatStore,
required this.ordersStore,
required this.anonpayTransactionsStore,
required this.sharedPreferences,
required this.keyService})
: hasSellAction = false,
hasBuyAction = false,
@@ -280,6 +284,7 @@ abstract class DashboardViewModelBase with Store {
bool get hasRescan => wallet.type == WalletType.monero || wallet.type == WalletType.haven;
final KeyService keyService;
final SharedPreferences sharedPreferences;
BalanceViewModel balanceViewModel;
@@ -497,4 +502,26 @@ abstract class DashboardViewModelBase with Store {
return affectedWallets;
}
Future<ServicesResponse> getServicesStatus() async {
try {
final res = await http.get(Uri.parse("https://service-api.cakewallet.com/v1/active-notices"));
if (res.statusCode < 200 || res.statusCode >= 300) {
throw res.body;
}
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);
} catch (_) {
return ServicesResponse([], false, '');
}
}
}
+2 -1
View File
@@ -427,9 +427,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
) {
if (walletType == WalletType.ethereum ||
walletType == WalletType.polygon ||
walletType == WalletType.solana ||
walletType == WalletType.haven) {
if (error.contains('gas required exceeds allowance') ||
error.contains('insufficient funds for')) {
error.contains('insufficient funds')) {
return S.current.do_not_have_enough_gas_asset(currency.toString());
}