From 9e22a7df6d0a02c3859dba41013474b1396eb1dd Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Thu, 13 Dec 2018 14:54:08 +0100 Subject: [PATCH] Add print tool for all markets used in https://github.com/bisq-network/bisq-website/blob/master/_includes/market_currency_selector.html --- .../java/bisq/desktop/MarketsPrintTool.java | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 desktop/src/test/java/bisq/desktop/MarketsPrintTool.java diff --git a/desktop/src/test/java/bisq/desktop/MarketsPrintTool.java b/desktop/src/test/java/bisq/desktop/MarketsPrintTool.java new file mode 100644 index 00000000000..3d34cbfb6c5 --- /dev/null +++ b/desktop/src/test/java/bisq/desktop/MarketsPrintTool.java @@ -0,0 +1,79 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.desktop; + +import bisq.core.locale.CryptoCurrency; +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.FiatCurrency; + +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.stream.Stream; + +public class MarketsPrintTool { + + public static void main(String[] args) { + // Prints out all coins in the format used in the market_currency_selector.html. + // Run that and copy paste the result to the market_currency_selector.html at new releases. + StringBuilder sb = new StringBuilder(); + Locale.setDefault(new Locale("en", "US")); + + // + // + + final List allSortedFiatCurrencies = CurrencyUtil.getAllSortedFiatCurrencies(); + final Stream fiatStream = allSortedFiatCurrencies.stream() + .filter(e -> !e.getCurrency().getCurrencyCode().equals("BSQ")) + .filter(e -> !e.getCurrency().getCurrencyCode().equals("BTC")) + .map(e -> new MarketCurrency("btc_" + e.getCode().toLowerCase(), e.getName(), e.getCode())) + .distinct(); + + final List allSortedCryptoCurrencies = CurrencyUtil.getAllSortedCryptoCurrencies(); + final Stream cryptoStream = allSortedCryptoCurrencies.stream() + .filter(e -> !e.getCode().equals("BSQ")) + .filter(e -> !e.getCode().equals("BTC")) + .map(e -> new MarketCurrency(e.getCode().toLowerCase() + "_btc", e.getName(), e.getCode())) + .distinct(); + + Stream.concat(fiatStream, cryptoStream) + .sorted(Comparator.comparing(o -> o.currencyName.toLowerCase())) + .distinct() + .forEach(e -> sb.append("") + .append("\n")); + System.out.println(sb.toString()); + } + + private static class MarketCurrency { + final String marketSelector; + final String currencyName; + final String currencyCode; + + MarketCurrency(String marketSelector, String currencyName, String currencyCode) { + this.marketSelector = marketSelector; + this.currencyName = currencyName; + this.currencyCode = currencyCode; + } + } +}