[bisq-network/bisq] Add getRole(tradeId) to core api (#4701)

sqrrm notifications at github.com
Fri Oct 30 12:43:32 UTC 2020


@sqrrm approved this pull request.

utACK

Some comments but nothing blocking merging, just stuff to consider.

> @@ -173,6 +174,27 @@ public String getPaymentMethodNameWithCountryCode(Trade trade) {
         return paymentMethodDescription;
     }
 
+    /**
+     * Returns a string describing a trader's role for a given trade.
+     * @param trade Trade
+     * @return String describing a trader's role for a given trade
+     */
+    public String getRole(Trade trade) {

Could consider renaming to `getMyRole` but perhaps that's rather implicit.

> +     * @return String describing a trader's role for a given trade
+     */
+    public String getRole(Trade trade) {
+        Contract contract = trade.getContract();
+        if (contract == null)
+            throw new IllegalStateException(format("could not get role because no contract was found for trade '%s'",
+                    trade.getShortId()));
+
+        Offer offer = trade.getOffer();
+        if (offer == null)
+            throw new IllegalStateException(format("could not get role because no offer was found for trade '%s'",
+                    trade.getShortId()));
+
+        return getRole(contract.isBuyerMakerAndSellerTaker(),
+                offer.isMyOffer(keyRing),
+                offer.getCurrencyCode());

I don't get why currenycode should be needed to decide role

> +    string takerFeeTxId = 9;
+    string depositTxId = 10;
+    string payoutTxId = 11;
+    uint64 tradeAmountAsLong = 12;
+    uint64 tradePrice = 13;
+    string tradingPeerNodeAddress = 14;
+    string state = 15;
+    string phase = 16;
+    string tradePeriodState = 17;
+    bool isDepositPublished = 18;
+    bool isDepositConfirmed = 19;
+    bool isFiatSent = 20;
+    bool isFiatReceived = 21;
+    bool isPayoutPublished = 22;
+    bool isWithdrawn = 23;
+    string contractAsJson = 24;

Would be easier to just add new fields at the end, but I guess there is some system to it.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/4701#pullrequestreview-520628071
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20201030/0320dcb3/attachment-0001.html>


More information about the bisq-github mailing list