Skip to content

Commit

Permalink
Add informational popup after account creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ripcurlx committed Oct 15, 2021
1 parent 5ec04af commit d9fc0eb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
7 changes: 7 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit d9fc0eb

Please sign in to comment.