dev
dart 37 lines 1.33 KB
Raw
1 import 'package:cake_wallet/entities/fiat_currency.dart';
2 import 'package:cw_core/crypto_currency.dart';
3
4 class TradePair<T, U> {
5 TradePair({required this.from, required this.to});
6
7 final T from;
8 final U to;
9 }
10
11 List<TradePair<CryptoCurrency, FiatCurrency>> supportedCryptoToFiatPairs({
12 required List<CryptoCurrency> notSupportedCrypto,
13 required List<FiatCurrency> notSupportedFiat,
14 }) {
15 final supportedCrypto =
16 CryptoCurrency.all.where((crypto) => !notSupportedCrypto.contains(crypto)).toList();
17 final supportedFiat = FiatCurrency.all.where((fiat) => !notSupportedFiat.contains(fiat)).toList();
18
19 return supportedCrypto
20 .expand((crypto) => supportedFiat
21 .map((fiat) => TradePair<CryptoCurrency, FiatCurrency>(from: crypto, to: fiat)))
22 .toList();
23 }
24
25 List<TradePair<FiatCurrency, CryptoCurrency>> supportedFiatToCryptoPairs({
26 required List<FiatCurrency> notSupportedFiat,
27 required List<CryptoCurrency> notSupportedCrypto,
28 }) {
29 final supportedFiat = FiatCurrency.all.where((fiat) => !notSupportedFiat.contains(fiat)).toList();
30 final supportedCrypto =
31 CryptoCurrency.all.where((crypto) => !notSupportedCrypto.contains(crypto)).toList();
32
33 return supportedFiat
34 .expand((fiat) => supportedCrypto
35 .map((crypto) => TradePair<FiatCurrency, CryptoCurrency>(from: fiat, to: crypto)))
36 .toList();
37 }