Skip to content

Commit 4908afb

Browse files
authored
Prepare 1.3.1 release (#549)
2 parents fec640e + 4c28209 commit 4908afb

File tree

45 files changed

+7927
-296
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+7927
-296
lines changed

.env.IntegrationTest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ GENESIS_SHELLEY_PATH=/config/shelley-genesis.json
5656
GENESIS_BYRON_PATH=/config/byron-genesis.json
5757
GENESIS_ALONZO_PATH=/config/alonzo-genesis.json
5858
GENESIS_CONWAY_PATH=/config/conway-genesis.json
59-
SEARCH_PAGE_SIZE=100
59+
SEARCH_LIMIT=100
6060

6161
## Yaci Indexer env
6262
INDEXER_DOCKER_IMAGE_TAG=main

.env.docker-compose

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ GENESIS_SHELLEY_PATH=/config/shelley-genesis.json
5555
GENESIS_BYRON_PATH=/config/byron-genesis.json
5656
GENESIS_ALONZO_PATH=/config/alonzo-genesis.json
5757
GENESIS_CONWAY_PATH=/config/conway-genesis.json
58-
SEARCH_PAGE_SIZE=100
58+
SEARCH_LIMIT=100
5959

6060
## Yaci Indexer env
6161
INDEXER_DOCKER_IMAGE_TAG=main

.env.docker-compose-preprod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ GENESIS_SHELLEY_PATH=/config/shelley-genesis.json
5555
GENESIS_BYRON_PATH=/config/byron-genesis.json
5656
GENESIS_ALONZO_PATH=/config/alonzo-genesis.json
5757
GENESIS_CONWAY_PATH=/config/conway-genesis.json
58-
SEARCH_PAGE_SIZE=100
58+
SEARCH_LIMIT=100
5959

6060
## Yaci Indexer env
6161
INDEXER_DOCKER_IMAGE_TAG=main

.env.h2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GENESIS_SHELLEY_PATH=./config/${NETWORK}/shelley-genesis.json
3636
GENESIS_BYRON_PATH=./config/${NETWORK}/byron-genesis.json
3737
GENESIS_ALONZO_PATH=./config/${NETWORK}/alonzo-genesis.json
3838
GENESIS_CONWAY_PATH=./config/${NETWORK}/conway-genesis.json
39-
SEARCH_PAGE_SIZE=100
39+
SEARCH_LIMIT=100
4040

4141
## Yaci Indexer env
4242
INDEXER_DOCKER_IMAGE_TAG=main

.env.h2-testdata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ GENESIS_SHELLEY_PATH=./config/${NETWORK}/shelley-genesis.json
3636
GENESIS_BYRON_PATH=./config/${NETWORK}/byron-genesis.json
3737
GENESIS_ALONZO_PATH=./config/${NETWORK}/alonzo-genesis.json
3838
GENESIS_CONWAY_PATH=./config/${NETWORK}/conway-genesis.json
39-
SEARCH_PAGE_SIZE=100
39+
SEARCH_LIMIT=100
4040

4141
## Yaci Indexer env
4242
INDEXER_DOCKER_IMAGE_TAG=main

CLAUDE.md

Lines changed: 128 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,128 @@
1-
Rosetta-Java Cardano Application — Development Guide (Context Window For AI Agents)
2-
3-
✅ Overview
4-
5-
This project is a Java implementation of the Rosetta specification, adapted from Coinbase’s original mesh. It targets the Cardano blockchain and is optimized for performance, scalability, and testability.
6-
7-
8-
9-
🛠️ Technologies & Standards
10-
• Java 24 – Latest LTS features leveraged.
11-
• Lombok – For reducing boilerplate (e.g., getters, constructors).
12-
• Hibernate + JOOQ – A hybrid approach planned:
13-
• Hibernate for standard ORM tasks.
14-
• JOOQ for complex SQL operations.
15-
• Hibernate for standard ORM needs.
16-
• JOOQ for high-performance, complex SQL queries.
17-
• Flywheel – Used for event-sourced state and domain logic.
18-
• OpenAPI (api.yaml) – Contract-first approach:
19-
• Edit src/main/resources/rosetta-specifications-1.4.15/api.yaml for API changes.
20-
• Code generation tools automatically create request/response classes.
21-
• No Spring RestControllers – All endpoints are generated from OpenAPI spec; avoid manually annotating endpoints.
22-
• JUnit 5 with @Nested tests – Organize tests into logical groups.
23-
• AssertJ – Preferred assertion framework for fluent and expressive assertions.
24-
25-
26-
27-
📋 Step-by-Step Context Window / Discovery
28-
29-
1. Rosetta API Specification
30-
• Maintained in:
31-
src/main/resources/rosetta-specifications-1.4.15/api.yaml
32-
• ❗ All endpoints and models are generated, do not manually modify controller classes.
33-
34-
2. Code Generation
35-
• Triggered via build tools (Gradle/Maven).
36-
• Output includes:
37-
• DTOs
38-
• Server interfaces
39-
• Clients
40-
• Ensures OpenAPI remains the single source of truth.
41-
42-
3. Persistence Layer
43-
• Hibernate handles standard CRUD and entity management.
44-
• JOOQ will be used for:
45-
• Bulk operations
46-
• Deep filtering
47-
• Custom joins / window functions
48-
• Both work seamlessly alongside Flywheel event sourcing.
49-
50-
4. Domain Logic with Flywheel
51-
• Domain state transitions are event-driven.
52-
• Promotes traceability and immutability.
53-
54-
5. Testing Strategy
55-
• JUnit 5 with @Nested classes to:
56-
• Separate concerns within test files.
57-
• Improve readability and scope clarity.
58-
• AssertJ provides fluent API for:
59-
• Clean, expressive assertions.
60-
• Better failure messages than vanilla JUnit or Hamcrest.
61-
62-
63-
64-
📎 Notes
65-
• Avoid using @RestController or manual API layer.
66-
• All changes to API contract must be made in api.yaml.
67-
• Lombok annotations (@Value, @Builder, @Getter, etc.) are preferred to minimize boilerplate.
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Overview
6+
7+
This project is a Java implementation of the Rosetta specification for the Cardano blockchain, consisting of multiple Maven modules for API services, blockchain indexing, and testing utilities.
8+
9+
## Build and Development Commands
10+
11+
### Maven Commands
12+
```bash
13+
# Build entire project (from root)
14+
mvn clean install
15+
16+
# Build specific module
17+
mvn clean install -pl api
18+
mvn clean install -pl yaci-indexer
19+
mvn clean install -pl test-data-generator
20+
21+
# Run tests
22+
mvn test # All tests
23+
mvn test -pl api # API module tests only
24+
mvn test -Dtest=ClassName # Single test class
25+
26+
# Code generation (happens automatically during build)
27+
mvn generate-sources # Generates OpenAPI code from api.yaml
28+
29+
# Run application (API module)
30+
cd api && mvn spring-boot:run
31+
32+
# Package for deployment
33+
mvn clean package
34+
```
35+
36+
### Docker Commands
37+
```bash
38+
# Build from source
39+
docker build -t rosetta-java -f ./docker/Dockerfile .
40+
41+
# Run with docker-compose (full stack)
42+
docker-compose up -d
43+
44+
# Run specific services
45+
docker-compose up -d api indexer postgres
46+
47+
# View logs
48+
docker logs rosetta -f
49+
docker exec rosetta tail -f /logs/node.log
50+
docker exec rosetta tail -f /logs/indexer.log
51+
```
52+
53+
## Architecture Overview
54+
55+
### Multi-Module Structure
56+
- **`api/`** - Main Rosetta API implementation (Spring Boot)
57+
- **`yaci-indexer/`** - Blockchain data indexer using Yaci Store libraries
58+
- **`test-data-generator/`** - Testing utility for transaction test data
59+
60+
### Key Technologies
61+
- **Java 24** with preview features
62+
- **Spring Boot 3.5.0** with Spring Security and Web
63+
- **Maven** multi-module build
64+
- **OpenAPI 3.0** code generation from `/api/src/main/resources/rosetta-specifications-1.4.15/api.yaml`
65+
- **MapStruct** for object mapping
66+
- **Lombok** for boilerplate reduction
67+
- **JUnit 5** with `@Nested` test organization
68+
- **AssertJ** for test assertions
69+
- **PostgreSQL** (production) / **H2** (development/testing)
70+
71+
### Code Generation Pattern
72+
- All API endpoints and DTOs are generated from `api.yaml`
73+
- Generated code located in `/target/generated-sources/openapi/`
74+
- **NEVER** manually modify controller classes - edit `api.yaml` instead
75+
- Controller implementations in `api/{domain}/controller/` implement generated interfaces
76+
77+
### Database Architecture
78+
- **Hibernate JPA** for standard ORM operations
79+
- **Custom entities** with JSON storage for UTXO data using Hypersistence Utils
80+
- **Yaci-Store** handles blockchain data synchronization in separate indexer module
81+
- Database migration handled through Yaci Store's built-in Flyway integration
82+
83+
### API Layer Organization
84+
Each Rosetta endpoint has its own package under `api/src/main/java/org/cardanofoundation/rosetta/api/`:
85+
- `account/` - Account balances and UTXO operations
86+
- `block/` - Block and transaction retrieval
87+
- `construction/` - Transaction building and signing
88+
- `mempool/` - Mempool operations
89+
- `network/` - Network status and configuration
90+
- `search/` - Transaction search functionality
91+
92+
Each package contains:
93+
- `controller/` - REST endpoints implementing generated OpenAPI interfaces
94+
- `service/` - Business logic layer
95+
- `mapper/` - MapStruct mappers for entity/DTO conversion
96+
- `model/` - Domain objects and entities
97+
98+
### Testing Patterns
99+
- Use `@Nested` classes to group related tests
100+
- Extend `BaseSpringMvcSetup` for integration tests
101+
- Extend `BaseMapperSetup` for mapper tests
102+
- Test data stored in `/src/test/resources/testdata/`
103+
- Use AssertJ for fluent assertions: `assertThat(result).isNotNull().satisfies(...)`
104+
105+
### Configuration Management
106+
- Main config: `application.yaml`
107+
- Environment profiles: `application-{profile}.yaml` (h2, offline, online, staging, test)
108+
- Spring profiles control database backend and operational mode
109+
- Environment variables documented in README.md and Docker configs
110+
111+
### Development Workflow
112+
1. **API Changes**: Edit `api.yaml` → run build → implement in controller classes
113+
2. **Database Changes**: Modify entities → Yaci Store handles migrations automatically
114+
3. **New Features**: Follow domain package structure → add controller, service, mapper
115+
4. **Testing**: Write nested test classes → use appropriate base setup class
116+
117+
### Common Gotchas
118+
- OpenAPI code generation requires clean build when `api.yaml` changes
119+
- Yaci-indexer must be running for API integration tests
120+
- Use correct Spring profile for your database backend (h2/postgres)
121+
- Generated OpenAPI models use different package (`org.openapitools.client.model`)
122+
- MapStruct mappers require annotation processor to be enabled
123+
124+
### Module Dependencies
125+
- **API module** communicates with yaci-indexer via HTTP (`YaciHttpGateway`)
126+
- **Yaci-indexer** provides REST endpoints for blockchain data queries
127+
- **Test-data-generator** creates realistic transaction scenarios for testing
128+
- All modules share common configuration from parent POM

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ For every Release we provide pre-built docker images stored in the DockerHub Rep
100100
To start it use the following command:
101101

102102
```bash
103-
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.3.0
103+
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.3.1
104104
```
105105

106106
Changes to the configuration can be made by adjusting the `docker/.env.dockerfile` file. For more information on the environment variables, please refer to the [documentation](https://cardano-foundation.github.io/cardano-rosetta-java/docs/install-and-deploy/env-vars).
107107

108108
If you want to use the `cardano-submit-api` you can additionally expose port `8090`. It can then be used to submit raw cbor transaction (API documentation here: [Link](https://input-output-hk.github.io/cardano-rest/submit-api/))
109109

110110
```bash
111-
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8090:8090 -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.3.0
111+
docker run --name rosetta -v {CUSTOM_MOUNT_PATH}:/node --env-file ./docker/.env.dockerfile --env-file ./docker/.env.docker-profile-mid-level -p 8090:8090 -p 8082:8082 --shm-size=4g -d cardanofoundation/cardano-rosetta-java:1.3.1
112112
```
113113

114114
### Docker compose

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/domain/Amt.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ public class Amt implements Serializable {
2424
private String policyId;
2525
private String assetName;
2626
private BigInteger quantity;
27+
2728
}

api/src/main/java/org/cardanofoundation/rosetta/api/account/model/repository/AddressUtxoRepository.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package org.cardanofoundation.rosetta.api.account.model.repository;
22

3-
import java.util.List;
4-
3+
import org.cardanofoundation.rosetta.api.account.model.entity.AddressUtxoEntity;
4+
import org.cardanofoundation.rosetta.api.account.model.entity.UtxoId;
55
import org.springframework.data.jpa.repository.JpaRepository;
66
import org.springframework.data.jpa.repository.Query;
77
import org.springframework.data.repository.query.Param;
88
import org.springframework.stereotype.Repository;
99

10-
import org.cardanofoundation.rosetta.api.account.model.entity.AddressUtxoEntity;
11-
import org.cardanofoundation.rosetta.api.account.model.entity.UtxoId;
10+
import java.util.List;
1211

1312
@Repository
1413
public interface AddressUtxoRepository extends JpaRepository<AddressUtxoEntity, UtxoId> {
@@ -43,14 +42,6 @@ AND NOT EXISTS(SELECT 1 FROM TxInputEntity o WHERE o.txHash = a.txHash AND o.out
4342
""")
4443
List<AddressUtxoEntity> findUnspentUtxosByAddressAndBlock(@Param("address") String address, @Param("block") long block);
4544

46-
@Query(value =
47-
"""
48-
SELECT a FROM AddressUtxoEntity a WHERE
49-
a.ownerStakeAddr = :address
50-
AND NOT EXISTS(SELECT 1 FROM TxInputEntity o WHERE o.txHash = a.txHash AND o.outputIndex = a.outputIndex AND o.spentAtBlock <= :block)
51-
AND a.blockNumber <= :block
52-
""")
53-
List<AddressUtxoEntity> findUnspentUtxosByStakeAddressAndBlock(@Param("address") String stakeAddress, @Param("block") long block);
54-
5545
List<AddressUtxoEntity> findByTxHashIn(List<String> utxHashes);
46+
5647
}

api/src/main/java/org/cardanofoundation/rosetta/api/block/model/entity/TxInputEntity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ public class TxInputEntity {
3030

3131
@Column(name = "spent_tx_hash")
3232
private String spentTxHash;
33+
3334
}

0 commit comments

Comments
 (0)