2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
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 = {};
|
|
|
|
|
2023-04-28 20:29:30 +00:00
|
|
|
AggregateCurrency({
|
|
|
|
required List<Tuple2<String, Currency>> exchangeCurrencyPairs,
|
|
|
|
}) {
|
2023-02-08 19:06:26 +00:00
|
|
|
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 20:06:58 +00:00
|
|
|
|
2023-02-08 19:06:26 +00:00
|
|
|
String get name => _map.values.first!.name;
|
2023-02-08 20:06:58 +00:00
|
|
|
|
2023-02-08 19:06:26 +00:00
|
|
|
String get image => _map.values.first!.image;
|
2023-02-08 20:06:58 +00:00
|
|
|
|
2023-02-08 19:06:26 +00:00
|
|
|
SupportedRateType get rateType => _map.values.first!.rateType;
|
2023-02-08 20:06:58 +00:00
|
|
|
|
2023-02-08 19:06:26 +00:00
|
|
|
bool get isStackCoin => _map.values.first!.isStackCoin;
|
2023-02-08 20:06:58 +00:00
|
|
|
|
|
|
|
@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
|
|
|
}
|