Merge pull request #436 from cypherstack/disable_mb

Disable mb
This commit is contained in:
Diego Salazar 2023-03-27 14:58:58 -06:00 committed by GitHub
commit 36d222ebd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 127 additions and 118 deletions

View file

@ -2,9 +2,7 @@ import 'package:decimal/decimal.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:stackwallet/models/exchange/aggregate_currency.dart'; import 'package:stackwallet/models/exchange/aggregate_currency.dart';
import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; import 'package:stackwallet/models/exchange/response_objects/estimate.dart';
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
import 'package:stackwallet/services/exchange/exchange.dart'; import 'package:stackwallet/services/exchange/exchange.dart';
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
@ -325,28 +323,28 @@ class ExchangeFormState extends ChangeNotifier {
required bool shouldNotifyListeners, required bool shouldNotifyListeners,
}) async { }) async {
try { try {
switch (exchange.name) { // switch (exchange.name) {
case ChangeNowExchange.exchangeName: // case ChangeNowExchange.exchangeName:
if (!_exchangeSupported( // if (!_exchangeSupported(
exchangeName: exchange.name, // exchangeName: exchange.name,
sendCurrency: sendCurrency, // sendCurrency: sendCurrency,
receiveCurrency: receiveCurrency, // receiveCurrency: receiveCurrency,
exchangeRateType: exchangeRateType, // exchangeRateType: exchangeRateType,
)) { // )) {
_exchange = MajesticBankExchange.instance; // _exchange = MajesticBankExchange.instance;
} // }
break; // break;
case MajesticBankExchange.exchangeName: // case MajesticBankExchange.exchangeName:
if (!_exchangeSupported( // if (!_exchangeSupported(
exchangeName: exchange.name, // exchangeName: exchange.name,
sendCurrency: sendCurrency, // sendCurrency: sendCurrency,
receiveCurrency: receiveCurrency, // receiveCurrency: receiveCurrency,
exchangeRateType: exchangeRateType, // exchangeRateType: exchangeRateType,
)) { // )) {
_exchange = ChangeNowExchange.instance; // _exchange = ChangeNowExchange.instance;
} // }
break; // break;
} // }
await _updateRanges(shouldNotifyListeners: false); await _updateRanges(shouldNotifyListeners: false);
await _updateEstimate(shouldNotifyListeners: false); await _updateEstimate(shouldNotifyListeners: false);

View file

@ -9,7 +9,6 @@ import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart'; import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart';
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
@ -95,11 +94,12 @@ class _ExchangeCurrencySelectionViewState
if (widget.pairedTicker == null) { if (widget.pairedTicker == null) {
return await _getCurrencies(); return await _getCurrencies();
} }
List<Currency> currencies = await ExchangeDataLoadingService List<Currency> currencies = [];
.instance.isar.currencies // await ExchangeDataLoadingService
.where() // .instance.isar.currencies
.exchangeNameEqualTo(MajesticBankExchange.exchangeName) // .where()
.findAll(); // .exchangeNameEqualTo(MajesticBankExchange.exchangeName)
// .findAll();
final cn = await ChangeNowExchange.instance.getPairedCurrencies( final cn = await ChangeNowExchange.instance.getPairedCurrencies(
widget.pairedTicker!, widget.pairedTicker!,

View file

@ -71,11 +71,12 @@ class _ExchangeProviderOptionsState
sendCurrency: sendCurrency, sendCurrency: sendCurrency,
receiveCurrency: receivingCurrency, receiveCurrency: receivingCurrency,
); );
final showMajesticBank = exchangeSupported( final showMajesticBank = false;
exchangeName: MajesticBankExchange.exchangeName, // exchangeSupported(
sendCurrency: sendCurrency, // exchangeName: MajesticBankExchange.exchangeName,
receiveCurrency: receivingCurrency, // sendCurrency: sendCurrency,
); // receiveCurrency: receivingCurrency,
// );
return RoundedWhiteContainer( return RoundedWhiteContainer(
padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12), padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12),

View file

@ -93,7 +93,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
.trades .trades
.firstWhere((e) => e.tradeId == tradeId); .firstWhere((e) => e.tradeId == tradeId);
if (mounted) { if (mounted &&
trade.exchangeName != MajesticBankExchange.exchangeName) {
final exchange = Exchange.fromName(trade.exchangeName); final exchange = Exchange.fromName(trade.exchangeName);
final response = await exchange.updateTrade(trade); final response = await exchange.updateTrade(trade);

View file

@ -148,15 +148,16 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
), ),
children: infoToggle children: infoToggle
? [ ? [
if (Constants.enableExchange)
const TextSpan( const TextSpan(
text: text:
"Exchange data preloaded for a seamless experience."), "Exchange data preloaded for a seamless experience.\n\n"),
const TextSpan( const TextSpan(
text: text:
"\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."), "CoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency).\n\n"),
TextSpan( TextSpan(
text: text:
"\n\nRecommended for most crypto users.", "Recommended for most crypto users.",
style: isDesktop style: isDesktop
? STextStyles ? STextStyles
.desktopTextExtraExtraSmall600( .desktopTextExtraExtraSmall600(
@ -170,15 +171,16 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
), ),
] ]
: [ : [
if (Constants.enableExchange)
const TextSpan( const TextSpan(
text: text:
"Exchange data not preloaded (slower experience)."), "Exchange data not preloaded (slower experience).\n\n"),
const TextSpan( const TextSpan(
text: text:
"\n\nCoinGecko disabled (price changes not shown, no wallet value shown in other currencies)."), "CoinGecko disabled (price changes not shown, no wallet value shown in other currencies).\n\n"),
TextSpan( TextSpan(
text: text:
"\n\nRecommended for the privacy conscious.", "Recommended for the privacy conscious.",
style: isDesktop style: isDesktop
? STextStyles ? STextStyles
.desktopTextExtraExtraSmall600( .desktopTextExtraExtraSmall600(

View file

@ -96,6 +96,7 @@ class _StackPrivacyDialog extends ConsumerState<StackPrivacyDialog> {
), ),
children: infoToggle children: infoToggle
? [ ? [
if (Constants.enableExchange)
const TextSpan( const TextSpan(
text: text:
"Exchange data preloaded for a seamless experience."), "Exchange data preloaded for a seamless experience."),

View file

@ -273,10 +273,10 @@ class ExchangeDataLoadingService {
// } // }
Future<void> loadMajesticBankCurrencies() async { Future<void> loadMajesticBankCurrencies() async {
final exchange = MajesticBankExchange.instance; // final exchange = MajesticBankExchange.instance;
final responseCurrencies = await exchange.getAllCurrencies(false); // final responseCurrencies = await exchange.getAllCurrencies(false);
//
if (responseCurrencies.value != null) { // if (responseCurrencies.value != null) {
await isar.writeTxn(() async { await isar.writeTxn(() async {
final idsToDelete = await isar.currencies final idsToDelete = await isar.currencies
.where() .where()
@ -284,14 +284,14 @@ class ExchangeDataLoadingService {
.idProperty() .idProperty()
.findAll(); .findAll();
await isar.currencies.deleteAll(idsToDelete); await isar.currencies.deleteAll(idsToDelete);
await isar.currencies.putAll(responseCurrencies.value!); // await isar.currencies.putAll(responseCurrencies.value!);
}); });
} else { // } else {
Logging.instance.log( // Logging.instance.log(
"loadMajesticBankCurrencies: $responseCurrencies", // "loadMajesticBankCurrencies: $responseCurrencies",
level: LogLevel.Warning, // level: LogLevel.Warning,
); // );
} // }
} }
// Future<void> loadMajesticBankPairs() async { // Future<void> loadMajesticBankPairs() async {

View file

@ -14,10 +14,11 @@ import 'package:stackwallet/services/exchange/exchange_response.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
class MajesticBankAPI { class MajesticBankAPI {
static const String scheme = "https"; // ensure no api calls go out to mb
static const String authority = "majesticbank.sc"; static const String scheme = ""; //"""https";
static const String version = "v1"; static const String authority = ""; //"""majesticbank.sc";
static const kMajesticBankRefCode = "rjWugM"; static const String version = ""; //"""v1";
static const kMajesticBankRefCode = ""; //"""rjWugM";
MajesticBankAPI._(); MajesticBankAPI._();
@ -33,6 +34,8 @@ class MajesticBankAPI {
} }
Future<dynamic> _makeGetRequest(Uri uri) async { Future<dynamic> _makeGetRequest(Uri uri) async {
return null;
final client = this.client ?? http.Client(); final client = this.client ?? http.Client();
int code = -1; int code = -1;
try { try {

View file

@ -7,6 +7,7 @@ import 'package:stackwallet/hive/db.dart';
import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart';
import 'package:stackwallet/models/notification_model.dart'; import 'package:stackwallet/models/notification_model.dart';
import 'package:stackwallet/services/exchange/exchange_response.dart'; import 'package:stackwallet/services/exchange/exchange_response.dart';
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/notifications_api.dart'; import 'package:stackwallet/services/notifications_api.dart';
import 'package:stackwallet/services/trade_service.dart'; import 'package:stackwallet/services/trade_service.dart';
@ -197,6 +198,7 @@ class NotificationsService extends ChangeNotifier {
final oldTrade = trades.first; final oldTrade = trades.first;
late final ExchangeResponse<Trade> response; late final ExchangeResponse<Trade> response;
if (oldTrade.exchangeName != MajesticBankExchange.exchangeName) {
try { try {
final exchange = Exchange.fromName(oldTrade.exchangeName); final exchange = Exchange.fromName(oldTrade.exchangeName);
response = await exchange.updateTrade(oldTrade); response = await exchange.updateTrade(oldTrade);
@ -251,6 +253,7 @@ class NotificationsService extends ChangeNotifier {
} }
} }
} }
}
bool get hasUnreadNotifications { bool get hasUnreadNotifications {
// final count = (_unreadCountBox.get("count") ?? 0) > 0; // final count = (_unreadCountBox.get("count") ?? 0) > 0;