From 3be547c44586c73ccff10d8d0c6e4cdf945a1ab1 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Sun, 16 May 2021 11:11:32 +0200 Subject: [PATCH 1/8] Add Capitual payment method. Waiting for final Info text to add. --- .../java/bisq/core/locale/CurrencyUtil.java | 11 ++ .../bisq/core/payment/CapitualAccount.java | 46 +++++++ .../core/payment/PaymentAccountFactory.java | 2 + .../payload/CapitualAccountPayload.java | 99 ++++++++++++++ .../core/payment/payload/PaymentMethod.java | 4 + .../bisq/core/proto/CoreProtoResolver.java | 3 + .../trade/statistics/TradeStatistics3.java | 3 +- .../resources/i18n/displayStrings.properties | 8 +- .../paymentmethods/CapitualForm.java | 126 ++++++++++++++++++ .../fiataccounts/FiatAccountsView.java | 18 ++- .../steps/buyer/BuyerStep2View.java | 4 + .../util/validation/CapitualValidator.java | 25 ++++ .../validation/CapitualValidatorTest.java | 45 +++++++ proto/src/main/proto/pb.proto | 5 + 14 files changed, 396 insertions(+), 3 deletions(-) create mode 100644 core/src/main/java/bisq/core/payment/CapitualAccount.java create mode 100644 core/src/main/java/bisq/core/payment/payload/CapitualAccountPayload.java create mode 100644 desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java create mode 100644 desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java create mode 100644 desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java diff --git a/core/src/main/java/bisq/core/locale/CurrencyUtil.java b/core/src/main/java/bisq/core/locale/CurrencyUtil.java index d38729f8f0b..988db39c915 100644 --- a/core/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/core/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -348,6 +348,17 @@ public static List getAllAmazonGiftCardCurrencies() { return currencies; } + public static List getAllCapitualCurrencies() { + List currencies = new ArrayList<>(Arrays.asList( + new FiatCurrency("EUR"), + new FiatCurrency("BRL"), + new FiatCurrency("GBP"), + new FiatCurrency("USD") + )); + currencies.sort(Comparator.comparing(TradeCurrency::getCode)); + return currencies; + } + // https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange public static List getAllRevolutCurrencies() { ArrayList currencies = new ArrayList<>(Arrays.asList( diff --git a/core/src/main/java/bisq/core/payment/CapitualAccount.java b/core/src/main/java/bisq/core/payment/CapitualAccount.java new file mode 100644 index 00000000000..46ba14a43f1 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/CapitualAccount.java @@ -0,0 +1,46 @@ +/* + * 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 . + */ + +package bisq.core.payment; + +import bisq.core.locale.CurrencyUtil; +import bisq.core.payment.payload.CapitualAccountPayload; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PaymentMethod; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public final class CapitualAccount extends PaymentAccount { + public CapitualAccount() { + super(PaymentMethod.CAPITUAL); + tradeCurrencies.addAll(CurrencyUtil.getAllCapitualCurrencies()); + } + + @Override + protected PaymentAccountPayload createPayload() { + return new CapitualAccountPayload(paymentMethod.getId(), id); + } + + public void setAccountNr(String accountNr) { + ((CapitualAccountPayload) paymentAccountPayload).setAccountNr(accountNr); + } + + public String getAccountNr() { + return ((CapitualAccountPayload) paymentAccountPayload).getAccountNr(); + } +} diff --git a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java index faed57acd34..0cceb0cb865 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java @@ -86,6 +86,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) { return new AmazonGiftCardAccount(); case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: return new InstantCryptoCurrencyAccount(); + case PaymentMethod.CAPITUAL_ID: + return new CapitualAccount(); // Cannot be deleted as it would break old trade history entries case PaymentMethod.OK_PAY_ID: diff --git a/core/src/main/java/bisq/core/payment/payload/CapitualAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CapitualAccountPayload.java new file mode 100644 index 00000000000..e8db6f0b50a --- /dev/null +++ b/core/src/main/java/bisq/core/payment/payload/CapitualAccountPayload.java @@ -0,0 +1,99 @@ +/* + * 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 . + */ + +package bisq.core.payment.payload; + +import bisq.core.locale.Res; + +import com.google.protobuf.Message; + +import java.nio.charset.StandardCharsets; + +import java.util.HashMap; +import java.util.Map; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +@EqualsAndHashCode(callSuper = true) +@ToString +@Setter +@Getter +@Slf4j +public final class CapitualAccountPayload extends PaymentAccountPayload { + private String accountNr = ""; + + public CapitualAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // PROTO BUFFER + /////////////////////////////////////////////////////////////////////////////////////////// + + private CapitualAccountPayload(String paymentMethod, + String id, + String accountNr, + long maxTradePeriod, + Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + maxTradePeriod, + excludeFromJsonDataMap); + + this.accountNr = accountNr; + } + + @Override + public Message toProtoMessage() { + return getPaymentAccountPayloadBuilder() + .setCapitualAccountPayload(protobuf.CapitualAccountPayload.newBuilder() + .setAccountNr(accountNr)) + .build(); + } + + public static CapitualAccountPayload fromProto(protobuf.PaymentAccountPayload proto) { + return new CapitualAccountPayload(proto.getPaymentMethodId(), + proto.getId(), + proto.getCapitualAccountPayload().getAccountNr(), + proto.getMaxTradePeriod(), + new HashMap<>(proto.getExcludeFromJsonDataMap())); + } + + /////////////////////////////////////////////////////////////////////////////////////////// + // API + /////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public String getPaymentDetails() { + return Res.get(paymentMethodId) + " - " + Res.getWithCol("payment.capitual.cap") + " " + accountNr; + } + + @Override + public String getPaymentDetailsForTradePopup() { + return getPaymentDetails(); + } + + @Override + public byte[] getAgeWitnessInputData() { + return super.getAgeWitnessInputData(accountNr.getBytes(StandardCharsets.UTF_8)); + } +} 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 3d2c3004f27..0a6072e69dd 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -99,6 +99,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable. + */ + +package bisq.desktop.components.paymentmethods; + +import bisq.desktop.components.InputTextField; +import bisq.desktop.util.FormBuilder; +import bisq.desktop.util.Layout; +import bisq.desktop.util.validation.CapitualValidator; + +import bisq.core.account.witness.AccountAgeWitnessService; +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.Res; +import bisq.core.payment.CapitualAccount; +import bisq.core.payment.PaymentAccount; +import bisq.core.payment.payload.CapitualAccountPayload; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.util.coin.CoinFormatter; +import bisq.core.util.validation.InputValidator; + +import bisq.common.util.Tuple2; + +import org.apache.commons.lang3.StringUtils; + +import javafx.scene.control.Label; +import javafx.scene.layout.FlowPane; +import javafx.scene.layout.GridPane; + +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextField; +import static bisq.desktop.util.FormBuilder.addCompactTopLabelTextFieldWithCopyIcon; +import static bisq.desktop.util.FormBuilder.addTopLabelFlowPane; + +public class CapitualForm extends PaymentMethodForm { + private final CapitualAccount capitualAccount; + private final CapitualValidator capitualValidator; + private InputTextField accountNrInputTextField; + + public static int addFormForBuyer(GridPane gridPane, int gridRow, + PaymentAccountPayload paymentAccountPayload) { + addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.capitual.cap"), + ((CapitualAccountPayload) paymentAccountPayload).getAccountNr()); + return gridRow; + } + + public CapitualForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, CapitualValidator capitualValidator, + InputValidator inputValidator, GridPane gridPane, int gridRow, CoinFormatter formatter) { + super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); + this.capitualAccount = (CapitualAccount) paymentAccount; + this.capitualValidator = capitualValidator; + } + + @Override + public void addFormForAddAccount() { + gridRowFrom = gridRow + 1; + + accountNrInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.capitual.cap")); + accountNrInputTextField.setValidator(capitualValidator); + accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { + capitualAccount.setAccountNr(newValue); + updateFromInputs(); + }); + + addCurrenciesGrid(true); + addLimitations(false); + addAccountNameTextFieldWithAutoFillToggleButton(); + } + + private void addCurrenciesGrid(boolean isEditable) { + final Tuple2 labelFlowPaneTuple2 = addTopLabelFlowPane(gridPane, ++gridRow, Res.get("payment.supportedCurrencies"), 0); + + FlowPane flowPane = labelFlowPaneTuple2.second; + + if (isEditable) + flowPane.setId("flow-pane-checkboxes-bg"); + else + flowPane.setId("flow-pane-checkboxes-non-editable-bg"); + + CurrencyUtil.getAllCapitualCurrencies().stream().forEach(e -> + fillUpFlowPaneWithCurrencies(isEditable, flowPane, e, capitualAccount)); + } + + @Override + protected void autoFillNameTextField() { + if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) { + String accountNr = accountNrInputTextField.getText(); + accountNr = StringUtils.abbreviate(accountNr, 9); + String method = Res.get(paymentAccount.getPaymentMethod().getId()); + accountNameTextField.setText(method.concat(": ").concat(accountNr)); + } + } + + @Override + public void addFormForDisplayAccount() { + gridRowFrom = gridRow; + addCompactTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), + capitualAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), + Res.get(capitualAccount.getPaymentMethod().getId())); + addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.capitual.cap"), + capitualAccount.getAccountNr()); + addLimitations(true); + addCurrenciesGrid(false); + } + + @Override + public void updateAllInputsValid() { + allInputsValid.set(isAccountNameValid() + && capitualValidator.validate(capitualAccount.getAccountNr()).isValid + && capitualAccount.getTradeCurrencies().size() > 0); + } + +} diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index 728c87156e2..663abcb7d27 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -23,6 +23,7 @@ import bisq.desktop.components.paymentmethods.AliPayForm; import bisq.desktop.components.paymentmethods.AmazonGiftCardForm; import bisq.desktop.components.paymentmethods.AustraliaPayidForm; +import bisq.desktop.components.paymentmethods.CapitualForm; import bisq.desktop.components.paymentmethods.CashByMailForm; import bisq.desktop.components.paymentmethods.CashDepositForm; import bisq.desktop.components.paymentmethods.ChaseQuickPayForm; @@ -59,6 +60,7 @@ import bisq.desktop.util.validation.AliPayValidator; import bisq.desktop.util.validation.AustraliaPayidValidator; import bisq.desktop.util.validation.BICValidator; +import bisq.desktop.util.validation.CapitualValidator; import bisq.desktop.util.validation.ChaseQuickPayValidator; import bisq.desktop.util.validation.ClearXchangeValidator; import bisq.desktop.util.validation.F2FValidator; @@ -83,6 +85,7 @@ import bisq.core.offer.OfferRestrictions; import bisq.core.payment.AmazonGiftCardAccount; import bisq.core.payment.AustraliaPayid; +import bisq.core.payment.CapitualAccount; import bisq.core.payment.CashByMailAccount; import bisq.core.payment.CashDepositAccount; import bisq.core.payment.ClearXchangeAccount; @@ -135,6 +138,7 @@ public class FiatAccountsView extends PaymentAccountsView doSaveNewAccount(paymentAccount)) .show(); - } else { + } else if (paymentAccount instanceof CapitualAccount) { + new Popup().information(Res.get("payment.capitual.info", currencyName, currencyName)) + .width(900) + .closeButtonText(Res.get("shared.cancel")) + .actionButtonText(Res.get("shared.iUnderstand")) + .onAction(() -> doSaveNewAccount(paymentAccount)) + .show(); + } + else { doSaveNewAccount(paymentAccount); } }) @@ -530,6 +544,8 @@ private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod, Paym return new TransferwiseForm(paymentAccount, accountAgeWitnessService, transferwiseValidator, inputValidator, root, gridRow, formatter); case PaymentMethod.AMAZON_GIFT_CARD_ID: return new AmazonGiftCardForm(paymentAccount, accountAgeWitnessService, inputValidator, root, gridRow, formatter); + case PaymentMethod.CAPITUAL_ID: + return new CapitualForm(paymentAccount, accountAgeWitnessService, capitualValidator, inputValidator, root, gridRow, formatter); default: log.error("Not supported PaymentMethod: " + paymentMethod); return null; diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index fd6e456ba2a..dc051613f62 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -25,6 +25,7 @@ import bisq.desktop.components.paymentmethods.AliPayForm; import bisq.desktop.components.paymentmethods.AmazonGiftCardForm; import bisq.desktop.components.paymentmethods.AssetsForm; +import bisq.desktop.components.paymentmethods.CapitualForm; import bisq.desktop.components.paymentmethods.CashByMailForm; import bisq.desktop.components.paymentmethods.CashDepositForm; import bisq.desktop.components.paymentmethods.ChaseQuickPayForm; @@ -323,6 +324,9 @@ protected void addContent() { case PaymentMethod.AMAZON_GIFT_CARD_ID: gridRow = AmazonGiftCardForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); break; + case PaymentMethod.CAPITUAL_ID: + gridRow = CapitualForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); + break; default: log.error("Not supported PaymentMethod: " + paymentMethodId); } diff --git a/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java b/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java new file mode 100644 index 00000000000..a9ed18d92a8 --- /dev/null +++ b/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java @@ -0,0 +1,25 @@ +package bisq.desktop.util.validation; + +import bisq.core.locale.Res; +import bisq.core.util.validation.InputValidator; +import bisq.core.util.validation.RegexValidator; + +import javax.inject.Inject; + +public class CapitualValidator extends InputValidator { + private RegexValidator regexValidator; + + @Inject + public CapitualValidator(RegexValidator regexValidator) { + regexValidator.setPattern("CAP-[A-Za-z0-9]{6}"); + regexValidator.setErrorMessage(Res.get("validation.capitual.invalidFormat")); + this.regexValidator = regexValidator; + } + + @Override + public ValidationResult validate(String input) { + ValidationResult result = regexValidator.validate(input); + + return result; + } +} diff --git a/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java new file mode 100644 index 00000000000..a8c3ce69b9a --- /dev/null +++ b/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java @@ -0,0 +1,45 @@ +package bisq.desktop.util.validation; + +import bisq.core.locale.CurrencyUtil; +import bisq.core.locale.Res; +import bisq.core.util.validation.RegexValidator; + +import bisq.common.config.BaseCurrencyNetwork; +import bisq.common.config.Config; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class CapitualValidatorTest { + @Before + public void setup() { + final BaseCurrencyNetwork baseCurrencyNetwork = Config.baseCurrencyNetwork(); + final String currencyCode = baseCurrencyNetwork.getCurrencyCode(); + Res.setBaseCurrencyCode(currencyCode); + Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); + CurrencyUtil.setBaseCurrencyCode(currencyCode); + } + + @Test + public void validate(){ + CapitualValidator validator = new CapitualValidator( + new RegexValidator() + ); + + assertTrue(validator.validate("CAP-123456").isValid); + assertTrue(validator.validate("CAP-XXXXXX").isValid); + assertTrue(validator.validate("CAP-123XXX").isValid); + + assertFalse(validator.validate("").isValid); + assertFalse(validator.validate(null).isValid); + assertFalse(validator.validate("123456").isValid); + assertFalse(validator.validate("XXXXXX").isValid); + assertFalse(validator.validate("123XXX").isValid); + assertFalse(validator.validate("12XXX").isValid); + assertFalse(validator.validate("CAP-12XXX").isValid); + assertFalse(validator.validate("CA-12XXXx").isValid); + } +} diff --git a/proto/src/main/proto/pb.proto b/proto/src/main/proto/pb.proto index c4ee1dd88fa..cc833037170 100644 --- a/proto/src/main/proto/pb.proto +++ b/proto/src/main/proto/pb.proto @@ -996,6 +996,7 @@ message PaymentAccountPayload { AustraliaPayidPayload australia_payid_payload = 30; AmazonGiftCardAccountPayload amazon_gift_card_account_payload = 31; CashByMailAccountPayload cash_by_mail_account_payload = 32; + CapitualAccountPayload capitual_account_payload = 33; } map exclude_from_json_data = 15; } @@ -1217,6 +1218,10 @@ message TransferwiseAccountPayload { string email = 1; } +message CapitualAccountPayload { + string account_nr = 1; +} + /////////////////////////////////////////////////////////////////////////////////////////// // PersistableEnvelope /////////////////////////////////////////////////////////////////////////////////////////// From b47646b0e20f07bfb73a544738c030b4c692872f Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Mon, 17 May 2021 11:54:24 +0200 Subject: [PATCH 2/8] Fix Codacy issues --- .../main/account/content/fiataccounts/FiatAccountsView.java | 3 +-- .../bisq/desktop/util/validation/CapitualValidatorTest.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index 663abcb7d27..93da865815f 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -352,8 +352,7 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) { .actionButtonText(Res.get("shared.iUnderstand")) .onAction(() -> doSaveNewAccount(paymentAccount)) .show(); - } - else { + } else { doSaveNewAccount(paymentAccount); } }) diff --git a/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java b/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java index a8c3ce69b9a..36260dfdff1 100644 --- a/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java +++ b/desktop/src/test/java/bisq/desktop/util/validation/CapitualValidatorTest.java @@ -24,7 +24,7 @@ public void setup() { } @Test - public void validate(){ + public void validate() { CapitualValidator validator = new CapitualValidator( new RegexValidator() ); From e3fbc97fbc18d22a94d806f21dc0552043b59abe Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Mon, 14 Jun 2021 16:37:09 +0200 Subject: [PATCH 3/8] Add review feedbacks from KaiWitt --- core/src/main/java/bisq/core/locale/CurrencyUtil.java | 6 ++---- .../desktop/components/paymentmethods/CapitualForm.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/bisq/core/locale/CurrencyUtil.java b/core/src/main/java/bisq/core/locale/CurrencyUtil.java index 988db39c915..b7275ddf4a8 100644 --- a/core/src/main/java/bisq/core/locale/CurrencyUtil.java +++ b/core/src/main/java/bisq/core/locale/CurrencyUtil.java @@ -349,14 +349,12 @@ public static List getAllAmazonGiftCardCurrencies() { } public static List getAllCapitualCurrencies() { - List currencies = new ArrayList<>(Arrays.asList( - new FiatCurrency("EUR"), + return new ArrayList<>(Arrays.asList( new FiatCurrency("BRL"), + new FiatCurrency("EUR"), new FiatCurrency("GBP"), new FiatCurrency("USD") )); - currencies.sort(Comparator.comparing(TradeCurrency::getCode)); - return currencies; } // https://www.revolut.com/help/getting-started/exchanging-currencies/what-fiat-currencies-are-supported-for-holding-and-exchange diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java index dee3d81babc..00bfd9bedf5 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java @@ -89,7 +89,7 @@ private void addCurrenciesGrid(boolean isEditable) { else flowPane.setId("flow-pane-checkboxes-non-editable-bg"); - CurrencyUtil.getAllCapitualCurrencies().stream().forEach(e -> + CurrencyUtil.getAllCapitualCurrencies().forEach(e -> fillUpFlowPaneWithCurrencies(isEditable, flowPane, e, capitualAccount)); } @@ -120,7 +120,7 @@ public void addFormForDisplayAccount() { public void updateAllInputsValid() { allInputsValid.set(isAccountNameValid() && capitualValidator.validate(capitualAccount.getAccountNr()).isValid - && capitualAccount.getTradeCurrencies().size() > 0); + && !capitualAccount.getTradeCurrencies().isEmpty()); } } From ba786e518c6b2d7f79b9ef978c8c7cc9ca12230f Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Mon, 14 Jun 2021 16:47:44 +0200 Subject: [PATCH 4/8] Add missing info text for Capitual payment method --- core/src/main/resources/i18n/displayStrings.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index cd221bd9f9e..68011bbbb2b 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3481,7 +3481,7 @@ payment.amazonGiftCard.info=To pay with Amazon eGift Card, you will need to send - try to use creative, believable text for the gift card''s message (e.g., "Happy birthday Susan!") along with the trade ID (and use trader chat \ to tell your trading peer the reference text you picked so they can verify your payment)\n\ - Amazon eGift Cards can only be redeemed on the Amazon website they were purchased on (e.g., a gift card purchased on amazon.it can only be redeemed on amazon.it) -payment.capitual.info=TODO +payment.capitual.info=Include any special instructions for the payment method that both buyer and seller might need to be aware of # We use constants from the code so we do not use our normal naming convention # dynamic values are not recognized by IntelliJ From b6b26e81bacd55b227574e174890934cc192b896 Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Thu, 1 Jul 2021 15:45:40 +0200 Subject: [PATCH 5/8] Remove payment account info popup --- .../account/content/fiataccounts/FiatAccountsView.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index 93da865815f..344a54ba0fe 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -345,13 +345,6 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) { .actionButtonText(Res.get("shared.iUnderstand")) .onAction(() -> doSaveNewAccount(paymentAccount)) .show(); - } else if (paymentAccount instanceof CapitualAccount) { - new Popup().information(Res.get("payment.capitual.info", currencyName, currencyName)) - .width(900) - .closeButtonText(Res.get("shared.cancel")) - .actionButtonText(Res.get("shared.iUnderstand")) - .onAction(() -> doSaveNewAccount(paymentAccount)) - .show(); } else { doSaveNewAccount(paymentAccount); } From 88ec922ee3d680c43d881f085539332e7915267b Mon Sep 17 00:00:00 2001 From: BtcContributor <79100296+BtcContributor@users.noreply.github.com> Date: Thu, 1 Jul 2021 16:02:47 +0200 Subject: [PATCH 6/8] Remove unused import --- .../main/account/content/fiataccounts/FiatAccountsView.java | 1 - 1 file changed, 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index 344a54ba0fe..eb86ac98e25 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -85,7 +85,6 @@ import bisq.core.offer.OfferRestrictions; import bisq.core.payment.AmazonGiftCardAccount; import bisq.core.payment.AustraliaPayid; -import bisq.core.payment.CapitualAccount; import bisq.core.payment.CashByMailAccount; import bisq.core.payment.CashDepositAccount; import bisq.core.payment.ClearXchangeAccount; From 4321f20474324d34bbae71ebc51e426fb1e43509 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 19 Jul 2021 13:36:48 +0200 Subject: [PATCH 7/8] Remove unused translation --- core/src/main/resources/i18n/displayStrings.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 68011bbbb2b..0c7c1d863c5 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -3481,7 +3481,6 @@ payment.amazonGiftCard.info=To pay with Amazon eGift Card, you will need to send - try to use creative, believable text for the gift card''s message (e.g., "Happy birthday Susan!") along with the trade ID (and use trader chat \ to tell your trading peer the reference text you picked so they can verify your payment)\n\ - Amazon eGift Cards can only be redeemed on the Amazon website they were purchased on (e.g., a gift card purchased on amazon.it can only be redeemed on amazon.it) -payment.capitual.info=Include any special instructions for the payment method that both buyer and seller might need to be aware of # We use constants from the code so we do not use our normal naming convention # dynamic values are not recognized by IntelliJ From ca02610b6939028cd586daaa1b7187a38b235b6b Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Mon, 19 Jul 2021 13:38:00 +0200 Subject: [PATCH 8/8] Improve formatting and simplify code --- .../desktop/components/paymentmethods/CapitualForm.java | 9 +++++++-- .../bisq/desktop/util/validation/CapitualValidator.java | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java index 00bfd9bedf5..e4fa6163a4d 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CapitualForm.java @@ -56,8 +56,13 @@ public static int addFormForBuyer(GridPane gridPane, int gridRow, return gridRow; } - public CapitualForm(PaymentAccount paymentAccount, AccountAgeWitnessService accountAgeWitnessService, CapitualValidator capitualValidator, - InputValidator inputValidator, GridPane gridPane, int gridRow, CoinFormatter formatter) { + public CapitualForm(PaymentAccount paymentAccount, + AccountAgeWitnessService accountAgeWitnessService, + CapitualValidator capitualValidator, + InputValidator inputValidator, + GridPane gridPane, + int gridRow, + CoinFormatter formatter) { super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); this.capitualAccount = (CapitualAccount) paymentAccount; this.capitualValidator = capitualValidator; diff --git a/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java b/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java index a9ed18d92a8..f94b933340c 100644 --- a/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java +++ b/desktop/src/main/java/bisq/desktop/util/validation/CapitualValidator.java @@ -7,7 +7,7 @@ import javax.inject.Inject; public class CapitualValidator extends InputValidator { - private RegexValidator regexValidator; + private final RegexValidator regexValidator; @Inject public CapitualValidator(RegexValidator regexValidator) { @@ -18,8 +18,7 @@ public CapitualValidator(RegexValidator regexValidator) { @Override public ValidationResult validate(String input) { - ValidationResult result = regexValidator.validate(input); - return result; + return regexValidator.validate(input); } }