From 1c172edb3205f2cd7172219a57d5317472933aff Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 23 May 2023 17:39:26 -0400 Subject: [PATCH] refactor non-fiat iso codes --- core/src/main/java/haveno/core/locale/CurrencyUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/haveno/core/locale/CurrencyUtil.java b/core/src/main/java/haveno/core/locale/CurrencyUtil.java index bde94244cc..d94fb3a70c 100644 --- a/core/src/main/java/haveno/core/locale/CurrencyUtil.java +++ b/core/src/main/java/haveno/core/locale/CurrencyUtil.java @@ -103,8 +103,7 @@ public class CurrencyUtil { List currencies = CountryUtil.getAllCountries().stream() .map(country -> getCurrencyByCountryCode(country.code)) .collect(Collectors.toList()); - currencies.add(new TraditionalCurrency(Currency.getInstance("XAG"))); // add silver - currencies.add(new TraditionalCurrency(Currency.getInstance("XAU"))); // add gold + for (String isoCode : nonFiatIsoCodes) currencies.add(new TraditionalCurrency(Currency.getInstance(isoCode))); return currencies.stream().sorted(TradeCurrency::compareTo) .distinct() .collect(Collectors.toMap(TradeCurrency::getCode, Function.identity(), (x, y) -> x, LinkedHashMap::new)); @@ -126,12 +125,13 @@ public class CurrencyUtil { public static List getMainTraditionalCurrencies() { List list = getMainFiatCurrencies(); - list.add(new TraditionalCurrency("XAG")); - list.add(new TraditionalCurrency("XAU")); + for (String isoCode : nonFiatIsoCodes) list.add(new TraditionalCurrency(isoCode)); postProcessTraditionalCurrenciesList(list); return list; } + private static List nonFiatIsoCodes = Arrays.asList("XAG", "XAU"); + private static void postProcessTraditionalCurrenciesList(List list) { list.sort(TradeCurrency::compareTo);