Skip to content

Commit 45f532f

Browse files
author
Mateusz Czeladka
committed
refactor: streamline spring boot configuration.
1 parent 0ddc8e7 commit 45f532f

File tree

18 files changed

+136
-61
lines changed

18 files changed

+136
-61
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=cardano-foundation_cardano-rosetta-java&metric=coverage)](https://sonarcloud.io/summary/overall?id=cardano-foundation_cardano-rosetta-java)
55
[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B45571%2Fgithub.com%2Fcardano-foundation%2Fcardano-rosetta-java.svg?type=shield&issueType=license)](https://app.fossa.com/projects/custom%2B45571%2Fgithub.com%2Fcardano-foundation%2Fcardano-rosetta-java?ref=badge_shield&issueType=license)
66

7-
## What the project is about?
87

8+
## What the project is about?
99

1010
This repository provides a lightweight java implementation of the [Rosetta API](https://github.com/coinbase/mesh-specifications). It uses [Yaci-Store](https://github.com/bloxbean/yaci-store) as an indexer
1111
to fetch the data from a Cardano node.

api/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM ubuntu:22.04 AS build-common
22
WORKDIR /build
33

44
RUN apt update --fix-missing \
5-
&& apt install -y --no-install-recommends openjdk-21-jdk maven curl \
5+
&& apt install -y --no-install-recommends openjdk-21-jdk maven curl ca-certificates \
66
&& apt clean
77

88
COPY ./pom.xml /build/pom.xml
@@ -19,4 +19,4 @@ RUN rm -rf /build
1919

2020
ENTRYPOINT ["java", "--enable-preview", "-jar", "/app/api.jar"]
2121

22-
CMD ["/bin/sh", "-c", "bash"]
22+
CMD ["/bin/sh", "-c", "bash"]

api/pom.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
5+
56
<parent>
67
<artifactId>base</artifactId>
78
<groupId>org.cardanofoundation.rosetta-java</groupId>
@@ -30,6 +31,14 @@
3031
<artifactId>junit-jupiter</artifactId>
3132
<scope>test</scope>
3233
</dependency>
34+
<dependency>
35+
<groupId>org.springframework.boot</groupId>
36+
<artifactId>spring-boot-starter</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-security</artifactId>
41+
</dependency>
3342
<dependency>
3443
<groupId>org.springframework.boot</groupId>
3544
<artifactId>spring-boot-starter-web</artifactId>
@@ -52,10 +61,6 @@
5261
<groupId>org.springframework.data</groupId>
5362
<artifactId>spring-data-commons</artifactId>
5463
</dependency>
55-
<dependency>
56-
<groupId>org.springframework.boot</groupId>
57-
<artifactId>spring-boot-starter-security</artifactId>
58-
</dependency>
5964
<dependency>
6065
<groupId>org.springframework.boot</groupId>
6166
<artifactId>spring-boot-starter-validation</artifactId>
@@ -131,24 +136,26 @@
131136
<groupId>org.springframework.boot</groupId>
132137
<artifactId>spring-boot-starter-data-jpa</artifactId>
133138
</dependency>
139+
134140
<dependency>
135141
<artifactId>hibernate-jpamodelgen</artifactId>
136142
<groupId>org.hibernate.orm</groupId>
137143
<version>6.2.0.Final</version>
138144
<scope>provided</scope>
139145
</dependency>
140146

141-
142147
<dependency>
143148
<groupId>org.postgresql</groupId>
144149
<artifactId>postgresql</artifactId>
145150
<scope>runtime</scope>
146151
</dependency>
152+
147153
<dependency>
148154
<groupId>commons-validator</groupId>
149155
<artifactId>commons-validator</artifactId>
150156
<version>1.9.0</version>
151157
</dependency>
158+
152159
<dependency>
153160
<groupId>io.swagger.parser.v3</groupId>
154161
<artifactId>swagger-parser</artifactId>
@@ -165,8 +172,6 @@
165172
<dependency>
166173
<groupId>io.hypersistence</groupId>
167174
<artifactId>hypersistence-utils-hibernate-63</artifactId>
168-
<version>3.7.0</version>
169-
<scope>compile</scope>
170175
</dependency>
171176
<dependency>
172177
<groupId>${project.groupId}</groupId>

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ COPY ./yaci-indexer /root/app/yaci-indexer
159159
COPY ./test-data-generator /root/app/test-data-generator
160160
COPY ./.git /root/app/.git
161161

162-
RUN --mount=type=cache,target=/root/.m2 mvn -U clean package -DskipTests
162+
RUN --mount=type=cache,target=/root/.m2 mvn clean package -DskipTests
163163

164164
# Main
165165
FROM ubuntu:22.04
@@ -192,7 +192,7 @@ RUN mkdir -p /node/postgres
192192
RUN rm -rf /var/lib/postgresql/${PG_VERSION}/main
193193

194194
# Install jdk 21
195-
RUN apt install -y --no-install-recommends openjdk-21-jdk jq bc sudo curl \
195+
RUN apt install -y --no-install-recommends jq bc sudo curl \
196196
&& apt clean
197197

198198
# Copy cardano node

pom.xml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,19 @@
2626
</licenses>
2727

2828
<properties>
29+
<maven.compiler.proc>full</maven.compiler.proc>
2930
<revision>1.2.6</revision>
3031
<java.version>21</java.version>
3132
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
32-
<version.spring-boot>3.4.3</version.spring-boot>
33+
<version.spring-boot>3.4.4</version.spring-boot>
3334
<version.springdoc-openapi-ui>1.6.15</version.springdoc-openapi-ui>
3435
<version.openapi-generator-maven-plugin>6.4.0</version.openapi-generator-maven-plugin>
3536
<version.maven-compiler-plugin>3.13.0</version.maven-compiler-plugin>
3637
<version.maven-surefire-plugin>3.2.5</version.maven-surefire-plugin>
38+
<version.hibernate-types>3.7.1</version.hibernate-types>
3739
<version.jacoco-maven-plugin>0.8.11</version.jacoco-maven-plugin>
3840
<version.flatten-maven-plugin>1.3.0</version.flatten-maven-plugin>
39-
<version.lombok>1.18.30</version.lombok>
41+
<version.lombok>1.18.38</version.lombok>
4042
<version.swagger-annotations>2.2.8</version.swagger-annotations>
4143
<version.log4j>2.20.0</version.log4j>
4244
<version.client-lib>0.6.4</version.client-lib>
@@ -90,6 +92,18 @@
9092
</repositories>
9193
<dependencyManagement>
9294
<dependencies>
95+
<dependency>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-starter</artifactId>
98+
<version>${version.spring-boot}</version>
99+
</dependency>
100+
<dependency>
101+
<groupId>org.springframework.boot</groupId>
102+
<artifactId>spring-boot-dependencies</artifactId>
103+
<type>pom</type>
104+
<version>${version.spring-boot}</version>
105+
<scope>import</scope>
106+
</dependency>
93107
<dependency>
94108
<groupId>org.cardanofoundation</groupId>
95109
<artifactId>cf-cardano-conversions-java</artifactId>
@@ -100,13 +114,6 @@
100114
<artifactId>vavr</artifactId>
101115
<version>${version.vavr}</version>
102116
</dependency>
103-
<dependency>
104-
<groupId>org.springframework.boot</groupId>
105-
<artifactId>spring-boot-dependencies</artifactId>
106-
<type>pom</type>
107-
<version>${version.spring-boot}</version>
108-
<scope>import</scope>
109-
</dependency>
110117
<dependency>
111118
<groupId>org.springdoc</groupId>
112119
<artifactId>springdoc-openapi-ui</artifactId>
@@ -143,6 +150,11 @@
143150
<artifactId>yaci</artifactId>
144151
<version>${version.yaci}</version>
145152
</dependency>
153+
<dependency>
154+
<groupId>io.hypersistence</groupId>
155+
<artifactId>hypersistence-utils-hibernate-63</artifactId>
156+
<version>${version.hibernate-types}</version>
157+
</dependency>
146158
<dependency>
147159
<groupId>com.h2database</groupId>
148160
<artifactId>h2</artifactId>

test-data-generator/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@
6363
<version>${version.maven-compiler-plugin}</version>
6464
<configuration>
6565
<release>21</release>
66+
<annotationProcessorPaths>
67+
<path>
68+
<groupId>org.projectlombok</groupId>
69+
<artifactId>lombok</artifactId>
70+
<version>${version.lombok}</version>
71+
</path>
72+
</annotationProcessorPaths>
6673
</configuration>
6774
</plugin>
6875
</plugins>

yaci-indexer/pom.xml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<parent>
6-
<groupId>org.springframework.boot</groupId>
7-
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.2.4</version>
9-
<relativePath/> <!-- lookup parent from repository -->
6+
<artifactId>base</artifactId>
7+
<groupId>org.cardanofoundation.rosetta-java</groupId>
8+
<version>${revision}</version>
109
</parent>
1110

12-
<groupId>org.cardanofoundation.rosetta-java</groupId>
1311
<artifactId>yaci-indexer</artifactId>
1412
<version>1.0.0</version>
1513
<name>yaci-indexer</name>
14+
1615
<description>yaci-indexer</description>
16+
<packaging>jar</packaging>
17+
1718
<properties>
1819
<java.version>21</java.version>
20+
<maven.compiler.proc>full</maven.compiler.proc>
1921
<yaci-store.version>0.1.2</yaci-store.version>
2022
<sonar.exclusions>src/main/java/org/cardanofoundation/rosetta/yaciindexer/stores/txsize/model/*</sonar.exclusions>
2123
<version.spotless-maven-plugin>2.43.0</version.spotless-maven-plugin>
@@ -37,7 +39,6 @@
3739
<groupId>org.springframework.boot</groupId>
3840
<artifactId>spring-boot-starter</artifactId>
3941
</dependency>
40-
4142
<dependency>
4243
<groupId>org.springframework.boot</groupId>
4344
<artifactId>spring-boot-starter-test</artifactId>
@@ -87,6 +88,10 @@
8788
<artifactId>yaci-store-epoch-spring-boot-starter</artifactId>
8889
<version>${yaci-store.version}</version>
8990
</dependency>
91+
<dependency>
92+
<groupId>io.hypersistence</groupId>
93+
<artifactId>hypersistence-utils-hibernate-63</artifactId>
94+
</dependency>
9095
<!-- Add mysql or H2 or Postgres dependency based on your database -->
9196
<dependency>
9297
<groupId>org.postgresql</groupId>
@@ -99,6 +104,31 @@
99104
<plugin>
100105
<groupId>org.springframework.boot</groupId>
101106
<artifactId>spring-boot-maven-plugin</artifactId>
107+
<version>${version.spring-boot}</version>
108+
<executions>
109+
<execution>
110+
<goals>
111+
<goal>repackage</goal>
112+
<goal>build-info</goal>
113+
</goals>
114+
</execution>
115+
</executions>
116+
117+
</plugin>
118+
<plugin>
119+
<groupId>org.apache.maven.plugins</groupId>
120+
<artifactId>maven-compiler-plugin</artifactId>
121+
<version>${version.maven-compiler-plugin}</version>
122+
<configuration>
123+
<release>21</release>
124+
<annotationProcessorPaths>
125+
<path>
126+
<groupId>org.projectlombok</groupId>
127+
<artifactId>lombok</artifactId>
128+
<version>${version.lombok}</version>
129+
</path>
130+
</annotationProcessorPaths>
131+
</configuration>
102132
</plugin>
103133
<plugin>
104134
<groupId>com.diffplug.spotless</groupId>

yaci-indexer/src/main/java/org/cardanofoundation/rosetta/yaciindexer/service/AccountServiceImpl.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
package org.cardanofoundation.rosetta.yaciindexer.service;
22

3+
import java.math.BigInteger;
4+
import java.time.Duration;
5+
import java.util.Optional;
6+
import java.util.Set;
7+
import jakarta.annotation.Nullable;
8+
9+
import lombok.extern.slf4j.Slf4j;
10+
11+
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
12+
import org.springframework.stereotype.Service;
313
import com.bloxbean.cardano.client.address.Address;
414
import com.bloxbean.cardano.yaci.core.protocol.localstate.api.Era;
515
import com.bloxbean.cardano.yaci.core.protocol.localstate.queries.DelegationsAndRewardAccountsQuery;
616
import com.bloxbean.cardano.yaci.core.protocol.localstate.queries.DelegationsAndRewardAccountsResult;
717
import com.bloxbean.cardano.yaci.helper.LocalClientProvider;
818
import com.bloxbean.cardano.yaci.store.core.service.local.LocalClientProviderManager;
9-
import jakarta.annotation.Nullable;
10-
import lombok.extern.slf4j.Slf4j;
11-
import org.cardanofoundation.rosetta.yaciindexer.domain.model.StakeAccountRewardInfo;
12-
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
13-
import org.springframework.stereotype.Service;
1419
import reactor.core.publisher.Mono;
1520

16-
import java.math.BigInteger;
17-
import java.time.Duration;
18-
import java.util.Optional;
19-
import java.util.Set;
21+
import org.cardanofoundation.rosetta.yaciindexer.domain.model.StakeAccountRewardInfo;
2022

2123
@Service
2224
@Slf4j

yaci-indexer/src/main/java/org/cardanofoundation/rosetta/yaciindexer/service/TransactionScriptSizeCalculatorImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package org.cardanofoundation.rosetta.yaciindexer.service;
22

3+
import java.util.List;
4+
5+
import lombok.extern.slf4j.Slf4j;
6+
7+
import org.springframework.stereotype.Service;
38
import co.nstant.in.cbor.model.Array;
49
import co.nstant.in.cbor.model.ByteString;
510
import co.nstant.in.cbor.model.Map;
@@ -10,11 +15,8 @@
1015
import com.bloxbean.cardano.yaci.core.model.PlutusScript;
1116
import com.bloxbean.cardano.yaci.helper.model.Transaction;
1217
import com.fasterxml.jackson.core.JsonProcessingException;
13-
import lombok.extern.slf4j.Slf4j;
14-
import org.cardanofoundation.rosetta.yaciindexer.domain.model.TransactionBuildingConstants;
15-
import org.springframework.stereotype.Service;
1618

17-
import java.util.List;
19+
import org.cardanofoundation.rosetta.yaciindexer.domain.model.TransactionBuildingConstants;
1820

1921
import static com.bloxbean.cardano.client.util.HexUtil.decodeHexString;
2022
import static org.cardanofoundation.rosetta.yaciindexer.domain.model.TransactionBuildingConstants.*;

yaci-indexer/src/main/java/org/cardanofoundation/rosetta/yaciindexer/service/TransactionSizeCalculatorImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package org.cardanofoundation.rosetta.yaciindexer.service;
22

3-
import co.nstant.in.cbor.model.Map;
4-
import com.bloxbean.cardano.yaci.core.util.CborSerializationUtil;
53
import lombok.extern.slf4j.Slf4j;
4+
65
import org.springframework.stereotype.Service;
6+
import co.nstant.in.cbor.model.Map;
7+
import com.bloxbean.cardano.yaci.core.util.CborSerializationUtil;
78

89
@Service
910
@Slf4j

0 commit comments

Comments
 (0)