From d9fc0eb78611332ffcfe3e8e55e3548102df85f2 Mon Sep 17 00:00:00 2001 From: Christoph Atteneder Date: Fri, 15 Oct 2021 11:10:18 +0200 Subject: [PATCH] Add informational popup after account creation --- .../resources/i18n/displayStrings.properties | 7 +++++++ .../main/offer/offerbook/OfferBookView.java | 13 +++++++++++- .../offer/offerbook/OfferBookViewModel.java | 20 +++++++------------ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 8805f1e017a..81372decd9f 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -442,6 +442,13 @@ offerbook.info.buyAtFixedPrice=You will buy at this fixed price. offerbook.info.sellAtFixedPrice=You will sell at this fixed price. offerbook.info.noArbitrationInUserLanguage=In case of a dispute, please note that arbitration for this offer will be handled in {0}. Language is currently set to {1}. offerbook.info.roundedFiatVolume=The amount was rounded to increase the privacy of your trade. +offerbook.info.accountCreated.headline=Congratulations +offerbook.info.accountCreated.message=You''ve just successfully created a BSQ payment account.\n\ + Your account can be found under Account > Altcoins Accounts > {0} and your BSQ wallet under DAO > BSQ Wallet.\n\n +offerbook.info.accountCreated.tradeInstant=As you've chosen to take a BSQ instant offer a BSQ instant account was created for you. \ + For instant trading it is required that both trading peers are online to be able \ + to complete the trade in less than 1 hour.\n\n +offerbook.info.accountCreated.takeOffer=You can no proceed to take this offer after closing this popup. #################################################################### # Offerbook / Create offer diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 79ce68a777b..088be3436f7 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -745,7 +745,18 @@ private void openPopupForMissingAccountSetup(Offer offer) { new Popup().headLine(headline) .instruction(Res.get("offerbook.warning.noMatchingBsqAccount.msg")) .actionButtonText(Res.get("offerbook.takeOffer.createAccount")) - .onAction(() -> model.createBsqAccountAndTakeOffer(offer)).show(); + .onAction(() -> { + var bsqAccount = model.createBsqAccount(offer); + var message = Res.get("offerbook.info.accountCreated.message", bsqAccount.getAccountName()); + if (model.isInstantPaymentMethod(offer)) { + message += Res.get("offerbook.info.accountCreated.tradeInstant"); + } + message += Res.get("offerbook.info.accountCreated.takeOffer"); + new Popup().headLine(Res.get("offerbook.info.accountCreated.headline")) + .information(message) + .onClose(() -> model.onTakeOffer(offer)) + .show(); + }).show(); } else { var accountViewClass = CurrencyUtil.isFiatCurrency(offer.getCurrencyCode()) ? FiatAccountsView.class : AltCoinAccountsView.class; diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index 20fd3a7a754..cdc0eaf30ce 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -22,7 +22,6 @@ import bisq.desktop.main.MainView; import bisq.desktop.main.PriceUtil; import bisq.desktop.main.offer.OfferView; -import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.settings.SettingsView; import bisq.desktop.main.settings.preferences.PreferencesView; import bisq.desktop.util.DisplayUtils; @@ -679,22 +678,17 @@ private PaymentMethod getShowAllEntryForPaymentMethod() { return PaymentMethod.getDummyPaymentMethod(GUIUtil.SHOW_ALL_FLAG); } - public void createBsqAccountAndTakeOffer(Offer offer) { + public boolean isInstantPaymentMethod(Offer offer) { + return offer.getPaymentMethod().equals(PaymentMethod.BLOCK_CHAINS_INSTANT); + } + + public PaymentAccount createBsqAccount(Offer offer) { var unusedBsqAddressAsString = bsqWalletService.getUnusedBsqAddressAsString(); - // create required BSQ payment account - boolean isInstantPaymentMethod = offer.getPaymentMethod().equals(PaymentMethod.BLOCK_CHAINS_INSTANT); - coreApi.createCryptoCurrencyPaymentAccount(DisplayUtils.createAssetsAccountName("BSQ", unusedBsqAddressAsString), + return coreApi.createCryptoCurrencyPaymentAccount(DisplayUtils.createAssetsAccountName("BSQ", unusedBsqAddressAsString), "BSQ", unusedBsqAddressAsString, - isInstantPaymentMethod); - - if (isInstantPaymentMethod) { - new Popup().information(Res.get("payment.altcoin.tradeInstant.popup")).show(); - } - - // take offer - onTakeOffer(offer); + isInstantPaymentMethod(offer)); } public void setOfferActionHandler(OfferView.OfferActionHandler offerActionHandler) {