Revert "disabled mb"

This reverts commit c9eba36f31.
This commit is contained in:
julian 2023-04-01 09:04:34 -06:00
parent c7930ba32f
commit b1e6ee8d47
7 changed files with 105 additions and 111 deletions

View file

@ -2,7 +2,9 @@ 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';
@ -323,28 +325,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,6 +9,7 @@ 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';
@ -94,12 +95,11 @@ class _ExchangeCurrencySelectionViewState
if (widget.pairedTicker == null) { if (widget.pairedTicker == null) {
return await _getCurrencies(); return await _getCurrencies();
} }
List<Currency> currencies = []; List<Currency> currencies = await ExchangeDataLoadingService
// await ExchangeDataLoadingService .instance.isar.currencies
// .instance.isar.currencies .where()
// .where() .exchangeNameEqualTo(MajesticBankExchange.exchangeName)
// .exchangeNameEqualTo(MajesticBankExchange.exchangeName) .findAll();
// .findAll();
final cn = await ChangeNowExchange.instance.getPairedCurrencies( final cn = await ChangeNowExchange.instance.getPairedCurrencies(
widget.pairedTicker!, widget.pairedTicker!,

View file

@ -71,12 +71,11 @@ class _ExchangeProviderOptionsState
sendCurrency: sendCurrency, sendCurrency: sendCurrency,
receiveCurrency: receivingCurrency, receiveCurrency: receivingCurrency,
); );
final showMajesticBank = false; final showMajesticBank = exchangeSupported(
// exchangeSupported( exchangeName: MajesticBankExchange.exchangeName,
// exchangeName: MajesticBankExchange.exchangeName, sendCurrency: sendCurrency,
// sendCurrency: sendCurrency, receiveCurrency: receivingCurrency,
// 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,8 +93,7 @@ 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

@ -273,25 +273,25 @@ 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()
.exchangeNameEqualTo(MajesticBankExchange.exchangeName) .exchangeNameEqualTo(MajesticBankExchange.exchangeName)
.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,11 +14,10 @@ import 'package:stackwallet/services/exchange/exchange_response.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
class MajesticBankAPI { class MajesticBankAPI {
// ensure no api calls go out to mb static const String scheme = "https";
static const String scheme = ""; //"""https"; static const String authority = "majesticbank.sc";
static const String authority = ""; //"""majesticbank.sc"; static const String version = "v1";
static const String version = ""; //"""v1"; static const kMajesticBankRefCode = "rjWugM";
static const kMajesticBankRefCode = ""; //"""rjWugM";
MajesticBankAPI._(); MajesticBankAPI._();
@ -34,8 +33,6 @@ 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,7 +7,6 @@ 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';
@ -198,59 +197,57 @@ 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); } catch (_) {
} catch (_) { return;
return; }
if (response.value == null) {
return;
}
final trade = response.value!;
// only update if status has changed
if (trade.status != notification.title) {
bool shouldWatchForUpdates = true;
// TODO: make sure we set shouldWatchForUpdates to correct value here
switch (trade.status) {
case "Refunded":
case "refunded":
case "Failed":
case "failed":
case "closed":
case "expired":
case "Finished":
case "finished":
case "Completed":
case "completed":
case "Not found":
shouldWatchForUpdates = false;
break;
default:
shouldWatchForUpdates = true;
} }
if (response.value == null) { final updatedNotification = notification.copyWith(
return; title: trade.status,
shouldWatchForUpdates: shouldWatchForUpdates,
);
// remove from watch list if shouldWatchForUpdates was changed
if (!shouldWatchForUpdates) {
await _deleteWatchedTradeNotification(notification);
} }
final trade = response.value!; // replaces the current notification with the updated one
unawaited(add(updatedNotification, true));
// only update if status has changed // update the trade in db
if (trade.status != notification.title) { // over write trade stored in db with updated version
bool shouldWatchForUpdates = true; await tradesService.edit(trade: trade, shouldNotifyListeners: true);
// TODO: make sure we set shouldWatchForUpdates to correct value here
switch (trade.status) {
case "Refunded":
case "refunded":
case "Failed":
case "failed":
case "closed":
case "expired":
case "Finished":
case "finished":
case "Completed":
case "completed":
case "Not found":
shouldWatchForUpdates = false;
break;
default:
shouldWatchForUpdates = true;
}
final updatedNotification = notification.copyWith(
title: trade.status,
shouldWatchForUpdates: shouldWatchForUpdates,
);
// remove from watch list if shouldWatchForUpdates was changed
if (!shouldWatchForUpdates) {
await _deleteWatchedTradeNotification(notification);
}
// replaces the current notification with the updated one
unawaited(add(updatedNotification, true));
// update the trade in db
// over write trade stored in db with updated version
await tradesService.edit(trade: trade, shouldNotifyListeners: true);
}
} }
} }
} }