Fix haven currencies not getting serialized
OmarHatem committed
Dec 29, 2022 at 16:02 UTC
17751f236336a6736548298cd5d86328c164200e
1 file changed
+24
-8
cw_core/lib/crypto_currency.dart
+24
-8
@@ -67,6 +67,22 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
67
CryptoCurrency.stx,
68
];
69
70
+ static const havenCurrencies = [
71
+ xag,
72
+ xau,
73
+ xaud,
74
+ xbtc,
75
+ xcad,
76
+ xchf,
77
+ xcny,
78
+ xeur,
79
+ xgbp,
80
+ xjpy,
81
+ xnok,
82
+ xnzd,
83
+ xusd,
84
+ ];
85
+
86
static const xmr = CryptoCurrency(title: 'XMR', iconPath: 'assets/images/monero_icon.png', fullName: 'Monero', raw: 0, name: 'xmr');
87
static const ada = CryptoCurrency(title: 'ADA', iconPath: 'assets/images/ada_icon.png', fullName: 'Cardano', raw: 1, name: 'ada');
88
static const bch = CryptoCurrency(title: 'BCH', iconPath: 'assets/images/bch_icon.png',fullName: 'Bitcoin Cash', raw: 2, name: 'bch');
@@ -134,16 +150,16 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> {
150
static const stx = CryptoCurrency(title: 'STX', iconPath: 'assets/images/stx_icon.png', raw: 61, name: 'stx');
151
152
static final Map<int, CryptoCurrency> _rawCurrencyMap =
137
- all.fold<Map<int, CryptoCurrency>>(<int, CryptoCurrency>{}, (acc, item) {
138
- acc.addAll({item.raw: item});
139
- return acc;
140
- });
153
+ [...all, ...havenCurrencies].fold<Map<int, CryptoCurrency>>(<int, CryptoCurrency>{}, (acc, item) {
154
+ acc.addAll({item.raw: item});
155
+ return acc;
156
+ });
157
158
static final Map<String, CryptoCurrency> _nameCurrencyMap =
143
- all.fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
144
- acc.addAll({item.name: item});
145
- return acc;
146
- });
159
+ [...all, ...havenCurrencies].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
160
+ acc.addAll({item.name: item});
161
+ return acc;
162
+ });
163
164
static CryptoCurrency deserialize({required int raw}) {
165