diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b30b217..62cec55 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -12,7 +12,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: temurin
- java-version: '21'
+ java-version: '17'
cache: maven
- name: Build and test
run: mvn -B clean test
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 2669e7d..a03b982 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -7,21 +7,29 @@ jobs:
runs-on: gero-plain
permissions:
contents: read
- packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
- java-version: '21'
+ java-version: '17'
cache: maven
- server-id: github
+ server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- - name: Publish to GitHub Packages
- # maven.test.skip (not just skipTests) so drifted test sources don't block
- # the release; unit tests run in build.yml on PRs.
- run: mvn -B deploy -Dmaven.test.skip=true
+ - name: Import GPG key
+ run: |
+ echo "${GPG_PRIVATE_KEY}" | gpg --batch --import
+ echo "default-cache-ttl 7200" >> ~/.gnupg/gpg-agent.conf
+ echo "max-cache-ttl 7200" >> ~/.gnupg/gpg-agent.conf
env:
- MAVEN_USERNAME: ${{ github.actor }}
- MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
+ GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
+ # A maintainer must configure CENTRAL_TOKEN_USERNAME, CENTRAL_TOKEN_PASSWORD,
+ # GPG_PRIVATE_KEY and GPG_PASSPHRASE as repo secrets for this to work.
+ # Skip tests to allow drifted/absent test sources; unit tests run in build.yml on PRs.
+ - name: Publish to Maven Central
+ run: mvn -B -Prelease deploy -Dmaven.test.skip=true
+ env:
+ MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
+ MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
+ MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..2275b54
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the
+ purposes of this License, Derivative Works shall not include works
+ that remain separable from, or merely link (or bind by name) to the
+ interfaces of, the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2026 Gero Labs
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/README.md b/README.md
index 1ce967d..f7fbe94 100644
--- a/README.md
+++ b/README.md
@@ -4,20 +4,13 @@ Java client for the [Nexus](https://nexus.gerowallet.io) Cardano data API.
## Install
-Add the GitHub Packages repository and the dependency to your `pom.xml`:
+`nexus-java-client` is published to Maven Central — no extra repository needed:
```xml
-
-
- github-nexus-java-client
- https://maven.pkg.github.com/Gero-Labs/nexus-java-client
-
-
-
io.github.gero-labs
nexus-java-client
- 1.0.0
+ 1.1.0
```
@@ -47,3 +40,38 @@ Every service method returns a `Result`: `isSuccessful()`, `getCode()`,
```bash
mvn clean test
```
+
+## Release
+
+Releases publish to Maven Central under `io.github.gero-labs:nexus-java-client`. The
+tag-triggered `publish.yml` workflow runs this automatically; the steps below are for
+setting that up or running a release manually.
+
+One-time setup:
+
+1. Verify the `io.github.gero-labs` namespace with Sonatype Central
+ (https://central.sonatype.org/register/namespace/) — it's tied to the GitHub org.
+2. Generate a Central Portal user token
+ (https://central.sonatype.com/account) and add it to `~/.m2/settings.xml`:
+ ```xml
+
+
+ central
+ YOUR_TOKEN_USERNAME
+ YOUR_TOKEN_PASSWORD
+
+
+ ```
+3. Have a GPG key available for signing (`gpg --gen-key` if you don't have one) — Central
+ requires all release artifacts to be signed.
+
+To release:
+
+```bash
+mvn -Prelease deploy
+```
+
+This builds the jar, sources jar, and javadoc jar, signs all three with GPG, and uploads
+a deployment bundle to the Central Portal. The deployment lands in `PENDING`/`VALIDATED`
+state — sign in to https://central.sonatype.com/publishing and click **Publish** to make
+it live (this repo's `autoPublish` is `false` by design, so nothing goes live unattended).
diff --git a/docs/superpowers/plans/2026-08-07-nexus-java-client-metadata-script.md b/docs/superpowers/plans/2026-08-07-nexus-java-client-metadata-script.md
new file mode 100644
index 0000000..fcc7dea
--- /dev/null
+++ b/docs/superpowers/plans/2026-08-07-nexus-java-client-metadata-script.md
@@ -0,0 +1,410 @@
+# nexus-java-client — MetadataService + ScriptService + Java 17 + Maven Central Implementation Plan
+
+> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
+
+**Goal:** Add `MetadataService` (5 methods) + `ScriptService` (2 methods) to nexus-java-client, retarget the build to Java 17, and configure Maven Central publishing — so `cardano-client-lib`'s Nexus backend module (L3) can wrap the SDK for full bloxbean parity.
+
+**Architecture:** Each service is a Retrofit vertical mirroring the existing `transaction` vertical exactly: `XxxApi` (`@GET "api/..."` + `@Query("network")`) → `XxxService` (`Result`, `Network`, `throws ApiException`) → `XxxServiceImpl` (`ApiUtil.process(api.call(..., network.queryValue()))`) → Jackson models → registered on `BackendService`/`BackendServiceImpl`. Tests use MockWebServer asserting the exact request path/query and JSON→model mapping.
+
+**Tech Stack:** Java 17, Maven, Retrofit 2.11 + converter-jackson, Jackson 2.18, Lombok, OkHttp 4.12, JUnit 5.11, okhttp3 mockwebserver.
+
+## Global Constraints
+
+- Java **17** (`maven.compiler.release=17`) — retarget from 21. Version **1.0.4 → 1.1.0**.
+- Package root `adlabs.nexus.client.backend.api.`; new domains `metadata`, `script`.
+- Every service method takes `adlabs.nexus.client.util.Network` and `throws adlabs.nexus.client.backend.api.base.exception.ApiException`, returns `adlabs.nexus.client.backend.api.base.Result`.
+- Impls delegate via `adlabs.nexus.client.backend.api.base.ApiUtil.process(Call)`; `network` sent as `@Query("network")` = `network.queryValue()`.
+- Models: mirror the annotations of an existing model file (e.g. `.../transaction/model/Transaction.java` — Lombok + `@JsonIgnoreProperties(ignoreUnknown = true)`); JSON payload fields typed `com.fasterxml.jackson.databind.JsonNode`; metadatum `label` is `String`. Wire names are camelCase (server DTOs use no snake_case override on these fields) — confirm via the MockWebServer round-trip.
+- Tests: JUnit 5, `mvn -Dtest= test`. Build via `mvn -B clean test` (JDK 17). Mirror `src/test/java/adlabs/nexus/client/backend/api/transaction/TransactionServiceTest.java` (MockWebServer, assert `req.getPath()` + field mapping).
+- Maven Central: `io.github.gero-labs:nexus-java-client`. Credentialed release is a MANUAL human step; the build only produces the signed, sources+javadoc bundle. No secrets in the repo.
+
+---
+
+## File structure
+
+**Create:**
+- `src/main/java/adlabs/nexus/client/backend/api/metadata/model/{TxMetadataJson,TxMetadataCbor,MetadataLabel,LabelMetadataJson,LabelMetadataCbor}.java`
+- `src/main/java/adlabs/nexus/client/backend/api/metadata/{MetadataApi,MetadataService}.java`
+- `src/main/java/adlabs/nexus/client/backend/api/metadata/impl/MetadataServiceImpl.java`
+- `src/main/java/adlabs/nexus/client/backend/api/script/model/{ScriptDetail,Datum}.java`
+- `src/main/java/adlabs/nexus/client/backend/api/script/{ScriptApi,ScriptService}.java`
+- `src/main/java/adlabs/nexus/client/backend/api/script/impl/ScriptServiceImpl.java`
+- `src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataServiceTest.java`
+- `src/test/java/adlabs/nexus/client/backend/api/script/ScriptServiceTest.java`
+- `LICENSE` (Task 6)
+
+**Modify:**
+- `src/main/java/adlabs/nexus/client/backend/factory/BackendService.java` (2 getters)
+- `src/main/java/adlabs/nexus/client/backend/factory/impl/BackendServiceImpl.java` (2 fields + ctor + getters)
+- `src/test/java/adlabs/nexus/client/backend/factory/BackendServiceFactoryTest.java` (assert new getters)
+- `pom.xml` (Java 17, version, Central publish profile)
+- `.github/workflows/build.yml` (JDK 17), `.github/workflows/publish.yml` (Central)
+- `README.md` (release runbook)
+
+---
+
+### Task 1: Metadata models
+
+**Files:**
+- Create the 5 metadata model classes.
+- Test: `src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataModelMappingTest.java`
+
+**Interfaces:**
+- Produces: `TxMetadataJson{String label; JsonNode json}`, `TxMetadataCbor{String label; String cbor}`, `MetadataLabel{String label; String cip10; Long count}`, `LabelMetadataJson{String txHash; JsonNode json}`, `LabelMetadataCbor{String txHash; String cbor}`. Getters as generated by the model annotation style you mirror.
+
+- [ ] **Step 1: Read an existing model for the exact annotation style**
+
+Read `src/main/java/adlabs/nexus/client/backend/api/transaction/model/Transaction.java`. Note its Lombok annotations and `@JsonIgnoreProperties(ignoreUnknown = true)`. Use the IDENTICAL annotation set on the new models. (Do not invent a different style.)
+
+- [ ] **Step 2: Write the failing mapping test**
+
+```java
+package adlabs.nexus.client.backend.api.metadata;
+
+import adlabs.nexus.client.backend.api.metadata.model.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.*;
+
+class MetadataModelMappingTest {
+ private final ObjectMapper om = new ObjectMapper();
+
+ @Test
+ void labelMetadataJson_mapsCamelCase() throws Exception {
+ LabelMetadataJson d = om.readValue(
+ "{\"txHash\":\"abc\",\"json\":{\"msg\":[\"hi\"]}}", LabelMetadataJson.class);
+ assertEquals("abc", d.getTxHash());
+ assertEquals("hi", d.getJson().get("msg").get(0).asText());
+ }
+
+ @Test
+ void metadataLabel_mapsAllFields() throws Exception {
+ MetadataLabel d = om.readValue(
+ "{\"label\":\"674\",\"cip10\":\"CIP-20\",\"count\":\"5\"}", MetadataLabel.class);
+ assertEquals("674", d.getLabel());
+ assertEquals("CIP-20", d.getCip10());
+ assertEquals(Long.valueOf(5), d.getCount());
+ }
+}
+```
+
+- [ ] **Step 3: Run to verify fail** — `mvn -Dtest=MetadataModelMappingTest test` → FAIL (classes missing).
+
+- [ ] **Step 4: Create the 5 models** mirroring `Transaction.java`'s annotation style. Example:
+
+```java
+package adlabs.nexus.client.backend.api.metadata.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.Data; // match Transaction.java — adjust if it uses @Getter/@NoArgsConstructor etc.
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@Data
+public class LabelMetadataJson {
+ private String txHash;
+ private JsonNode json;
+}
+```
+
+Others: `TxMetadataJson{String label; JsonNode json}`, `TxMetadataCbor{String label; String cbor}`, `MetadataLabel{String label; String cip10; Long count}`, `LabelMetadataCbor{String txHash; String cbor}`.
+
+- [ ] **Step 5: Run to verify pass** — `mvn -Dtest=MetadataModelMappingTest test` → PASS.
+
+- [ ] **Step 6: Commit**
+
+```bash
+git add src/main/java/adlabs/nexus/client/backend/api/metadata/model src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataModelMappingTest.java
+git commit -m "feat: metadata models"
+```
+
+---
+
+### Task 2: MetadataService vertical
+
+**Files:**
+- Create `metadata/MetadataApi.java`, `metadata/MetadataService.java`, `metadata/impl/MetadataServiceImpl.java`.
+- Test: `src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataServiceTest.java`
+
+**Interfaces:**
+- Consumes: Task 1 models; `ApiUtil.process`, `Result`, `Network`, `RetrofitClient`.
+- Produces: `MetadataService` with the 5 methods (see Global Constraints signatures), constructed as `new MetadataServiceImpl(Retrofit)`.
+
+- [ ] **Step 1: Write the failing MockWebServer test** (mirror `TransactionServiceTest` structure — MockWebServer in `@BeforeEach`, `RetrofitClient.build(server.url("/").toString(), "key", Duration.ofSeconds(5), Duration.ofSeconds(5))`):
+
+```java
+@Test
+void getTxMetadata_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"label\":\"674\",\"json\":{\"msg\":[\"hi\"]}}]"));
+ Result> r = service.getTxMetadata(Network.MAINNET, "tx1");
+ assertTrue(r.isSuccessful());
+ assertEquals("674", r.getValue().get(0).getLabel());
+ assertEquals("hi", r.getValue().get(0).getJson().get("msg").get(0).asText());
+ assertEquals("/api/transactions/tx1/metadata?network=cardano-mainnet", server.takeRequest().getPath());
+}
+
+@Test
+void getMetadataByLabel_hitsPath_withPagination() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"txHash\":\"abc\",\"json\":{\"k\":\"v\"}}]"));
+ Result> r = service.getMetadataByLabel(Network.MAINNET, "674", 2, 50);
+ assertTrue(r.isSuccessful());
+ assertEquals("abc", r.getValue().get(0).getTxHash());
+ assertEquals("/api/metadata/txs/labels/674?network=cardano-mainnet&page=2&pageSize=50",
+ server.takeRequest().getPath());
+}
+
+@Test
+void getTxMetadata_nonSuccess_returnsError() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(503).setBody("nope"));
+ Result> r = service.getTxMetadata(Network.MAINNET, "tx1");
+ assertFalse(r.isSuccessful());
+ assertEquals(503, r.getCode());
+}
+```
+
+Add analogous path-assertion tests for `getTxMetadataCbor` (`/api/transactions/tx1/metadata/cbor?network=cardano-mainnet`), `getMetadataLabels` (`/api/metadata/txs/labels?network=cardano-mainnet&page=1&pageSize=100`), and `getMetadataCborByLabel` (`/api/metadata/txs/labels/674/cbor?network=cardano-mainnet&page=1&pageSize=100`). Note: verify the actual query-param ordering Retrofit emits and match the assertion to it (path params before query; `@Query` order as declared).
+
+- [ ] **Step 2: Run to verify fail** — `mvn -Dtest=MetadataServiceTest test` → FAIL.
+
+- [ ] **Step 3: Create `MetadataApi`** (exact endpoints from the spec):
+
+```java
+package adlabs.nexus.client.backend.api.metadata;
+
+import adlabs.nexus.client.backend.api.metadata.model.*;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Path;
+import retrofit2.http.Query;
+import java.util.List;
+
+public interface MetadataApi {
+ @GET("api/transactions/{txHash}/metadata")
+ Call> getTxMetadata(@Path("txHash") String txHash, @Query("network") String network);
+
+ @GET("api/transactions/{txHash}/metadata/cbor")
+ Call> getTxMetadataCbor(@Path("txHash") String txHash, @Query("network") String network);
+
+ @GET("api/metadata/txs/labels")
+ Call> getMetadataLabels(@Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+
+ @GET("api/metadata/txs/labels/{label}")
+ Call> getMetadataByLabel(@Path("label") String label, @Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+
+ @GET("api/metadata/txs/labels/{label}/cbor")
+ Call> getMetadataCborByLabel(@Path("label") String label, @Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+}
+```
+
+- [ ] **Step 4: Create `MetadataService`** — the 5 methods per Global Constraints (Network + throws ApiException, Result>). Add javadoc noting `cip10`/`count` are best-effort (may be null) and by-label may 5xx on networks without a label provider (surfaces as `Result.error`).
+
+- [ ] **Step 5: Create `MetadataServiceImpl`** (mirror `TransactionServiceImpl`):
+
+```java
+package adlabs.nexus.client.backend.api.metadata.impl;
+// imports...
+public class MetadataServiceImpl implements MetadataService {
+ private final MetadataApi api;
+ public MetadataServiceImpl(Retrofit retrofit) { this.api = retrofit.create(MetadataApi.class); }
+
+ @Override public Result> getTxMetadata(Network n, String txHash) throws ApiException {
+ return ApiUtil.process(api.getTxMetadata(txHash, n.queryValue()));
+ }
+ @Override public Result> getTxMetadataCbor(Network n, String txHash) throws ApiException {
+ return ApiUtil.process(api.getTxMetadataCbor(txHash, n.queryValue()));
+ }
+ @Override public Result> getMetadataLabels(Network n, int page, int pageSize) throws ApiException {
+ return ApiUtil.process(api.getMetadataLabels(n.queryValue(), page, pageSize));
+ }
+ @Override public Result> getMetadataByLabel(Network n, String label, int page, int pageSize) throws ApiException {
+ return ApiUtil.process(api.getMetadataByLabel(label, n.queryValue(), page, pageSize));
+ }
+ @Override public Result> getMetadataCborByLabel(Network n, String label, int page, int pageSize) throws ApiException {
+ return ApiUtil.process(api.getMetadataCborByLabel(label, n.queryValue(), page, pageSize));
+ }
+}
+```
+
+- [ ] **Step 6: Run to verify pass** — `mvn -Dtest=MetadataServiceTest test` → PASS (all path + mapping + error assertions).
+
+- [ ] **Step 7: Commit** `feat: MetadataService vertical`.
+
+---
+
+### Task 3: ScriptService vertical (models + service)
+
+**Files:**
+- Create `script/model/{ScriptDetail,Datum}.java`, `script/ScriptApi.java`, `script/ScriptService.java`, `script/impl/ScriptServiceImpl.java`.
+- Test: `src/test/java/adlabs/nexus/client/backend/api/script/ScriptServiceTest.java`
+
+**Interfaces:**
+- Produces: `ScriptDetail{String hash; String type; String cbor; Integer size; JsonNode json}`, `Datum{String hash; String cbor; JsonNode json}`; `ScriptService.getScriptByHash(Network, String)->Result`, `getDatumByHash(Network, String)->Result`.
+
+- [ ] **Step 1: Write the failing MockWebServer test**
+
+```java
+@Test
+void getScriptByHash_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "{\"hash\":\"h1\",\"type\":\"plutusV2\",\"cbor\":\"49...\",\"size\":12}"));
+ Result r = service.getScriptByHash(Network.MAINNET, "h1");
+ assertTrue(r.isSuccessful());
+ assertEquals("plutusV2", r.getValue().getType());
+ assertEquals(Integer.valueOf(12), r.getValue().getSize());
+ assertEquals("/api/scripts/h1?network=cardano-mainnet", server.takeRequest().getPath());
+}
+
+@Test
+void getDatumByHash_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "{\"hash\":\"d1\",\"cbor\":\"a1...\",\"json\":{\"int\":5}}"));
+ Result r = service.getDatumByHash(Network.MAINNET, "d1");
+ assertTrue(r.isSuccessful());
+ assertEquals("a1...", r.getValue().getCbor());
+ assertEquals(5, r.getValue().getJson().get("int").asInt());
+ assertEquals("/api/scripts/datum/d1?network=cardano-mainnet", server.takeRequest().getPath());
+}
+
+@Test
+void getScriptByHash_notFound_returnsError() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404).setBody("no"));
+ Result r = service.getScriptByHash(Network.MAINNET, "h1");
+ assertFalse(r.isSuccessful());
+ assertEquals(404, r.getCode());
+}
+```
+
+- [ ] **Step 2: Run to verify fail** — `mvn -Dtest=ScriptServiceTest test` → FAIL.
+
+- [ ] **Step 3: Create the 2 models** (mirror `Transaction.java` annotation style; `ScriptDetail{hash,type,cbor,size(Integer),json(JsonNode)}`, `Datum{hash,cbor,json(JsonNode)}`).
+
+- [ ] **Step 4: Create `ScriptApi`**
+
+```java
+public interface ScriptApi {
+ @GET("api/scripts/{scriptHash}")
+ Call getScriptByHash(@Path("scriptHash") String scriptHash, @Query("network") String network);
+
+ @GET("api/scripts/datum/{datumHash}")
+ Call getDatumByHash(@Path("datumHash") String datumHash, @Query("network") String network);
+}
+```
+
+- [ ] **Step 5: Create `ScriptService` + `ScriptServiceImpl`** (mirror the metadata impl: `ApiUtil.process(api.getScriptByHash(scriptHash, n.queryValue()))`, etc.).
+
+- [ ] **Step 6: Run to verify pass** — `mvn -Dtest=ScriptServiceTest test` → PASS.
+
+- [ ] **Step 7: Commit** `feat: ScriptService vertical`.
+
+---
+
+### Task 4: BackendService wiring
+
+**Files:**
+- Modify `factory/BackendService.java`, `factory/impl/BackendServiceImpl.java`.
+- Test: `src/test/java/adlabs/nexus/client/backend/factory/BackendServiceFactoryTest.java`
+
+**Interfaces:**
+- Consumes: `MetadataService`/`MetadataServiceImpl` (Task 2), `ScriptService`/`ScriptServiceImpl` (Task 3).
+- Produces: `BackendService.getMetadataService()`, `BackendService.getScriptService()`.
+
+- [ ] **Step 1: Extend the failing factory test** — add to `BackendServiceFactoryTest`:
+
+```java
+@Test
+void factory_wiresMetadataAndScriptServices() {
+ BackendService svc = BackendServiceFactory.getNexusBackendService("http://localhost:1", "key");
+ assertNotNull(svc.getMetadataService());
+ assertNotNull(svc.getScriptService());
+}
+```
+
+(Match how the existing factory test constructs the service — read the file first; use its existing helper/URL style.)
+
+- [ ] **Step 2: Run to verify fail** — `mvn -Dtest=BackendServiceFactoryTest test` → FAIL (getters missing).
+
+- [ ] **Step 3: Add getters to `BackendService`** — `MetadataService getMetadataService();` and `ScriptService getScriptService();` (with imports).
+
+- [ ] **Step 4: Wire `BackendServiceImpl`** — add two fields, construct in the ctor (`this.metadataService = new MetadataServiceImpl(retrofit); this.scriptService = new ScriptServiceImpl(retrofit);`), implement the two getters.
+
+- [ ] **Step 5: Run to verify pass** — `mvn -Dtest=BackendServiceFactoryTest test` → PASS.
+
+- [ ] **Step 6: Commit** `feat: wire metadata + script services into BackendService`.
+
+---
+
+### Task 5: Java 17 retarget
+
+**Files:**
+- Modify `pom.xml` (compiler release + version), `.github/workflows/build.yml` (JDK 17).
+
+**Interfaces:** none new.
+
+- [ ] **Step 1: Scan for Java-18+ usage** — grep the source for anything newer than 17 (e.g. `SequencedCollection`, unnamed patterns, string templates). The codebase is plain Retrofit/Jackson/Lombok; expect none. Report what you searched.
+
+- [ ] **Step 2: Edit `pom.xml`** — `17` (was 21); `1.1.0` (was 1.0.4).
+
+- [ ] **Step 3: Edit `build.yml`** — `java-version: '17'` (was '21').
+
+- [ ] **Step 4: Full build + test under JDK 17**
+
+Run: `mvn -B clean test` (ensure JDK 17 is the active toolchain — `java -version` should be 17; if the environment defaults to 21, set `JAVA_HOME` to a 17 JDK). Expected: BUILD SUCCESS, all tests (existing + new) green. If a 21-only API surfaced, replace it with a 17 equivalent and note it.
+
+- [ ] **Step 5: Commit** `build: retarget to Java 17, bump to 1.1.0`.
+
+---
+
+### Task 6: Maven Central publish config + LICENSE + CI + README
+
+**Files:**
+- Create `LICENSE`.
+- Modify `pom.xml` (Central publishing in a `release` profile; POM metadata; remove GH-Packages distributionManagement).
+- Modify `.github/workflows/publish.yml` (Central deploy).
+- Modify `README.md` (release runbook).
+
+**Interfaces:** none new. **Prerequisite decision:** the license (see Step 1).
+
+- [ ] **Step 1: Add `LICENSE`** — use the license the user chose (default **Apache-2.0** unless told otherwise). Write the full license text to `LICENSE` and note the SPDX id for the POM. If the user hasn't confirmed, STOP and ask before proceeding — the license value is baked into the published POM and is hard to change post-release.
+
+- [ ] **Step 2: Verify the current Sonatype Central plugin** — confirm the current `org.sonatype.central:central-publishing-maven-plugin` version (check central.sonatype.org docs or Maven Central). Do NOT hardcode a guessed version — use the actual latest stable.
+
+- [ ] **Step 3: Edit `pom.xml`** —
+ - Remove the GitHub-Packages ``.
+ - Add POM metadata Central requires: ``, `` (already present), `https://github.com/Gero-Labs/nexus-java-client`, `` (the chosen license + SPDX url), `` (Gero-Labs), `` (connection/developerConnection/url for the GitHub repo).
+ - Add a `release` profile containing: `central-publishing-maven-plugin` (from Step 2, `central`), `maven-source-plugin` (attach-sources), `maven-javadoc-plugin` (attach-javadocs), `maven-gpg-plugin` (sign). Keep normal `test`/`package` builds free of GPG (profile-gated) so CI + local dev don't need a key.
+
+- [ ] **Step 4: Verify the bundle build (no secrets)** —
+
+Run: `mvn -Prelease -DskipTests -Dgpg.skip=true package`
+Expected: builds a main jar + `-sources.jar` + `-javadoc.jar` under `target/`. (GPG signing + the actual Central upload require the user's key/token and are the manual release step — do NOT attempt them here.) Confirm the three jars exist.
+
+- [ ] **Step 5: Edit `publish.yml`** — replace the GitHub-Packages deploy with the Central flow: `setup-java` with `server-id: central` + `MAVEN_USERNAME`/`MAVEN_PASSWORD` from `secrets.CENTRAL_TOKEN_USERNAME`/`CENTRAL_TOKEN_PASSWORD`, import the GPG key from `secrets.GPG_PRIVATE_KEY` + `secrets.GPG_PASSPHRASE`, and run `mvn -B -Prelease deploy -Dmaven.test.skip=true`. Add a comment that these secrets must be configured by a maintainer for the tag-triggered publish to work; JDK `17`.
+
+- [ ] **Step 6: README release runbook** — document: Maven Central coordinates (`io.github.gero-labs:nexus-java-client:1.1.0`), the one-time Sonatype namespace verification + `~/.m2/settings.xml` `` token entry, the GPG key requirement, `mvn -Prelease deploy`, and the Central Portal "publish" confirmation. Update the install snippet from GitHub Packages to plain Maven Central (drop the `` block).
+
+- [ ] **Step 7: Commit** `build: publish to Maven Central (config only; credentialed release is manual)`.
+
+---
+
+### Task 7: Final build + branch verification
+
+**Files:** none new.
+
+- [ ] **Step 1: Clean full build + all tests under JDK 17** — `mvn -B clean test` → BUILD SUCCESS, every test green (metadata 5-method + error, script 2-method + error, model mapping, factory wiring, plus all pre-existing SDK tests). Confirm no regression in the existing service tests.
+- [ ] **Step 2: Bundle sanity** — `mvn -Prelease -DskipTests -Dgpg.skip=true package` produces main+sources+javadoc jars. Confirm.
+- [ ] **Step 3: Push the branch** — `git push -u origin feat/metadata-script-java17`. (PR + the credentialed Central release are the human's steps.)
+
+---
+
+## Self-review
+
+**Spec coverage:** MetadataService 5 methods → Tasks 1-2; ScriptService 2 → Task 3; BackendService wiring → Task 4; Java 17 retarget + version bump → Task 5; Maven Central config + POM metadata + LICENSE + publish.yml + README → Task 6; models mirror server DTOs field-exact → Tasks 1/3 (with round-trip tests); testing (MockWebServer path+mapping+error, factory wiring) → Tasks 2/3/4; final verification → Task 7.
+
+**Placeholder scan:** no TBD/TODO. Two deliberate verify-then-act steps (Task 6 Step 2 plugin version; Task 5 Step 1 Java-21 scan) are concrete instructions, not placeholders. The license value is an explicit prerequisite decision surfaced in Task 6 Step 1 with a stop-and-ask guard (it can't be defaulted silently — it's baked into the published POM).
+
+**Type consistency:** model field names/types identical across Tasks 1/3 and their consumers (2/3/4); `MetadataServiceImpl`/`ScriptServiceImpl` signatures match the `MetadataService`/`ScriptService` interfaces; `getMetadataService()`/`getScriptService()` names consistent Tasks 4 uses. `Network`/`Result`/`ApiUtil`/`ApiException` names verbatim from the existing SDK.
diff --git a/docs/superpowers/specs/2026-08-07-nexus-java-client-metadata-script-design.md b/docs/superpowers/specs/2026-08-07-nexus-java-client-metadata-script-design.md
new file mode 100644
index 0000000..3ac570d
--- /dev/null
+++ b/docs/superpowers/specs/2026-08-07-nexus-java-client-metadata-script-design.md
@@ -0,0 +1,175 @@
+# nexus-java-client — MetadataService + ScriptService + Java 17 + Maven Central (Design)
+
+Date: 2026-08-07
+Status: Approved design — ready for implementation plan
+Layer: 2 of 3. Upstream: Nexus server metadata endpoints (L1, PR Gero-Labs/nexus#772). Downstream: `cardano-client-lib` `backend-modules/nexus` (L3).
+
+## Why
+
+The `cardano-client-lib` Nexus backend module (L3) wraps this SDK to implement bloxbean's
+`BackendService`. Two of bloxbean's sub-services — `MetadataService` and `ScriptService` —
+have no counterpart in this SDK yet. L1 added the server endpoints they need (metadata) and
+the server already served scripts/datums. This layer adds the two SDK service verticals so
+L3 has full coverage, retargets the SDK to Java 17 (cardano-client-lib's baseline — L3 must
+consume this jar on JDK 17), and publishes to Maven Central (so L3's Gradle build resolves it
+without GitHub-Packages auth).
+
+## Scope
+
+- Add `MetadataService` (5 methods) + `ScriptService` (2 methods), each a full vertical
+ (`XxxApi` Retrofit interface → `XxxService` → `XxxServiceImpl` → models), wired into
+ `BackendService` + `BackendServiceImpl`.
+- Retarget `maven.compiler.release` 21 → 17. Version bump 1.0.4 → 1.1.0.
+- Replace GitHub-Packages publishing with Maven Central publishing config (signed bundle;
+ the credentialed release is a manual human step).
+
+Out of scope: Utxo/NetworkInfo work (SDK already exposes Network + tx/address utxos that L3
+synthesizes from); any server change; the L3 module itself.
+
+## Pattern (established, mirror exactly)
+
+Every existing SDK service follows this shape (reference: `transaction` vertical):
+- `adlabs.nexus.client.backend.api..Api` — Retrofit interface, `@GET("api/...")`,
+ path via `@Path`, `network` via `@Query("network")`, returns `Call`.
+- `Service` — public interface, methods take `Network` + throw `ApiException`, return
+ `Result`.
+- `impl.ServiceImpl(Retrofit)` — `api = retrofit.create(Api.class)`; each method
+ `return ApiUtil.process(api.call(, network.queryValue()));`.
+- `model.*` — Jackson POJOs (Lombok), `@JsonProperty` only where the wire name differs from the
+ Java field.
+- Registered in `factory.BackendService` (getter) + `factory.impl.BackendServiceImpl` (field +
+ constructor `new ServiceImpl(retrofit)` + getter).
+
+`Network.queryValue()` yields e.g. `cardano-mainnet`; the server binds that to its own
+`Network` enum (same mechanism the existing tx endpoints already use). `ApiUtil.process` maps
+2xx→`Result.success`, non-2xx→`Result.error(code, body)`, `IOException`→`ApiException`.
+
+## MetadataService
+
+Package `adlabs.nexus.client.backend.api.metadata`.
+
+```java
+public interface MetadataService {
+ Result> getTxMetadata(Network network, String txHash) throws ApiException;
+ Result> getTxMetadataCbor(Network network, String txHash) throws ApiException;
+ Result> getMetadataLabels(Network network, int page, int pageSize) throws ApiException;
+ Result> getMetadataByLabel(Network network, String label, int page, int pageSize) throws ApiException;
+ Result> getMetadataCborByLabel(Network network, String label, int page, int pageSize) throws ApiException;
+}
+```
+
+`MetadataApi` (Retrofit):
+
+```java
+@GET("api/transactions/{txHash}/metadata")
+Call> getTxMetadata(@Path("txHash") String txHash, @Query("network") String network);
+
+@GET("api/transactions/{txHash}/metadata/cbor")
+Call> getTxMetadataCbor(@Path("txHash") String txHash, @Query("network") String network);
+
+@GET("api/metadata/txs/labels")
+Call> getMetadataLabels(@Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+
+@GET("api/metadata/txs/labels/{label}")
+Call> getMetadataByLabel(@Path("label") String label, @Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+
+@GET("api/metadata/txs/labels/{label}/cbor")
+Call> getMetadataCborByLabel(@Path("label") String label, @Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+```
+
+Models (mirror the L1 server DTOs field-exact; camelCase wire names, no snake_case overrides):
+- `TxMetadataJson{ String label; JsonNode json; }`
+- `TxMetadataCbor{ String label; String cbor; }`
+- `MetadataLabel{ String label; String cip10; Long count; }`
+- `LabelMetadataJson{ String txHash; JsonNode json; }`
+- `LabelMetadataCbor{ String txHash; String cbor; }`
+
+`label` is `String` end-to-end (uint64 metadatum labels). `json` is `com.fasterxml.jackson.databind.JsonNode`.
+
+Behavioral notes to carry into javadoc (from L1): `cip10`/`count` are best-effort (populated
+only when Blockfrost serves; may be null). by-label on preview networks yields a 5xx (no
+provider) → surfaces as `Result.error` — document, don't special-case.
+
+## ScriptService
+
+Package `adlabs.nexus.client.backend.api.script`.
+
+```java
+public interface ScriptService {
+ Result getScriptByHash(Network network, String scriptHash) throws ApiException;
+ Result getDatumByHash(Network network, String datumHash) throws ApiException;
+}
+```
+
+`ScriptApi`:
+```java
+@GET("api/scripts/{scriptHash}")
+Call getScriptByHash(@Path("scriptHash") String scriptHash, @Query("network") String network);
+
+@GET("api/scripts/datum/{datumHash}")
+Call getDatumByHash(@Path("datumHash") String datumHash, @Query("network") String network);
+```
+
+Models (mirror server `ScriptDetailDto` / `DatumDto`):
+- `ScriptDetail{ String hash; String type; String cbor; Integer size; JsonNode json; }`
+ (`type` ∈ `plutusV1|plutusV2|plutusV3|native`; `cbor` for Plutus, `json` for native).
+- `Datum{ String hash; String cbor; JsonNode json; }`
+
+## BackendService wiring
+
+- `factory.BackendService`: add `MetadataService getMetadataService();` and
+ `ScriptService getScriptService();`.
+- `factory.impl.BackendServiceImpl`: add two fields, construct in the ctor
+ (`new MetadataServiceImpl(retrofit)`, `new ScriptServiceImpl(retrofit)`), add getters.
+
+## Java 17 retarget
+
+- `pom.xml`: `17` (was 21).
+- Verify no Java-18+ API/syntax is used anywhere (the codebase is plain Retrofit + Jackson +
+ Lombok — low risk; confirm by a clean `mvn -DskipTests package` under JDK 17 and a scan for
+ any 21-only usage). If anything 21-only surfaces, replace with a 17-compatible equivalent.
+- Version 1.0.4 → 1.1.0 (additive features).
+
+## Maven Central publishing config
+
+Replace the GitHub-Packages `distributionManagement` with Central Portal publishing:
+- `central-publishing-maven-plugin` (Sonatype Central Portal) as the deploy plugin.
+- `maven-gpg-plugin` — sign artifacts (activated by a release profile).
+- `maven-source-plugin` + `maven-javadoc-plugin` — attach `-sources` and `-javadoc` jars
+ (Central requires both).
+- POM metadata Central requires: ``, ``, ``, ``,
+ ``, ``.
+- Credentials are NOT in the repo: the Central token goes in the user's `~/.m2/settings.xml`
+ `` entry; the GPG key + passphrase are the user's. **The signed-bundle build is
+ automated; the authenticated release to Central is a documented manual step.**
+
+Document the release runbook in the repo README (namespace `io.github.gero-labs`, the
+`settings.xml` server id, GPG key requirement, `mvn -Prelease deploy`, and the Central Portal
+"publish" confirmation).
+
+## Testing
+
+Mirror `TransactionServiceTest`: per-method MockWebServer tests that (a) enqueue a canned JSON
+body and (b) assert the exact request path + query string AND the JSON→model mapping.
+- `MetadataServiceTest`: 5 methods — assert paths `/api/transactions/{tx}/metadata`,
+ `/metadata/cbor`, `/api/metadata/txs/labels?...`, `/labels/{label}`, `/labels/{label}/cbor`,
+ each with `network=cardano-mainnet` + pagination query where applicable; assert list mapping
+ (label/json/cbor/txHash/cip10/count fields).
+- `ScriptServiceTest`: 2 methods — assert `/api/scripts/{hash}`, `/api/scripts/datum/{hash}`;
+ assert `ScriptDetail`/`Datum` field mapping incl. `JsonNode json`.
+- `BackendServiceFactoryTest` (extend existing): assert `getMetadataService()` /
+ `getScriptService()` return non-null wired instances.
+- Empty-body / non-2xx cases: assert `Result.isSuccessful()==false` + code propagation for at
+ least one method per service.
+
+## Open items for the plan
+
+1. Confirm the metadata DTO wire field names against the L1 branch (`Gero-Labs/nexus#772`):
+ camelCase `label/json/cbor/txHash/cip10/count` expected — pin via a MockWebServer round-trip.
+2. Confirm `central-publishing-maven-plugin` is the current Sonatype-recommended path (vs the
+ legacy `nexus-staging-maven-plugin`) and its exact coordinates/version at plan time.
+3. Decide the license value for the POM (match whatever `LICENSE` the repo already carries).
+4. Confirm JDK 17 is available in the build/CI environment for the retarget verification.
diff --git a/pom.xml b/pom.xml
index 95f07a8..e87065e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,14 +6,35 @@
io.github.gero-labs
nexus-java-client
- 1.0.4
+ 1.1.0
jar
nexus-java-client
Java client for the Nexus Cardano data API
+ https://github.com/Gero-Labs/nexus-java-client
+
+
+
+ The Apache License, Version 2.0
+ https://www.apache.org/licenses/LICENSE-2.0.txt
+
+
+
+
+
+ gero-labs
+ Gero Labs
+
+
+
+
+ scm:git:https://github.com/Gero-Labs/nexus-java-client.git
+ scm:git:ssh://git@github.com/Gero-Labs/nexus-java-client.git
+ https://github.com/Gero-Labs/nexus-java-client
+
- 21
+ 17
UTF-8
2.11.0
2.18.2
@@ -84,6 +105,15 @@
org.apache.maven.plugins
maven-compiler-plugin
3.13.0
+
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+
+
+
org.apache.maven.plugins
@@ -108,11 +138,58 @@
-
-
- github
- GitHub Packages
- https://maven.pkg.github.com/Gero-Labs/nexus-java-client
-
-
+
+
+
+ release
+
+
+
+ org.sonatype.central
+ central-publishing-maven-plugin
+ 0.11.0
+ true
+
+ central
+ false
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.4.0
+
+
+ attach-sources
+ jar-no-fork
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 3.12.0
+
+
+ attach-javadocs
+ jar
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 3.2.8
+
+
+ sign-artifacts
+ verify
+ sign
+
+
+
+
+
+
+
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/MetadataApi.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/MetadataApi.java
new file mode 100644
index 0000000..d5dc99c
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/MetadataApi.java
@@ -0,0 +1,32 @@
+package adlabs.nexus.client.backend.api.metadata;
+
+import adlabs.nexus.client.backend.api.metadata.model.*;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Path;
+import retrofit2.http.Query;
+
+import java.util.List;
+
+public interface MetadataApi {
+
+ @GET("api/transactions/{txHash}/metadata")
+ Call> getTxMetadata(@Path("txHash") String txHash,
+ @Query("network") String network);
+
+ @GET("api/transactions/{txHash}/metadata/cbor")
+ Call> getTxMetadataCbor(@Path("txHash") String txHash,
+ @Query("network") String network);
+
+ @GET("api/metadata/txs/labels")
+ Call> getMetadataLabels(@Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+
+ @GET("api/metadata/txs/labels/{label}")
+ Call> getMetadataByLabel(@Path("label") String label, @Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+
+ @GET("api/metadata/txs/labels/{label}/cbor")
+ Call> getMetadataCborByLabel(@Path("label") String label, @Query("network") String network,
+ @Query("page") int page, @Query("pageSize") int pageSize);
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/MetadataService.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/MetadataService.java
new file mode 100644
index 0000000..6f88c8c
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/MetadataService.java
@@ -0,0 +1,32 @@
+package adlabs.nexus.client.backend.api.metadata;
+
+import adlabs.nexus.client.backend.api.base.Result;
+import adlabs.nexus.client.backend.api.base.exception.ApiException;
+import adlabs.nexus.client.backend.api.metadata.model.*;
+import adlabs.nexus.client.util.Network;
+
+import java.util.List;
+
+/** Cardano transaction metadata endpoints. */
+public interface MetadataService {
+
+ Result> getTxMetadata(Network network, String txHash) throws ApiException;
+
+ Result> getTxMetadataCbor(Network network, String txHash) throws ApiException;
+
+ /**
+ * Lists known metadata labels. {@code cip10}/{@code count} are best-effort and may be null
+ * depending on the underlying provider.
+ */
+ Result> getMetadataLabels(Network network, int page, int pageSize) throws ApiException;
+
+ /**
+ * Looks up metadata by label. May return {@link Result#error} (5xx) on networks whose
+ * provider doesn't support label indexing.
+ */
+ Result> getMetadataByLabel(Network network, String label, int page, int pageSize)
+ throws ApiException;
+
+ Result> getMetadataCborByLabel(Network network, String label, int page, int pageSize)
+ throws ApiException;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/impl/MetadataServiceImpl.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/impl/MetadataServiceImpl.java
new file mode 100644
index 0000000..6a02e27
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/impl/MetadataServiceImpl.java
@@ -0,0 +1,49 @@
+package adlabs.nexus.client.backend.api.metadata.impl;
+
+import adlabs.nexus.client.backend.api.base.ApiUtil;
+import adlabs.nexus.client.backend.api.base.Result;
+import adlabs.nexus.client.backend.api.base.exception.ApiException;
+import adlabs.nexus.client.backend.api.metadata.MetadataApi;
+import adlabs.nexus.client.backend.api.metadata.MetadataService;
+import adlabs.nexus.client.backend.api.metadata.model.*;
+import adlabs.nexus.client.util.Network;
+import retrofit2.Retrofit;
+
+import java.util.List;
+
+public class MetadataServiceImpl implements MetadataService {
+
+ private final MetadataApi api;
+
+ public MetadataServiceImpl(Retrofit retrofit) {
+ this.api = retrofit.create(MetadataApi.class);
+ }
+
+ @Override
+ public Result> getTxMetadata(Network network, String txHash) throws ApiException {
+ return ApiUtil.process(api.getTxMetadata(txHash, network.queryValue()));
+ }
+
+ @Override
+ public Result> getTxMetadataCbor(Network network, String txHash) throws ApiException {
+ return ApiUtil.process(api.getTxMetadataCbor(txHash, network.queryValue()));
+ }
+
+ @Override
+ public Result> getMetadataLabels(Network network, int page, int pageSize)
+ throws ApiException {
+ return ApiUtil.process(api.getMetadataLabels(network.queryValue(), page, pageSize));
+ }
+
+ @Override
+ public Result> getMetadataByLabel(Network network, String label, int page, int pageSize)
+ throws ApiException {
+ return ApiUtil.process(api.getMetadataByLabel(label, network.queryValue(), page, pageSize));
+ }
+
+ @Override
+ public Result> getMetadataCborByLabel(Network network, String label, int page,
+ int pageSize) throws ApiException {
+ return ApiUtil.process(api.getMetadataCborByLabel(label, network.queryValue(), page, pageSize));
+ }
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/model/LabelMetadataCbor.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/LabelMetadataCbor.java
new file mode 100644
index 0000000..f6ea208
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/LabelMetadataCbor.java
@@ -0,0 +1,14 @@
+package adlabs.nexus.client.backend.api.metadata.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class LabelMetadataCbor {
+ private String txHash;
+ private String cbor;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/model/LabelMetadataJson.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/LabelMetadataJson.java
new file mode 100644
index 0000000..cf4c0c2
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/LabelMetadataJson.java
@@ -0,0 +1,15 @@
+package adlabs.nexus.client.backend.api.metadata.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class LabelMetadataJson {
+ private String txHash;
+ private JsonNode json;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/model/MetadataLabel.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/MetadataLabel.java
new file mode 100644
index 0000000..0585d07
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/MetadataLabel.java
@@ -0,0 +1,15 @@
+package adlabs.nexus.client.backend.api.metadata.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class MetadataLabel {
+ private String label;
+ private String cip10;
+ private Long count;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/model/TxMetadataCbor.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/TxMetadataCbor.java
new file mode 100644
index 0000000..529b89a
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/TxMetadataCbor.java
@@ -0,0 +1,14 @@
+package adlabs.nexus.client.backend.api.metadata.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class TxMetadataCbor {
+ private String label;
+ private String cbor;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/metadata/model/TxMetadataJson.java b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/TxMetadataJson.java
new file mode 100644
index 0000000..c07f493
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/metadata/model/TxMetadataJson.java
@@ -0,0 +1,15 @@
+package adlabs.nexus.client.backend.api.metadata.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class TxMetadataJson {
+ private String label;
+ private JsonNode json;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/script/ScriptApi.java b/src/main/java/adlabs/nexus/client/backend/api/script/ScriptApi.java
new file mode 100644
index 0000000..df8fa02
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/script/ScriptApi.java
@@ -0,0 +1,16 @@
+package adlabs.nexus.client.backend.api.script;
+
+import adlabs.nexus.client.backend.api.script.model.*;
+import retrofit2.Call;
+import retrofit2.http.GET;
+import retrofit2.http.Path;
+import retrofit2.http.Query;
+
+public interface ScriptApi {
+
+ @GET("api/scripts/{scriptHash}")
+ Call getScriptByHash(@Path("scriptHash") String scriptHash, @Query("network") String network);
+
+ @GET("api/scripts/datum/{datumHash}")
+ Call getDatumByHash(@Path("datumHash") String datumHash, @Query("network") String network);
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/script/ScriptService.java b/src/main/java/adlabs/nexus/client/backend/api/script/ScriptService.java
new file mode 100644
index 0000000..69b80ce
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/script/ScriptService.java
@@ -0,0 +1,14 @@
+package adlabs.nexus.client.backend.api.script;
+
+import adlabs.nexus.client.backend.api.base.Result;
+import adlabs.nexus.client.backend.api.base.exception.ApiException;
+import adlabs.nexus.client.backend.api.script.model.*;
+import adlabs.nexus.client.util.Network;
+
+/** Cardano Plutus/native script and datum lookup endpoints. */
+public interface ScriptService {
+
+ Result getScriptByHash(Network network, String scriptHash) throws ApiException;
+
+ Result getDatumByHash(Network network, String datumHash) throws ApiException;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/script/impl/ScriptServiceImpl.java b/src/main/java/adlabs/nexus/client/backend/api/script/impl/ScriptServiceImpl.java
new file mode 100644
index 0000000..5ea8aa3
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/script/impl/ScriptServiceImpl.java
@@ -0,0 +1,29 @@
+package adlabs.nexus.client.backend.api.script.impl;
+
+import adlabs.nexus.client.backend.api.base.ApiUtil;
+import adlabs.nexus.client.backend.api.base.Result;
+import adlabs.nexus.client.backend.api.base.exception.ApiException;
+import adlabs.nexus.client.backend.api.script.ScriptApi;
+import adlabs.nexus.client.backend.api.script.ScriptService;
+import adlabs.nexus.client.backend.api.script.model.*;
+import adlabs.nexus.client.util.Network;
+import retrofit2.Retrofit;
+
+public class ScriptServiceImpl implements ScriptService {
+
+ private final ScriptApi api;
+
+ public ScriptServiceImpl(Retrofit retrofit) {
+ this.api = retrofit.create(ScriptApi.class);
+ }
+
+ @Override
+ public Result getScriptByHash(Network network, String scriptHash) throws ApiException {
+ return ApiUtil.process(api.getScriptByHash(scriptHash, network.queryValue()));
+ }
+
+ @Override
+ public Result getDatumByHash(Network network, String datumHash) throws ApiException {
+ return ApiUtil.process(api.getDatumByHash(datumHash, network.queryValue()));
+ }
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/script/model/Datum.java b/src/main/java/adlabs/nexus/client/backend/api/script/model/Datum.java
new file mode 100644
index 0000000..44174a8
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/script/model/Datum.java
@@ -0,0 +1,16 @@
+package adlabs.nexus.client.backend.api.script.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Datum {
+ private String hash;
+ private String cbor;
+ private JsonNode json;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/api/script/model/ScriptDetail.java b/src/main/java/adlabs/nexus/client/backend/api/script/model/ScriptDetail.java
new file mode 100644
index 0000000..53b7188
--- /dev/null
+++ b/src/main/java/adlabs/nexus/client/backend/api/script/model/ScriptDetail.java
@@ -0,0 +1,18 @@
+package adlabs.nexus.client.backend.api.script.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.*;
+
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ScriptDetail {
+ private String hash;
+ private String type;
+ private String cbor;
+ private Integer size;
+ private JsonNode json;
+}
diff --git a/src/main/java/adlabs/nexus/client/backend/factory/BackendService.java b/src/main/java/adlabs/nexus/client/backend/factory/BackendService.java
index 159b2b4..8c862f8 100644
--- a/src/main/java/adlabs/nexus/client/backend/factory/BackendService.java
+++ b/src/main/java/adlabs/nexus/client/backend/factory/BackendService.java
@@ -6,8 +6,10 @@
import adlabs.nexus.client.backend.api.block.BlockService;
import adlabs.nexus.client.backend.api.epoch.EpochService;
import adlabs.nexus.client.backend.api.marketdata.MarketDataService;
+import adlabs.nexus.client.backend.api.metadata.MetadataService;
import adlabs.nexus.client.backend.api.network.NetworkService;
import adlabs.nexus.client.backend.api.pool.PoolService;
+import adlabs.nexus.client.backend.api.script.ScriptService;
import adlabs.nexus.client.backend.api.transaction.TransactionService;
/** Entry point — exposes every Nexus Cardano resource service. */
@@ -25,9 +27,13 @@ public interface BackendService {
MarketDataService getMarketDataService();
+ MetadataService getMetadataService();
+
NetworkService getNetworkService();
PoolService getPoolService();
+ ScriptService getScriptService();
+
TransactionService getTransactionService();
}
diff --git a/src/main/java/adlabs/nexus/client/backend/factory/impl/BackendServiceImpl.java b/src/main/java/adlabs/nexus/client/backend/factory/impl/BackendServiceImpl.java
index db52552..7651bc7 100644
--- a/src/main/java/adlabs/nexus/client/backend/factory/impl/BackendServiceImpl.java
+++ b/src/main/java/adlabs/nexus/client/backend/factory/impl/BackendServiceImpl.java
@@ -12,10 +12,14 @@
import adlabs.nexus.client.backend.api.epoch.impl.EpochServiceImpl;
import adlabs.nexus.client.backend.api.marketdata.MarketDataService;
import adlabs.nexus.client.backend.api.marketdata.impl.MarketDataServiceImpl;
+import adlabs.nexus.client.backend.api.metadata.MetadataService;
+import adlabs.nexus.client.backend.api.metadata.impl.MetadataServiceImpl;
import adlabs.nexus.client.backend.api.network.NetworkService;
import adlabs.nexus.client.backend.api.network.impl.NetworkServiceImpl;
import adlabs.nexus.client.backend.api.pool.PoolService;
import adlabs.nexus.client.backend.api.pool.impl.PoolServiceImpl;
+import adlabs.nexus.client.backend.api.script.ScriptService;
+import adlabs.nexus.client.backend.api.script.impl.ScriptServiceImpl;
import adlabs.nexus.client.backend.api.transaction.TransactionService;
import adlabs.nexus.client.backend.api.transaction.impl.TransactionServiceImpl;
import adlabs.nexus.client.backend.factory.BackendService;
@@ -29,8 +33,10 @@ public class BackendServiceImpl implements BackendService {
private final BlockService blockService;
private final EpochService epochService;
private final MarketDataService marketDataService;
+ private final MetadataService metadataService;
private final NetworkService networkService;
private final PoolService poolService;
+ private final ScriptService scriptService;
private final TransactionService transactionService;
public BackendServiceImpl(Retrofit retrofit) {
@@ -40,8 +46,10 @@ public BackendServiceImpl(Retrofit retrofit) {
this.blockService = new BlockServiceImpl(retrofit);
this.epochService = new EpochServiceImpl(retrofit);
this.marketDataService = new MarketDataServiceImpl(retrofit);
+ this.metadataService = new MetadataServiceImpl(retrofit);
this.networkService = new NetworkServiceImpl(retrofit);
this.poolService = new PoolServiceImpl(retrofit);
+ this.scriptService = new ScriptServiceImpl(retrofit);
this.transactionService = new TransactionServiceImpl(retrofit);
}
@@ -75,6 +83,11 @@ public MarketDataService getMarketDataService() {
return marketDataService;
}
+ @Override
+ public MetadataService getMetadataService() {
+ return metadataService;
+ }
+
@Override
public NetworkService getNetworkService() {
return networkService;
@@ -85,6 +98,11 @@ public PoolService getPoolService() {
return poolService;
}
+ @Override
+ public ScriptService getScriptService() {
+ return scriptService;
+ }
+
@Override
public TransactionService getTransactionService() {
return transactionService;
diff --git a/src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataModelMappingTest.java b/src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataModelMappingTest.java
new file mode 100644
index 0000000..7f3a517
--- /dev/null
+++ b/src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataModelMappingTest.java
@@ -0,0 +1,52 @@
+package adlabs.nexus.client.backend.api.metadata;
+
+import adlabs.nexus.client.backend.api.metadata.model.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class MetadataModelMappingTest {
+ private final ObjectMapper om = new ObjectMapper();
+
+ @Test
+ void labelMetadataJson_mapsCamelCase() throws Exception {
+ LabelMetadataJson d = om.readValue(
+ "{\"txHash\":\"abc\",\"json\":{\"msg\":[\"hi\"]}}", LabelMetadataJson.class);
+ assertEquals("abc", d.getTxHash());
+ assertEquals("hi", d.getJson().get("msg").get(0).asText());
+ }
+
+ @Test
+ void metadataLabel_mapsAllFields() throws Exception {
+ MetadataLabel d = om.readValue(
+ "{\"label\":\"674\",\"cip10\":\"CIP-20\",\"count\":\"5\"}", MetadataLabel.class);
+ assertEquals("674", d.getLabel());
+ assertEquals("CIP-20", d.getCip10());
+ assertEquals(Long.valueOf(5), d.getCount());
+ }
+
+ @Test
+ void txMetadataJson_mapsCamelCase() throws Exception {
+ TxMetadataJson d = om.readValue(
+ "{\"label\":\"123\",\"json\":{\"data\":\"test\"}}", TxMetadataJson.class);
+ assertEquals("123", d.getLabel());
+ assertEquals("test", d.getJson().get("data").asText());
+ }
+
+ @Test
+ void txMetadataCbor_mapsCamelCase() throws Exception {
+ TxMetadataCbor d = om.readValue(
+ "{\"label\":\"456\",\"cbor\":\"d8799f\"}", TxMetadataCbor.class);
+ assertEquals("456", d.getLabel());
+ assertEquals("d8799f", d.getCbor());
+ }
+
+ @Test
+ void labelMetadataCbor_mapsCamelCase() throws Exception {
+ LabelMetadataCbor d = om.readValue(
+ "{\"txHash\":\"def\",\"cbor\":\"a1\"}", LabelMetadataCbor.class);
+ assertEquals("def", d.getTxHash());
+ assertEquals("a1", d.getCbor());
+ }
+}
diff --git a/src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataServiceTest.java b/src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataServiceTest.java
new file mode 100644
index 0000000..b455d0e
--- /dev/null
+++ b/src/test/java/adlabs/nexus/client/backend/api/metadata/MetadataServiceTest.java
@@ -0,0 +1,109 @@
+package adlabs.nexus.client.backend.api.metadata;
+
+import adlabs.nexus.client.backend.api.base.Result;
+import adlabs.nexus.client.backend.api.metadata.impl.MetadataServiceImpl;
+import adlabs.nexus.client.backend.api.metadata.model.LabelMetadataCbor;
+import adlabs.nexus.client.backend.api.metadata.model.LabelMetadataJson;
+import adlabs.nexus.client.backend.api.metadata.model.MetadataLabel;
+import adlabs.nexus.client.backend.api.metadata.model.TxMetadataCbor;
+import adlabs.nexus.client.backend.api.metadata.model.TxMetadataJson;
+import adlabs.nexus.client.http.RetrofitClient;
+import adlabs.nexus.client.util.Network;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import okhttp3.mockwebserver.RecordedRequest;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class MetadataServiceTest {
+
+ private MockWebServer server;
+ private MetadataService service;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ server = new MockWebServer();
+ server.start();
+ service = new MetadataServiceImpl(RetrofitClient.build(
+ server.url("/").toString(), "key", Duration.ofSeconds(5), Duration.ofSeconds(5)));
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ server.shutdown();
+ }
+
+ @Test
+ void getTxMetadata_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"label\":\"674\",\"json\":{\"msg\":[\"hi\"]}}]"));
+ Result> r = service.getTxMetadata(Network.MAINNET, "tx1");
+ assertTrue(r.isSuccessful());
+ assertEquals("674", r.getValue().get(0).getLabel());
+ assertEquals("hi", r.getValue().get(0).getJson().get("msg").get(0).asText());
+ assertEquals("/api/transactions/tx1/metadata?network=cardano-mainnet", server.takeRequest().getPath());
+ }
+
+ @Test
+ void getTxMetadataCbor_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"label\":\"674\",\"cbor\":\"a100\"}]"));
+ Result> r = service.getTxMetadataCbor(Network.MAINNET, "tx1");
+ assertTrue(r.isSuccessful());
+ assertEquals("674", r.getValue().get(0).getLabel());
+ assertEquals("a100", r.getValue().get(0).getCbor());
+ RecordedRequest req = server.takeRequest();
+ assertEquals("/api/transactions/tx1/metadata/cbor?network=cardano-mainnet", req.getPath());
+ }
+
+ @Test
+ void getMetadataLabels_hitsPath_withPagination_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"label\":\"674\",\"cip10\":\"msg\",\"count\":42}]"));
+ Result> r = service.getMetadataLabels(Network.MAINNET, 1, 100);
+ assertTrue(r.isSuccessful());
+ assertEquals("674", r.getValue().get(0).getLabel());
+ assertEquals("msg", r.getValue().get(0).getCip10());
+ assertEquals(Long.valueOf(42), r.getValue().get(0).getCount());
+ RecordedRequest req = server.takeRequest();
+ assertEquals("/api/metadata/txs/labels?network=cardano-mainnet&page=1&pageSize=100", req.getPath());
+ }
+
+ @Test
+ void getMetadataByLabel_hitsPath_withPagination() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"txHash\":\"abc\",\"json\":{\"k\":\"v\"}}]"));
+ Result> r = service.getMetadataByLabel(Network.MAINNET, "674", 2, 50);
+ assertTrue(r.isSuccessful());
+ assertEquals("abc", r.getValue().get(0).getTxHash());
+ assertEquals("/api/metadata/txs/labels/674?network=cardano-mainnet&page=2&pageSize=50",
+ server.takeRequest().getPath());
+ }
+
+ @Test
+ void getMetadataCborByLabel_hitsPath_withPagination_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "[{\"txHash\":\"abc\",\"cbor\":\"a100\"}]"));
+ Result> r = service.getMetadataCborByLabel(Network.MAINNET, "674", 1, 100);
+ assertTrue(r.isSuccessful());
+ assertEquals("abc", r.getValue().get(0).getTxHash());
+ assertEquals("a100", r.getValue().get(0).getCbor());
+ RecordedRequest req = server.takeRequest();
+ assertEquals("/api/metadata/txs/labels/674/cbor?network=cardano-mainnet&page=1&pageSize=100",
+ req.getPath());
+ }
+
+ @Test
+ void getTxMetadata_nonSuccess_returnsError() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(503).setBody("nope"));
+ Result> r = service.getTxMetadata(Network.MAINNET, "tx1");
+ assertFalse(r.isSuccessful());
+ assertEquals(503, r.getCode());
+ }
+}
diff --git a/src/test/java/adlabs/nexus/client/backend/api/script/ScriptServiceTest.java b/src/test/java/adlabs/nexus/client/backend/api/script/ScriptServiceTest.java
new file mode 100644
index 0000000..eaeae10
--- /dev/null
+++ b/src/test/java/adlabs/nexus/client/backend/api/script/ScriptServiceTest.java
@@ -0,0 +1,66 @@
+package adlabs.nexus.client.backend.api.script;
+
+import adlabs.nexus.client.backend.api.base.Result;
+import adlabs.nexus.client.backend.api.script.impl.ScriptServiceImpl;
+import adlabs.nexus.client.backend.api.script.model.Datum;
+import adlabs.nexus.client.backend.api.script.model.ScriptDetail;
+import adlabs.nexus.client.http.RetrofitClient;
+import adlabs.nexus.client.util.Network;
+import okhttp3.mockwebserver.MockResponse;
+import okhttp3.mockwebserver.MockWebServer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class ScriptServiceTest {
+
+ private MockWebServer server;
+ private ScriptService service;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ server = new MockWebServer();
+ server.start();
+ service = new ScriptServiceImpl(RetrofitClient.build(
+ server.url("/").toString(), "key", Duration.ofSeconds(5), Duration.ofSeconds(5)));
+ }
+
+ @AfterEach
+ void tearDown() throws Exception {
+ server.shutdown();
+ }
+
+ @Test
+ void getScriptByHash_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "{\"hash\":\"h1\",\"type\":\"plutusV2\",\"cbor\":\"49...\",\"size\":12}"));
+ Result r = service.getScriptByHash(Network.MAINNET, "h1");
+ assertTrue(r.isSuccessful());
+ assertEquals("plutusV2", r.getValue().getType());
+ assertEquals(Integer.valueOf(12), r.getValue().getSize());
+ assertEquals("/api/scripts/h1?network=cardano-mainnet", server.takeRequest().getPath());
+ }
+
+ @Test
+ void getDatumByHash_hitsPath_andMaps() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(200).setBody(
+ "{\"hash\":\"d1\",\"cbor\":\"a1...\",\"json\":{\"int\":5}}"));
+ Result r = service.getDatumByHash(Network.MAINNET, "d1");
+ assertTrue(r.isSuccessful());
+ assertEquals("a1...", r.getValue().getCbor());
+ assertEquals(5, r.getValue().getJson().get("int").asInt());
+ assertEquals("/api/scripts/datum/d1?network=cardano-mainnet", server.takeRequest().getPath());
+ }
+
+ @Test
+ void getScriptByHash_notFound_returnsError() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404).setBody("no"));
+ Result r = service.getScriptByHash(Network.MAINNET, "h1");
+ assertFalse(r.isSuccessful());
+ assertEquals(404, r.getCode());
+ }
+}
diff --git a/src/test/java/adlabs/nexus/client/backend/factory/BackendServiceFactoryTest.java b/src/test/java/adlabs/nexus/client/backend/factory/BackendServiceFactoryTest.java
index e722c68..a6ae2b5 100644
--- a/src/test/java/adlabs/nexus/client/backend/factory/BackendServiceFactoryTest.java
+++ b/src/test/java/adlabs/nexus/client/backend/factory/BackendServiceFactoryTest.java
@@ -46,4 +46,12 @@ void factory_buildsWorkingBackendService() throws Exception {
assertTrue(result.isSuccessful());
assertEquals("blk1", result.getValue().getHash());
}
+
+ @Test
+ void factory_wiresMetadataAndScriptServices() {
+ BackendService svc = BackendServiceFactory.getNexusBackendService(
+ server.url("/").toString(), "key");
+ assertNotNull(svc.getMetadataService());
+ assertNotNull(svc.getScriptService());
+ }
}