mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
parent
c7930ba32f
commit
b1e6ee8d47
7 changed files with 105 additions and 111 deletions
|
@ -2,7 +2,9 @@ import 'package:decimal/decimal.dart';
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:stackwallet/models/exchange/aggregate_currency.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/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
||||
|
@ -323,28 +325,28 @@ class ExchangeFormState extends ChangeNotifier {
|
|||
required bool shouldNotifyListeners,
|
||||
}) async {
|
||||
try {
|
||||
// switch (exchange.name) {
|
||||
// case ChangeNowExchange.exchangeName:
|
||||
// if (!_exchangeSupported(
|
||||
// exchangeName: exchange.name,
|
||||
// sendCurrency: sendCurrency,
|
||||
// receiveCurrency: receiveCurrency,
|
||||
// exchangeRateType: exchangeRateType,
|
||||
// )) {
|
||||
// _exchange = MajesticBankExchange.instance;
|
||||
// }
|
||||
// break;
|
||||
// case MajesticBankExchange.exchangeName:
|
||||
// if (!_exchangeSupported(
|
||||
// exchangeName: exchange.name,
|
||||
// sendCurrency: sendCurrency,
|
||||
// receiveCurrency: receiveCurrency,
|
||||
// exchangeRateType: exchangeRateType,
|
||||
// )) {
|
||||
// _exchange = ChangeNowExchange.instance;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
switch (exchange.name) {
|
||||
case ChangeNowExchange.exchangeName:
|
||||
if (!_exchangeSupported(
|
||||
exchangeName: exchange.name,
|
||||
sendCurrency: sendCurrency,
|
||||
receiveCurrency: receiveCurrency,
|
||||
exchangeRateType: exchangeRateType,
|
||||
)) {
|
||||
_exchange = MajesticBankExchange.instance;
|
||||
}
|
||||
break;
|
||||
case MajesticBankExchange.exchangeName:
|
||||
if (!_exchangeSupported(
|
||||
exchangeName: exchange.name,
|
||||
sendCurrency: sendCurrency,
|
||||
receiveCurrency: receiveCurrency,
|
||||
exchangeRateType: exchangeRateType,
|
||||
)) {
|
||||
_exchange = ChangeNowExchange.instance;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
await _updateRanges(shouldNotifyListeners: false);
|
||||
await _updateEstimate(shouldNotifyListeners: false);
|
||||
|
|
|
@ -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/services/exchange/change_now/change_now_exchange.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/constants.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
|
@ -94,12 +95,11 @@ class _ExchangeCurrencySelectionViewState
|
|||
if (widget.pairedTicker == null) {
|
||||
return await _getCurrencies();
|
||||
}
|
||||
List<Currency> currencies = [];
|
||||
// await ExchangeDataLoadingService
|
||||
// .instance.isar.currencies
|
||||
// .where()
|
||||
// .exchangeNameEqualTo(MajesticBankExchange.exchangeName)
|
||||
// .findAll();
|
||||
List<Currency> currencies = await ExchangeDataLoadingService
|
||||
.instance.isar.currencies
|
||||
.where()
|
||||
.exchangeNameEqualTo(MajesticBankExchange.exchangeName)
|
||||
.findAll();
|
||||
|
||||
final cn = await ChangeNowExchange.instance.getPairedCurrencies(
|
||||
widget.pairedTicker!,
|
||||
|
|
|
@ -71,12 +71,11 @@ class _ExchangeProviderOptionsState
|
|||
sendCurrency: sendCurrency,
|
||||
receiveCurrency: receivingCurrency,
|
||||
);
|
||||
final showMajesticBank = false;
|
||||
// exchangeSupported(
|
||||
// exchangeName: MajesticBankExchange.exchangeName,
|
||||
// sendCurrency: sendCurrency,
|
||||
// receiveCurrency: receivingCurrency,
|
||||
// );
|
||||
final showMajesticBank = exchangeSupported(
|
||||
exchangeName: MajesticBankExchange.exchangeName,
|
||||
sendCurrency: sendCurrency,
|
||||
receiveCurrency: receivingCurrency,
|
||||
);
|
||||
|
||||
return RoundedWhiteContainer(
|
||||
padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12),
|
||||
|
|
|
@ -93,8 +93,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
|||
.trades
|
||||
.firstWhere((e) => e.tradeId == tradeId);
|
||||
|
||||
if (mounted &&
|
||||
trade.exchangeName != MajesticBankExchange.exchangeName) {
|
||||
if (mounted) {
|
||||
final exchange = Exchange.fromName(trade.exchangeName);
|
||||
final response = await exchange.updateTrade(trade);
|
||||
|
||||
|
|
|
@ -273,10 +273,10 @@ class ExchangeDataLoadingService {
|
|||
// }
|
||||
|
||||
Future<void> loadMajesticBankCurrencies() async {
|
||||
// final exchange = MajesticBankExchange.instance;
|
||||
// final responseCurrencies = await exchange.getAllCurrencies(false);
|
||||
//
|
||||
// if (responseCurrencies.value != null) {
|
||||
final exchange = MajesticBankExchange.instance;
|
||||
final responseCurrencies = await exchange.getAllCurrencies(false);
|
||||
|
||||
if (responseCurrencies.value != null) {
|
||||
await isar.writeTxn(() async {
|
||||
final idsToDelete = await isar.currencies
|
||||
.where()
|
||||
|
@ -284,14 +284,14 @@ class ExchangeDataLoadingService {
|
|||
.idProperty()
|
||||
.findAll();
|
||||
await isar.currencies.deleteAll(idsToDelete);
|
||||
// await isar.currencies.putAll(responseCurrencies.value!);
|
||||
await isar.currencies.putAll(responseCurrencies.value!);
|
||||
});
|
||||
// } else {
|
||||
// Logging.instance.log(
|
||||
// "loadMajesticBankCurrencies: $responseCurrencies",
|
||||
// level: LogLevel.Warning,
|
||||
// );
|
||||
// }
|
||||
} else {
|
||||
Logging.instance.log(
|
||||
"loadMajesticBankCurrencies: $responseCurrencies",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Future<void> loadMajesticBankPairs() async {
|
||||
|
|
|
@ -14,11 +14,10 @@ import 'package:stackwallet/services/exchange/exchange_response.dart';
|
|||
import 'package:stackwallet/utilities/logger.dart';
|
||||
|
||||
class MajesticBankAPI {
|
||||
// ensure no api calls go out to mb
|
||||
static const String scheme = ""; //"""https";
|
||||
static const String authority = ""; //"""majesticbank.sc";
|
||||
static const String version = ""; //"""v1";
|
||||
static const kMajesticBankRefCode = ""; //"""rjWugM";
|
||||
static const String scheme = "https";
|
||||
static const String authority = "majesticbank.sc";
|
||||
static const String version = "v1";
|
||||
static const kMajesticBankRefCode = "rjWugM";
|
||||
|
||||
MajesticBankAPI._();
|
||||
|
||||
|
@ -34,8 +33,6 @@ class MajesticBankAPI {
|
|||
}
|
||||
|
||||
Future<dynamic> _makeGetRequest(Uri uri) async {
|
||||
return null;
|
||||
|
||||
final client = this.client ?? http.Client();
|
||||
int code = -1;
|
||||
try {
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:stackwallet/hive/db.dart';
|
|||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||
import 'package:stackwallet/models/notification_model.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/notifications_api.dart';
|
||||
import 'package:stackwallet/services/trade_service.dart';
|
||||
|
@ -198,7 +197,6 @@ class NotificationsService extends ChangeNotifier {
|
|||
final oldTrade = trades.first;
|
||||
late final ExchangeResponse<Trade> response;
|
||||
|
||||
if (oldTrade.exchangeName != MajesticBankExchange.exchangeName) {
|
||||
try {
|
||||
final exchange = Exchange.fromName(oldTrade.exchangeName);
|
||||
response = await exchange.updateTrade(oldTrade);
|
||||
|
@ -253,7 +251,6 @@ class NotificationsService extends ChangeNotifier {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool get hasUnreadNotifications {
|
||||
// final count = (_unreadCountBox.get("count") ?? 0) > 0;
|
||||
|
|
Loading…
Reference in a new issue