stack_wallet/lib/models/exchange/aggregate_currency.dart

41 lines
1 KiB
Dart
Raw Normal View History

2023-02-08 19:06:26 +00:00
import 'package:stackwallet/models/isar/exchange_cache/currency.dart';
import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
import 'package:tuple/tuple.dart';
class AggregateCurrency {
final Map<String, Currency?> _map = {};
AggregateCurrency(
{required List<Tuple2<String, Currency>> exchangeCurrencyPairs}) {
assert(exchangeCurrencyPairs.isNotEmpty);
for (final item in exchangeCurrencyPairs) {
_map[item.item1] = item.item2;
}
}
Currency? forExchange(String exchangeName) {
return _map[exchangeName];
}
String get ticker => _map.values.first!.ticker;
2023-02-08 19:06:26 +00:00
String get name => _map.values.first!.name;
2023-02-08 19:06:26 +00:00
String get image => _map.values.first!.image;
2023-02-08 19:06:26 +00:00
SupportedRateType get rateType => _map.values.first!.rateType;
2023-02-08 19:06:26 +00:00
bool get isStackCoin => _map.values.first!.isStackCoin;
@override
String toString() {
String str = "AggregateCurrency: {";
for (final key in _map.keys) {
str += " $key: ${_map[key]},";
}
str += " }";
return str;
}
2023-02-08 19:06:26 +00:00
}