Skip to content

Commit

Permalink
Koios Alignment with Koios Instance 1.3.0 - Closes #179, #178, #177, #…
Browse files Browse the repository at this point in the history
…175, 173
  • Loading branch information
edridudi committed Dec 22, 2024
1 parent e0bf01c commit cee9a07
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 26 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca

| Koios Instance | Koios Java Client |
|:--------------:|:-----------------:|
| 1.3.0 | 1.20.0 |
| 1.2.0 | 1.19.3 |
| 1.1.2 | 1.18.2 |
| 1.0.10 | 1.17.3 |
Expand All @@ -422,13 +423,13 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca
<dependency>
<groupId>io.github.cardano-community</groupId>
<artifactId>koios-java-client</artifactId>
<version>1.19.3</version>
<version>1.20.0</version>
</dependency>
```

- For Gradle, add the following dependency to build.gradle
```
compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.19.3'
compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.20.0'
```

### Get Koios Backend Service (No API Token)
Expand Down
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.cardano-community</groupId>
<artifactId>koios-java-client</artifactId>
<version>1.19.3</version>
<version>1.20.0</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Koios Java Client is a Java REST Client library which allows interacting with Koios Server Instances using Java Objects</description>
<url>https://github.com/cardano-community/koios-java-client</url>
Expand All @@ -14,18 +14,18 @@
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<retrofit.version>2.11.0</retrofit.version>
<jackson-databind.version>2.17.2</jackson-databind.version>
<jackson-databind.version>2.18.2</jackson-databind.version>
<logging-interceptor.version>4.12.0</logging-interceptor.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
<slf4j-api.version>2.0.16</slf4j-api.version>
<slf4j-reload4j.version>2.0.16</slf4j-reload4j.version>
<commons-collections4.version>4.4</commons-collections4.version>
<lombok.version>1.18.34</lombok.version>
<bcprov-jdk15to18.version>1.78.1</bcprov-jdk15to18.version>
<junit-jupiter.version>5.11.0</junit-jupiter.version>
<bcprov-jdk15to18.version>1.79</bcprov-jdk15to18.version>
<junit-jupiter.version>5.11.3</junit-jupiter.version>
<maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
<maven-javadoc-plugin.version>3.10.0</maven-javadoc-plugin.version>
<maven-surefire-plugin.version>3.5.0</maven-surefire-plugin.version>
<maven-javadoc-plugin.version>3.11.1</maven-javadoc-plugin.version>
<maven-surefire-plugin.version>3.5.1</maven-surefire-plugin.version>
<junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version>
<jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ public interface BlockService {
* @param assets Controls whether to include assets involved within transaction the result
* @param withdrawals Controls whether to include any stake account reward withdrawals in the
* @param certs Controls whether to include transaction certificates in the result
* @param scripts Controls whether to include any details regarding
* @param scripts Controls whether to include any details regarding collateral/reference/datum/script objects in the result
* @param byteCode Controls whether to include bytecode for associated reference/plutus scripts
* @param options Filtering and Pagination options (optional)
* @return Result of Type List of {@link TxInfo} Included Transactions of a specific block
* @throws ApiException if an error occurs while attempting to invoke the API
*
*/
Result<List<TxInfo>> getBlockTransactionsInfo(List<String> blockHashes, Boolean inputs, Boolean metadata, Boolean assets,
Boolean withdrawals, Boolean certs, Boolean scripts, Options options) throws ApiException;
Boolean withdrawals, Boolean certs, Boolean scripts, Boolean byteCode, Options options) throws ApiException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@ public Result<List<BlockTxHash>> getBlockTransactions(List<String> blockHashes,
}

@Override
public Result<List<TxInfo>> getBlockTransactionsInfo(List<String> blockHashes, Boolean inputs, Boolean metadata, Boolean assets, Boolean withdrawals, Boolean certs, Boolean scripts, Options options) throws ApiException {
public Result<List<TxInfo>> getBlockTransactionsInfo(List<String> blockHashes, Boolean inputs, Boolean metadata,
Boolean assets, Boolean withdrawals, Boolean certs,
Boolean scripts, Boolean byteCode, Options options) throws ApiException {
for (String blockHash : blockHashes) {
validateHexFormat(blockHash);
}
Call<List<TxInfo>> call = blockApi.getBlockTransactionsInfo(buildBodyBlockTxInfo(blockHashes, inputs, metadata, assets, withdrawals, certs, scripts), optionsToParamMap(options));
Call<List<TxInfo>> call = blockApi.getBlockTransactionsInfo(buildBodyBlockTxInfo(blockHashes, inputs, metadata, assets, withdrawals, certs, scripts, byteCode), optionsToParamMap(options));
return processResponse(call);
}

private Map<String, Object> buildBodyBlockTxInfo(List<String> blockHashes, Boolean inputs, Boolean metadata, Boolean assets, Boolean withdrawals, Boolean certs, Boolean scripts) {
private Map<String, Object> buildBodyBlockTxInfo(List<String> blockHashes, Boolean inputs, Boolean metadata,
Boolean assets, Boolean withdrawals, Boolean certs,
Boolean scripts, Boolean byteCode) {
Map<String, Object> bodyMap = new HashMap<>();
bodyMap.put("_block_hashes", blockHashes);
bodyMap.put("_inputs", Optional.ofNullable(inputs).orElse(false));
Expand All @@ -89,6 +93,7 @@ private Map<String, Object> buildBodyBlockTxInfo(List<String> blockHashes, Boole
bodyMap.put("_withdrawals", Optional.ofNullable(withdrawals).orElse(false));
bodyMap.put("_certs", Optional.ofNullable(certs).orElse(false));
bodyMap.put("_scripts", Optional.ofNullable(scripts).orElse(false));
bodyMap.put("_bytecode", Optional.ofNullable(byteCode).orElse(false));
return bodyMap;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package rest.koios.client.backend.api.governance.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.*;
Expand All @@ -12,6 +13,7 @@
@ToString
@NoArgsConstructor
@EqualsAndHashCode
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class DRep {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public class DRepInfo {
/**
* A URL to a JSON payload of metadata (null if not applicable)
*/
private String url;
private String metaUrl;

/**
* A hash of the contents of the metadata URL (null if not applicable)
*/
private String hash;
private String meatHash;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ public class DRepMetadata {
/**
* A URL to a JSON payload of metadata (null if not applicable)
*/
private String url;
private String metaUrl;

/**
* A hash of the contents of the metadata URL (null if not applicable)
*/
private String hash;
private String metaHash;

/**
* The raw bytes of the payload (null if not applicable)
*/
private JsonNode json;
private JsonNode metaJson;

/**
* A warning that occurred while validating the metadata (null if not applicable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class ProposalVotingSummary {
*/
private Double drepNoPct;

/**
* Number of active 'abstain' votes from dreps
*/
private Integer drepAbstainVotesCast;

/**
* Number of 'yes' votes casted by pools
*/
Expand Down Expand Up @@ -87,6 +92,31 @@ public class ProposalVotingSummary {
*/
private Double poolNoPct;

/**
* Percentage of 'abstain' votes from pools
*/
private Double poolAbstainVotesCast;

/**
* Number of non-voting SPO pool reward addresses delegating to 'always_abstain' drep
*/
private Integer poolPassiveAlwaysAbstainVotesAssigned;

/**
* Combined power of non-voting SPO pool votes where reward addresses delegate to 'always_abstain'
*/
private Integer poolPassiveAlwaysAbstainVotePower;

/**
* Number of non-voting SPO pool reward addresses delegating to 'always_no_confidence' drep
*/
private Integer poolPassiveAlwaysNoConfidenceVotesAssigned;

/**
* Combined power of non-voting SPO pool votes where reward addresses delegate to
*/
private Integer poolPassiveAlwaysNoConfidenceVotePower;

/**
* Number of 'yes' votes casted by committee
*/
Expand All @@ -106,4 +136,9 @@ public class ProposalVotingSummary {
* Percentage of 'no' votes from committee
*/
private Double committeeNoPct;

/**
* Percentage of 'abstain' votes from committee
*/
private Double committeeAbstainVotesCast;
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public class Pool {
*/
private String poolStatus;

/**
* Amount of delegated stake to this pool at the time of epoch snapshot
*/
private String activeStake;

/**
* Announced retiring epoch (nullable)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public class PoolInfo {
*/
private String rewardAddr;

/**
* Reward address' current delegation status to DRep ID in CIP-129 Bech32 format
*/
private String rewardAddrDelegatedDrep;

/**
* List of Pool (co)owner address
*/
Expand Down Expand Up @@ -143,4 +148,9 @@ public class PoolInfo {
* Pool live saturation (decimal format)
*/
private Double liveSaturation;

/**
* Current voting power (lovelaces) of this stake pool
*/
private String votingPower;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ public class RawTx {
/**
* Hash identifier of the transaction
*/
private String txHash = null;
private String txHash;

private String blockHash;

private Long blockHeight;

private Integer epochNo;

private Long absoluteSlot;

private Long txTimestamp;

/**
* Raw Tx in CBOR format
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package rest.koios.client.backend.api.transactions.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
Expand All @@ -15,6 +16,7 @@
@Setter
@ToString
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class TxMetadata {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void getBlockTransactionsBadRequestTest() {
@Test
void getBlockTransactionsInfoTest() throws ApiException {
String hash = "f6192a1aaa6d3d05b4703891a6b66cd757801c61ace86cbe5ab0d66e07f601ab";
Result<List<TxInfo>> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, Options.EMPTY);
Result<List<TxInfo>> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY);
Assertions.assertTrue(blockTransactionsResult.isSuccessful());
Assertions.assertNotNull(blockTransactionsResult.getValue());
log.info(blockTransactionsResult.getValue().toString());
Expand All @@ -131,7 +131,7 @@ void getBlockTransactionsInfoTest() throws ApiException {
@Test
void getBlockTransactionsInfoBadRequestTest() {
String hash = "test";
ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, Options.EMPTY));
ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY));
assertInstanceOf(ApiException.class, exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void getBlockTransactionsBadRequestTest() {
@Test
void getBlockTransactionsInfoTest() throws ApiException {
String hash = "065b9f0a52b3d3897160a065a7fe2bcb64b2bf635937294ade457de6a7bfd2a4";
Result<List<TxInfo>> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, Options.EMPTY);
Result<List<TxInfo>> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY);
Assertions.assertTrue(blockTransactionsResult.isSuccessful());
Assertions.assertNotNull(blockTransactionsResult.getValue());
log.info(blockTransactionsResult.getValue().toString());
Expand All @@ -119,7 +119,7 @@ void getBlockTransactionsInfoTest() throws ApiException {
@Test
void getBlockTransactionsInfoBadRequestTest() {
String hash = "test";
ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, Options.EMPTY));
ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY));
assertInstanceOf(ApiException.class, exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void getBlockTransactionsBadRequestTest() {
@Test
void getBlockTransactionsInfoTest() throws ApiException {
String hash = "501fc2c3e3d03f61ec6d19d3f8feb38f3c3c30df66c68027abbd6c99b5acef0e";
Result<List<TxInfo>> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, Options.EMPTY);
Result<List<TxInfo>> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY);
Assertions.assertTrue(blockTransactionsResult.isSuccessful());
Assertions.assertNotNull(blockTransactionsResult.getValue());
log.info(blockTransactionsResult.getValue().toString());
Expand All @@ -119,7 +119,7 @@ void getBlockTransactionsInfoTest() throws ApiException {
@Test
void getBlockTransactionsInfoBadRequestTest() {
String hash = "test";
ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, Options.EMPTY));
ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY));
assertInstanceOf(ApiException.class, exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void getDRepsInfoTest() throws ApiException {

@Test
void getDRepsMetadataTest() throws ApiException {
List<String> drepIds = List.of("drep17l6sywnwqu9aedd6aumev42w39ln5zfl9nw7j4ak6u8swyrwvz3", "drep1s9q5uyddsvza4uk2n9wswy90n8wx9d2jmrq4zgcvlyv055007av");
List<String> drepIds = List.of("drep1y2ltat8kjqrmnff3lkkpxy0j5tn66d3m0gy64dc92asft5g6dl9ws", "drep1s9q5uyddsvza4uk2n9wswy90n8wx9d2jmrq4zgcvlyv055007av");
Result<List<DRepMetadata>> result = governanceService.getDRepsMetadata(drepIds, Options.EMPTY);
Assertions.assertTrue(result.isSuccessful());
Assertions.assertNotNull(result.getValue());
Expand Down

0 comments on commit cee9a07

Please sign in to comment.