Skip to content

Commit

Permalink
Merge pull request #6135 from ripcurlx/improve-navigation-structure
Browse files Browse the repository at this point in the history
Improve navigation structure
  • Loading branch information
ripcurlx authored Apr 22, 2022
2 parents dde4199 + 7ad2dd0 commit 0466f41
Show file tree
Hide file tree
Showing 148 changed files with 3,251 additions and 1,208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.AdvancedCashAccount;
import bisq.core.payment.AliPayAccount;
import bisq.core.payment.AustraliaPayid;
import bisq.core.payment.AustraliaPayidAccount;
import bisq.core.payment.CapitualAccount;
import bisq.core.payment.CashDepositAccount;
import bisq.core.payment.ClearXchangeAccount;
Expand Down Expand Up @@ -81,7 +81,8 @@
import static bisq.apitest.config.ApiTestConfig.USD;
import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.cli.table.builder.TableType.PAYMENT_ACCOUNT_TBL;
import static bisq.core.locale.CurrencyUtil.*;
import static bisq.core.locale.CurrencyUtil.getAllSortedFiatCurrencies;
import static bisq.core.locale.CurrencyUtil.getTradeCurrency;
import static bisq.core.payment.payload.PaymentMethod.*;
import static java.util.Comparator.comparing;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -117,7 +118,7 @@ public void testCreateAdvancedCashAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, ADVANCED_CASH_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Advanced Cash Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NR, "0000 1111 2222");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllAdvancedCashCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, AdvancedCashAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -126,7 +127,7 @@ public void testCreateAdvancedCashAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
AdvancedCashAccount paymentAccount = (AdvancedCashAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllAdvancedCashCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(AdvancedCashAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down Expand Up @@ -166,7 +167,7 @@ public void testCreateAustraliaPayidAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_ACCOUNT_NAME, "Credit Union Australia");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Australia Pay ID Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
AustraliaPayid paymentAccount = (AustraliaPayid) createPaymentAccount(aliceClient, jsonString);
AustraliaPayidAccount paymentAccount = (AustraliaPayidAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("AUD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
Expand All @@ -185,7 +186,7 @@ public void testCreateCapitualAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, CAPITUAL_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Capitual Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NR, "1111 2222 3333-4");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllCapitualCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, CapitualAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -194,7 +195,7 @@ public void testCreateCapitualAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
CapitualAccount paymentAccount = (CapitualAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllCapitualCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(CapitualAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down Expand Up @@ -491,7 +492,7 @@ public void testCreateMoneyGramAccount(TestInfo testInfo) {
PROPERTY_NAME_STATE);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, MONEY_GRAM_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Money Gram Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllMoneyGramCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, MoneyGramAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -504,7 +505,7 @@ public void testCreateMoneyGramAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
MoneyGramAccount paymentAccount = (MoneyGramAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllMoneyGramCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(MoneyGramAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down Expand Up @@ -544,7 +545,7 @@ public void testCreatePaxumAccount(TestInfo testInfo) {
PROPERTY_NAME_EMAIL);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, PAXUM_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Paxum Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllPaxumCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, PaxumAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -554,7 +555,7 @@ public void testCreatePaxumAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
PaxumAccount paymentAccount = (PaxumAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllPaxumCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(PaxumAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand All @@ -570,7 +571,7 @@ public void testCreatePayseraAccount(TestInfo testInfo) {
PROPERTY_NAME_EMAIL);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, PAYSERA_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Paysera Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllPayseraCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, PayseraAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -580,7 +581,7 @@ public void testCreatePayseraAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
PayseraAccount paymentAccount = (PayseraAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllPayseraCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(PayseraAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down Expand Up @@ -638,7 +639,7 @@ public void testCreateRevolutAccount(TestInfo testInfo) {
PROPERTY_NAME_USERNAME);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, REVOLUT_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Revolut Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllRevolutCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, RevolutAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -648,7 +649,7 @@ public void testCreateRevolutAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
RevolutAccount paymentAccount = (RevolutAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllRevolutCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(RevolutAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down Expand Up @@ -959,7 +960,7 @@ public void testCreateTransferwiseAccountWithSupportedTradeCurrencies(TestInfo t
PROPERTY_NAME_EMAIL);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, TRANSFERWISE_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Transferwise Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllTransferwiseCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, TransferwiseAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -969,7 +970,7 @@ public void testCreateTransferwiseAccountWithSupportedTradeCurrencies(TestInfo t
String jsonString = getCompletedFormAsJsonString();
TransferwiseAccount paymentAccount = (TransferwiseAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllTransferwiseCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(TransferwiseAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down Expand Up @@ -1024,7 +1025,7 @@ public void testCreateUpholdAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PAYMENT_METHOD_ID, UPHOLD_ID);
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NAME, "Uphold Acct");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_ID, "UA 9876");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, getAllUpholdCurrencies()
COMPLETED_FORM_MAP.put(PROPERTY_NAME_TRADE_CURRENCIES, UpholdAccount.SUPPORTED_CURRENCIES
.stream()
.map(TradeCurrency::getCode)
.collect(Collectors.joining(",")));
Expand All @@ -1033,7 +1034,7 @@ public void testCreateUpholdAccount(TestInfo testInfo) {
String jsonString = getCompletedFormAsJsonString();
UpholdAccount paymentAccount = (UpholdAccount) createPaymentAccount(aliceClient, jsonString);
verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllUpholdCurrencies(), paymentAccount);
verifyAccountTradeCurrencies(UpholdAccount.SUPPORTED_CURRENCIES, paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_SELECTED_TRADE_CURRENCY),
paymentAccount.getSelectedTradeCurrency().getCode());
verifyCommonFormEntries(paymentAccount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
import static bisq.common.util.ReflectionUtils.*;
import static bisq.common.util.Utilities.decodeFromHex;
import static bisq.core.locale.CountryUtil.findCountryByCode;
import static bisq.core.locale.CurrencyUtil.*;
import static bisq.core.payment.payload.PaymentMethod.*;
import static bisq.core.locale.CurrencyUtil.getCurrencyByCountryCode;
import static bisq.core.locale.CurrencyUtil.getTradeCurrenciesInList;
import static bisq.core.locale.CurrencyUtil.getTradeCurrency;
import static bisq.core.payment.payload.PaymentMethod.MONEY_GRAM_ID;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import static java.util.Arrays.stream;
Expand Down Expand Up @@ -377,30 +379,7 @@ private boolean didReadTradeCurrenciesField(JsonReader in,

private Optional<List<TradeCurrency>> getReconciledTradeCurrencies(List<String> currencyCodes,
PaymentAccount account) {
if (account.hasPaymentMethodWithId(ADVANCED_CASH_ID))
return getTradeCurrenciesInList(currencyCodes, getAllAdvancedCashCurrencies());
else if (account.hasPaymentMethodWithId(AMAZON_GIFT_CARD_ID))
return getTradeCurrenciesInList(currencyCodes, getAllAmazonGiftCardCurrencies());
else if (account.hasPaymentMethodWithId(CAPITUAL_ID))
return getTradeCurrenciesInList(currencyCodes, getAllCapitualCurrencies());
else if (account.hasPaymentMethodWithId(MONEY_GRAM_ID))
return getTradeCurrenciesInList(currencyCodes, getAllMoneyGramCurrencies());
else if (account.hasPaymentMethodWithId(PAXUM_ID))
return getTradeCurrenciesInList(currencyCodes, getAllPaxumCurrencies());
else if (account.hasPaymentMethodWithId(PAYSERA_ID))
return getTradeCurrenciesInList(currencyCodes, getAllPayseraCurrencies());
else if (account.hasPaymentMethodWithId(REVOLUT_ID))
return getTradeCurrenciesInList(currencyCodes, getAllRevolutCurrencies());
else if (account.hasPaymentMethodWithId(SWIFT_ID))
return getTradeCurrenciesInList(currencyCodes,
new ArrayList<>(getAllSortedFiatCurrencies(
comparing(TradeCurrency::getCode))));
else if (account.hasPaymentMethodWithId(TRANSFERWISE_ID))
return getTradeCurrenciesInList(currencyCodes, getAllTransferwiseCurrencies());
else if (account.hasPaymentMethodWithId(UPHOLD_ID))
return getTradeCurrenciesInList(currencyCodes, getAllUpholdCurrencies());
else
return Optional.empty();
return getTradeCurrenciesInList(currencyCodes, account.getSupportedCurrencies());
}

private boolean didReadSelectedTradeCurrencyField(JsonReader in,
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/java/bisq/core/locale/CountryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -61,7 +62,7 @@ public static List<Country> getAllAmazonGiftCardCountries() {
String[] codes = {"AU", "CA", "FR", "DE", "IT", "NL", "ES", "GB", "IN", "JP",
"SA", "SE", "SG", "TR", "US"};
populateCountryListByCodes(list, codes);
list.sort((a, b) -> a.name.compareTo(b.name));
list.sort(Comparator.comparing(a -> a.name));

return list;
}
Expand Down
Loading

0 comments on commit 0466f41

Please sign in to comment.