<p></p>
<p><b>@sqrrm</b> requested changes on this pull request.</p>
<p>Some smaller comments, but over all I think it looks good again.</p><hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510074795">apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java</a>:</p>
<pre style='color:#555'>> + @BeforeEach
+ public void init() {
+ alicesAccount = getDefaultPerfectDummyPaymentAccount(alicedaemon);
+ bobsAccount = getDefaultPerfectDummyPaymentAccount(bobdaemon);
+ }
+
+ @Test
+ @Order(1)
+ public void testTakeAlicesBuyOffer() {
+ try {
+ var alicesOffer = createAliceOffer(alicesAccount, "buy", "usd", 12500000);
+ var offerId = alicesOffer.getId();
+
+ // Wait for Alice's AddToOfferBook task.
+ // Wait times vary; my logs show >= 2 second delay.
+ sleep(3000);
</pre>
<p>All these wait times in the test will make the test very slow eventually. I don't really have a solution to it, more of a general observation.</p>
<p>Maybe grouping all the tasks that need waiting on and then run the tests, but that would also group the tests, making them less independent and thus less useful.</p>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510080003">apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java</a>:</p>
<pre style='color:#555'>> + // TODO is this a bug? Why is offer.state == available?
+ assertEquals(AVAILABLE.name(), trade.getOffer().getState());
</pre>
<p>I suspect it's keeping the last state after the offer was taken, although I haven't looked into it before. There is no <code>TAKEN</code> state either. I think it's used to handle the state of the offer during its life cycle, which ends once the offer is taken and everything is then handled by the <code>Trade</code>.</p>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510089605">core/src/main/java/bisq/core/api/CoreTradesService.java</a>:</p>
<pre style='color:#555'>> + trade -> {
+ resultHandler.accept(trade);
+ },
</pre>
⬇️ Suggested change
<pre style="color: #555">- trade -> {
- resultHandler.accept(trade);
- },
+ resultHandler::accept,
</pre>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510090257">core/src/main/java/bisq/core/api/CoreTradesService.java</a>:</p>
<pre style='color:#555'>> + Trade getTrade(String tradeId) {
+ return getTradeWithId(tradeId);
+ }
+
+ private Trade getTradeWithId(String tradeId) {
+ return tradeManager.getTradeById(tradeId).orElseThrow(() ->
+ new IllegalArgumentException(format("trade with id '%s' not found", tradeId)));
+ }
</pre>
<p>I don't understand why this has to be split in two methods, plans for future PRs?</p>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510110682">core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java</a>:</p>
<pre style='color:#555'>> + // Set the default values (in rare cases if the fee request was not done yet we get the hard coded default values)
+ // But the "take offer" happens usually after that so we should have already the value from the estimation service.
+ txFeePerByteFromFeeService = feeService.getTxFeePerByte();
+ txFeeFromFeeService = offerUtil.getTxFeeBySize(txFeePerByteFromFeeService, feeTxSize);
</pre>
<p>Is this really necessary for the api? We probably want to wait for the fee to be calculated properly as an atomic part of initModel.</p>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510111340">core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java</a>:</p>
<pre style='color:#555'>> + txFeePerByteFromFeeService = feeService.getTxFeePerByte();
+ txFeeFromFeeService = offerUtil.getTxFeeBySize(txFeePerByteFromFeeService, feeTxSize);
+ calculateTotalToPay();
</pre>
<p>Fees are calculated here, after getting the reply from feeService.</p>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510111662">core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java</a>:</p>
<pre style='color:#555'>> + this.offer = offer;
+ this.paymentAccount = paymentAccount;
+ this.addressEntry = btcWalletService.getOrCreateAddressEntry(offer.getId(), OFFER_FUNDING);
+ validateModelInputs();
+
+ this.useSavingsWallet = useSavingsWallet;
+ this.amount = valueOf(Math.min(offer.getAmount().value, getMaxTradeLimit()));
+ this.securityDeposit = offer.getDirection() == SELL
+ ? offer.getBuyerSecurityDeposit()
+ : offer.getSellerSecurityDeposit();
+ this.isCurrencyForTakerFeeBtc = offerUtil.isCurrencyForTakerFeeBtc(amount);
+ this.takerFee = offerUtil.getTakerFee(isCurrencyForTakerFeeBtc, amount);
+
+ calculateTxFees();
+ calculateVolume();
+ calculateTotalToPay();
</pre>
<p>This is already done in calculateTxFees</p>
<hr>
<p>In <a href="https://github.com/bisq-network/bisq/pull/4673#discussion_r510118677">core/src/main/java/bisq/core/offer/takeoffer/TakeOfferModel.java</a>:</p>
<pre style='color:#555'>> + private Coin takerFee;
+ @Getter
+ private Coin totalToPayAsCoin;
+ @Getter
+ private Coin missingCoin = ZERO;
+ @Getter
+ private Coin totalAvailableBalance;
+ @Getter
+ private Coin balance;
+ @Getter
+ private boolean isBtcWalletFunded;
+ @Getter
+ private Volume volume;
+
+ @Inject
+ public TakeOfferModel(AccountAgeWitnessService accountAgeWitnessService,
</pre>
<p>There's a lot of code that would be nice to reuse from <code>TakeOfferDataModel</code> here. Can be done later though in some pure refactor commit.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/bisq-network/bisq/pull/4673#pullrequestreview-514610085">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AJFFTNTQIW7SSGN7OZROGTDSMAQWHANCNFSM4SYYEP2Q">unsubscribe</a>.<img src="https://github.com/notifications/beacon/AJFFTNTQPZ3FZQRB2HVD5SDSMAQWHA5CNFSM4SYYEP22YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOD2WFHJI.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/bisq-network/bisq/pull/4673#pullrequestreview-514610085",
"url": "https://github.com/bisq-network/bisq/pull/4673#pullrequestreview-514610085",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>