Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove apitest's create bsq-swap account method #5811

Merged
merged 3 commits into from Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -20,7 +20,10 @@

import joptsimple.OptionSpec;

import static bisq.cli.opts.OptLabel.*;
import static bisq.cli.opts.OptLabel.OPT_ACCOUNT_NAME;
import static bisq.cli.opts.OptLabel.OPT_ADDRESS;
import static bisq.cli.opts.OptLabel.OPT_CURRENCY_CODE;
import static bisq.cli.opts.OptLabel.OPT_TRADE_INSTANT;

public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodOptionParser implements MethodOpts {

Expand All @@ -38,11 +41,6 @@ public class CreateCryptoCurrencyPaymentAcctOptionParser extends AbstractMethodO
.ofType(boolean.class)
.defaultsTo(Boolean.FALSE);

final OptionSpec<Boolean> tradeBsqSwapOpt = parser.accepts(OPT_TRADE_BSQ_SWAP, "create trade bsq swap account")
.withOptionalArg()
.ofType(boolean.class)
.defaultsTo(Boolean.FALSE);

public CreateCryptoCurrencyPaymentAcctOptionParser(String[] args) {
super(args);
}
Expand Down Expand Up @@ -84,8 +82,4 @@ public String getAddress() {
public boolean getIsTradeInstant() {
return options.valueOf(tradeInstantOpt);
}

public boolean getIsTradeBsqSwap() {
return options.valueOf(tradeBsqSwapOpt);
}
}
1 change: 0 additions & 1 deletion cli/src/main/java/bisq/cli/opts/OptLabel.java
Expand Up @@ -44,7 +44,6 @@ public class OptLabel {
public final static String OPT_REGISTRATION_KEY = "registration-key";
public final static String OPT_SECURITY_DEPOSIT = "security-deposit";
public final static String OPT_SHOW_CONTRACT = "show-contract";
public final static String OPT_TRADE_BSQ_SWAP = "trade-bsq-swap";
public final static String OPT_TRADE_ID = "trade-id";
public final static String OPT_TRADE_INSTANT = "trade-instant";
public final static String OPT_TIMEOUT = "timeout";
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/java/bisq/core/api/CoreApi.java
Expand Up @@ -240,13 +240,11 @@ public String getPaymentAccountForm(String paymentMethodId) {
public PaymentAccount createCryptoCurrencyPaymentAccount(String accountName,
String currencyCode,
String address,
boolean tradeInstant,
boolean isBsqSwap) {
boolean tradeInstant) {
return paymentAccountsService.createCryptoCurrencyPaymentAccount(accountName,
currencyCode,
address,
tradeInstant,
isBsqSwap);
tradeInstant);
}

public List<PaymentMethod> getCryptoCurrencyPaymentMethods() {
Expand Down
20 changes: 5 additions & 15 deletions core/src/main/java/bisq/core/api/CorePaymentAccountsService.java
Expand Up @@ -103,30 +103,20 @@ File getPaymentAccountForm(String paymentMethodId) {
PaymentAccount createCryptoCurrencyPaymentAccount(String accountName,
String currencyCode,
String address,
boolean tradeInstant,
boolean isBsqSwap) {
boolean tradeInstant) {
String bsqCode = currencyCode.toUpperCase();
if (!bsqCode.equals("BSQ"))
throw new IllegalArgumentException("api does not currently support " + currencyCode + " accounts");

// Validate the BSQ address string but ignore the return value.
coreWalletsService.getValidBsqAddress(address);

// TODO Split into 2 methods: createAtomicPaymentAccount(), createCryptoCurrencyPaymentAccount().
PaymentAccount cryptoCurrencyAccount;
if (isBsqSwap) {
cryptoCurrencyAccount = PaymentAccountFactory.getPaymentAccount(PaymentMethod.BSQ_SWAP);
} else {
cryptoCurrencyAccount = tradeInstant
? (InstantCryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS_INSTANT)
: (CryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS);
}
AssetAccount cryptoCurrencyAccount = tradeInstant
? (InstantCryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS_INSTANT)
: (CryptoCurrencyAccount) PaymentAccountFactory.getPaymentAccount(PaymentMethod.BLOCK_CHAINS);
cryptoCurrencyAccount.init();
cryptoCurrencyAccount.setAccountName(accountName);
if (!isBsqSwap) {
((AssetAccount) cryptoCurrencyAccount).setAddress(address);
}

cryptoCurrencyAccount.setAddress(address);
Optional<CryptoCurrency> cryptoCurrency = getCryptoCurrency(bsqCode);
cryptoCurrency.ifPresent(cryptoCurrencyAccount::setSingleTradeCurrency);
user.addPaymentAccount(cryptoCurrencyAccount);
Expand Down
Expand Up @@ -136,8 +136,7 @@ public void createCryptoCurrencyPaymentAccount(CreateCryptoCurrencyPaymentAccoun
PaymentAccount paymentAccount = coreApi.createCryptoCurrencyPaymentAccount(req.getAccountName(),
req.getCurrencyCode(),
req.getAddress(),
req.getTradeInstant(),
req.getIsBsqSwap());
req.getTradeInstant());
var reply = CreateCryptoCurrencyPaymentAccountReply.newBuilder()
.setPaymentAccount(paymentAccount.toProtoMessage())
.build();
Expand Down
1 change: 0 additions & 1 deletion proto/src/main/proto/grpc.proto
Expand Up @@ -311,7 +311,6 @@ message CreateCryptoCurrencyPaymentAccountRequest {
string currencyCode = 2;
string address = 3;
bool tradeInstant = 4;
bool isBsqSwap = 5;
}

message CreateCryptoCurrencyPaymentAccountReply {
Expand Down