Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add print tool for all markets used in https://github.com/bisq-networ…
- Loading branch information
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
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")); | ||
|
||
// <option value="onion_btc">DeepOnion (ONION)</option> | ||
// <option value="btc_bhd">Bahraini Dinar (BHD)</option> | ||
|
||
final List<FiatCurrency> allSortedFiatCurrencies = CurrencyUtil.getAllSortedFiatCurrencies(); | ||
final Stream<MarketCurrency> 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<CryptoCurrency> allSortedCryptoCurrencies = CurrencyUtil.getAllSortedCryptoCurrencies(); | ||
final Stream<MarketCurrency> 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("<option value=\"") | ||
.append(e.marketSelector) | ||
.append("\">") | ||
.append(e.currencyName) | ||
.append(" (") | ||
.append(e.currencyCode) | ||
.append(")</option>") | ||
.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; | ||
} | ||
} | ||
} |