Skip to content

Commit

Permalink
proto-plugin removed from gradle, AddressDetails moved
Browse files Browse the repository at this point in the history
  • Loading branch information
bsc7 committed Nov 19, 2024
1 parent e5d4099 commit 00a2c25
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 48 deletions.
1 change: 0 additions & 1 deletion apps/rest-api-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id("bisq.java-library")
id("bisq.protobuf")
application
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,20 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.rest_api.proto;
package bisq.rest_api.report;

import bisq.common.proto.NetworkProto;
import bisq.common.proto.Proto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import static com.google.common.base.Preconditions.checkArgument;

@Slf4j
@Getter
@EqualsAndHashCode
@ToString
@Schema(name = "AddressDetails")
public final class AddressDetails implements NetworkProto {
public final class AddressDetails {
private final String address;
private final String bondedRoleType;
private final String nickNameOrBondUserName;
Expand All @@ -42,30 +38,4 @@ public AddressDetails(String address, String bondedRoleType, String nickNameOrBo
this.bondedRoleType = bondedRoleType;
this.nickNameOrBondUserName = nickNameOrBondUserName;
}

@Override
public void verify() {
checkArgument(address != null && address.length() > 0);
checkArgument(bondedRoleType != null && bondedRoleType.length() > 0);
checkArgument(nickNameOrBondUserName != null && nickNameOrBondUserName.length() > 0);
}

@Override
public bisq.rest_api.protobuf.AddressDetails toProto(boolean serializeForHash) {
return resolveProto(serializeForHash);
}

@Override
public bisq.rest_api.protobuf.AddressDetails.Builder getBuilder(boolean serializeForHash) {
return bisq.rest_api.protobuf.AddressDetails.newBuilder()
.setAddress(this.address)
.setBondedRoleType(this.bondedRoleType)
.setNickNameOrBondUserName(this.nickNameOrBondUserName);
}

public static AddressDetails fromProto(bisq.rest_api.protobuf.AddressDetails proto) {
return new AddressDetails(proto.getAddress(),
proto.getBondedRoleType(),
proto.getNickNameOrBondUserName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ public List<Report> getReports(
@Path("/addresses/details")
@Operation(description = "Get address info for a set of host:port addresses")
@ApiResponse(responseCode = "200", description = "The set of address info (host, role type, nickname or bond name)",
content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = bisq.rest_api.proto.AddressDetails[].class)))
public List<bisq.rest_api.proto.AddressDetails> getAddressDetailsDto(
content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = AddressDetails[].class)))
public List<AddressDetails> getAddressDetailsDto(
@QueryParam("addresses") String addresses) { // Comma-separated list
try {
log.info("Received request to get address infos for: {}", addresses);
Expand All @@ -166,13 +166,13 @@ public List<bisq.rest_api.proto.AddressDetails> getAddressDetailsDto(
}
}

public List<bisq.rest_api.proto.AddressDetails> getAddressDetailsProtobufs(List<String> addressList) {
public List<AddressDetails> getAddressDetailsProtobufs(List<String> addressList) {
Set<BondedRole> bondedRoles = bondedRolesService.getAuthorizedBondedRolesService().getBondedRoles();
return bondedRoles.stream()
.flatMap(bondedRole -> bondedRole.getAuthorizedBondedRole().getAddressByTransportTypeMap()
.map(addressMap -> addressMap.entrySet().stream()
.filter(entry -> addressList.contains(entry.getValue().toString())) // Nutze addressList
.map(entry -> new bisq.rest_api.proto.AddressDetails(
.map(entry -> new AddressDetails(
entry.getValue().toString(),
bondedRole.getAuthorizedBondedRole().getBondedRoleType().name(),
userService.getUserProfileService()
Expand All @@ -182,6 +182,5 @@ public List<bisq.rest_api.proto.AddressDetails> getAddressDetailsProtobufs(List<
))
).orElse(Stream.empty()))
.collect(Collectors.toList());

}
}
10 changes: 0 additions & 10 deletions apps/rest-api-app/src/main/proto/rest_api.proto

This file was deleted.

0 comments on commit 00a2c25

Please sign in to comment.