Skip to content

Commit f04f9d7

Browse files
Remove none existent endpoints
Signed-off-by: Ndacyayisenga-droid <[email protected]>
1 parent 882fd3c commit f04f9d7

File tree

9 files changed

+62
-252
lines changed

9 files changed

+62
-252
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.openelements.hiero.base.data;
2+
3+
import java.util.List;
4+
import java.util.Objects;
5+
6+
/**
7+
* Basic {@link Page} implementation backed by an in-memory list.
8+
*
9+
* @param <T> element type for the page
10+
*/
11+
public final class SinglePage<T> implements Page<T> {
12+
13+
private final List<T> data;
14+
15+
public SinglePage(final List<T> data) {
16+
this.data = List.copyOf(Objects.requireNonNull(data, "data must not be null"));
17+
}
18+
19+
@Override
20+
public int getPageIndex() {
21+
return 0;
22+
}
23+
24+
@Override
25+
public int getSize() {
26+
return data.size();
27+
}
28+
29+
@Override
30+
public List<T> getData() {
31+
return data;
32+
}
33+
34+
@Override
35+
public boolean hasNext() {
36+
return false;
37+
}
38+
39+
@Override
40+
public Page<T> next() {
41+
throw new IllegalStateException("No next page");
42+
}
43+
44+
@Override
45+
public Page<T> first() {
46+
return this;
47+
}
48+
49+
@Override
50+
public boolean isFirst() {
51+
return true;
52+
}
53+
}
54+

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/implementation/AbstractMirrorNodeClient.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,24 +121,4 @@ public final Optional<TopicMessage> queryTopicMessageBySequenceNumber(TopicId to
121121
return getJsonConverter().toContract(json);
122122
}
123123

124-
@Override
125-
public @NonNull Page<Contract> queryContractsByEvmAddress(@NonNull final String evmAddress) throws HieroException {
126-
Objects.requireNonNull(evmAddress, "evmAddress must not be null");
127-
final JSON json = getRestClient().queryContractsByEvmAddress(evmAddress);
128-
return getJsonConverter().toContractPage(json);
129-
}
130-
131-
@Override
132-
public @NonNull Page<Contract> queryContractsByFileId(@NonNull final String fileId) throws HieroException {
133-
Objects.requireNonNull(fileId, "fileId must not be null");
134-
final JSON json = getRestClient().queryContractsByFileId(fileId);
135-
return getJsonConverter().toContractPage(json);
136-
}
137-
138-
@Override
139-
public @NonNull Page<Contract> queryContractsByProxyAccountId(@NonNull final String proxyAccountId) throws HieroException {
140-
Objects.requireNonNull(proxyAccountId, "proxyAccountId must not be null");
141-
final JSON json = getRestClient().queryContractsByProxyAccountId(proxyAccountId);
142-
return getJsonConverter().toContractPage(json);
143-
}
144124
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/implementation/ContractRepositoryImpl.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,4 @@ public Page<Contract> findAll() throws HieroException {
3737
public Optional<Contract> findById(@NonNull final ContractId contractId) throws HieroException {
3838
return mirrorNodeClient.queryContractById(contractId);
3939
}
40-
41-
@NonNull
42-
@Override
43-
public Page<Contract> findByEvmAddress(@NonNull final String evmAddress) throws HieroException {
44-
return mirrorNodeClient.queryContractsByEvmAddress(evmAddress);
45-
}
46-
47-
@NonNull
48-
@Override
49-
public Page<Contract> findByFileId(@NonNull final String fileId) throws HieroException {
50-
return mirrorNodeClient.queryContractsByFileId(fileId);
51-
}
52-
53-
@NonNull
54-
@Override
55-
public Page<Contract> findByProxyAccountId(@NonNull final String proxyAccountId) throws HieroException {
56-
return mirrorNodeClient.queryContractsByProxyAccountId(proxyAccountId);
57-
}
5840
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/implementation/MirrorNodeRestClient.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,4 @@ default JSON queryContractById(@NonNull final ContractId contractId) throws Hier
8080
Objects.requireNonNull(contractId, "contractId must not be null");
8181
return doGetCall("/api/v1/contracts/" + contractId);
8282
}
83-
84-
@NonNull
85-
default JSON queryContractsByEvmAddress(@NonNull final String evmAddress) throws HieroException {
86-
Objects.requireNonNull(evmAddress, "evmAddress must not be null");
87-
return doGetCall("/api/v1/contracts?evm.address=" + evmAddress);
88-
}
89-
90-
@NonNull
91-
default JSON queryContractsByFileId(@NonNull final String fileId) throws HieroException {
92-
Objects.requireNonNull(fileId, "fileId must not be null");
93-
return doGetCall("/api/v1/contracts?file.id=" + fileId);
94-
}
95-
96-
@NonNull
97-
default JSON queryContractsByProxyAccountId(@NonNull final String proxyAccountId) throws HieroException {
98-
Objects.requireNonNull(proxyAccountId, "proxyAccountId must not be null");
99-
return doGetCall("/api/v1/contracts?proxy.account.id=" + proxyAccountId);
100-
}
10183
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/mirrornode/ContractRepository.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,33 +45,4 @@ default Optional<Contract> findById(@NonNull String contractId) throws HieroExce
4545
return findById(ContractId.fromString(contractId));
4646
}
4747

