From 7ad2e20d958621f35f9cdee5b66c0060e31a7a2f Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 23 Jun 2022 11:16:13 -0400 Subject: [PATCH] support paxum --- .../core/api/model/PaymentAccountForm.java | 3 ++- .../java/bisq/core/payment/PaxumAccount.java | 18 ++++++++++++++++-- .../java/bisq/core/payment/PaymentAccount.java | 1 + .../java/bisq/core/payment/RevolutAccount.java | 7 ------- .../core/payment/payload/PaymentMethod.java | 3 ++- proto/src/main/proto/pb.proto | 1 + 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java b/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java index 98c07f3f..b8d881fe 100644 --- a/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java +++ b/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java @@ -75,7 +75,8 @@ public final class PaymentAccountForm implements PersistablePayload { STRIKE, MONEY_GRAM, FASTER_PAYMENTS, - UPHOLD; + UPHOLD, + PAXUM; public static PaymentAccountForm.FormId fromProto(protobuf.PaymentAccountForm.FormId formId) { return ProtoUtil.enumFromProto(PaymentAccountForm.FormId.class, formId.name()); diff --git a/core/src/main/java/bisq/core/payment/PaxumAccount.java b/core/src/main/java/bisq/core/payment/PaxumAccount.java index d232d438..47288727 100644 --- a/core/src/main/java/bisq/core/payment/PaxumAccount.java +++ b/core/src/main/java/bisq/core/payment/PaxumAccount.java @@ -25,7 +25,7 @@ import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; import java.util.List; - +import java.util.stream.Collectors; import lombok.EqualsAndHashCode; import org.jetbrains.annotations.NotNull; @@ -33,6 +33,13 @@ import org.jetbrains.annotations.NotNull; @EqualsAndHashCode(callSuper = true) public final class PaxumAccount extends PaymentAccount { + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.EMAIL, + PaymentAccountFormField.FieldId.TRADE_CURRENCIES, + PaymentAccountFormField.FieldId.SALT + ); + // https://github.com/bisq-network/growth/issues/235 public static final List SUPPORTED_CURRENCIES = List.of( new FiatCurrency("AUD"), @@ -71,7 +78,7 @@ public final class PaxumAccount extends PaymentAccount { @Override public @NotNull List getInputFieldIds() { - throw new RuntimeException("Not implemented"); + return INPUT_FIELD_IDS; } public void setEmail(String accountId) { @@ -81,4 +88,11 @@ public final class PaxumAccount extends PaymentAccount { public String getEmail() { return ((PaxumAccountPayload) paymentAccountPayload).getEmail(); } + + @Override + protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { + var field = super.getEmptyFormField(fieldId); + if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setValue(""); + return field; + } } diff --git a/core/src/main/java/bisq/core/payment/PaymentAccount.java b/core/src/main/java/bisq/core/payment/PaymentAccount.java index fae08823..791c32e1 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccount.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccount.java @@ -665,6 +665,7 @@ public abstract class PaymentAccount implements PersistablePayload { field.setComponent(PaymentAccountFormField.Component.SELECT_MULTIPLE); field.setLabel("Supported currencies"); field.setSupportedCurrencies(getSupportedCurrencies()); + field.setValue(String.join(",", getSupportedCurrencies().stream().map(TradeCurrency::getCode).collect(Collectors.toList()))); break; case USER_NAME: field.setComponent(PaymentAccountFormField.Component.TEXT); diff --git a/core/src/main/java/bisq/core/payment/RevolutAccount.java b/core/src/main/java/bisq/core/payment/RevolutAccount.java index 1a616fc2..495349c4 100644 --- a/core/src/main/java/bisq/core/payment/RevolutAccount.java +++ b/core/src/main/java/bisq/core/payment/RevolutAccount.java @@ -124,11 +124,4 @@ public final class RevolutAccount extends PaymentAccount { public @NonNull List getSupportedCurrencies() { return SUPPORTED_CURRENCIES; } - - @Override - protected PaymentAccountFormField getEmptyFormField(PaymentAccountFormField.FieldId fieldId) { - var field = super.getEmptyFormField(fieldId); - if (field.getId() == PaymentAccountFormField.FieldId.TRADE_CURRENCIES) field.setValue(String.join(",", getSupportedCurrencies().stream().map(TradeCurrency::getCode).collect(Collectors.toList()))); - return field; - } } diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java index ef2b728d..d3e35fdf 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -338,7 +338,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList()); } diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 1d63753a..84e58b8b 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -2085,6 +2085,7 @@ message PaymentAccountForm { MONEY_GRAM = 8; FASTER_PAYMENTS = 9; UPHOLD = 10; + PAXUM = 11; } FormId id = 1; repeated PaymentAccountFormField fields = 2;