2024-05-23 00:37:06 +00:00
|
|
|
import 'wallets/crypto_currency/crypto_currency.dart';
|
|
|
|
import 'wallets/crypto_currency/intermediate/frost_currency.dart';
|
2024-05-22 19:38:49 +00:00
|
|
|
|
|
|
|
part 'app_config.g.dart';
|
2024-05-21 18:48:48 +00:00
|
|
|
|
2024-05-13 19:44:19 +00:00
|
|
|
abstract class AppConfig {
|
2024-05-22 19:38:49 +00:00
|
|
|
static const appName = _prefix + _separator + suffix;
|
|
|
|
|
|
|
|
static const prefix = _prefix;
|
|
|
|
static const suffix = _suffix;
|
2024-05-13 17:48:05 +00:00
|
|
|
|
2024-05-23 15:20:11 +00:00
|
|
|
static String get appDefaultDataDirName => _appDataDirName;
|
|
|
|
|
2024-05-22 19:38:49 +00:00
|
|
|
static List<CryptoCurrency> get coins => _supportedCoins;
|
2024-05-13 17:48:05 +00:00
|
|
|
|
2024-05-23 17:05:30 +00:00
|
|
|
static CryptoCurrency? getCryptoCurrencyFor(String coinIdentifier) {
|
|
|
|
try {
|
|
|
|
return coins.firstWhere((e) => e.identifier == coinIdentifier);
|
|
|
|
} catch (_) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2024-05-13 18:02:39 +00:00
|
|
|
|
2024-05-23 17:05:30 +00:00
|
|
|
static CryptoCurrency? getCryptoCurrencyForTicker(
|
2024-05-22 19:38:49 +00:00
|
|
|
final String ticker, {
|
|
|
|
bool caseInsensitive = true,
|
|
|
|
}) {
|
|
|
|
final _ticker = caseInsensitive ? ticker.toLowerCase() : ticker;
|
2024-05-23 17:05:30 +00:00
|
|
|
try {
|
|
|
|
return coins.firstWhere(
|
|
|
|
caseInsensitive
|
|
|
|
? (e) => e.ticker.toLowerCase() == _ticker && e is! FrostCurrency
|
|
|
|
: (e) => e.ticker == _ticker && e is! FrostCurrency,
|
|
|
|
);
|
|
|
|
} catch (_) {
|
|
|
|
return null;
|
|
|
|
}
|
2024-05-22 19:38:49 +00:00
|
|
|
}
|
2024-05-21 18:48:48 +00:00
|
|
|
|
2024-05-22 19:38:49 +00:00
|
|
|
/// Fuzzy logic. Use with caution!!
|
|
|
|
@Deprecated("dangerous")
|
|
|
|
static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) {
|
|
|
|
final name = prettyName.replaceAll(" ", "").toLowerCase();
|
|
|
|
try {
|
|
|
|
return coins.firstWhere(
|
|
|
|
(e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName,
|
|
|
|
);
|
|
|
|
} catch (_) {
|
|
|
|
throw Exception("getCryptoCurrencyByPrettyName($prettyName) failed!");
|
|
|
|
}
|
|
|
|
}
|
2024-05-13 17:48:05 +00:00
|
|
|
}
|