48-
/**
49-
* Return contracts by EVM address.
50-
*
51-
* @param evmAddress the EVM address of the contract
52-
* @return first page of contracts
53-
* @throws HieroException if the search fails
54-
*/
55-
@NonNull
56-
Page<Contract> findByEvmAddress(@NonNull String evmAddress) throws HieroException;
57-
58-
/**
59-
* Return contracts by file ID.
60-
*
61-
* @param fileId the file ID associated with the contract
62-
* @return first page of contracts
63-
* @throws HieroException if the search fails
64-
*/
65-
@NonNull
66-
Page<Contract> findByFileId(@NonNull String fileId) throws HieroException;
67-
68-
/**
69-
* Return contracts by proxy account ID.
70-
*
71-
* @param proxyAccountId the proxy account ID
72-
* @return first page of contracts
73-
* @throws HieroException if the search fails
74-
*/
75-
@NonNull
76-
Page<Contract> findByProxyAccountId(@NonNull String proxyAccountId) throws HieroException;
7748
}

hiero-enterprise-base/src/main/java/com/openelements/hiero/base/mirrornode/MirrorNodeClient.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -494,33 +494,4 @@ default Optional<Contract> queryContractById(@NonNull String contractId) throws
494494
return queryContractById(ContractId.fromString(contractId));
495495
}
496496

497-
/**
498-
* Queries contracts by EVM address.
499-
*
500-
* @param evmAddress the EVM address
501-
* @return the contracts
502-
* @throws HieroException if an error occurs
503-
*/
504-
@NonNull
505-
Page<Contract> queryContractsByEvmAddress(@NonNull String evmAddress) throws HieroException;
506-
507-
/**
508-
* Queries contracts by file ID.
509-
*
510-
* @param fileId the file ID
511-
* @return the contracts
512-
* @throws HieroException if an error occurs
513-
*/
514-
@NonNull
515-
Page<Contract> queryContractsByFileId(@NonNull String fileId) throws HieroException;
516-
517-
/**
518-
* Queries contracts by proxy account ID.
519-
*
520-
* @param proxyAccountId the proxy account ID
521-
* @return the contracts
522-
* @throws HieroException if an error occurs
523-
*/
524-
@NonNull
525-
Page<Contract> queryContractsByProxyAccountId(@NonNull String proxyAccountId) throws HieroException;
526497
}

