Remove spurious PaymentAccount#canSupportMultipleCurrencies()

Method was added on the false assumption `PaymentAccount#hasMultipleCurrencies()`
would not always return a correct value when a `PaymentAccount` instance is created
via reflection.  But `hasMultipleCurrencies()` will work as long as appropriate
PaymentAccount subclasses continue setting their `tradeCurrencies` fields within
their default constructors.
This commit is contained in:
ghubstan 2021-09-07 11:31:56 -03:00
parent 1adde70c7a
commit ab929d4435
No known key found for this signature in database
GPG Key ID: E35592D6800A861E
4 changed files with 5 additions and 21 deletions

View File

@ -1002,7 +1002,7 @@ public class CreatePaymentAccountTest extends AbstractPaymentAccountTest {
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
createPaymentAccount(aliceClient, jsonString));
assertEquals("INVALID_ARGUMENT: no trade currencies defined for transferwise payment account",
assertEquals("INVALID_ARGUMENT: no trade currency defined for transferwise payment account",
exception.getMessage());
}

View File

@ -138,11 +138,7 @@ class CorePaymentAccountsService {
}
private void verifyPaymentAccountHasRequiredFields(PaymentAccount paymentAccount) {
if (paymentAccount.canSupportMultipleCurrencies() && paymentAccount.getTradeCurrencies().isEmpty())
throw new IllegalArgumentException(format("no trade currencies defined for %s payment account",
paymentAccount.getPaymentMethod().getDisplayString().toLowerCase()));
if (!paymentAccount.canSupportMultipleCurrencies() && paymentAccount.getSingleTradeCurrency() == null)
if (!paymentAccount.hasMultipleCurrencies() && paymentAccount.getSingleTradeCurrency() == null)
throw new IllegalArgumentException(format("no trade currency defined for %s payment account",
paymentAccount.getPaymentMethod().getDisplayString().toLowerCase()));
}

View File

@ -145,7 +145,7 @@ class PaymentAccountTypeAdapter extends TypeAdapter<PaymentAccount> {
private void writeInnerMutableFields(JsonWriter out, PaymentAccount account) {
if (account.canSupportMultipleCurrencies()) {
if (account.hasMultipleCurrencies()) {
writeTradeCurrenciesField(out, account);
writeSelectedTradeCurrencyField(out, account);
}

View File

@ -41,7 +41,8 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Nullable;
import static bisq.core.payment.payload.PaymentMethod.*;
import static bisq.core.payment.payload.PaymentMethod.TRANSFERWISE_ID;
import static bisq.core.payment.payload.PaymentMethod.getPaymentMethodById;
import static com.google.common.base.Preconditions.checkNotNull;
@EqualsAndHashCode
@ -152,19 +153,6 @@ public abstract class PaymentAccount implements PersistablePayload {
return tradeCurrencies.size() > 1;
}
public boolean canSupportMultipleCurrencies() {
return this.hasPaymentMethodWithId(ADVANCED_CASH_ID)
|| this.hasPaymentMethodWithId(AMAZON_GIFT_CARD_ID)
|| this.hasPaymentMethodWithId(CAPITUAL_ID)
|| this.hasPaymentMethodWithId(MONEY_GRAM_ID)
|| this.hasPaymentMethodWithId(PAYSERA_ID)
|| this.hasPaymentMethodWithId(PAXUM_ID)
|| this.hasPaymentMethodWithId(REVOLUT_ID)
// || this.hasPaymentMethodWithId(SWIFT_ID)
|| this.hasPaymentMethodWithId(TRANSFERWISE_ID)
|| this.hasPaymentMethodWithId(UPHOLD_ID);
}
public void setSingleTradeCurrency(TradeCurrency tradeCurrency) {
tradeCurrencies.clear();
tradeCurrencies.add(tradeCurrency);