From 752cf7dbf87420d0b500378851b8e06aa33410a4 Mon Sep 17 00:00:00 2001 From: dudiedri Date: Mon, 14 Apr 2025 22:12:39 -0700 Subject: [PATCH] Add new governance endpoints and enhance model structuring Introduce new API endpoints for DRep and Pool voting power history, address outputs, and CLI protocol parameters. Update governance, address, network, and pool models to include additional fields and improve clarity. Adjust deprecated methods and ensure better validation in integration tests. --- README.md | 61 ++++++++----- SPONSORS.md | 2 +- pom.xml | 10 +-- .../backend/api/account/AccountService.java | 48 +++++++++- .../backend/api/account/api/AccountApi.java | 33 +++++++ .../api/account/impl/AccountServiceImpl.java | 30 +++++++ .../api/account/model/AccountInfo.java | 7 ++ .../account/model/AccountRewardHistory.java | 50 +++++++++++ .../account/model/AccountStakeHistory.java | 39 ++++++++ .../account/model/AccountUpdateHistory.java | 55 ++++++++++++ .../backend/api/address/AddressService.java | 20 ++++- .../backend/api/address/api/AddressApi.java | 11 +++ .../api/address/impl/AddressServiceImpl.java | 10 +++ .../api/address/model/AddressOutput.java | 67 ++++++++++++++ .../backend/api/asset/model/PolicyAsset.java | 1 - .../client/backend/api/base/BaseService.java | 2 +- .../backend/api/block/BlockService.java | 13 +++ .../backend/api/block/api/BlockApi.java | 12 +++ .../api/block/impl/BlockServiceImpl.java | 10 +++ .../backend/api/block/model/BlockTxCbor.java | 54 ++++++++++++ .../api/governance/GovernanceService.java | 50 +++++++++-- .../api/governance/api/GovernanceApi.java | 35 +++++++- .../impl/GovernanceServiceImpl.java | 45 +++++++++- .../model/DRepVotingPowerHistory.java | 32 +++++++ .../model/PoolsVotingPowerHistory.java | 32 +++++++ .../model/ProposalVotingSummary.java | 58 +++++++++--- .../backend/api/governance/model/Vote.java | 88 +++++++++++++++++++ .../backend/api/network/NetworkService.java | 15 ++++ .../backend/api/network/api/NetworkApi.java | 4 + .../api/network/impl/NetworkServiceImpl.java | 8 +- .../client/backend/api/network/model/Tip.java | 6 ++ .../backend/api/network/model/Totals.java | 20 +++++ .../client/backend/api/pool/PoolService.java | 39 ++++++++ .../client/backend/api/pool/api/PoolApi.java | 29 ++++++ .../api/pool/impl/PoolServiceImpl.java | 21 +++++ .../client/backend/api/pool/model/Pool.java | 7 +- .../api/pool/model/PoolCalidusKey.java | 64 ++++++++++++++ .../backend/api/pool/model/PoolGroup.java | 44 ++++++++++ .../api/pool/model/PoolOwnerHistory.java | 44 ++++++++++ .../backend/api/transactions/model/RawTx.java | 4 - .../rest/koios/client/utils/Bech32Util.java | 3 +- .../java/rest/koios/client/utils/HexUtil.java | 4 +- .../java/rest/koios/client/utils/Tuple.java | 4 +- .../AccountServiceMainnetIntegrationTest.java | 14 +-- .../AccountServicePreprodIntegrationTest.java | 15 ++-- .../AccountServicePreviewIntegrationTest.java | 14 +-- .../AddressServiceMainnetIntegrationTest.java | 11 +++ .../AssetServiceMainnetIntegrationTest.java | 5 -- .../BlockServiceMainnetIntegrationTest.java | 22 ++++- .../BlockServicePreprodIntegrationTest.java | 22 ++++- .../BlockServicePreviewIntegrationTest.java | 22 ++++- ...vernanceServiceMainnetIntegrationTest.java | 26 +++++- .../NetworkServiceMainnetIntegrationTest.java | 9 ++ .../PoolServiceMainnetIntegrationTest.java | 28 +++++- 54 files changed, 1277 insertions(+), 102 deletions(-) create mode 100644 src/main/java/rest/koios/client/backend/api/account/model/AccountRewardHistory.java create mode 100644 src/main/java/rest/koios/client/backend/api/account/model/AccountStakeHistory.java create mode 100644 src/main/java/rest/koios/client/backend/api/account/model/AccountUpdateHistory.java create mode 100644 src/main/java/rest/koios/client/backend/api/address/model/AddressOutput.java create mode 100644 src/main/java/rest/koios/client/backend/api/block/model/BlockTxCbor.java create mode 100644 src/main/java/rest/koios/client/backend/api/governance/model/DRepVotingPowerHistory.java create mode 100644 src/main/java/rest/koios/client/backend/api/governance/model/PoolsVotingPowerHistory.java create mode 100644 src/main/java/rest/koios/client/backend/api/governance/model/Vote.java create mode 100644 src/main/java/rest/koios/client/backend/api/pool/model/PoolCalidusKey.java create mode 100644 src/main/java/rest/koios/client/backend/api/pool/model/PoolGroup.java create mode 100644 src/main/java/rest/koios/client/backend/api/pool/model/PoolOwnerHistory.java diff --git a/README.md b/README.md index a725d91..b9cbf33 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca - Network + Network Chain Tip Get the tip info about the latest block seen by chain @@ -58,6 +58,10 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Param Update Proposals Get all parameter update proposals submitted to the chain starting Shelley era + + CLI Protocol Parameters + Get Current Protocol Parameters as published by cardano-cli. + Reserve Withdrawals List of all withdrawals from reserves against stake accounts @@ -93,8 +97,8 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get a list of all transactions included in a provided block - Block Transactions (Detailed Info) - Get detailed information about transaction(s) for requested blocks + Block Transactions (Raw CBOR) + Get raw CBOR data for all transaction(s) within requested blocks Transactions @@ -126,7 +130,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get the number of block confirmations for a given transaction hash list - Address + Address Address Information Get address info - balance, associated stake address (if any) and UTxO set @@ -134,6 +138,10 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Address UTxOs Get UTxO set for given addresses + + Address Outputs + Basic transaction output info for given addresses + UTxOs from payment credentials Get UTxO details for requested payment credentials @@ -172,11 +180,11 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get a list of all Txs for a given stake address (account) - Account Rewards + Account Reward History Get the full rewards history (including MIR) for a stake address, or certain epoch if specified - Account Updates + Account Update History Get the account updates (registration, deregistration, delegation and withdrawals) @@ -188,11 +196,11 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get the native asset balance of an account - Account History + Account Stake History Get the staking history of an account - Asset + Asset Asset List Get the list of all native assets (paginated) @@ -204,10 +212,6 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Asset Token Registry Get a list of assets registered via token registry on github - - Asset Information - Get the information of an asset including first minting & token registry metadata - Asset Information (Bulk) Get the information of a list of assets including first minting & token registry metadata @@ -249,7 +253,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get the list of all asset transaction hashes (newest first) - Governance + Governance DReps Epoch Summary Summary of voting power and DRep count for each epoch @@ -270,8 +274,8 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca List of updates for requested (or all) delegated representatives (DReps) - DReps Votes - List of all votes casted by requested delegated representative (DRep) + DReps Voting Power History + History of DReps voting power against each (or requested) epoch DReps Delegators @@ -302,11 +306,15 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca List of all votes cast on specified governance action - Pool Votes - List of all votes casted by a pool + Vote List + List of all votes posted on-chain + + + Pool's Voting Power History + History of Pool voting power against each (or requested) epoch - Pool + Pool Pool List A list of all currently registered/retiring (not retired) pools @@ -330,6 +338,10 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Pool Blocks Return information about blocks minted by a given pool in current epoch (or _epoch_no if provided) + + Pool Owner History + List of Cardano pool IDs (bech32 format) + Pool Stake, Block and Reward History Return information about pool stake, block and reward history in a given epoch _epoch_no (or all epochs that pool existed for, in descending order if no _epoch_no was provided) @@ -350,10 +362,18 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Pool Relays A list of registered relays for all currently registered/retiring (not retired) pools + + Pool Groups + List of all registered pool and their groups across sources from pool_groups repository. This is only relevant for mainnet + Pool Metadata Metadata (on & off-chain) for all currently registered/retiring (not retired) pools + + Pool Calidus Keys + List of valid calidus keys for all pools + Script Script Information @@ -388,6 +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.0 | 1.20.1 | | 1.2.0 | 1.19.3 | | 1.1.2 | 1.18.2 | @@ -407,13 +428,13 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca io.github.cardano-community koios-java-client - 1.20.1 + 1.21.0 ``` - For Gradle, add the following dependency to build.gradle ``` -compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.20.1' +compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.21.0' ``` ### Get Koios Backend Service (No API Token) diff --git a/SPONSORS.md b/SPONSORS.md index 10b230b..fb208ec 100644 --- a/SPONSORS.md +++ b/SPONSORS.md @@ -8,7 +8,7 @@ We'll be happy to show your name in the sponsor list.


- + qr