hiero-enterprise-microprofile/src/main/java/com/openelements/hiero/microprofile/implementation/MirrorNodeJsonConverterImpl.java

Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.openelements.hiero.base.data.NetworkSupplies;
1818
import com.openelements.hiero.base.data.Nft;
1919
import com.openelements.hiero.base.data.Page;
20+
import com.openelements.hiero.base.data.SinglePage;
2021
import com.openelements.hiero.base.data.TransactionInfo;
2122
import com.openelements.hiero.base.data.Token;
2223
import com.openelements.hiero.base.data.TokenInfo;
@@ -678,12 +679,12 @@ private Optional<Balance> toBalance(JsonObject jsonObject) {
678679
public @NonNull Page<Contract> toContractPage(@NonNull JsonObject jsonObject) {
679680
Objects.requireNonNull(jsonObject, "jsonObject must not be null");
680681
if (jsonObject.isEmpty()) {
681-
return new SimplePage<>(List.of());
682+
return new SinglePage<>(List.of());
682683
}
683684

684685
try {
685686
final List<Contract> contracts = toContracts(jsonObject);
686-
return new SimplePage<>(contracts);
687+
return new SinglePage<>(contracts);
687688
} catch (final Exception e) {
688689
throw new IllegalStateException("Can not parse JSON: " + jsonObject, e);
689690
}
@@ -697,9 +698,9 @@ private Optional<Balance> toBalance(JsonObject jsonObject) {
697698
}
698699
final JsonArray contractsArray = jsonObject.getJsonArray("contracts");
699700
if (contractsArray == null) {
700-
throw new IllegalArgumentException("Contracts array is not an array: " + contractsArray);
701+
throw new IllegalArgumentException("No contracts array in JSON");
701702
}
702-
Spliterator<JsonValue> spliterator = Spliterators.spliteratorUnknownSize(contractsArray.iterator(),
703+
final Spliterator<JsonValue> spliterator = Spliterators.spliteratorUnknownSize(contractsArray.iterator(),
703704
Spliterator.ORDERED);
704705
return StreamSupport.stream(spliterator, false)
705706
.map(n -> toContract(n.asJsonObject()))
@@ -708,48 +709,4 @@ private Optional<Balance> toBalance(JsonObject jsonObject) {
708709
.toList();
709710
}
710711

711-
// Simple Page implementation for converter methods
712-
private static class SimplePage<T> implements Page<T> {
713-
private final List<T> data;
714-
715-
public SimplePage(List<T> data) {
716-
this.data = data;
717-
}
718-
719-
@Override
720-
public int getPageIndex() {
721-
return 0;
722-
}
723-
724-
@Override
725-
public int getSize() {
726-
return data.size();
727-
}
728-
729-
@Override
730-
public List<T> getData() {
731-
return data;
732-
}
733-
734-
@Override
735-
public boolean hasNext() {
736-
return false;
737-
}
738-
739-
@Override
740-
public Page<T> next() {
741-
throw new IllegalStateException("No next page");
742-
}
743-
744-
@Override
745-
public Page<T> first() {
746-
return this;
747-
}
748-
749-
@Override
750-
public boolean isFirst() {
751-
return true;
752-
}
753-
}
754712
}
755-

hiero-enterprise-spring/src/main/java/com/openelements/hiero/spring/implementation/MirrorNodeJsonConverterImpl.java

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.openelements.hiero.base.data.NetworkSupplies;
1919
import com.openelements.hiero.base.data.Nft;
2020
import com.openelements.hiero.base.data.Page;
21+
import com.openelements.hiero.base.data.SinglePage;
2122
import com.openelements.hiero.base.data.TransactionInfo;
2223
import com.openelements.hiero.base.data.Token;
2324
import com.openelements.hiero.base.data.TokenInfo;
@@ -46,13 +47,9 @@
4647
import java.util.stream.Stream;
4748
import java.util.stream.StreamSupport;
4849
import org.jspecify.annotations.NonNull;
49-
import org.slf4j.Logger;
50-
import org.slf4j.LoggerFactory;
5150

5251
public class MirrorNodeJsonConverterImpl implements MirrorNodeJsonConverter<JsonNode> {
5352

54-
private static final Logger log = LoggerFactory.getLogger(MirrorNodeJsonConverterImpl.class);
55-
5653
@Override
5754
public Optional<Nft> toNft(final JsonNode node) {
5855
Objects.requireNonNull(node, "jsonNode must not be null");
@@ -694,12 +691,12 @@ private Stream<JsonNode> jsonArrayToStream(@NonNull final JsonNode node) {
694691
public @NonNull Page<Contract> toContractPage(@NonNull JsonNode node) {
695692
Objects.requireNonNull(node, "jsonNode must not be null");
696693
if (node.isNull() || node.isEmpty()) {
697-
return new SimplePage<>(List.of());
694+
return new SinglePage<>(List.of());
698695
}
699696

700697
try {
701698
final List<Contract> contracts = toContracts(node);
702-
return new SimplePage<>(contracts);
699+
return new SinglePage<>(contracts);
703700
} catch (final Exception e) {
704701
throw new JsonParseException(node, e);
705702
}
@@ -724,47 +721,4 @@ private Stream<JsonNode> jsonArrayToStream(@NonNull final JsonNode node) {
724721
.toList();
725722
}
726723

727-
// Simple Page implementation for converter methods
728-
private static class SimplePage<T> implements Page<T> {
729-
private final List<T> data;
730-
731-
public SimplePage(List<T> data) {
732-
this.data = data;
733-
}
734-
735-
@Override
736-
public int getPageIndex() {
737-
return 0;
738-
}
739-
740-
@Override
741-
public int getSize() {
742-
return data.size();
743-
}
744-
745-
@Override
746-
public List<T> getData() {
747-
return data;
748-
}
749-
750-
@Override
751-
public boolean hasNext() {
752-
return false;
753-
}
754-
755-
@Override
756-
public Page<T> next() {
757-
throw new IllegalStateException("No next page");
758-
}
759-
760-
@Override
761-
public Page<T> first() {
762-
return this;
763-
}
764-
765-
@Override
766-
public boolean isFirst() {
767-
return true;
768-
}
769-
}
770724
}

0 commit comments

Comments
 (0)