mirror of
https://github.com/haveno-dex/haveno.git
synced 2026-01-08 02:55:35 -05:00
Merge branch 'master' into fix/connection-timeout-tor-root-cause
This commit is contained in:
commit
45f54169e8
5 changed files with 38 additions and 13 deletions
|
|
@ -19,6 +19,7 @@ package haveno.core.api.model;
|
|||
|
||||
import haveno.common.Payload;
|
||||
import haveno.core.api.model.builder.OfferInfoBuilder;
|
||||
import haveno.core.locale.CountryUtil;
|
||||
import haveno.core.monetary.Price;
|
||||
import haveno.core.offer.Offer;
|
||||
import haveno.core.offer.OpenOffer;
|
||||
|
|
@ -34,6 +35,8 @@ import static haveno.core.util.PriceUtil.reformatMarketPrice;
|
|||
import static haveno.core.util.VolumeUtil.formatVolume;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@EqualsAndHashCode
|
||||
@ToString
|
||||
@Getter
|
||||
|
|
@ -61,8 +64,6 @@ public class OfferInfo implements Payload {
|
|||
private final String paymentAccountId;
|
||||
private final String paymentMethodId;
|
||||
private final String paymentMethodShortName;
|
||||
// For traditional offer the baseCurrencyCode is XMR and the counterCurrencyCode is the traditional currency
|
||||
// For crypto offers it is the opposite. baseCurrencyCode is the crypto and the counterCurrencyCode is XMR.
|
||||
private final String baseCurrencyCode;
|
||||
private final String counterCurrencyCode;
|
||||
private final long date;
|
||||
|
|
@ -82,6 +83,7 @@ public class OfferInfo implements Payload {
|
|||
private final String challenge;
|
||||
private final String extraInfo;
|
||||
private final List<String> acceptedCountryCodes;
|
||||
private final String acceptedCountriesString;
|
||||
private final String city;
|
||||
|
||||
public OfferInfo(OfferInfoBuilder builder) {
|
||||
|
|
@ -120,6 +122,7 @@ public class OfferInfo implements Payload {
|
|||
this.challenge = builder.getChallenge();
|
||||
this.extraInfo = builder.getExtraInfo();
|
||||
this.acceptedCountryCodes = builder.getAcceptedCountryCodes();
|
||||
this.acceptedCountriesString = builder.getAcceptedCountriesString();
|
||||
this.city = builder.getCity();
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +163,8 @@ public class OfferInfo implements Payload {
|
|||
currencyCode);
|
||||
var roundedVolume = formatVolume(requireNonNull(offer.getVolume()));
|
||||
var roundedMinVolume = formatVolume(requireNonNull(offer.getMinVolume()));
|
||||
boolean hasAcceptedCountries = offer.getAcceptedCountryCodes() != null && !offer.getAcceptedCountryCodes().isEmpty();
|
||||
String city = offer.getF2FCity();
|
||||
return new OfferInfoBuilder()
|
||||
.withId(offer.getId())
|
||||
.withDirection(offer.getDirection().name())
|
||||
|
|
@ -191,8 +196,9 @@ public class OfferInfo implements Payload {
|
|||
.withIsPrivateOffer(offer.isPrivateOffer())
|
||||
.withChallenge(offer.getChallenge())
|
||||
.withExtraInfo(offer.getCombinedExtraInfo())
|
||||
.withAcceptedCountryCodes(offer.getAcceptedCountryCodes())
|
||||
.withCity(offer.getF2FCity());
|
||||
.withAcceptedCountryCodes(hasAcceptedCountries ? offer.getAcceptedCountryCodes() : null)
|
||||
.withAcceptedCountriesString(hasAcceptedCountries ? CountryUtil.getCountriesString(offer.getAcceptedCountryCodes()) : null)
|
||||
.withCity(city == null || city.isEmpty() ? null : city);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -236,8 +242,9 @@ public class OfferInfo implements Payload {
|
|||
Optional.ofNullable(splitOutputTxHash).ifPresent(builder::setSplitOutputTxHash);
|
||||
Optional.ofNullable(challenge).ifPresent(builder::setChallenge);
|
||||
Optional.ofNullable(extraInfo).ifPresent(builder::setExtraInfo);
|
||||
Optional.ofNullable(acceptedCountryCodes).ifPresent(builder::addAllAcceptedCountryCodes);
|
||||
builder.setCity(city == null ? "" : city);
|
||||
Optional.ofNullable(acceptedCountryCodes).ifPresent(e -> builder.addAllAcceptedCountryCodes(acceptedCountryCodes));
|
||||
Optional.ofNullable(acceptedCountriesString).ifPresent(builder::setAcceptedCountriesString);
|
||||
Optional.ofNullable(city).ifPresent(builder::setCity);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
|
@ -279,6 +286,7 @@ public class OfferInfo implements Payload {
|
|||
.withChallenge(proto.getChallenge())
|
||||
.withExtraInfo(proto.getExtraInfo())
|
||||
.withAcceptedCountryCodes(proto.getAcceptedCountryCodesList())
|
||||
.withAcceptedCountriesString(proto.getAcceptedCountriesString())
|
||||
.withCity(proto.getCity())
|
||||
.build();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package haveno.core.api.model.builder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import haveno.core.api.model.OfferInfo;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
|
@ -68,6 +70,7 @@ public final class OfferInfoBuilder {
|
|||
private String challenge;
|
||||
private String extraInfo;
|
||||
private List<String> acceptedCountryCodes;
|
||||
private String acceptedCountriesString;
|
||||
private String city;
|
||||
|
||||
public OfferInfoBuilder withId(String id) {
|
||||
|
|
@ -260,6 +263,11 @@ public final class OfferInfoBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public OfferInfoBuilder withAcceptedCountriesString(String acceptedCountriesString) {
|
||||
this.acceptedCountriesString = acceptedCountriesString;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OfferInfoBuilder withCity(String city) {
|
||||
this.city = city;
|
||||
return this;
|
||||
|
|
|
|||
|
|
@ -199,6 +199,18 @@ public class CountryUtil {
|
|||
return getNamesByCodes(countryCodes).stream().collect(Collectors.joining(",\n"));
|
||||
}
|
||||
|
||||
public static String getCountriesString(List<String> countryCodes) {
|
||||
if (CountryUtil.containsAllSepaEuroCountries(countryCodes)) {
|
||||
return Res.get("shared.allEuroCountries");
|
||||
} else {
|
||||
if (countryCodes.size() == 1) {
|
||||
return CountryUtil.getNameAndCode(countryCodes.get(0));
|
||||
} else {
|
||||
return CountryUtil.getCodesString(countryCodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Region> getAllRegions() {
|
||||
final List<Region> allRegions = new ArrayList<>();
|
||||
|
||||
|
|
|
|||
|
|
@ -303,16 +303,12 @@ public class OfferDetailsWindow extends Overlay<OfferDetailsWindow> {
|
|||
}
|
||||
if (showAcceptedCountryCodes) {
|
||||
addSeparator(gridPane, ++rowIndex);
|
||||
String countries;
|
||||
String countries = CountryUtil.getCountriesString(acceptedCountryCodes);
|
||||
Tooltip tooltip = null;
|
||||
if (CountryUtil.containsAllSepaEuroCountries(acceptedCountryCodes)) {
|
||||
countries = Res.get("shared.allEuroCountries");
|
||||
} else {
|
||||
if (!CountryUtil.containsAllSepaEuroCountries(acceptedCountryCodes)) {
|
||||
if (acceptedCountryCodes.size() == 1) {
|
||||
countries = CountryUtil.getNameAndCode(acceptedCountryCodes.get(0));
|
||||
tooltip = new Tooltip(countries);
|
||||
} else {
|
||||
countries = CountryUtil.getCodesString(acceptedCountryCodes);
|
||||
tooltip = new Tooltip(CountryUtil.getNamesByCodesString(acceptedCountryCodes));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -613,7 +613,8 @@ message OfferInfo {
|
|||
string challenge = 33;
|
||||
string extra_info = 34;
|
||||
repeated string accepted_country_codes = 35;
|
||||
string city = 36;
|
||||
string accepted_countries_string = 36;
|
||||
string city = 37;
|
||||
}
|
||||
|
||||
message AvailabilityResultWithDescription {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue