From 2f6d323430079e2d8c874e4b3606c2c783a18eda Mon Sep 17 00:00:00 2001 From: dudiedri Date: Sun, 15 Jun 2025 14:09:38 +0300 Subject: [PATCH] Add optional parameters to TransactionsService for enhanced flexibility 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. --- README.md | 6 ++--- pom.xml | 2 +- .../api/transactions/TransactionsService.java | 12 ++++++++-- .../impl/TransactionsServiceImpl.java | 24 +++++++++---------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b9cbf33..b9ea25e 100644 --- a/README.md +++ b/README.md @@ -408,7 +408,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca | Koios Instance | Koios Java Client | |:--------------:|:-----------------:| -| 1.3.2 | 1.21.0 | +| 1.3.2 | 1.21.1 | | 1.3.0 | 1.20.1 | | 1.2.0 | 1.19.3 | | 1.1.2 | 1.18.2 | @@ -428,13 +428,13 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca io.github.cardano-community koios-java-client - 1.21.0 + 1.21.1 ``` - For Gradle, add the following dependency to build.gradle ``` -compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.21.0' +compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.21.1' ``` ### Get Koios Backend Service (No API Token) diff --git a/pom.xml b/pom.xml index 7e0b003..f3e6e58 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.github.cardano-community koios-java-client - 1.21.0 + 1.21.1 ${project.groupId}:${project.artifactId} Koios Java Client is a Java REST Client library which allows interacting with Koios Server Instances using Java Objects https://github.com/cardano-community/koios-java-client diff --git a/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java b/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java index 55afeea..1bcebd0 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java @@ -40,6 +40,14 @@ public interface TransactionsService { */ Result> getRawTransaction(List txHashes, Options options) throws ApiException; + default Result getTransactionInformation(String txHash) throws ApiException { + return getTransactionInformation(txHash, true, true, true, true, true, true, true); + } + + default Result> getTransactionInformation(List txHashes, Options options) throws ApiException { + return getTransactionInformation(txHashes, true, true, true, true, true, true, true, options); + } + /** * Transaction Information for Specific Transaction * Get detailed information about transaction @@ -51,7 +59,7 @@ public interface TransactionsService { * @return Result of Type List of {@link TxInfo} detailed information about transaction(s) * @throws ApiException if an error occurs while attempting to invoke the API */ - Result getTransactionInformation(String txHash) throws ApiException; + Result getTransactionInformation(String txHash, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode) throws ApiException; /** * Transaction Information @@ -65,7 +73,7 @@ public interface TransactionsService { * @return Result of Type List of {@link TxInfo} detailed information about transaction(s) * @throws ApiException if an error occurs while attempting to invoke the API */ - Result> getTransactionInformation(List txHashes, Options options) throws ApiException; + Result> getTransactionInformation(List txHashes, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode, Options options) throws ApiException; /** * Transaction Metadata diff --git a/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java b/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java index 2a9fdc7..51efca4 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java @@ -51,18 +51,18 @@ public Result> getRawTransaction(List txHashes, Options opti } @Override - public Result getTransactionInformation(String txHash) throws ApiException { + public Result getTransactionInformation(String txHash, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode) throws ApiException { validateHexFormat(txHash); - Call> call = transactionApi.getTransactionInformation(buildTxInfoBody(List.of(txHash)), Collections.emptyMap()); + Call> call = transactionApi.getTransactionInformation(buildTxInfoBody(List.of(txHash), isInputs, isMetadata, isAssets, isWithdrawals, isCertificates, isScripts, isByteCode), Collections.emptyMap()); return processResponseGetOne(call); } @Override - public Result> getTransactionInformation(List txHashes, Options options) throws ApiException { + public Result> getTransactionInformation(List txHashes, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode, Options options) throws ApiException { for (String tx : txHashes) { validateHexFormat(tx); } - Call> call = transactionApi.getTransactionInformation(buildTxInfoBody(txHashes), optionsToParamMap(options)); + Call> call = transactionApi.getTransactionInformation(buildTxInfoBody(txHashes, isInputs, isMetadata, isAssets, isWithdrawals, isCertificates, isScripts, isByteCode), optionsToParamMap(options)); return processResponse(call); } @@ -97,16 +97,16 @@ public Result> getTransactionStatus(List txHashes, Option return processResponse(call); } - private Map buildTxInfoBody(List txHashes) { + private Map buildTxInfoBody(List txHashes, boolean isInputs, boolean isMetadata, boolean isAssets, boolean isWithdrawals, boolean isCertificates, boolean isScripts, boolean isByteCode) { Map bodyMap = new HashMap<>(); bodyMap.put("_tx_hashes", txHashes); - bodyMap.put("_inputs", true); - bodyMap.put("_metadata", true); - bodyMap.put("_assets", true); - bodyMap.put("_withdrawals", true); - bodyMap.put("_certs", true); - bodyMap.put("_scripts", true); - bodyMap.put("_bytecode", true); + bodyMap.put("_inputs", isInputs); + bodyMap.put("_metadata", isMetadata); + bodyMap.put("_assets", isAssets); + bodyMap.put("_withdrawals", isWithdrawals); + bodyMap.put("_certs", isCertificates); + bodyMap.put("_scripts", isScripts); + bodyMap.put("_bytecode", isByteCode); return bodyMap; }