Skip to content

Commit c2e5bf1

Browse files
edridudidudiedri
andauthored
Add optional parameters to TransactionsService for enhanced flexibility (#189)
Introduced optional parameters to `getTransactionInformation` methods, allowing fine-grained control over returned transaction details such as inputs, metadata, assets, withdrawals, certificates, scripts, and bytecode. Updated default implementations and related documentation to reflect these changes, and incremented version to 1.21.1. Co-authored-by: dudiedri <dudi.edri@ox.security>
1 parent 3d7b4d6 commit c2e5bf1

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca
408408

409409
| Koios Instance | Koios Java Client |
410410
|:--------------:|:-----------------:|
411-
| 1.3.2 | 1.21.0 |
411+
| 1.3.2 | 1.21.1 |
412412
| 1.3.0 | 1.20.1 |
413413
| 1.2.0 | 1.19.3 |
414414
| 1.1.2 | 1.18.2 |
@@ -428,13 +428,13 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca
428428
<dependency>
429429
<groupId>io.github.cardano-community</groupId>
430430
<artifactId>koios-java-client</artifactId>
431-
<version>1.21.0</version>
431+
<version>1.21.1</version>
432432
</dependency>
433433
```
434434

435435
- For Gradle, add the following dependency to build.gradle
436436
```
437-
compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.21.0'
437+
compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.21.1'
438438
```
439439

440440
### Get Koios Backend Service (No API Token)

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>io.github.cardano-community</groupId>
77
<artifactId>koios-java-client</artifactId>
8-
<version>1.21.0</version>
8+
<version>1.21.1</version>
99
<name>${project.groupId}:${project.artifactId}</name>
1010
<description>Koios Java Client is a Java REST Client library which allows interacting with Koios Server Instances using Java Objects</description>
1111
<url>https://github.com/cardano-community/koios-java-client</url>

src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ public interface TransactionsService {
4040
*/
4141
Result<List<RawTx>> getRawTransaction(List<String> txHashes, Options options) throws ApiException;
4242

43+
default Result<TxInfo> getTransactionInformation(String txHash) throws ApiException {
44+
return getTransactionInformation(txHash, true, true, true, true, true, true, true);
45+
}
46+
47+
default Result<List<TxInfo>> getTransactionInformation(List<String> txHashes, Options options) throws ApiException {
48+
return getTransactionInformation(txHashes, true, true, true, true, true, true, true, options);
49+
}
50+
4351
/**
4452
* Transaction Information for Specific Transaction
4553
* Get detailed information about transaction
@@ -51,7 +59,7 @@ public interface TransactionsService {
5159
* @return Result of Type List of {@link TxInfo} detailed information about transaction(s)
5260
* @throws ApiException if an error occurs while attempting to invoke the API
5361
*/
54-
Result<TxInfo> getTransactionInformation(String txHash) throws ApiException;
62+
Result<TxInfo> getTransactionInformation(String txHash, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode) throws ApiException;
5563

5664
/**
5765
* Transaction Information
@@ -65,7 +73,7 @@ public interface TransactionsService {
6573
* @return Result of Type List of {@link TxInfo} detailed information about transaction(s)
6674
* @throws ApiException if an error occurs while attempting to invoke the API
6775
*/
68-
Result<List<TxInfo>> getTransactionInformation(List<String> txHashes, Options options) throws ApiException;
76+
Result<List<TxInfo>> getTransactionInformation(List<String> txHashes, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode, Options options) throws ApiException;
6977

7078
/**
7179
* Transaction Metadata

src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ public Result<List<RawTx>> getRawTransaction(List<String> txHashes, Options opti
5151
}
5252

5353
@Override
54-
public Result<TxInfo> getTransactionInformation(String txHash) throws ApiException {
54+
public Result<TxInfo> getTransactionInformation(String txHash, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode) throws ApiException {
5555
validateHexFormat(txHash);
56-
Call<List<TxInfo>> call = transactionApi.getTransactionInformation(buildTxInfoBody(List.of(txHash)), Collections.emptyMap());
56+
Call<List<TxInfo>> call = transactionApi.getTransactionInformation(buildTxInfoBody(List.of(txHash), isInputs, isMetadata, isAssets, isWithdrawals, isCertificates, isScripts, isByteCode), Collections.emptyMap());
5757
return processResponseGetOne(call);
5858
}
5959

6060
@Override
61-
public Result<List<TxInfo>> getTransactionInformation(List<String> txHashes, Options options) throws ApiException {
61+
public Result<List<TxInfo>> getTransactionInformation(List<String> txHashes, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode, Options options) throws ApiException {
6262
for (String tx : txHashes) {
6363
validateHexFormat(tx);
6464
}
65-
Call<List<TxInfo>> call = transactionApi.getTransactionInformation(buildTxInfoBody(txHashes), optionsToParamMap(options));
65+
Call<List<TxInfo>> call = transactionApi.getTransactionInformation(buildTxInfoBody(txHashes, isInputs, isMetadata, isAssets, isWithdrawals, isCertificates, isScripts, isByteCode), optionsToParamMap(options));
6666
return processResponse(call);
6767
}
6868

@@ -97,16 +97,16 @@ public Result<List<TxStatus>> getTransactionStatus(List<String> txHashes, Option
9797
return processResponse(call);
9898
}
9999

100-
private Map<String, Object> buildTxInfoBody(List<String> txHashes) {
100+
private Map<String, Object> buildTxInfoBody(List<String> txHashes, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode) {
101101
Map<String, Object> bodyMap = new HashMap<>();
102102
bodyMap.put("_tx_hashes", txHashes);
103-
bodyMap.put("_inputs", true);
104-
bodyMap.put("_metadata", true);
105-
bodyMap.put("_assets", true);
106-
bodyMap.put("_withdrawals", true);
107-
bodyMap.put("_certs", true);
108-
bodyMap.put("_scripts", true);
109-
bodyMap.put("_bytecode", true);
103+
bodyMap.put("_inputs", isInputs);
104+
bodyMap.put("_metadata", isMetadata);
105+
bodyMap.put("_assets", isAssets);
106+
bodyMap.put("_withdrawals", isWithdrawals);
107+
bodyMap.put("_certs", isCertificates);
108+
bodyMap.put("_scripts", isScripts);
109+
bodyMap.put("_bytecode", isByteCode);
110110
return bodyMap;
111111
}
112112

0 commit comments

Comments
 (0)