diff --git a/cli/src/main/java/bisq/cli/GrpcClient.java b/cli/src/main/java/bisq/cli/GrpcClient.java index 4d20a2d4b7..c16c4c5186 100644 --- a/cli/src/main/java/bisq/cli/GrpcClient.java +++ b/cli/src/main/java/bisq/cli/GrpcClient.java @@ -65,12 +65,15 @@ import bisq.proto.grpc.WithdrawFundsRequest; import protobuf.PaymentAccount; import protobuf.PaymentMethod; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import static java.util.Comparator.comparing; +import static protobuf.OfferPayload.Direction.BUY; +import static protobuf.OfferPayload.Direction.SELL; @SuppressWarnings("ResultOfMethodCallIgnored") @@ -280,6 +283,13 @@ public final class GrpcClient { return grpcStubs.offersService.getOffers(request).getOffersList(); } + public List getOffersSortedByDate(String currencyCode) { + ArrayList offers = new ArrayList<>(); + offers.addAll(getOffers(BUY.name(), currencyCode)); + offers.addAll(getOffers(SELL.name(), currencyCode)); + return sortOffersByDate(offers); + } + public List getOffersSortedByDate(String direction, String currencyCode) { var offers = getOffers(direction, currencyCode); return offers.isEmpty() ? offers : sortOffersByDate(offers); @@ -303,8 +313,7 @@ public final class GrpcClient { return offers.isEmpty() ? null : offers.get(offers.size() - 1); } - // TODO move to bottom of class - private List sortOffersByDate(List offerInfoList) { + public List sortOffersByDate(List offerInfoList) { return offerInfoList.stream() .sorted(comparing(OfferInfo::getDate)) .collect(Collectors.toList());