Add informational popup after account creation

This commit is contained in:
Christoph Atteneder 2021-10-15 11:10:18 +02:00
parent 55826cb4a2
commit e17fd9ef54
No known key found for this signature in database
GPG Key ID: CD5DC1C529CDFD3B
3 changed files with 26 additions and 14 deletions

View File

@ -443,6 +443,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.bsqSwap.createOffer=Create Bsq swap offer

View File

@ -752,7 +752,18 @@ public class OfferBookView extends ActivatableViewAndModel<GridPane, OfferBookVi
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;

View File

@ -21,7 +21,6 @@ import bisq.desktop.Navigation;
import bisq.desktop.common.model.ActivatableViewModel;
import bisq.desktop.main.MainView;
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 @@ class OfferBookViewModel extends ActivatableViewModel {
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) {