addr1qy9m8j6jp32fgnqjljk6ert9hlndcnptwhruzjamyevzgspgewr0dw33mfjfm72t8a2et6w48u4k5uwq2hgltxxs4a6sg6ptd9 diff --git a/pom.xml b/pom.xml index 1d1e48b..7e0b003 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.github.cardano-community koios-java-client - 1.20.1 + 1.21.0 ${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 @@ -20,12 +20,12 @@ 2.0.16 2.0.16 4.4 - 1.18.34 - 1.79 + 1.18.36 + 1.80 5.11.3 3.13.0 - 3.11.1 - 3.5.1 + 3.11.2 + 3.5.2 1.3.2 0.8.12 3.3.1 diff --git a/src/main/java/rest/koios/client/backend/api/account/AccountService.java b/src/main/java/rest/koios/client/backend/api/account/AccountService.java index 64a0500..dc1ea2a 100644 --- a/src/main/java/rest/koios/client/backend/api/account/AccountService.java +++ b/src/main/java/rest/koios/client/backend/api/account/AccountService.java @@ -63,7 +63,7 @@ public interface AccountService { *

404 - The server does not recognise the combination of endpoint and parameters provided * * @param stakeAddresses List of Cardano stake address(es) in bech32 format - * @param extended Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call + * @param extended Controls whether certain optional fields supported by a given endpoint are populated as a part of the call * @param options Filtering and Pagination options (optional) * @return Result of Type List of {@link UTxO} associated with stake address * @throws ApiException if an error occurs while attempting to invoke the API @@ -99,8 +99,24 @@ public interface AccountService { * @return Result of Type List of {@link AccountRewards} * @throws ApiException if an error occurs while attempting to invoke the API */ + @Deprecated Result> getAccountRewards(List addressList, Integer epochNo, Options options) throws ApiException; + /** + * Account Reward History + * Get the full rewards history (including MIR) for given stake addresses (accounts) + *

200 - Success! + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param addressList Array of Cardano stake address(es) in bech32 format + * @param epochNo Only fetch information for a specific epoch (optional) + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link AccountRewardHistory} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getAccountRewardHistory(List addressList, Integer epochNo, Options options) throws ApiException; + /** * Account Updates (History) * Get the account updates (registration, deregistration, delegation and withdrawals) @@ -113,8 +129,23 @@ public interface AccountService { * @return Result of Type List of {@link AccountUpdates} * @throws ApiException if an error occurs while attempting to invoke the API */ + @Deprecated Result> getAccountUpdates(List addressList, Options options) throws ApiException; + /** + * Account Updates History + * Get the account updates (registration, deregistration, delegation and withdrawals) + *

200 - Success! + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param addressList Array of Cardano stake address(es) in bech32 format (required) + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link AccountUpdateHistory} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getAccountUpdateHistory(List addressList, Options options) throws ApiException; + /** * Account Addresses * Get all addresses associated with given staking accounts @@ -160,5 +191,20 @@ public interface AccountService { * @return Result of Type List of {@link AccountHistory} active stake values per epoch * @throws ApiException if an error occurs while attempting to invoke the API */ + @Deprecated Result> getAccountHistory(List addressList, Integer epochNo, Options options) throws ApiException; + + /** + * Account Stake History + * Get the staking history of given stake addresses (accounts) + *

200 - Array of active stake values per epoch + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param addressList Array of Cardano stake address(es) in bech32 format + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link AccountStakeHistory} active stake values per epoch + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getAccountStakeHistory(List addressList, Options options) throws ApiException; } diff --git a/src/main/java/rest/koios/client/backend/api/account/api/AccountApi.java b/src/main/java/rest/koios/client/backend/api/account/api/AccountApi.java index 962d4f0..34dab23 100644 --- a/src/main/java/rest/koios/client/backend/api/account/api/AccountApi.java +++ b/src/main/java/rest/koios/client/backend/api/account/api/AccountApi.java @@ -70,9 +70,20 @@ public interface AccountApi { * @param paramsMap Query Params * @return Full rewards history (including MIR) for a stake address, or certain epoch if specified */ + @Deprecated @POST("account_rewards") Call> getAccountRewards(@Body Map requestBody, @QueryMap Map paramsMap); + /** + * Account Reward History + * + * @param requestBody Array of Cardano stake address(es) in bech32 format + * @param paramsMap Query Params + * @return Full rewards history (including MIR) for a stake address, or certain epoch if specified + */ + @POST("account_reward_history") + Call> getAccountRewardHistory(@Body Map requestBody, @QueryMap Map paramsMap); + /** * Get Account Updates * @@ -80,9 +91,20 @@ public interface AccountApi { * @param paramsMap Query Params * @return Account updates (registration, deregistration, delegation and withdrawals) */ + @Deprecated @POST("account_updates") Call> getAccountUpdates(@Body Map requestBody, @QueryMap Map paramsMap); + /** + * Account Update History + * + * @param requestBody Array of Cardano stake address(es) in bech32 format + * @param paramsMap Query Params + * @return Account updates (registration, deregistration, delegation and withdrawals) + */ + @POST("account_update_history") + Call> getAccountUpdateHistory(@Body Map requestBody, @QueryMap Map paramsMap); + /** * Get Account Addresses * @@ -110,6 +132,17 @@ public interface AccountApi { * @param paramsMap Query Params * @return Staking history of an account */ + @Deprecated @POST("account_history") Call> getAccountHistory(@Body Map requestBody, @QueryMap Map paramsMap); + + /** + * Get Account Stake History + * + * @param requestBody List of Cardano stake address(es) in bech32 format + * @param paramsMap Query Params + * @return List of active stake values per epoch + */ + @POST("account_stake_history") + Call> getAccountStakeHistory(@Body Map requestBody, @QueryMap Map paramsMap); } diff --git a/src/main/java/rest/koios/client/backend/api/account/impl/AccountServiceImpl.java b/src/main/java/rest/koios/client/backend/api/account/impl/AccountServiceImpl.java index 117c6d0..70cf3ae 100644 --- a/src/main/java/rest/koios/client/backend/api/account/impl/AccountServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/account/impl/AccountServiceImpl.java @@ -90,6 +90,18 @@ public Result> getAccountRewards(List addressList, return processResponse(call); } + @Override + public Result> getAccountRewardHistory(List addressList, Integer epochNo, Options options) throws ApiException { + for (String address : addressList) { + validateBech32(address); + } + if (epochNo != null) { + validateEpoch(epochNo); + } + Call> call = accountApi.getAccountRewardHistory(buildBody("_stake_addresses", addressList, epochNo, null, null), optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getAccountUpdates(List addressList, Options options) throws ApiException { for (String address : addressList) { @@ -99,6 +111,15 @@ public Result> getAccountUpdates(List addressList, return processResponse(call); } + @Override + public Result> getAccountUpdateHistory(List addressList, Options options) throws ApiException { + for (String address : addressList) { + validateBech32(address); + } + Call> call = accountApi.getAccountUpdateHistory(buildBody("_stake_addresses", addressList, null, null, null), optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getAccountAddresses(List addressList, boolean firstOnly, boolean empty, Options options) throws ApiException { for (String address : addressList) { @@ -132,6 +153,15 @@ public Result> getAccountHistory(List addressList, return processResponse(call); } + @Override + public Result> getAccountStakeHistory(List addressList, Options options) throws ApiException { + for (String address : addressList) { + validateBech32(address); + } + Call> call = accountApi.getAccountStakeHistory(buildBody("_stake_addresses", addressList, null, null, null), optionsToParamMap(options)); + return processResponse(call); + } + private Map buildBody(String arrayObjString, List list, Integer epochNo, Boolean firstOnly, Boolean empty) { Map bodyMap = new HashMap<>(); bodyMap.put(arrayObjString, list); diff --git a/src/main/java/rest/koios/client/backend/api/account/model/AccountInfo.java b/src/main/java/rest/koios/client/backend/api/account/model/AccountInfo.java index e08513e..1aa30ca 100644 --- a/src/main/java/rest/koios/client/backend/api/account/model/AccountInfo.java +++ b/src/main/java/rest/koios/client/backend/api/account/model/AccountInfo.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.account.model; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.*; @@ -74,4 +75,10 @@ public class AccountInfo { * Total treasury MIR value of the account */ private String treasury; + + /** + * Total proposal refund for this account + */ + @JsonProperty("proposal-refund") + private String proposalRefund; } diff --git a/src/main/java/rest/koios/client/backend/api/account/model/AccountRewardHistory.java b/src/main/java/rest/koios/client/backend/api/account/model/AccountRewardHistory.java new file mode 100644 index 0000000..7c97ebb --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/account/model/AccountRewardHistory.java @@ -0,0 +1,50 @@ +package rest.koios.client.backend.api.account.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Account Reward History + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class AccountRewardHistory { + + /** + * Cardano staking address (reward account) in bech32 format + */ + private String stakeAddress; + + /** + * Earned Rewards Epoch + */ + private Integer earnedEpoch; + + /** + * Spendable Epoch + */ + private Integer spendableEpoch; + + /** + * Amount of rewards earned (in lovelace) + */ + private String amount; + + /** + * The source of the rewards + * Allowed: member|leader|treasury|reserves + */ + private String type; + + /** + * Bech32 representation of pool ID + */ + private String poolIdBech32; +} diff --git a/src/main/java/rest/koios/client/backend/api/account/model/AccountStakeHistory.java b/src/main/java/rest/koios/client/backend/api/account/model/AccountStakeHistory.java new file mode 100644 index 0000000..e9566c8 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/account/model/AccountStakeHistory.java @@ -0,0 +1,39 @@ +package rest.koios.client.backend.api.account.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Account Stake History + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class AccountStakeHistory { + + /** + * Cardano staking address (reward account) in bech32 format + */ + private String stakeAddress; + + /** + * Bech32 representation of pool ID + */ + private String poolIdBech32 = null; + + /** + * Epoch number + */ + private Integer epochNo = null; + + /** + * Active stake amount (in numbers) + */ + private String activeStake = null; +} diff --git a/src/main/java/rest/koios/client/backend/api/account/model/AccountUpdateHistory.java b/src/main/java/rest/koios/client/backend/api/account/model/AccountUpdateHistory.java new file mode 100644 index 0000000..88f8f88 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/account/model/AccountUpdateHistory.java @@ -0,0 +1,55 @@ +package rest.koios.client.backend.api.account.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Account Update History + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class AccountUpdateHistory { + + /** + * Cardano staking address (reward account) in bech32 format + */ + private String stakeAddress; + + /** + * Type of certificate submitted + * Allowed: registration | delegation | withdrawal | deregistration + */ + private String actionType; + + /** + * Hash identifier of the transaction + */ + private String txHash; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * Slot number of the block in epoch + */ + private Integer epochSlot; + + /** + * Absolute slot number of the block + */ + private Integer absoluteSlot; + + /** + * UNIX timestamp of the block + */ + private Integer blockTime; +} diff --git a/src/main/java/rest/koios/client/backend/api/address/AddressService.java b/src/main/java/rest/koios/client/backend/api/address/AddressService.java index ebddb3e..f0b6554 100644 --- a/src/main/java/rest/koios/client/backend/api/address/AddressService.java +++ b/src/main/java/rest/koios/client/backend/api/address/AddressService.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.address; +import rest.koios.client.backend.api.address.model.AddressOutput; import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.api.address.model.AddressAsset; import rest.koios.client.backend.api.address.model.AddressInfo; @@ -52,13 +53,28 @@ public interface AddressService { *

404 - The server does not recognise the combination of endpoint and parameters provided * * @param addresses List of Cardano payment address(es) in bech32 format - * @param extended Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call + * @param extended Controls whether certain optional fields supported by a given endpoint are populated as a part of the call * @param options Filtering and Pagination options (optional) * @return Result of Type List of address {@link UTxO}s. * @throws ApiException if an error occurs while attempting to invoke the API */ Result> getAddressUTxOs(List addresses, boolean extended, Options options) throws ApiException; + /** + * Address Outputs + * Basic transaction output info for given addresses + *

200 - List of basic transaction output information + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param addresses List of Cardano payment address(es) in bech32 format + * @param afterBlockHeight Only fetch information after specific block height + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of address {@link UTxO}s. + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getAddressOutputs(List addresses, Integer afterBlockHeight, Options options) throws ApiException; + /** * UTxOs from payment credentials * Get UTxO details for requested payment credentials @@ -67,7 +83,7 @@ public interface AddressService { *

404 - The server does not recognise the combination of endpoint and parameters provided * * @param paymentCredentials List of Cardano payment credential(s) in hex format - * @param extended Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call + * @param extended Controls whether certain optional fields supported by a given endpoint are populated as a part of the call * @param options Filtering and Pagination options (optional) * @return Result of Type List of address {@link UTxO}s. * @throws ApiException if an error occurs while attempting to invoke the API diff --git a/src/main/java/rest/koios/client/backend/api/address/api/AddressApi.java b/src/main/java/rest/koios/client/backend/api/address/api/AddressApi.java index 257dcfe..7ce3aef 100644 --- a/src/main/java/rest/koios/client/backend/api/address/api/AddressApi.java +++ b/src/main/java/rest/koios/client/backend/api/address/api/AddressApi.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.address.api; +import rest.koios.client.backend.api.address.model.AddressOutput; import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.api.address.model.AddressAsset; import rest.koios.client.backend.api.address.model.AddressInfo; @@ -38,6 +39,16 @@ public interface AddressApi { @POST("address_utxos") Call> getAddressUTxOs(@Body Map requestBody, @QueryMap Map paramsMap); + /** + * Get Address Outputs + * + * @param requestBody Json Body containing List of Cardano payment address(es) in bech32 format + * @param paramsMap Query Params + * @return List of complete UTxO information + */ + @POST("address_outputs") + Call> getAddressOutputs(@Body Map requestBody, @QueryMap Map paramsMap); + /** * UTxOs from payment credentials * Get UTxO details for requested payment credentials diff --git a/src/main/java/rest/koios/client/backend/api/address/impl/AddressServiceImpl.java b/src/main/java/rest/koios/client/backend/api/address/impl/AddressServiceImpl.java index 59f0623..f440388 100644 --- a/src/main/java/rest/koios/client/backend/api/address/impl/AddressServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/address/impl/AddressServiceImpl.java @@ -4,6 +4,7 @@ import rest.koios.client.backend.api.address.api.AddressApi; import rest.koios.client.backend.api.address.model.AddressAsset; import rest.koios.client.backend.api.address.model.AddressInfo; +import rest.koios.client.backend.api.address.model.AddressOutput; import rest.koios.client.backend.api.base.BaseService; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.common.TxHash; @@ -75,6 +76,15 @@ public Result> getAddressUTxOs(List addresses, boolean extend return processResponse(call); } + @Override + public Result> getAddressOutputs(List addresses, Integer afterBlockHeight, Options options) throws ApiException { + for (String address : addresses) { + validateBech32(address); + } + Call> call = addressApi.getAddressOutputs(buildBody("_addresses", addresses, afterBlockHeight), optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getUTxOsFromPaymentCredentials(List paymentCredentials, boolean extended, Options options) throws ApiException { for (String address : paymentCredentials) { diff --git a/src/main/java/rest/koios/client/backend/api/address/model/AddressOutput.java b/src/main/java/rest/koios/client/backend/api/address/model/AddressOutput.java new file mode 100644 index 0000000..c0f6689 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/address/model/AddressOutput.java @@ -0,0 +1,67 @@ +package rest.koios.client.backend.api.address.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Address Output + */ +@Getter +@Setter +@ToString +@EqualsAndHashCode +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class AddressOutput { + + /** + * A Cardano payment/base address (bech32 encoded) + */ + private String address; + + /** + * Hash identifier of the transaction + */ + private String txHash; + + /** + * Index of UTxO in the transaction + */ + private Integer txIndex; + + /** + * Total sum of ADA on the UTxO + */ + private String value; + + /** + * Cardano staking address (reward account) in bech32 + */ + private String stakeAddress; + + /** + * Payment credential + */ + private String paymentCred; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * Block height + */ + private Integer blockHeight; + + /** + * Timestamp of the block + */ + private Integer blockTime; + + /** + * True if the UTXO has been spent + */ + private Boolean isSpent; +} diff --git a/src/main/java/rest/koios/client/backend/api/asset/model/PolicyAsset.java b/src/main/java/rest/koios/client/backend/api/asset/model/PolicyAsset.java index 1ee8016..998aec8 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/model/PolicyAsset.java +++ b/src/main/java/rest/koios/client/backend/api/asset/model/PolicyAsset.java @@ -1,6 +1,5 @@ package rest.koios.client.backend.api.asset.model; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.Getter; diff --git a/src/main/java/rest/koios/client/backend/api/base/BaseService.java b/src/main/java/rest/koios/client/backend/api/base/BaseService.java index 825e3a9..ab4e566 100644 --- a/src/main/java/rest/koios/client/backend/api/base/BaseService.java +++ b/src/main/java/rest/koios/client/backend/api/base/BaseService.java @@ -220,7 +220,7 @@ private void sleep(int timeMillis) { private int retry(int tryCount, Integer responseCode) throws ApiException { tryCount++; if (tryCount < retriesCount) { - log.info("Retrying in {}s ... (" + tryCount + "/" + retriesCount + ")", getSleepTimeSec() * tryCount); + log.info("Retrying in {}s ... ({}/{})", getSleepTimeSec() * tryCount, tryCount, retriesCount); sleep(getSleepTimeSec() * tryCount); } else if (responseCode == null) { throw new ApiException("Timeout Error"); diff --git a/src/main/java/rest/koios/client/backend/api/block/BlockService.java b/src/main/java/rest/koios/client/backend/api/block/BlockService.java index a6a6908..a7a72dd 100644 --- a/src/main/java/rest/koios/client/backend/api/block/BlockService.java +++ b/src/main/java/rest/koios/client/backend/api/block/BlockService.java @@ -4,6 +4,7 @@ import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.block.model.Block; import rest.koios.client.backend.api.block.model.BlockInfo; +import rest.koios.client.backend.api.block.model.BlockTxCbor; import rest.koios.client.backend.api.block.model.BlockTxHash; import rest.koios.client.backend.api.transactions.model.TxInfo; import rest.koios.client.backend.factory.options.Options; @@ -81,6 +82,17 @@ public interface BlockService { */ Result> getBlockTransactions(List blockHashes, Options options) throws ApiException; + /** + * Block Transactions (Raw CBOR) + * Get raw CBOR data for all transaction(s) within requested blocks + * + * @param blockHashes List of Block Hashes in hex format (required) + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link BlockTxCbor} Included Transaction of a specific block + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getBlockTransactionsCbor(List blockHashes, Options options) throws ApiException; + /** * Block Transactions (Detailed Info) * Get detailed information about transaction(s) for requested blocks @@ -101,6 +113,7 @@ public interface BlockService { * @throws ApiException if an error occurs while attempting to invoke the API * */ + @Deprecated Result> getBlockTransactionsInfo(List blockHashes, Boolean inputs, Boolean metadata, Boolean assets, Boolean withdrawals, Boolean certs, Boolean scripts, Boolean byteCode, Options options) throws ApiException; } diff --git a/src/main/java/rest/koios/client/backend/api/block/api/BlockApi.java b/src/main/java/rest/koios/client/backend/api/block/api/BlockApi.java index a8cd139..b34d909 100644 --- a/src/main/java/rest/koios/client/backend/api/block/api/BlockApi.java +++ b/src/main/java/rest/koios/client/backend/api/block/api/BlockApi.java @@ -2,6 +2,7 @@ import rest.koios.client.backend.api.block.model.Block; import rest.koios.client.backend.api.block.model.BlockInfo; +import rest.koios.client.backend.api.block.model.BlockTxCbor; import rest.koios.client.backend.api.block.model.BlockTxHash; import rest.koios.client.backend.api.transactions.model.TxInfo; import retrofit2.Call; @@ -47,6 +48,16 @@ public interface BlockApi { @POST("block_txs") Call> getBlockTransactions(@Body Map requestBody, @QueryMap Map paramsMap); + /** + * Get raw CBOR data for all transaction(s) within requested blocks + * + * @param requestBody Array of Block Hash IDs + * @param paramsMap Options and Filters Map + * @return List of {@link BlockTxCbor} + */ + @POST("block_tx_cbor") + Call> getBlockTransactionsCbor(@Body Map requestBody, @QueryMap Map paramsMap); + /** * Get a list of all transactions included in provided blocks * @@ -55,5 +66,6 @@ public interface BlockApi { * @return List of {@link BlockTxHash} */ @POST("block_tx_info") + @Deprecated Call> getBlockTransactionsInfo(@Body Map requestBody, @QueryMap Map paramsMap); } diff --git a/src/main/java/rest/koios/client/backend/api/block/impl/BlockServiceImpl.java b/src/main/java/rest/koios/client/backend/api/block/impl/BlockServiceImpl.java index 3373d92..0b4f41b 100644 --- a/src/main/java/rest/koios/client/backend/api/block/impl/BlockServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/block/impl/BlockServiceImpl.java @@ -7,6 +7,7 @@ import rest.koios.client.backend.api.block.api.BlockApi; import rest.koios.client.backend.api.block.model.Block; import rest.koios.client.backend.api.block.model.BlockInfo; +import rest.koios.client.backend.api.block.model.BlockTxCbor; import rest.koios.client.backend.api.block.model.BlockTxHash; import rest.koios.client.backend.api.transactions.model.TxInfo; import rest.koios.client.backend.factory.options.Limit; @@ -71,6 +72,15 @@ public Result> getBlockTransactions(List blockHashes, return processResponse(call); } + @Override + public Result> getBlockTransactionsCbor(List blockHashes, Options options) throws ApiException { + for (String blockHash : blockHashes) { + validateHexFormat(blockHash); + } + Call> call = blockApi.getBlockTransactionsCbor(buildBody(blockHashes), optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getBlockTransactionsInfo(List blockHashes, Boolean inputs, Boolean metadata, Boolean assets, Boolean withdrawals, Boolean certs, diff --git a/src/main/java/rest/koios/client/backend/api/block/model/BlockTxCbor.java b/src/main/java/rest/koios/client/backend/api/block/model/BlockTxCbor.java new file mode 100644 index 0000000..c16a0f6 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/block/model/BlockTxCbor.java @@ -0,0 +1,54 @@ +package rest.koios.client.backend.api.block.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Block Tx Cbor + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class BlockTxCbor { + + /** + * Hash identifier of the transaction + */ + private String txHash; + + /** + * Hash of the block + */ + private String blockHash; + + /** + * Block height + */ + private Integer blockHeight; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * Absolute slot number of the block + */ + private Integer absoluteSlot; + + /** + * UNIX timestamp of the transaction + */ + private Integer txTimestamp; + + /** + * CBOR encoded raw transaction + */ + private String cbor; +} diff --git a/src/main/java/rest/koios/client/backend/api/governance/GovernanceService.java b/src/main/java/rest/koios/client/backend/api/governance/GovernanceService.java index 10f8af3..6261f1b 100644 --- a/src/main/java/rest/koios/client/backend/api/governance/GovernanceService.java +++ b/src/main/java/rest/koios/client/backend/api/governance/GovernanceService.java @@ -66,15 +66,28 @@ public interface GovernanceService { */ Result> getDRepsUpdates(String drepId, Options options) throws ApiException; + /** + * DReps Voting Power History + * History of DReps voting power against each (or requested) epoch + * + * @param drepId DRep ID in bech32 format + * @param epochNo Epoch Number to fetch details for + * @param options Filtering Options (optional) + * @return History of DReps voting power against each (or requested) epoch + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getDRepsVotingPowerHistory(String drepId, Integer epochNo, Options options) throws ApiException; + /** * DReps Votes - * List of all votes casted by requested delegated representative (DRep) + * List of all votes cast by requested delegated representative (DRep) * * @param drepId DRep ID in bech32 format * @param options Filtering Options (optional) - * @return List of all votes casted by requested delegated representative (DRep) + * @return List of all votes cast by requested delegated representative (DRep) * @throws ApiException if an error occurs while attempting to invoke the API */ + @Deprecated Result> getDRepsVotes(String drepId, Options options) throws ApiException; /** @@ -100,11 +113,11 @@ public interface GovernanceService { /** * Committee Votes - * List of all votes casted by a given committee member or collective + * List of all votes cast by a given committee member or collective * * @param ccHotId Committee member hot key ID in Bech32 format (CIP-5 | CIP-129) * @param options Filtering Options (optional) - * @return List of all votes casted by a given committee member or collective + * @return List of all votes cast by a given committee member or collective * @throws ApiException if an error occurs while attempting to invoke the API */ Result> getCommitteeVotes(String ccHotId, Options options) throws ApiException; @@ -123,7 +136,7 @@ public interface GovernanceService { * Voter's Proposal List * List of all governance proposals for specified DRep, SPO or Committee credential * - * @param voterId Voter ID (DRep, SPO, Committee Member) in Bech32 format (CIP-5 | CIP-129) + * @param voterId Voter ID (DRep, SPO, Committee Member) in Bech32 format (CIP-5 | CIP-129) (optional) * @param options Filtering Options (optional) * @return List of all governance action proposals for the specified voter * @throws ApiException if an error occurs while attempting to invoke the API @@ -152,14 +165,37 @@ public interface GovernanceService { */ Result> getProposalVotes(String proposalId, Options options) throws ApiException; + /** + * Vote List + * List of all votes posted on-chain + * + * @param options Filtering Options (optional) + * @return List of all votes posted on-chain + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getVoteList(Options options) throws ApiException; + + /** + * Pool's Voting Power History + * History of Pool voting power against each (or requested) epoch + * + * @param poolBech32 Pool ID in bech32 format + * @param epochNo Epoch Number to fetch details for + * @param options Filtering Options (optional) + * @return List of all votes cast by the requested pool + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolsVotingPowerHistory(String poolBech32, Integer epochNo, Options options) throws ApiException; + /** * Pool Votes - * List of all votes casted by a pool + * List of all votes cast by a pool * * @param poolBech32 Pool ID in bech32 format * @param options Filtering Options (optional) - * @return List of all votes casted by the requested pool + * @return List of all votes cast by the requested pool * @throws ApiException if an error occurs while attempting to invoke the API */ + @Deprecated Result> getPoolVotes(String poolBech32, Options options) throws ApiException; } diff --git a/src/main/java/rest/koios/client/backend/api/governance/api/GovernanceApi.java b/src/main/java/rest/koios/client/backend/api/governance/api/GovernanceApi.java index 2bc7255..868cc8e 100644 --- a/src/main/java/rest/koios/client/backend/api/governance/api/GovernanceApi.java +++ b/src/main/java/rest/koios/client/backend/api/governance/api/GovernanceApi.java @@ -66,6 +66,17 @@ public interface GovernanceApi { @GET("drep_updates") Call> getDRepsUpdates(@Query("_drep_id") String drepId, @QueryMap Map paramsMap); + /** + * DReps Voting Power History + * History of DReps voting power against each (or requested) epoch + * + * @param drepId DRep ID in bech32 format + * @param paramsMap Filtering Options Query Parameters + * @return List of all votes casted by requested delegated representative (DRep) + */ + @GET("drep_voting_power_history") + Call> getDRepsVotingPowerHistory(@Query("_drep_id") String drepId, @QueryMap Map paramsMap); + /** * DReps Votes * List of all votes casted by requested delegated representative (DRep) @@ -74,6 +85,7 @@ public interface GovernanceApi { * @param paramsMap Filtering Options Query Parameters * @return List of all votes casted by requested delegated representative (DRep) */ + @Deprecated @GET("drep_votes") Call> getDRepsVotes(@Query("_drep_id") String drepId, @QueryMap Map paramsMap); @@ -123,12 +135,11 @@ public interface GovernanceApi { * Voter's Proposal List * List of all governance proposals for specified DRep, SPO or Committee credential * - * @param voterId Voter ID (Drep, SPO, Committee Member) in Bech32 format (CIP-5 | CIP-129) * @param paramsMap Filtering Options Query Parameters * @return List of all governance action proposals */ @GET("voter_proposal_list") - Call> getVoterProposal(@Query("_voter_id") String voterId, @QueryMap Map paramsMap); + Call> getVoterProposal(@QueryMap Map paramsMap); /** * Proposal Voting Summary @@ -152,6 +163,25 @@ public interface GovernanceApi { @GET("proposal_votes") Call> getProposalVotes(@Query("_proposal_id") String proposalId, @QueryMap Map paramsMap); + /** + * Vote List + * + * @param paramsMap Filtering Options Query Parameters + * @return List of all votes posted on-chain + */ + @GET("vote_list") + Call> getVoteList(@QueryMap Map paramsMap); + + /** + * Pool's Voting Power History + * + * @param poolBech32 Pool ID in bech32 format + * @param paramsMap Filtering Options Query Parameters + * @return History of Pool voting power against each (or requested) epoch + */ + @GET("pool_voting_power_history") + Call> getPoolsVotingPowerHistory(@Query("_pool_bech32") String poolBech32, @QueryMap Map paramsMap); + /** * Pool Votes * List of all votes casted by a pool @@ -160,6 +190,7 @@ public interface GovernanceApi { * @param paramsMap Filtering Options Query Parameters * @return List of all votes casted by requested pool */ + @Deprecated @GET("pool_votes") Call> getPoolVotes(@Query("_pool_bech32") String poolBech32, @QueryMap Map paramsMap); } diff --git a/src/main/java/rest/koios/client/backend/api/governance/impl/GovernanceServiceImpl.java b/src/main/java/rest/koios/client/backend/api/governance/impl/GovernanceServiceImpl.java index f3ebcd3..403c0f5 100644 --- a/src/main/java/rest/koios/client/backend/api/governance/impl/GovernanceServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/governance/impl/GovernanceServiceImpl.java @@ -7,6 +7,8 @@ import rest.koios.client.backend.api.governance.api.GovernanceApi; import rest.koios.client.backend.api.governance.model.*; import rest.koios.client.backend.factory.options.Options; +import rest.koios.client.backend.factory.options.filters.Filter; +import rest.koios.client.backend.factory.options.filters.FilterType; import retrofit2.Call; import java.util.HashMap; @@ -61,6 +63,19 @@ public Result> getDRepsUpdates(String drepId, Options options) return processResponse(call); } + @Override + public Result> getDRepsVotingPowerHistory(String drepId, Integer epochNo, Options options) throws ApiException { + if (epochNo != null) { + validateEpoch(epochNo); + if (options == null) { + options = new Options(); + } + options.getOptionList().add(Filter.of("epoch_no", FilterType.EQ, String.valueOf(epochNo))); + } + Call> call = governanceApi.getDRepsVotingPowerHistory(drepId, optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getDRepsVotes(String drepId, Options options) throws ApiException { Call> call = governanceApi.getDRepsVotes(drepId, optionsToParamMap(options)); @@ -93,7 +108,16 @@ public Result> getProposalList(Options options) throws ApiExcepti @Override public Result> getVoterProposals(String voterId, Options options) throws ApiException { - Call> call = governanceApi.getVoterProposal(voterId, optionsToParamMap(options)); + Map paramsMap; + if (options == null) { + paramsMap = new HashMap<>(); + } else { + paramsMap = optionsToParamMap(options); + } + if (voterId != null) { + paramsMap.put("_voter_id", voterId); + } + Call> call = governanceApi.getVoterProposal(paramsMap); return processResponse(call); } @@ -109,6 +133,25 @@ public Result> getProposalVotes(String proposalId, Options op return processResponse(call); } + @Override + public Result> getVoteList(Options options) throws ApiException { + Call> call = governanceApi.getVoteList(optionsToParamMap(options)); + return processResponse(call); + } + + @Override + public Result> getPoolsVotingPowerHistory(String poolBech32, Integer epochNo, Options options) throws ApiException { + if (epochNo != null) { + validateEpoch(epochNo); + if (options == null) { + options = new Options(); + } + options.getOptionList().add(Filter.of("epoch_no", FilterType.EQ, String.valueOf(epochNo))); + } + Call> call = governanceApi.getPoolsVotingPowerHistory(poolBech32, optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getPoolVotes(String poolBech32, Options options) throws ApiException { Call> call = governanceApi.getPoolVotes(poolBech32, optionsToParamMap(options)); diff --git a/src/main/java/rest/koios/client/backend/api/governance/model/DRepVotingPowerHistory.java b/src/main/java/rest/koios/client/backend/api/governance/model/DRepVotingPowerHistory.java new file mode 100644 index 0000000..bee8628 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/governance/model/DRepVotingPowerHistory.java @@ -0,0 +1,32 @@ +package rest.koios.client.backend.api.governance.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * DRep Voting Power History + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class DRepVotingPowerHistory { + + /** + * DRep ID in CIP-129 bech32 format + */ + private String drepId; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * History of DReps voting power against each (or requested) epoch + */ + private String amount; +} diff --git a/src/main/java/rest/koios/client/backend/api/governance/model/PoolsVotingPowerHistory.java b/src/main/java/rest/koios/client/backend/api/governance/model/PoolsVotingPowerHistory.java new file mode 100644 index 0000000..96a64da --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/governance/model/PoolsVotingPowerHistory.java @@ -0,0 +1,32 @@ +package rest.koios.client.backend.api.governance.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Pools Voting Power History + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class PoolsVotingPowerHistory { + + /** + * Pool ID (bech32 format) + */ + private String poolIdBech32; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * The voting power for the pool for the epoch + */ + private String amount; +} diff --git a/src/main/java/rest/koios/client/backend/api/governance/model/ProposalVotingSummary.java b/src/main/java/rest/koios/client/backend/api/governance/model/ProposalVotingSummary.java index 96cb155..e1ff34d 100644 --- a/src/main/java/rest/koios/client/backend/api/governance/model/ProposalVotingSummary.java +++ b/src/main/java/rest/koios/client/backend/api/governance/model/ProposalVotingSummary.java @@ -1,10 +1,8 @@ package rest.koios.client.backend.api.governance.model; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.*; -import rest.koios.client.backend.api.transactions.model.TxWithdrawal; /** * Proposal Voting Summary @@ -33,9 +31,14 @@ public class ProposalVotingSummary { private Integer drepYesVotesCast; /** - * Power of 'yes' votes from dreps + * Power of 'yes' votes that were explicitly cast */ - private Integer drepYesVotePower; + private String drepActiveYesVotePower; + + /** + * Power of 'yes' votes from dreps (includes explicit yes and inferred via other means) + */ + private String drepYesVotePower; /** * Percentage of 'yes' votes from dreps @@ -48,9 +51,14 @@ public class ProposalVotingSummary { private Integer drepNoVotesCast; /** - * Power of 'no' votes from dreps + * Power of 'no' votes that were explicitly cast + */ + private String drepActiveNoVotePower; + + /** + * Power of 'no' votes from dreps (includes explicit no and inferred via other means) */ - private Integer drepNoVotePower; + private String drepNoVotePower; /** * Percentage of 'no' votes from dreps @@ -62,15 +70,35 @@ public class ProposalVotingSummary { */ private Integer drepAbstainVotesCast; + /** + * Power of 'abstain' votes that were explicitly cast + */ + private String drepActiveAbstainVotePower; + + /** + * Power of votes delegated to 'always_no_confidence' predefined drep + */ + private String drepAlwaysNoConfidenceVotePower; + + /** + * Power of votes delegated to 'always_abstain' predefined drep + */ + private String drepAlwaysAbstainVotePower; + /** * Number of 'yes' votes casted by pools */ private Integer poolYesVotesCast; /** - * Power of 'yes' votes from pools + * Power of 'yes' pool votes that were explicitly cast + */ + private String poolActiveYesVotePower; + + /** + * Power of 'yes' votes from pools (includes explicit yes and inferred via other means) */ - private Integer poolYesVotePower; + private String poolYesVotePower; /** * Percentage of 'yes' votes from pools @@ -83,9 +111,14 @@ public class ProposalVotingSummary { private Integer poolNoVotesCast; /** - * Power of 'no' votes from pools + * Power of 'no' pool votes that were explicitly cast */ - private Integer poolNoVotePower; + private String poolActiveNoVotePower; + + /** + * Power of 'no' votes from pools (includes explicit no and inferred via other means) + */ + private String poolNoVotePower; /** * Percentage of 'no' votes from pools @@ -97,6 +130,11 @@ public class ProposalVotingSummary { */ private Double poolAbstainVotesCast; + /** + * Power of 'abstain' pool votes that were explicitly cast + */ + private String poolActiveAbstainVotePower; + /** * Number of non-voting SPO pool reward addresses delegating to 'always_abstain' drep */ diff --git a/src/main/java/rest/koios/client/backend/api/governance/model/Vote.java b/src/main/java/rest/koios/client/backend/api/governance/model/Vote.java new file mode 100644 index 0000000..8394dd9 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/governance/model/Vote.java @@ -0,0 +1,88 @@ +package rest.koios.client.backend.api.governance.model; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.*; + +/** + * Vote + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@EqualsAndHashCode +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class Vote { + + /** + * The transaction hash where-in vote was posted + */ + private String voteTxHash; + + /** + * The role of the voter (ConstitutionalCommittee, DRep, SPO) + */ + private String voterRole; + + /** + * Voter's DRep ID (CIP-129 bech32 format), pool ID (bech32 format) or committee + */ + private String voterId; + + /** + * Proposal Action ID in accordance with CIP-129 format + */ + private String proposalId; + + /** + * Hash identifier of the proposal transaction + */ + private String proposalTxHash; + + /** + * Index of governance proposal in transaction + */ + private Integer proposalIndex; + + /** + * Proposal Action Type (ParameterChange, HardForkInitiation, TreasuryWithdrawals, NoConfidence, NewCommittee, NewConstitution, InfoAction) + */ + private String proposalType; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * Block Height + */ + private Integer blockHeight; + + /** + * UNIX timestamp of the block + */ + private Integer blockTime; + + /** + * Actual Vote casted (Yes, No, Abstain) + */ + private String vote; + + /** + * A URL to a JSON payload of metadata (null if not applicable) + */ + private String metaUrl; + + /** + * A hash of the contents of the metadata URL (null if not applicable) + */ + private String metaHash; + + /** + * The payload as JSON + */ + private JsonNode metaJson; +} diff --git a/src/main/java/rest/koios/client/backend/api/network/NetworkService.java b/src/main/java/rest/koios/client/backend/api/network/NetworkService.java index 8ef3f82..d28b425 100644 --- a/src/main/java/rest/koios/client/backend/api/network/NetworkService.java +++ b/src/main/java/rest/koios/client/backend/api/network/NetworkService.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.network; +import com.fasterxml.jackson.databind.JsonNode; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.network.model.*; @@ -76,6 +77,20 @@ public interface NetworkService { */ Result> getParamUpdateProposals(Options options) throws ApiException; + /** + * CLI Protocol Parameters + * Get Current Protocol Parameters as published by cardano-cli. Note that the output schema of this command is unfortunately fluid on cardano-node and may vary between CLI versions/era. Accordingly, the returned output for this endpoint is left as raw JSON (single row) and any filtering to output should be done on client-side + *

200 - Success!! + *

400 - The server cannot process the request due to invalid input + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param options Filtering options (optional) + * @return Result of Current Protocol Parameters as raw JSON {@link JsonNode} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result getCliProtocolParameters(Options options) throws ApiException; + /** * Reserve Withdrawals * List of withdrawals from reserves against stake accounts diff --git a/src/main/java/rest/koios/client/backend/api/network/api/NetworkApi.java b/src/main/java/rest/koios/client/backend/api/network/api/NetworkApi.java index d4f21ee..8b30128 100644 --- a/src/main/java/rest/koios/client/backend/api/network/api/NetworkApi.java +++ b/src/main/java/rest/koios/client/backend/api/network/api/NetworkApi.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.network.api; +import com.fasterxml.jackson.databind.JsonNode; import rest.koios.client.backend.api.network.model.*; import retrofit2.Call; import retrofit2.http.GET; @@ -29,6 +30,9 @@ public interface NetworkApi { @GET("param_updates") Call> getParamUpdateProposals(@QueryMap Map paramsMap); + @GET("cli_protocol_params") + Call getCliProtocolParameters(@QueryMap Map paramsMap); + @GET("reserve_withdrawals") Call> getReserveWithdrawals(@QueryMap Map paramsMap); diff --git a/src/main/java/rest/koios/client/backend/api/network/impl/NetworkServiceImpl.java b/src/main/java/rest/koios/client/backend/api/network/impl/NetworkServiceImpl.java index b5c0da7..d82a59e 100644 --- a/src/main/java/rest/koios/client/backend/api/network/impl/NetworkServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/network/impl/NetworkServiceImpl.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.network.impl; +import com.fasterxml.jackson.databind.JsonNode; import rest.koios.client.backend.api.base.BaseService; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; @@ -57,7 +58,12 @@ public Result> getHistoricalTokenomicStats(Options options) throws @Override public Result> getParamUpdateProposals(Options options) throws ApiException { Call> call = networkApi.getParamUpdateProposals(optionsToParamMap(options)); - ; + return processResponse(call); + } + + @Override + public Result getCliProtocolParameters(Options options) throws ApiException { + Call call = networkApi.getCliProtocolParameters(optionsToParamMap(options)); return processResponse(call); } diff --git a/src/main/java/rest/koios/client/backend/api/network/model/Tip.java b/src/main/java/rest/koios/client/backend/api/network/model/Tip.java index 9197c9d..b314ed9 100644 --- a/src/main/java/rest/koios/client/backend/api/network/model/Tip.java +++ b/src/main/java/rest/koios/client/backend/api/network/model/Tip.java @@ -40,8 +40,14 @@ public class Tip { /** * Block Height number on chain **/ + @Deprecated private Integer blockNo = null; + /** + * Block Height + */ + private Integer blockHeight; + /** * UNIX timestamp of the block **/ diff --git a/src/main/java/rest/koios/client/backend/api/network/model/Totals.java b/src/main/java/rest/koios/client/backend/api/network/model/Totals.java index 2b8b75f..9f97d43 100644 --- a/src/main/java/rest/koios/client/backend/api/network/model/Totals.java +++ b/src/main/java/rest/koios/client/backend/api/network/model/Totals.java @@ -46,4 +46,24 @@ public class Totals { * Total Reserves yet to be unlocked on chain **/ private String reserves = null; + + /** + * The amount (in Lovelace) in the fee pot + */ + private String fees; + + /** + * The amount (in Lovelace) in the obligation pot coming from stake key and pool deposits. + */ + private String depositsStake; + + /** + * The amount (in Lovelace) in the obligation pot coming from drep registrations deposits. + */ + private String depositsDrep; + + /** + * The amount (in Lovelace) in the obligation pot coming from governance proposal deposits. + */ + private String depositsProposal; } diff --git a/src/main/java/rest/koios/client/backend/api/pool/PoolService.java b/src/main/java/rest/koios/client/backend/api/pool/PoolService.java index 0ec7aff..c11333d 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/PoolService.java +++ b/src/main/java/rest/koios/client/backend/api/pool/PoolService.java @@ -111,6 +111,19 @@ public interface PoolService { */ Result> getPoolBlocks(String poolBech32, Options options) throws ApiException; + /** + * Return information about pool owner's historical stake and their promised pledge to their pools + *

200 - Success! + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param poolIds List of Cardano Pool Ids (bech32 format) + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link PoolOwnerHistory} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolOwnerHistory(List poolIds, Options options) throws ApiException; + /** * Pool Stake, Block and Reward History by Epoch with Filtering, Pagination, Ordering Options * Return information about pool stake, block and reward history in a given epoch _epoch_no (or all epochs that pool existed for, in descending order if no _epoch_no was provided) @@ -208,6 +221,19 @@ public interface PoolService { */ Result> getPoolRelays(Options options) throws ApiException; + /** + * Pool Groups with Filtering, Pagination, Ordering Options + * List of all registered pool and their groups across sources from pool_groups repository. This is only relevant for mainnet + *

200 - Success! + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link PoolGroup} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolGroups(Options options) throws ApiException; + /** * Pool Metadata with Filtering, Pagination, Ordering Options * Metadata(on & off-chain) for all currently registered/retiring (not retired) pools @@ -234,4 +260,17 @@ public interface PoolService { * @throws ApiException if an error occurs while attempting to invoke the API */ Result> getPoolMetadata(List poolIds, Options options) throws ApiException; + + /** + * Pool Calidus Keys with Filtering, Pagination, Ordering Options + * List of valid calidus keys for all pools + *

200 - Success! + *

401 - The selected server has restricted the endpoint to be only usable via authentication. The authentication supplied was not authorized to access the endpoint + *

404 - The server does not recognise the combination of endpoint and parameters provided + * + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link PoolCalidusKey} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolCalidusKeys(Options options) throws ApiException; } diff --git a/src/main/java/rest/koios/client/backend/api/pool/api/PoolApi.java b/src/main/java/rest/koios/client/backend/api/pool/api/PoolApi.java index 7c5233a..fe07838 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/api/PoolApi.java +++ b/src/main/java/rest/koios/client/backend/api/pool/api/PoolApi.java @@ -84,6 +84,17 @@ public interface PoolApi { @GET("pool_blocks") Call> getPoolBlocks(@Query("_pool_bech32") String poolBech32, @QueryMap Map paramsMap); + /** + * Pool Owner History + * Return information about pool owner's historical stake and their promised pledge to their pools + * + * @param requestBody List of Cardano pool IDs (bech32 format) + * @param paramsMap Options and Filters Map + * @return List of {@link PoolOwnerHistory} + */ + @POST("pool_owner_history") + Call> getPoolOwnerHistory(@Body Map requestBody, @QueryMap Map paramsMap); + /** * Return information about pool stake, block and reward history in a given epoch _epoch_no (or all epochs that pool existed for, in descending order if no _epoch_no was provided) * @@ -154,6 +165,15 @@ public interface PoolApi { @GET("pool_relays") Call> getPoolRelays(@QueryMap Map paramsMap); + /** + * List of all registered pool and their groups across sources from pool_groups repository. This is only relevant for mainnet + * + * @param paramsMap Options and Filters Map + * @return List of {@link PoolGroup} + */ + @GET("pool_groups") + Call> getPoolGroups(@QueryMap Map paramsMap); + /** * Metadata (on and off-chain) for all currently registered/retiring (not retired) pools * @@ -163,4 +183,13 @@ public interface PoolApi { */ @POST("pool_metadata") Call> getPoolMetadata(@Body Map requestBody, @QueryMap Map paramsMap); + + /** + * List of valid calidus keys for all pools + * + * @param paramsMap Options and Filters Map + * @return List of {@link PoolCalidusKey} + */ + @GET("pool_calidus_keys") + Call> getPoolCalidusKeys(@QueryMap Map paramsMap); } diff --git a/src/main/java/rest/koios/client/backend/api/pool/impl/PoolServiceImpl.java b/src/main/java/rest/koios/client/backend/api/pool/impl/PoolServiceImpl.java index 5562c18..b55da34 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/impl/PoolServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/pool/impl/PoolServiceImpl.java @@ -86,6 +86,15 @@ public Result> getPoolBlocks(String poolBech32, Options options) return processResponse(call); } + @Override + public Result> getPoolOwnerHistory(List poolIds, Options options) throws ApiException { + for (String poolId : poolIds) { + validateBech32(poolId); + } + Call> call = poolApi.getPoolOwnerHistory(buildBody(poolIds), optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result getPoolHistoryByEpoch(String poolBech32, Integer epochNo, Options options) throws ApiException { validateBech32(poolBech32); @@ -132,6 +141,12 @@ public Result> getPoolRelays(Options options) throws ApiExceptio return processResponse(call); } + @Override + public Result> getPoolGroups(Options options) throws ApiException { + Call> call = poolApi.getPoolGroups(optionsToParamMap(options)); + return processResponse(call); + } + @Override public Result> getPoolMetadata(Options options) throws ApiException { return getPoolMetadata(Collections.emptyList(), options); @@ -146,6 +161,12 @@ public Result> getPoolMetadata(List poolIds, Options return processResponse(call); } + @Override + public Result> getPoolCalidusKeys(Options options) throws ApiException { + Call> call = poolApi.getPoolCalidusKeys(optionsToParamMap(options)); + return processResponse(call); + } + private Map buildBody(List poolIds) { Map bodyMap = new HashMap<>(); if (!poolIds.isEmpty()) { diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/Pool.java b/src/main/java/rest/koios/client/backend/api/pool/model/Pool.java index 62b6263..e1974f2 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/model/Pool.java +++ b/src/main/java/rest/koios/client/backend/api/pool/model/Pool.java @@ -72,7 +72,12 @@ public class Pool { /** * Pool ticker */ - private String ticker = null; + private String ticker; + + /** + * A group that the pool was identified to be associated with + */ + private String poolGroup; /** * Pool metadata URL diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolCalidusKey.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolCalidusKey.java new file mode 100644 index 0000000..4ca18a7 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolCalidusKey.java @@ -0,0 +1,64 @@ +package rest.koios.client.backend.api.pool.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Pool Calidus Key + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class PoolCalidusKey { + + /** + * Pool ID (bech32 format) + */ + private String poolIdBech32; + + /** + * Pool status (registered | retiring | retired) + */ + private String poolStatus; + + /** + * Unique nonce for pool's calidus key + */ + private Integer calidusNonce; + + /** + * Calidus public key as per CIP-88 + */ + private String calidusPubKey; + + /** + * Calidus key in bech32 format as per CIP-88 + */ + private String calidusIdBech32; + + /** + * Hash identifier of the transaction + */ + private String txHash; + + /** + * Epoch number + */ + private Integer epochNo; + + /** + * Block Height + */ + private Integer blockHeight; + + /** + * UNIX timestamp of the block + */ + private Integer blockTime; +} diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolGroup.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolGroup.java new file mode 100644 index 0000000..ca991d8 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolGroup.java @@ -0,0 +1,44 @@ +package rest.koios.client.backend.api.pool.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Pool Group + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class PoolGroup { + + /** + * Pool ID (bech32 format) + */ + private String poolIdBech32; + + /** + * A group that the pool was identified to be associated with + */ + private String poolGroup; + + /** + * Pool ticker + */ + private String ticker; + + /** + * The pool's group identification as per adastat.net + */ + private String adastatGroup; + + /** + * The pool's group identification as per balanceanalytics.io + */ + private String balanceanalyticsGroup; +} diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolOwnerHistory.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolOwnerHistory.java new file mode 100644 index 0000000..4e62aef --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolOwnerHistory.java @@ -0,0 +1,44 @@ +package rest.koios.client.backend.api.pool.model; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Pool Calidus Key + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class PoolOwnerHistory { + + /** + * Pool ID (bech32 format) + */ + private String poolIdBech32; + + /** + * Individual Stake account registered as (one of the) pool owner(s) + */ + private String stakeAddress; + + /** + * Pool pledge in number + */ + private String declaredPledge; + + /** + * Epoch for which the pool history data is shown + */ + private Integer epoch; + + /** + * Amount of delegated stake to this pool at the time of epoch snapshot + */ + private String activeStake; +} diff --git a/src/main/java/rest/koios/client/backend/api/transactions/model/RawTx.java b/src/main/java/rest/koios/client/backend/api/transactions/model/RawTx.java index 096ff05..1fbb8cd 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/model/RawTx.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/model/RawTx.java @@ -1,15 +1,11 @@ package rest.koios.client.backend.api.transactions.model; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import rest.koios.client.backend.api.base.common.Asset; - -import java.util.List; /** * Raw Transaction diff --git a/src/main/java/rest/koios/client/utils/Bech32Util.java b/src/main/java/rest/koios/client/utils/Bech32Util.java index 2a6a996..c31e7c3 100644 --- a/src/main/java/rest/koios/client/utils/Bech32Util.java +++ b/src/main/java/rest/koios/client/utils/Bech32Util.java @@ -75,8 +75,7 @@ public static boolean hasValidChars(String bech32EncodedString) { private static boolean isValidHrp(String hrp) { return hrp != null && - hrp.trim().length() > 0 && - hrp.length() >= HRP_MIN_LENGTH && + !hrp.trim().isEmpty() && hrp.length() < HRP_MAX_LENGTH && hrp.chars().allMatch(character -> character >= HRP_MIN_VALUE && character <= HRP_MAX_VALUE); } diff --git a/src/main/java/rest/koios/client/utils/HexUtil.java b/src/main/java/rest/koios/client/utils/HexUtil.java index ef7d9f0..f3bfba2 100644 --- a/src/main/java/rest/koios/client/utils/HexUtil.java +++ b/src/main/java/rest/koios/client/utils/HexUtil.java @@ -25,10 +25,10 @@ public static String encodeHexString(byte[] byteArray, boolean withPrefix) { } public static byte[] decodeHexString(String hexString) { - if(hexString != null && hexString.startsWith("0x")) + if (hexString != null && hexString.startsWith("0x")) hexString = hexString.substring(2); - if (hexString.length() % 2 == 1) { + if (hexString == null || hexString.length() % 2 == 1) { throw new IllegalArgumentException( "Invalid hexadecimal String supplied. " + hexString); } diff --git a/src/main/java/rest/koios/client/utils/Tuple.java b/src/main/java/rest/koios/client/utils/Tuple.java index 32a7b8e..4ca46f5 100644 --- a/src/main/java/rest/koios/client/utils/Tuple.java +++ b/src/main/java/rest/koios/client/utils/Tuple.java @@ -11,12 +11,12 @@ public class Tuple { /** * First Parameter */ - public T _1; + public final T _1; /** * Second Parameter */ - public Z _2; + public final Z _2; /** * Tuple Constructor diff --git a/src/test/java/rest/koios/client/backend/api/account/AccountServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/account/AccountServiceMainnetIntegrationTest.java index aba819d..3f8588b 100644 --- a/src/test/java/rest/koios/client/backend/api/account/AccountServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/account/AccountServiceMainnetIntegrationTest.java @@ -107,24 +107,24 @@ void getAccountTxsBadRequestTest() { void getAccountRewardsTest() throws ApiException { int epochNo = 294; String stakeAddress = "stake1u8yxtugdv63wxafy9d00nuz6hjyyp4qnggvc9a3vxh8yl0ckml2uz"; - Result> accountRewardsResult = accountService.getAccountRewards(List.of(stakeAddress), epochNo, Options.EMPTY); + Result> accountRewardsResult = accountService.getAccountRewardHistory(List.of(stakeAddress), epochNo, Options.EMPTY); Assertions.assertTrue(accountRewardsResult.isSuccessful()); Assertions.assertNotNull(accountRewardsResult.getValue()); - assertEquals(epochNo, accountRewardsResult.getValue().get(0).getRewards().get(0).getEarnedEpoch()); + assertEquals(epochNo, accountRewardsResult.getValue().get(0).getEarnedEpoch()); log.info(accountRewardsResult.getValue().toString()); } @Test void getAccountRewardsBadRequestTest() { String stakeAddress = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountRewards(List.of(stakeAddress), 294, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountRewardHistory(List.of(stakeAddress), 294, Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } @Test void getAccountUpdatesTest() throws ApiException { String stakeAddress = "stake1u8yxtugdv63wxafy9d00nuz6hjyyp4qnggvc9a3vxh8yl0ckml2uz"; - Result> accountUpdatesResult = accountService.getAccountUpdates(List.of(stakeAddress), Options.EMPTY); + Result> accountUpdatesResult = accountService.getAccountUpdateHistory(List.of(stakeAddress), Options.EMPTY); Assertions.assertTrue(accountUpdatesResult.isSuccessful()); Assertions.assertNotNull(accountUpdatesResult.getValue()); log.info(accountUpdatesResult.getValue().toString()); @@ -133,7 +133,7 @@ void getAccountUpdatesTest() throws ApiException { @Test void getAccountUpdatesBadRequestTest() { String stakeAddress = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUpdates(List.of(stakeAddress), Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUpdateHistory(List.of(stakeAddress), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } @@ -172,7 +172,7 @@ void getAccountAssetsBadRequestTest() { @Test void getAccountHistoryTest() throws ApiException { String address = "stake1u8yxtugdv63wxafy9d00nuz6hjyyp4qnggvc9a3vxh8yl0ckml2uz"; - Result> accountHistoryResult = accountService.getAccountHistory(List.of(address), null, Options.EMPTY); + Result> accountHistoryResult = accountService.getAccountStakeHistory(List.of(address), Options.EMPTY); Assertions.assertTrue(accountHistoryResult.isSuccessful()); Assertions.assertNotNull(accountHistoryResult.getValue()); log.info(accountHistoryResult.getValue().toString()); @@ -181,7 +181,7 @@ void getAccountHistoryTest() throws ApiException { @Test void getAccountHistoryBadRequestTest() { String address = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountHistory(List.of(address), null, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountStakeHistory(List.of(address), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } } diff --git a/src/test/java/rest/koios/client/backend/api/account/AccountServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/account/AccountServicePreprodIntegrationTest.java index d65ec6e..0cfee6c 100644 --- a/src/test/java/rest/koios/client/backend/api/account/AccountServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/account/AccountServicePreprodIntegrationTest.java @@ -107,26 +107,25 @@ void getAccountTxsBadRequestTest() { void getAccountRewardsTest() throws ApiException { int epochNo = 33; String stakeAddress = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountRewardsResult = accountService.getAccountRewards(List.of(stakeAddress), epochNo, Options.EMPTY); + Result> accountRewardsResult = accountService.getAccountRewardHistory(List.of(stakeAddress), epochNo, Options.EMPTY); Assertions.assertTrue(accountRewardsResult.isSuccessful()); Assertions.assertNotNull(accountRewardsResult.getValue()); assertFalse(accountRewardsResult.getValue().isEmpty()); - assertFalse(accountRewardsResult.getValue().get(0).getRewards().isEmpty()); - assertEquals(epochNo, accountRewardsResult.getValue().get(0).getRewards().get(0).getEarnedEpoch()); + assertEquals(epochNo, accountRewardsResult.getValue().get(0).getEarnedEpoch()); log.info(accountRewardsResult.getValue().toString()); } @Test void getAccountRewardsBadRequestBadAddressTest() { String stakeAddress = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountRewards(List.of(stakeAddress), 180, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountRewardHistory(List.of(stakeAddress), 180, Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } @Test void getAccountUpdatesTest() throws ApiException { String stakeAddress = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountUpdatesResult = accountService.getAccountUpdates(List.of(stakeAddress), Options.EMPTY); + Result> accountUpdatesResult = accountService.getAccountUpdateHistory(List.of(stakeAddress), Options.EMPTY); Assertions.assertTrue(accountUpdatesResult.isSuccessful()); Assertions.assertNotNull(accountUpdatesResult.getValue()); log.info(accountUpdatesResult.getValue().toString()); @@ -135,7 +134,7 @@ void getAccountUpdatesTest() throws ApiException { @Test void getAccountUpdatesBadRequestTest() { String stakeAddress = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUpdates(List.of(stakeAddress), Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUpdateHistory(List.of(stakeAddress), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } @@ -174,7 +173,7 @@ void getAccountAssetsBadRequestTest() { @Test void getAccountHistoryTest() throws ApiException { String address = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountHistoryResult = accountService.getAccountHistory(List.of(address),null, Options.EMPTY); + Result> accountHistoryResult = accountService.getAccountStakeHistory(List.of(address), Options.EMPTY); Assertions.assertTrue(accountHistoryResult.isSuccessful()); Assertions.assertNotNull(accountHistoryResult.getValue()); log.info(accountHistoryResult.getValue().toString()); @@ -183,7 +182,7 @@ void getAccountHistoryTest() throws ApiException { @Test void getAccountHistoryBadRequestTest() { String address = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountHistory(List.of(address), null, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountStakeHistory(List.of(address), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } } diff --git a/src/test/java/rest/koios/client/backend/api/account/AccountServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/account/AccountServicePreviewIntegrationTest.java index 7c829e0..529e520 100644 --- a/src/test/java/rest/koios/client/backend/api/account/AccountServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/account/AccountServicePreviewIntegrationTest.java @@ -107,24 +107,24 @@ void getAccountTxsBadRequestTest() { void getAccountRewardsTest() throws ApiException { int epochNo = 21; String stakeAddress = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountRewardsResult = accountService.getAccountRewards(List.of(stakeAddress), epochNo, Options.EMPTY); + Result> accountRewardsResult = accountService.getAccountRewardHistory(List.of(stakeAddress), epochNo, Options.EMPTY); Assertions.assertTrue(accountRewardsResult.isSuccessful()); Assertions.assertNotNull(accountRewardsResult.getValue()); - assertEquals(epochNo, accountRewardsResult.getValue().get(0).getRewards().get(0).getEarnedEpoch()); + assertEquals(epochNo, accountRewardsResult.getValue().get(0).getEarnedEpoch()); log.info(accountRewardsResult.getValue().toString()); } @Test void getAccountRewardsBadRequestBadAddressTest() { String stakeAddress = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountRewards(List.of(stakeAddress), 180, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountRewardHistory(List.of(stakeAddress), 180, Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } @Test void getAccountUpdatesTest() throws ApiException { String stakeAddress = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountUpdatesResult = accountService.getAccountUpdates(List.of(stakeAddress), Options.EMPTY); + Result> accountUpdatesResult = accountService.getAccountUpdateHistory(List.of(stakeAddress), Options.EMPTY); Assertions.assertTrue(accountUpdatesResult.isSuccessful()); Assertions.assertNotNull(accountUpdatesResult.getValue()); log.info(accountUpdatesResult.getValue().toString()); @@ -133,7 +133,7 @@ void getAccountUpdatesTest() throws ApiException { @Test void getAccountUpdatesBadRequestTest() { String stakeAddress = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUpdates(List.of(stakeAddress), Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUpdateHistory(List.of(stakeAddress), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } @@ -172,7 +172,7 @@ void getAccountAssetsBadRequestTest() { @Test void getAccountHistoryTest() throws ApiException { String address = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountHistoryResult = accountService.getAccountHistory(List.of(address),null, Options.EMPTY); + Result> accountHistoryResult = accountService.getAccountStakeHistory(List.of(address), Options.EMPTY); Assertions.assertTrue(accountHistoryResult.isSuccessful()); Assertions.assertNotNull(accountHistoryResult.getValue()); log.info(accountHistoryResult.getValue().toString()); @@ -181,7 +181,7 @@ void getAccountHistoryTest() throws ApiException { @Test void getAccountHistoryBadRequestTest() { String address = "a123sd"; - ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountHistory(List.of(address), null, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountStakeHistory(List.of(address), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } } diff --git a/src/test/java/rest/koios/client/backend/api/address/AddressServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/address/AddressServiceMainnetIntegrationTest.java index 67cf162..0e2c353 100644 --- a/src/test/java/rest/koios/client/backend/api/address/AddressServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/address/AddressServiceMainnetIntegrationTest.java @@ -5,6 +5,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import rest.koios.client.backend.api.address.model.AddressOutput; import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.api.address.model.AddressAsset; import rest.koios.client.backend.api.address.model.AddressInfo; @@ -75,6 +76,16 @@ void getAddressUTxOsBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAddressOutputs() throws ApiException { + List addresses = List.of("addr1qy2jt0qpqz2z2z9zx5w4xemekkce7yderz53kjue53lpqv90lkfa9sgrfjuz6uvt4uqtrqhl2kj0a9lnr9ndzutx32gqleeckv", + "addr1q9xvgr4ehvu5k5tmaly7ugpnvekpqvnxj8xy50pa7kyetlnhel389pa4rnq6fmkzwsaynmw0mnldhlmchn2sfd589fgsz9dd0y"); + Result> addressUTxOsResult = addressService.getAddressOutputs(addresses, 6238675, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + @Test void getUTxOsFromPaymentCredentialsTest() throws ApiException { List addresses = List.of("025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52", diff --git a/src/test/java/rest/koios/client/backend/api/asset/AssetServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/asset/AssetServiceMainnetIntegrationTest.java index f88e566..05a6ce5 100644 --- a/src/test/java/rest/koios/client/backend/api/asset/AssetServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/asset/AssetServiceMainnetIntegrationTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import org.junit.platform.commons.util.StringUtils; import rest.koios.client.backend.api.asset.model.*; import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.api.base.Result; @@ -21,12 +20,8 @@ import rest.koios.client.utils.Tuple; import java.math.BigInteger; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.List; -import java.util.StringJoiner; -import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; diff --git a/src/test/java/rest/koios/client/backend/api/block/BlockServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/block/BlockServiceMainnetIntegrationTest.java index 81a39e7..a31a67a 100644 --- a/src/test/java/rest/koios/client/backend/api/block/BlockServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/block/BlockServiceMainnetIntegrationTest.java @@ -9,8 +9,8 @@ import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.block.model.Block; import rest.koios.client.backend.api.block.model.BlockInfo; +import rest.koios.client.backend.api.block.model.BlockTxCbor; import rest.koios.client.backend.api.block.model.BlockTxHash; -import rest.koios.client.backend.api.transactions.model.TxInfo; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -119,10 +119,26 @@ void getBlockTransactionsBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getBlockTransactionsCborTest() throws ApiException { + String hash = "f6192a1aaa6d3d05b4703891a6b66cd757801c61ace86cbe5ab0d66e07f601ab"; + Result> blockTransactionsResult = blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY); + Assertions.assertTrue(blockTransactionsResult.isSuccessful()); + Assertions.assertNotNull(blockTransactionsResult.getValue()); + log.info(blockTransactionsResult.getValue().toString()); + } + + @Test + void getBlockTransactionsCborBadRequestTest() { + String hash = "test"; + ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + @Test void getBlockTransactionsInfoTest() throws ApiException { String hash = "f6192a1aaa6d3d05b4703891a6b66cd757801c61ace86cbe5ab0d66e07f601ab"; - Result> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY); + Result> blockTransactionsResult = blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY); Assertions.assertTrue(blockTransactionsResult.isSuccessful()); Assertions.assertNotNull(blockTransactionsResult.getValue()); log.info(blockTransactionsResult.getValue().toString()); @@ -131,7 +147,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, true, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } } diff --git a/src/test/java/rest/koios/client/backend/api/block/BlockServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/block/BlockServicePreprodIntegrationTest.java index ff05eca..2d70832 100644 --- a/src/test/java/rest/koios/client/backend/api/block/BlockServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/block/BlockServicePreprodIntegrationTest.java @@ -9,8 +9,8 @@ import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.block.model.Block; import rest.koios.client.backend.api.block.model.BlockInfo; +import rest.koios.client.backend.api.block.model.BlockTxCbor; import rest.koios.client.backend.api.block.model.BlockTxHash; -import rest.koios.client.backend.api.transactions.model.TxInfo; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -107,10 +107,26 @@ void getBlockTransactionsBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getBlockTransactionsCborTest() throws ApiException { + String hash = "065b9f0a52b3d3897160a065a7fe2bcb64b2bf635937294ade457de6a7bfd2a4"; + Result> blockTransactionsResult = blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY); + Assertions.assertTrue(blockTransactionsResult.isSuccessful()); + Assertions.assertNotNull(blockTransactionsResult.getValue()); + log.info(blockTransactionsResult.getValue().toString()); + } + + @Test + void getBlockTransactionsCborBadRequestTest() { + String hash = "test"; + ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + @Test void getBlockTransactionsInfoTest() throws ApiException { String hash = "065b9f0a52b3d3897160a065a7fe2bcb64b2bf635937294ade457de6a7bfd2a4"; - Result> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY); + Result> blockTransactionsResult = blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY); Assertions.assertTrue(blockTransactionsResult.isSuccessful()); Assertions.assertNotNull(blockTransactionsResult.getValue()); log.info(blockTransactionsResult.getValue().toString()); @@ -119,7 +135,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, true, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } } diff --git a/src/test/java/rest/koios/client/backend/api/block/BlockServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/block/BlockServicePreviewIntegrationTest.java index 173d748..f04b3fc 100644 --- a/src/test/java/rest/koios/client/backend/api/block/BlockServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/block/BlockServicePreviewIntegrationTest.java @@ -9,8 +9,8 @@ import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.block.model.Block; import rest.koios.client.backend.api.block.model.BlockInfo; +import rest.koios.client.backend.api.block.model.BlockTxCbor; import rest.koios.client.backend.api.block.model.BlockTxHash; -import rest.koios.client.backend.api.transactions.model.TxInfo; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -107,10 +107,26 @@ void getBlockTransactionsBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getBlockTransactionsCborTest() throws ApiException { + String hash = "501fc2c3e3d03f61ec6d19d3f8feb38f3c3c30df66c68027abbd6c99b5acef0e"; + Result> blockTransactionsResult = blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY); + Assertions.assertTrue(blockTransactionsResult.isSuccessful()); + Assertions.assertNotNull(blockTransactionsResult.getValue()); + log.info(blockTransactionsResult.getValue().toString()); + } + + @Test + void getBlockTransactionsCborBadRequestTest() { + String hash = "test"; + ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + @Test void getBlockTransactionsInfoTest() throws ApiException { String hash = "501fc2c3e3d03f61ec6d19d3f8feb38f3c3c30df66c68027abbd6c99b5acef0e"; - Result> blockTransactionsResult = blockService.getBlockTransactionsInfo(List.of(hash), true, true, true, true, true, true, true, Options.EMPTY); + Result> blockTransactionsResult = blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY); Assertions.assertTrue(blockTransactionsResult.isSuccessful()); Assertions.assertNotNull(blockTransactionsResult.getValue()); log.info(blockTransactionsResult.getValue().toString()); @@ -119,7 +135,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, true, Options.EMPTY)); + ApiException exception = assertThrows(ApiException.class, () -> blockService.getBlockTransactionsCbor(List.of(hash), Options.EMPTY)); assertInstanceOf(ApiException.class, exception); } } diff --git a/src/test/java/rest/koios/client/backend/api/governance/GovernanceServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/governance/GovernanceServiceMainnetIntegrationTest.java index 93dc672..ff31e29 100644 --- a/src/test/java/rest/koios/client/backend/api/governance/GovernanceServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/governance/GovernanceServiceMainnetIntegrationTest.java @@ -10,6 +10,8 @@ import rest.koios.client.backend.api.governance.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Options; +import rest.koios.client.backend.factory.options.filters.Filter; +import rest.koios.client.backend.factory.options.filters.FilterType; import java.util.List; @@ -68,10 +70,20 @@ void getDRepsUpdatesTest() throws ApiException { log.info(result.getValue().toString()); } + @Test + void getDRepsVotingPowerTest() throws ApiException { + int epochNo = 320; + String drepId = "drep17l6sywnwqu9aedd6aumev42w39ln5zfl9nw7j4ak6u8swyrwvz3"; + Result> result = governanceService.getDRepsVotingPowerHistory(drepId, epochNo, Options.EMPTY); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + log.info(result.getValue().toString()); + } + @Test void getDRepsVotesTest() throws ApiException { String drepId = "drep17l6sywnwqu9aedd6aumev42w39ln5zfl9nw7j4ak6u8swyrwvz3"; - Result> result = governanceService.getDRepsVotes(drepId, Options.EMPTY); + Result> result = governanceService.getVoteList(Options.builder().option(Filter.of("voter_id", FilterType.EQ, drepId)).build()); Assertions.assertTrue(result.isSuccessful()); Assertions.assertNotNull(result.getValue()); log.info(result.getValue().toString()); @@ -138,10 +150,20 @@ void getProposalVotesTest() throws ApiException { log.info(result.getValue().toString()); } + @Test + void getPoolsVotingPowerHistoryTest() throws ApiException { + int epochNo = 320; + String poolBech32 = "pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc"; + Result> result = governanceService.getPoolsVotingPowerHistory(poolBech32, epochNo, Options.EMPTY); + Assertions.assertTrue(result.isSuccessful()); + Assertions.assertNotNull(result.getValue()); + log.info(result.getValue().toString()); + } + @Test void getPoolVotesTest() throws ApiException { String poolBech32 = "pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc"; - Result> result = governanceService.getPoolVotes(poolBech32, Options.EMPTY); + Result> result = governanceService.getVoteList(Options.builder().option(Filter.of("voter_id", FilterType.EQ, poolBech32)).build()); Assertions.assertTrue(result.isSuccessful()); Assertions.assertNotNull(result.getValue()); log.info(result.getValue().toString()); diff --git a/src/test/java/rest/koios/client/backend/api/network/NetworkServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/network/NetworkServiceMainnetIntegrationTest.java index 4da11c4..ffafed8 100644 --- a/src/test/java/rest/koios/client/backend/api/network/NetworkServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/network/NetworkServiceMainnetIntegrationTest.java @@ -1,5 +1,6 @@ package rest.koios.client.backend.api.network; +import com.fasterxml.jackson.databind.JsonNode; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -81,6 +82,14 @@ void getParamUpdateProposalsTest() throws ApiException { Assertions.assertEquals(10, paramUpdateProposalsResult.getValue().size()); } + @Test + void getCliProtocolParametersTest() throws ApiException { + Result cliProtocolParametersResult = networkService.getCliProtocolParameters(Options.EMPTY); + Assertions.assertTrue(cliProtocolParametersResult.isSuccessful()); + Assertions.assertNotNull(cliProtocolParametersResult.getValue()); + log.info(cliProtocolParametersResult.getValue().toString()); + } + @Test void getReserveWithdrawalsTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); diff --git a/src/test/java/rest/koios/client/backend/api/pool/PoolServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/pool/PoolServiceMainnetIntegrationTest.java index 39a4d98..aa63f9e 100644 --- a/src/test/java/rest/koios/client/backend/api/pool/PoolServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/pool/PoolServiceMainnetIntegrationTest.java @@ -15,7 +15,6 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.assertEquals; @Slf4j @TestInstance(TestInstance.Lifecycle.PER_CLASS) @@ -124,6 +123,17 @@ void getPoolBlocksBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getPoolOwnerHistoryTest() throws ApiException { + String poolBech32 = "pool100wj94uzf54vup2hdzk0afng4dhjaqggt7j434mtgm8v2gfvfgp"; + String poolBech32_2 = "pool102s2nqtea2hf5q0s4amj0evysmfnhrn4apyyhd4azcmsclzm96m"; + String poolBech32_3 = "pool102vsulhfx8ua2j9fwl2u7gv57fhhutc3tp6juzaefgrn7ae35wm"; + Result> poolBlocksResult = poolService.getPoolOwnerHistory(List.of(poolBech32, poolBech32_2, poolBech32_3), Options.EMPTY); + Assertions.assertTrue(poolBlocksResult.isSuccessful()); + Assertions.assertNotNull(poolBlocksResult.getValue()); + log.info(poolBlocksResult.getValue().toString()); + } + @Test void getPoolHistoryByEpochTest() throws ApiException { String poolBech32 = "pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc"; @@ -206,6 +216,14 @@ void getPoolRelaysLimitTest() throws ApiException { assertEquals(10, poolRelaysResult.getValue().size()); } + @Test + void getPoolGroupsTest() throws ApiException { + Result> poolGroupsResult = poolService.getPoolGroups(Options.EMPTY); + Assertions.assertTrue(poolGroupsResult.isSuccessful()); + Assertions.assertNotNull(poolGroupsResult.getValue()); + log.info(poolGroupsResult.getValue().toString()); + } + @Test void getPoolMetadataLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); @@ -215,4 +233,12 @@ void getPoolMetadataLimitTest() throws ApiException { log.info(poolMetadataResult.getValue().toString()); assertEquals(10, poolMetadataResult.getValue().size()); } + + @Test + void getPoolCalidusKeysTest() throws ApiException { + Result> poolCalidusKeysResult = poolService.getPoolCalidusKeys(Options.EMPTY); + Assertions.assertTrue(poolCalidusKeysResult.isSuccessful()); + Assertions.assertNotNull(poolCalidusKeysResult.getValue()); + log.info(poolCalidusKeysResult.getValue().toString()); + } }