Skip to content

Commit

Permalink
Merge branch 'main' into fix/RA-84-block-diff-with-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
shleger committed May 6, 2024
2 parents 03d75ec + d005dc8 commit 352d348
Show file tree
Hide file tree
Showing 23 changed files with 256 additions and 120 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@

---

# :rotating_light: This Repository is under active development. :rotating_light:
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=cardano-foundation_cardano-rosetta-java&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=cardano-foundation_cardano-rosetta-java)

# Cardano Rosetta API Java implementation
This repository provides a lightweight java implementation of the Rosetta API. It uses [Yaci-Store](https://github.com/bloxbean/yaci-store) as an indexer
Expand Down
7 changes: 0 additions & 7 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,6 @@
<version>2.0.1</version>
</dependency>


<!-- https://mvnrepository.com/artifact/com.squareup.okhttp3/logging-interceptor -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.filter.ForwardedHeaderFilter;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
Expand Down Expand Up @@ -51,4 +53,9 @@ public FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
public JsonNullableModule jsonNullableModule() {
return new JsonNullableModule();
}

@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import jakarta.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.mutable.MutableInt;
import org.jetbrains.annotations.NotNull;
import org.modelmapper.builder.ConfigurableConditionExpression;
import org.openapitools.client.model.Amount;
import org.openapitools.client.model.Currency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ private String convert(CertificateType model) {
if (model == null) {
return null;
} else {
return model.equals(CertificateType.STAKE_REGISTRATION)
? OperationType.STAKE_KEY_REGISTRATION.getValue() :
model.equals(CertificateType.STAKE_DEREGISTRATION)
? OperationType.STAKE_KEY_DEREGISTRATION.getValue() : null;
return switch (model) {
case CertificateType.STAKE_REGISTRATION -> OperationType.STAKE_KEY_REGISTRATION.getValue();
case CertificateType.STAKE_DEREGISTRATION -> OperationType.STAKE_KEY_DEREGISTRATION.getValue();
default -> null;
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.NoArgsConstructor;

@Data
@Builder //TODO saa: refactor tests and remove builder and *argConstructor annotations
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Delegation {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.NoArgsConstructor;

@Data
@Builder // TODO saa: remove this and refactor tests
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PoolRetirement {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class ProtocolParams {

private BigInteger minPoolCost; //16
private BigInteger adaPerUtxoByte; //17
//private String nonce;

//Alonzo changes
private Map<String, long[]> costModels; //18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.bloxbean.cardano.yaci.core.model.certs.CertificateType;

@Data
@Builder //TODO saa: remove this and refactor tests
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class StakeRegistration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public class ProtocolParamsEntity {

private BigInteger minPoolCost; //16
private BigInteger adaPerUtxoByte; //17
//private String nonce;

//Alonzo changes
private Map<String, long[]> costModels; //18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import jakarta.validation.constraints.NotNull;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Component;
import org.apache.commons.lang3.ObjectUtils;
import org.jetbrains.annotations.NotNull;
import org.modelmapper.ModelMapper;

import org.cardanofoundation.rosetta.api.account.model.domain.Utxo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
package org.cardanofoundation.rosetta.api.construction.service;


import org.openapitools.client.model.*;
import org.openapitools.client.model.ConstructionCombineRequest;
import org.openapitools.client.model.ConstructionCombineResponse;
import org.openapitools.client.model.ConstructionDeriveRequest;
import org.openapitools.client.model.ConstructionDeriveResponse;
import org.openapitools.client.model.ConstructionHashRequest;
import org.openapitools.client.model.ConstructionMetadataRequest;
import org.openapitools.client.model.ConstructionMetadataResponse;
import org.openapitools.client.model.ConstructionParseRequest;
import org.openapitools.client.model.ConstructionParseResponse;
import org.openapitools.client.model.ConstructionPayloadsRequest;
import org.openapitools.client.model.ConstructionPayloadsResponse;
import org.openapitools.client.model.ConstructionPreprocessRequest;
import org.openapitools.client.model.ConstructionPreprocessResponse;
import org.openapitools.client.model.ConstructionSubmitRequest;
import org.openapitools.client.model.TransactionIdentifierResponse;


public interface ConstructionApiService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ConstructionApiServiceImpl implements ConstructionApiService {

private final CardanoAddressService cardanoAddressService;
private final CardanoService cardanoService;
private final ProtocolParamService protocolParamService;
private final ProtocolParamService protocolParamService;
private final DataMapper dataMapper;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import java.lang.reflect.Type;
import jakarta.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;

import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageConverter;
Expand All @@ -13,13 +14,12 @@
import org.cardanofoundation.rosetta.common.services.LoggingService;

@ControllerAdvice
@RequiredArgsConstructor
public class CustomRequestBodyAdviceAdapter extends RequestBodyAdviceAdapter {

@Autowired
LoggingService loggingService;
final LoggingService loggingService;

@Autowired
HttpServletRequest httpServletRequest;
final HttpServletRequest httpServletRequest;

@Override
public boolean supports(MethodParameter methodParameter, Type type, Class<? extends HttpMessageConverter<?>> aClass) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.cardanofoundation.rosetta.common.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;

import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
Expand All @@ -14,10 +15,10 @@
import org.cardanofoundation.rosetta.common.services.LoggingService;

@ControllerAdvice
@RequiredArgsConstructor
public class CustomResponseBodyAdviceAdapter implements ResponseBodyAdvice<Object> {

@Autowired
LoggingService loggingService;
final LoggingService loggingService;

@Override
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;

import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
Expand All @@ -13,10 +14,10 @@
import org.cardanofoundation.rosetta.common.services.LoggingService;

@Component
@RequiredArgsConstructor
public class LogInterceptor implements HandlerInterceptor {

@Autowired
LoggingService loggingService;
final LoggingService loggingService;

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
package org.cardanofoundation.rosetta.common.model.cardano.transaction;

import java.util.Arrays;
import java.util.Objects;

import org.openapitools.client.model.TransactionIdentifier;

public record MemPoolTransaction(TransactionIdentifier identifier, byte[] txBytes) {}
public record MemPoolTransaction(TransactionIdentifier identifier, byte[] txBytes) {

@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null || getClass() != object.getClass()) {
return false;
}
MemPoolTransaction that = (MemPoolTransaction) object;
return Objects.equals(identifier, that.identifier) && Arrays.equals(txBytes,
that.txBytes);
}

@Override
public int hashCode() {
int result = Objects.hash(identifier);
result = 31 * result + Arrays.hashCode(txBytes);
return result;
}

@Override
public String toString() {
return "MemPoolTransaction{" +
"identifier=" + identifier +
", txBytes=" + Arrays.toString(txBytes) +
'}';
}
}

0 comments on commit 352d348

Please sign in to comment.