mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-31 19:39:06 +00:00
add trocador currencies to loading/caching process
This commit is contained in:
parent
31a29be929
commit
73b7af77f6
1 changed files with 24 additions and 0 deletions
|
@ -7,6 +7,7 @@ import 'package:stackwallet/models/isar/exchange_cache/currency.dart';
|
|||
import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
|
||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||
import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart';
|
||||
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
||||
import 'package:stackwallet/utilities/logger.dart';
|
||||
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||
|
@ -128,6 +129,7 @@ class ExchangeDataLoadingService {
|
|||
// loadSimpleswapFixedRateCurrencies(ref),
|
||||
// loadSimpleswapFloatingRateCurrencies(ref),
|
||||
loadMajesticBankCurrencies(),
|
||||
loadTrocadorCurrencies(),
|
||||
]);
|
||||
|
||||
// quicker to load available currencies on the fly for a specific base currency
|
||||
|
@ -302,6 +304,28 @@ class ExchangeDataLoadingService {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> loadTrocadorCurrencies() async {
|
||||
final exchange = TrocadorExchange.instance;
|
||||
final responseCurrencies = await exchange.getAllCurrencies(false);
|
||||
|
||||
if (responseCurrencies.value != null) {
|
||||
await isar.writeTxn(() async {
|
||||
final idsToDelete = await isar.currencies
|
||||
.where()
|
||||
.exchangeNameEqualTo(TrocadorExchange.exchangeName)
|
||||
.idProperty()
|
||||
.findAll();
|
||||
await isar.currencies.deleteAll(idsToDelete);
|
||||
await isar.currencies.putAll(responseCurrencies.value!);
|
||||
});
|
||||
} else {
|
||||
Logging.instance.log(
|
||||
"loadTrocadorCurrencies: $responseCurrencies",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Future<void> loadMajesticBankPairs() async {
|
||||
// final exchange = MajesticBankExchange.instance;
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue