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 cf6febb245..98c07f3f31 100644 --- a/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java +++ b/core/src/main/java/bisq/core/api/model/PaymentAccountForm.java @@ -74,7 +74,8 @@ public final class PaymentAccountForm implements PersistablePayload { F2F, STRIKE, MONEY_GRAM, - FASTER_PAYMENTS; + FASTER_PAYMENTS, + UPHOLD; 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/PaymentAccount.java b/core/src/main/java/bisq/core/payment/PaymentAccount.java index b97d4f54a3..fae0882319 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccount.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccount.java @@ -35,6 +35,7 @@ import bisq.core.payment.validation.EmailValidator; import bisq.core.payment.validation.IBANValidator; import bisq.core.payment.validation.LengthValidator; import bisq.core.proto.CoreProtoResolver; +import bisq.core.util.validation.InputValidator; import bisq.core.util.validation.InputValidator.ValidationResult; import bisq.common.proto.ProtoUtil; import bisq.common.proto.persistable.PersistablePayload; @@ -310,7 +311,8 @@ public abstract class PaymentAccount implements PersistablePayload { break; } case ACCOUNT_ID: - throw new IllegalArgumentException("Not implemented"); + processValidationResult(new InputValidator().validate(value)); + break; case ACCOUNT_NAME: processValidationResult(new LengthValidator(2, 100).validate(value)); break; @@ -318,7 +320,8 @@ public abstract class PaymentAccount implements PersistablePayload { processValidationResult(new AccountNrValidator("GB").validate(value)); break; case ACCOUNT_OWNER: - throw new IllegalArgumentException("Not implemented"); + processValidationResult(new LengthValidator(2, 100).validate(value)); + break; case ACCOUNT_TYPE: throw new IllegalArgumentException("Not implemented"); case ANSWER: @@ -380,7 +383,7 @@ public abstract class PaymentAccount implements PersistablePayload { processValidationResult(new LengthValidator(2, 34).validate(value)); break; case CONTACT: - checkNotEmpty(value); + processValidationResult(new InputValidator().validate(value)); break; case COUNTRY: if (this instanceof CountryBasedPaymentAccount) { @@ -394,11 +397,9 @@ public abstract class PaymentAccount implements PersistablePayload { if (!CountryUtil.findCountryByCode(value).isPresent()) throw new IllegalArgumentException("Invalid country code: " + value); break; case EMAIL: - checkNotEmpty(value); processValidationResult(new EmailValidator().validate(value)); break; case EMAIL_OR_MOBILE_NR: - checkNotEmpty(value); processValidationResult(new EmailOrMobileNrValidator().validate(value)); break; case EXTRA_INFO: @@ -454,13 +455,12 @@ public abstract class PaymentAccount implements PersistablePayload { } break; case TRADE_CURRENCIES: - checkNotEmpty(value); + processValidationResult(new InputValidator().validate(value)); List currencyCodes = commaDelimitedCodesToList.apply(value); Optional> tradeCurrencies = CurrencyUtil.getTradeCurrenciesInList(currencyCodes, getSupportedCurrencies()); if (!tradeCurrencies.isPresent()) throw new IllegalArgumentException("No trade currencies were found in the " + getPaymentMethod().getDisplayString() + " account form"); break; case USER_NAME: - checkNotEmpty(value); processValidationResult(new LengthValidator(3, 100).validate(value)); break; case VIRTUAL_PAYMENT_ADDRESS: @@ -470,10 +470,6 @@ public abstract class PaymentAccount implements PersistablePayload { } } - protected void checkNotEmpty(String input) { - if (input == null || "".equals(input)) throw new IllegalArgumentException("Field must not be empty"); - } - protected void processValidationResult(ValidationResult result) { if (!result.isValid) throw new IllegalArgumentException(result.errorMessage); } @@ -487,7 +483,9 @@ public abstract class PaymentAccount implements PersistablePayload { field.setSupportedCountries(((CountryBasedPaymentAccount) this).getSupportedCountries()); break; case ACCOUNT_ID: - throw new IllegalArgumentException("Not implemented"); + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Username or email or phone no."); + break; case ACCOUNT_NAME: field.setComponent(PaymentAccountFormField.Component.TEXT); field.setLabel("Account name"); // TODO: pull all labels from language file @@ -499,7 +497,9 @@ public abstract class PaymentAccount implements PersistablePayload { field.setLabel("Account number"); break; case ACCOUNT_OWNER: - throw new IllegalArgumentException("Not implemented"); + field.setComponent(PaymentAccountFormField.Component.TEXT); + field.setLabel("Account owner full name"); + break; case ACCOUNT_TYPE: throw new IllegalArgumentException("Not implemented"); case ANSWER: diff --git a/core/src/main/java/bisq/core/payment/UpholdAccount.java b/core/src/main/java/bisq/core/payment/UpholdAccount.java index 72340cb841..8226581f62 100644 --- a/core/src/main/java/bisq/core/payment/UpholdAccount.java +++ b/core/src/main/java/bisq/core/payment/UpholdAccount.java @@ -34,6 +34,14 @@ import org.jetbrains.annotations.NotNull; @EqualsAndHashCode(callSuper = true) public final class UpholdAccount extends PaymentAccount { + private static final List INPUT_FIELD_IDS = List.of( + PaymentAccountFormField.FieldId.ACCOUNT_NAME, + PaymentAccountFormField.FieldId.ACCOUNT_OWNER, + PaymentAccountFormField.FieldId.ACCOUNT_ID, + PaymentAccountFormField.FieldId.TRADE_CURRENCIES, + PaymentAccountFormField.FieldId.SALT + ); + // https://support.uphold.com/hc/en-us/articles/202473803-Supported-currencies public static final List SUPPORTED_CURRENCIES = List.of( new FiatCurrency("AED"), @@ -78,7 +86,7 @@ public final class UpholdAccount extends PaymentAccount { @Override public @NotNull List getInputFieldIds() { - throw new RuntimeException("Not implemented"); + return INPUT_FIELD_IDS; } public void setAccountId(String accountId) { 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 c92a620ed7..ef2b728d08 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -337,7 +337,8 @@ public final class PaymentMethod implements PersistablePayload, Comparable paymentMethodIds.contains(paymentMethod.getId())).collect(Collectors.toList()); } diff --git a/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java index 161fb37a34..05f2f4d07a 100644 --- a/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/UpholdAccountPayload.java @@ -41,9 +41,6 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public final class UpholdAccountPayload extends PaymentAccountPayload { private String accountId = ""; - - // For backward compatibility we need to exclude the new field from the contract json. - @JsonExclude private String accountOwner = ""; public UpholdAccountPayload(String paymentMethod, String id) { diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index 0aebdb3cb7..1d63753aa7 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -2084,6 +2084,7 @@ message PaymentAccountForm { STRIKE = 7; MONEY_GRAM = 8; FASTER_PAYMENTS = 9; + UPHOLD = 10; } FormId id = 1; repeated PaymentAccountFormField fields = 2;