only add stack coins to list

TODO refactor isStackCoin into a reusable form instead of copying it around 3 times :P
This commit is contained in:
sneurlax 2023-01-26 17:08:57 -06:00
parent 9a3e9f345d
commit 6c48caff48

View file

@ -8,6 +8,7 @@ import 'package:stackwallet/models/buy/response_objects/fiat.dart';
import 'package:stackwallet/models/buy/response_objects/order.dart'; import 'package:stackwallet/models/buy/response_objects/order.dart';
import 'package:stackwallet/models/buy/response_objects/quote.dart'; import 'package:stackwallet/models/buy/response_objects/quote.dart';
import 'package:stackwallet/services/buy/buy_response.dart'; import 'package:stackwallet/services/buy/buy_response.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/fiat_enum.dart'; import 'package:stackwallet/utilities/enums/fiat_enum.dart';
import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/prefs.dart';
@ -71,6 +72,7 @@ class SimplexAPI {
for (final crypto in jsonArray as List) { for (final crypto in jsonArray as List) {
// TODO validate jsonArray // TODO validate jsonArray
if (isStackCoin("${crypto['ticker_symbol']}")) {
cryptos.add(Crypto.fromJson({ cryptos.add(Crypto.fromJson({
'ticker': "${crypto['ticker_symbol']}", 'ticker': "${crypto['ticker_symbol']}",
'name': crypto['name'], 'name': crypto['name'],
@ -79,6 +81,7 @@ class SimplexAPI {
'image': "", 'image': "",
})); }));
} }
}
return BuyResponse(value: cryptos); return BuyResponse(value: cryptos);
} catch (e, s) { } catch (e, s) {
@ -331,3 +334,14 @@ class SimplexAPI {
String timeZoneFormatter(Duration offset) => String timeZoneFormatter(Duration offset) =>
"${offset.isNegative ? "-" : "+"}${offset.inHours.abs().toString().padLeft(2, "0")}:${(offset.inMinutes - offset.inHours * 60).abs().toString().padLeft(2, "0")}"; "${offset.isNegative ? "-" : "+"}${offset.inHours.abs().toString().padLeft(2, "0")}:${(offset.inMinutes - offset.inHours * 60).abs().toString().padLeft(2, "0")}";
} }
bool isStackCoin(String? ticker) {
if (ticker == null) return false;
try {
coinFromTickerCaseInsensitive(ticker);
return true;
} on ArgumentError catch (_) {
return false;
}
}