diff --git a/README.md b/README.md index c5cc618..7a25c2f 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,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 @@ -66,13 +66,21 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get the Genesis parameters used to start specific era on chain - Get historical tokenomic stats + Historical tokenomic stats Get the circulating utxo, treasury, rewards, supply and reserves in lovelace for specified epoch, all epochs if empty Param Update Proposals Get all parameter update proposals submitted to the chain starting Shelley era + + Reserve Withdrawals + List of all withdrawals from reserves against stake accounts + + + Treasury Withdrawals + List of all withdrawals from treasury against stake accounts + Epoch Epoch Information @@ -101,12 +109,12 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Transactions - Transaction Information - Get detailed information about transaction(s) + UTxO Info + Get UTxO set for requested UTxO references - Transaction UTxOs - Get UTxO set (inputs/outputs) of transactions. + Transaction Information + Get detailed information about transaction(s) Transaction Metadata @@ -125,24 +133,32 @@ 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 - Address Transactions - Get the transaction hash list of input address array, optionally filtering after specified block height (inclusive) + Address UTxOs + Get UTxO set for given addresses - Address Assets - Get the list of all the assets (policy, name and quantity) for a given address + UTxOs from payment credentials + Get UTxO details for requested payment credentials + + + Address Transactions + Get the transaction hash list of input address array, optionally filtering after specified block height (inclusive) Transactions from payment credentials Get the transaction hash list of input payment credential array, optionally filtering after specified block height (inclusive) - Stake Account + Address Assets + Get the list of all the assets (policy, name and quantity) for a given address + + + Stake Account Account List Get a list of all accounts @@ -150,13 +166,17 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Account Information Get the account info of any (payment or staking) address + + Account Information (Cached) + Get the cached account information for given stake addresses (accounts) + Account UTxOs - Get a list of all UTxOs for a given stake address (account) + Get a list of all UTxOs for given stake addresses (account)s - Account Information (Cached) - Get the cached account information for given stake addresses (accounts) + Account Txs + Get a list of all Txs for a given stake address (account) Account Rewards @@ -179,21 +199,17 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get the staking history of an account - Asset + Asset Asset List Get the list of all native assets (paginated) - Asset Token Registry - Get a list of assets registered via token registry on github - - - Asset Addresses - Get the list of all addresses holding a given asset + Policy Asset List + Get the list of asset under the given policy (including balances) - NFT Address - Get the address where specified NFT currently reside on + Asset Token Registry + Get a list of assets registered via token registry on github Asset Information @@ -203,10 +219,22 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Asset Information (Bulk) Get the information of a list of assets including first minting & token registry metadata + + Asset UTxOs + Get the UTXO information of a list of assets including + Asset History Get the mint/burn history of an asset + + Asset Addresses + Get the list of all addresses holding a given asset + + + NFT Address + Get the address where specified NFT currently reside on + Policy Asset Address List Get the list of addresses with quantity for each asset on the given policy. @@ -215,10 +243,6 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Policy Asset Information Get the information for all assets under the same policy - - Policy Asset List - Get the list of asset under the given policy (including balances) - Asset Summary Get the summary of an asset (total transactions exclude minting/total wallets include only wallets with asset balance) @@ -228,7 +252,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Get the list of all asset transaction hashes (newest first) - Pool + Pool Pool List A list of all currently registered/retiring (not retired) pools @@ -260,6 +284,14 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Pool Updates (History) Return all pool updates for all pools or only updates for specific pool if specified + + Pool Registrations + Return all pool registrations initiated in the requested epoch + + + Pool Retirements + Return all pool retirements initiated in the requested epoch + Pool Relays A list of registered relays for all currently registered/retiring (not retired) pools @@ -269,7 +301,11 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Metadata (on & off-chain) for all currently registered/retiring (not retired) pools - Script + Script + Script Information + List of script information for given script hashes + + Native Script List List of all existing native script hashes along with their creation transaction hashes @@ -281,6 +317,10 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca Script Redeemers List of all redeemers for a given script hash + + Script UTxOs + List of all UTXOs for a given script hash + Datum Information List of datum information for given datum hashes @@ -294,6 +334,7 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca | Koios Instance | Koios Java Client | |:--------------:|:-----------------:| +| 1.1.0 | 1.18.0 | | 1.0.10 | 1.17.3 | | 1.0.9 | 1.16.3 | | 1.0.8 | 1.15.2 | @@ -310,13 +351,13 @@ Resource and maintenance requirements for Cardano blockchain components (e.g. ca io.github.cardano-community koios-java-client - 1.17.3 + 1.18.0 ``` - For Gradle, add the following dependency to build.gradle ``` -compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.17.2' +compile group: 'io.github.cardano-community', name: 'koios-java-client', version: '1.18.0' ``` ### Get Koios Backend Service diff --git a/pom.xml b/pom.xml index 8f85172..b0b80cc 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.github.cardano-community koios-java-client - 1.17.3 + 1.18.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 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 73b3541..64a0500 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 @@ -2,6 +2,7 @@ import rest.koios.client.backend.api.account.model.*; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.options.Options; @@ -39,34 +40,51 @@ public interface AccountService { */ Result> getAccountInformation(List stakeAddresses, Options options) throws ApiException; + /** + * Account Information (Cached) + * Get the cached account information 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 stakeAddresses List of Cardano stake address(es) in bech32 format (required) + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link AccountInfo} per the specified payment or staking address + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getCachedAccountInformation(List stakeAddresses, Options options) throws ApiException; + /** * Account UTxOs - * Get a list of all UTxOs for a given stake address (account) + * Get a list of all UTxOs for a given stake address (account)s *

200 - List of account UTxOs associated with stake address *

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 stakeAddress Cardano staking address (reward account) in bech32 format - * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link AccountUTxO} associated with stake address + * @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 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 */ - Result> getAccountUTxOs(String stakeAddress, Options options) throws ApiException; + Result> getAccountUTxOs(List stakeAddresses, boolean extended, Options options) throws ApiException; /** - * Account Information (Cached) - * Get the cached account information for given stake addresses (accounts) - *

200 - Success! + * Account Txs + * Get a list of all Txs for a given stake address (account) + *

200 - List of Txs associated with stake address (account) + *

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 stakeAddresses List of Cardano stake address(es) in bech32 format (required) - * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link AccountInfo} per the specified payment or staking address + * @param stakeAddress Cardano staking address (reward account) in bech32 format + * @param afterBlockHeight Block height for specifying time delta + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link AccountTx} associated with stake address (account) * @throws ApiException if an error occurs while attempting to invoke the API */ - Result> getCachedAccountInformation(List stakeAddresses, Options options) throws ApiException; + Result> getAccountTxs(String stakeAddress, Integer afterBlockHeight, Options options) throws ApiException; /** * Account Rewards @@ -124,10 +142,10 @@ public interface AccountService { * @param addressList Array of Cardano stake address(es) in bech32 format (required) * @param epochNo Only fetch information for a specific epoch (optional) * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link AccountAssets} + * @return Result of Type List of {@link AccountAsset} * @throws ApiException if an error occurs while attempting to invoke the API */ - Result> getAccountAssets(List addressList, Integer epochNo, Options options) throws ApiException; + Result> getAccountAssets(List addressList, Integer epochNo, Options options) throws ApiException; /** * Account History 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 c25fea8..962d4f0 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 @@ -1,6 +1,7 @@ package rest.koios.client.backend.api.account.api; import rest.koios.client.backend.api.account.model.*; +import rest.koios.client.backend.api.base.common.UTxO; import retrofit2.Call; import retrofit2.http.*; @@ -31,16 +32,6 @@ public interface AccountApi { @POST("account_info") Call> getAccountInformation(@Body Map requestBody, @QueryMap Map paramsMap); - /** - * Get Account UTxOs - * - * @param stakeAddress Cardano staking address (reward account) in bech32 format - * @param paramsMap Query Params - * @return List of account UTxOs associated with stake address - */ - @GET("account_utxos") - Call> getAccountUTxOs(@Query("_stake_address") String stakeAddress, @QueryMap Map paramsMap); - /** * Get Account Information (Cached) * @@ -51,6 +42,27 @@ public interface AccountApi { @POST("account_info_cached") Call> getCachedAccountInformation(@Body Map requestBody, @QueryMap Map paramsMap); + /** + * Get Account UTxOs + * + * @param requestBody Json Body containing List of Cardano stake address(es) in bech32 format + * @param paramsMap Query Params + * @return List of account UTxOs associated with stake address + */ + @POST("account_utxos") + Call> getAccountUTxOs(@Body Map requestBody, @QueryMap Map paramsMap); + + /** + * Get Account Txs + * + * @param paramsMap Query Params + * @param stakeAddress Cardano staking address (reward account) in bech32 format + * @param blockHeight Block height for specifying time delta + * @return List of Txs associated with stake address (account) + */ + @GET("account_txs") + Call> getAccountTxs(@Query("_stake_address") String stakeAddress, @Query("_after_block_height") Integer blockHeight, @QueryMap Map paramsMap); + /** * Get Account Rewards * @@ -89,7 +101,7 @@ public interface AccountApi { * @return Native asset balance of an account */ @POST("account_assets") - Call> getAccountAssets(@Body Map requestBody, @QueryMap Map paramsMap); + Call> getAccountAssets(@Body Map requestBody, @QueryMap Map paramsMap); /** * Get Account History 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 ec661af..e9bc75e 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 @@ -5,6 +5,7 @@ import rest.koios.client.backend.api.account.model.*; import rest.koios.client.backend.api.base.BaseService; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.options.Options; import retrofit2.Call; @@ -59,11 +60,13 @@ public Result> getAccountInformation(List stakeAddress } @Override - public Result> getAccountUTxOs(String stakeAddress, Options options) throws ApiException { - validateBech32(stakeAddress); - Call> call = accountApi.getAccountUTxOs(stakeAddress, optionsToParamMap(options)); + public Result> getCachedAccountInformation(List stakeAddresses, Options options) throws ApiException { + for (String address : stakeAddresses) { + validateBech32(address); + } + Call> call = accountApi.getCachedAccountInformation(buildBody("_stake_addresses", stakeAddresses, null, null, null), optionsToParamMap(options)); try { - Response> response = (Response) execute(call); + Response> response = (Response) execute(call); return processResponse(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); @@ -71,13 +74,31 @@ public Result> getAccountUTxOs(String stakeAddress, Options op } @Override - public Result> getCachedAccountInformation(List stakeAddresses, Options options) throws ApiException { - for (String address : stakeAddresses) { - validateBech32(address); + public Result> getAccountUTxOs(List stakeAddresses, boolean extended, Options options) throws ApiException { + for (String stakeAddress : stakeAddresses) { + validateBech32(stakeAddress); } - Call> call = accountApi.getCachedAccountInformation(buildBody("_stake_addresses", stakeAddresses, null, null, null), optionsToParamMap(options)); + Call> call = accountApi.getAccountUTxOs(buildBodyUTxOs(stakeAddresses, extended), optionsToParamMap(options)); try { - Response> response = (Response) execute(call); + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getAccountTxs(String stakeAddress, Integer afterBlockHeight, Options options) throws ApiException { + validateBech32(stakeAddress); + if (afterBlockHeight == null) { + afterBlockHeight = 0; + } + if (afterBlockHeight < 0) { + throw new ApiException("Non Positive \"afterBlockHeight\" Value"); + } + Call> call = accountApi.getAccountTxs(stakeAddress, afterBlockHeight, optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); return processResponse(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); @@ -130,16 +151,16 @@ public Result> getAccountAddresses(List addressList } @Override - public Result> getAccountAssets(List addressList, Integer epochNo, Options options) throws ApiException { + public Result> getAccountAssets(List addressList, Integer epochNo, Options options) throws ApiException { for (String address : addressList) { validateBech32(address); } if (epochNo != null) { validateEpoch(epochNo); } - Call> call = accountApi.getAccountAssets(buildBody("_stake_addresses", addressList, epochNo, null, null), optionsToParamMap(options)); + Call> call = accountApi.getAccountAssets(buildBody("_stake_addresses", addressList, epochNo, null, null), optionsToParamMap(options)); try { - Response> response = (Response) execute(call); + Response> response = (Response) execute(call); return processResponse(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); @@ -177,4 +198,11 @@ private Map buildBody(String arrayObjString, List list, } return bodyMap; } + + private Map buildBodyUTxOs(List stakeAddresses, boolean extended) { + Map bodyMap = new HashMap<>(); + bodyMap.put("_stake_addresses", stakeAddresses); + bodyMap.put("_extended", extended); + return bodyMap; + } } diff --git a/src/main/java/rest/koios/client/backend/api/account/model/AccountAssets.java b/src/main/java/rest/koios/client/backend/api/account/model/AccountAsset.java similarity index 74% rename from src/main/java/rest/koios/client/backend/api/account/model/AccountAssets.java rename to src/main/java/rest/koios/client/backend/api/account/model/AccountAsset.java index 926bdb5..7ed2d84 100644 --- a/src/main/java/rest/koios/client/backend/api/account/model/AccountAssets.java +++ b/src/main/java/rest/koios/client/backend/api/account/model/AccountAsset.java @@ -6,9 +6,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import rest.koios.client.backend.api.common.Asset; - -import java.util.List; +import rest.koios.client.backend.api.base.common.Asset; /** * Account Assets @@ -18,15 +16,10 @@ @ToString @NoArgsConstructor @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -public class AccountAssets { +public class AccountAsset extends Asset { /** * Cardano staking address (reward account) in bech32 format */ private String stakeAddress; - - /** - * List of Assets - */ - private List assetList; } diff --git a/src/main/java/rest/koios/client/backend/api/account/model/AccountUTxO.java b/src/main/java/rest/koios/client/backend/api/account/model/AccountTx.java similarity index 63% rename from src/main/java/rest/koios/client/backend/api/account/model/AccountUTxO.java rename to src/main/java/rest/koios/client/backend/api/account/model/AccountTx.java index f2e5661..e7ed2f0 100644 --- a/src/main/java/rest/koios/client/backend/api/account/model/AccountUTxO.java +++ b/src/main/java/rest/koios/client/backend/api/account/model/AccountTx.java @@ -8,34 +8,24 @@ import lombok.ToString; /** - * AccountUTxO + * Account Tx */ @Getter @Setter @ToString @NoArgsConstructor @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -public class AccountUTxO { +public class AccountTx { /** - * Hash of transaction for UTxO + * Hash identifier of the transaction */ private String txHash; /** - * Index of UTxO in the transaction + * Epoch number of the block */ - private Integer txIndex; - - /** - * A Cardano payment/base address (bech32 encoded) for transaction's input UTxO - */ - private String address; - - /** - * Total sum of ADA on the UTxO - */ - private String value; + private Integer epochNo; /** * Block height 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 49685b1..6bd3bb2 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,9 +1,10 @@ package rest.koios.client.backend.api.address; -import rest.koios.client.backend.api.common.TxHash; +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; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.options.Options; import rest.koios.client.backend.factory.options.SortType; @@ -43,6 +44,36 @@ public interface AddressService { */ Result getAddressInformation(List addressList, SortType utxoSortType, Options options) throws ApiException; + /** + * Address UTXOs + * Get UTxO set for given addresses + *

200 - List of address UTxOs + *

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 extended Controls whether or not 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; + + /** + * UTxOs from payment credentials + * Get UTxO details for requested payment credentials + *

200 - List of address UTxOs + *

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 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 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> getUTxOsFromPaymentCredentials(List paymentCredentials, boolean extended, Options options) throws ApiException; + /** * Address Transactions with Filtering, Pagination, Ordering Options * Get the transaction hash list of input address array 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 b96e2b5..257dcfe 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,8 +1,9 @@ package rest.koios.client.backend.api.address.api; -import rest.koios.client.backend.api.common.TxHash; +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; +import rest.koios.client.backend.api.base.common.UTxO; import retrofit2.Call; import retrofit2.http.Body; import retrofit2.http.POST; @@ -27,12 +28,33 @@ public interface AddressApi { @POST("address_info") Call> getAddressInformation(@Body Map requestBody, @QueryMap Map paramsMap); + /** + * Get Address UTxOs + * + * @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_utxos") + Call> getAddressUTxOs(@Body Map requestBody, @QueryMap Map paramsMap); + + /** + * UTxOs from payment credentials + * Get UTxO details for requested payment credentials + * + * @param requestBody Json Body containing List of Cardano payment credential(s) in hex format + * @param paramsMap Query Params + * @return List of complete UTxO information + */ + @POST("credential_utxos") + Call> getUTxOsFromPaymentCredentials(@Body Map requestBody, @QueryMap Map paramsMap); + /** * Address Transactions * Get the transaction hash list of input address array, optionally filtering after specified block height (inclusive) * * @param requestBody Array of Cardano payment address(es) in bech32 format - * @param paramsMap Options and Filters Map + * @param paramsMap Options and Filters Map * @return List of {@link TxHash} */ @POST("address_txs") 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 d137031..4c8d783 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 @@ -1,13 +1,14 @@ package rest.koios.client.backend.api.address.impl; -import rest.koios.client.backend.api.address.AddressService; import rest.koios.client.backend.api.address.api.AddressApi; +import rest.koios.client.backend.api.address.AddressService; import rest.koios.client.backend.api.address.model.AddressAsset; import rest.koios.client.backend.api.address.model.AddressInfo; import rest.koios.client.backend.api.base.BaseService; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.common.TxHash; +import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.factory.options.Options; import rest.koios.client.backend.factory.options.SortType; import retrofit2.Call; @@ -65,6 +66,34 @@ public Result getAddressInformation(List addressList, SortT } } + @Override + public Result> getAddressUTxOs(List addresses, boolean extended, Options options) throws ApiException { + for (String address : addresses) { + validateBech32(address); + } + Call> call = addressApi.getAddressUTxOs(buildBodyUTxOs(addresses, extended), optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getUTxOsFromPaymentCredentials(List paymentCredentials, boolean extended, Options options) throws ApiException { + for (String address : paymentCredentials) { + validateHexFormat(address); + } + Call> call = addressApi.getUTxOsFromPaymentCredentials(buildBodyUTxOsFromPaymentCredentials(paymentCredentials, extended), optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + @Override public Result> getAddressTransactions(List addressList, Options options) throws ApiException { return getAddressTransactions(addressList,0,options); @@ -131,4 +160,18 @@ private Map buildBody(String arrayObjString, List list, I } return bodyMap; } + + private Map buildBodyUTxOs(List addresses, boolean extended) { + Map bodyMap = new HashMap<>(); + bodyMap.put("_addresses", addresses); + bodyMap.put("_extended", extended); + return bodyMap; + } + + private Map buildBodyUTxOsFromPaymentCredentials(List paymentCredentials, boolean extended) { + Map bodyMap = new HashMap<>(); + bodyMap.put("_payment_credentials", paymentCredentials); + bodyMap.put("_extended", extended); + return bodyMap; + } } diff --git a/src/main/java/rest/koios/client/backend/api/address/model/AddressAsset.java b/src/main/java/rest/koios/client/backend/api/address/model/AddressAsset.java index 0fbe18e..67e71a8 100644 --- a/src/main/java/rest/koios/client/backend/api/address/model/AddressAsset.java +++ b/src/main/java/rest/koios/client/backend/api/address/model/AddressAsset.java @@ -6,9 +6,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import rest.koios.client.backend.api.common.Asset; - -import java.util.List; +import rest.koios.client.backend.api.base.common.Asset; /** * Address Asset @@ -18,15 +16,10 @@ @ToString @NoArgsConstructor @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -public class AddressAsset { +public class AddressAsset extends Asset { /** * A Cardano payment/base address (bech32 encoded) for transaction's input UTxO */ private String address; - - /** - * An array of assets on the UTxO - */ - private List assetList; } diff --git a/src/main/java/rest/koios/client/backend/api/address/model/AddressUtxo.java b/src/main/java/rest/koios/client/backend/api/address/model/AddressUtxo.java index 706a0ea..bb15f52 100644 --- a/src/main/java/rest/koios/client/backend/api/address/model/AddressUtxo.java +++ b/src/main/java/rest/koios/client/backend/api/address/model/AddressUtxo.java @@ -3,9 +3,9 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.*; -import rest.koios.client.backend.api.common.Asset; -import rest.koios.client.backend.api.common.InlineDatum; -import rest.koios.client.backend.api.common.ReferenceScript; +import rest.koios.client.backend.api.base.common.Asset; +import rest.koios.client.backend.api.base.common.InlineDatum; +import rest.koios.client.backend.api.base.common.ReferenceScript; import java.util.ArrayList; diff --git a/src/main/java/rest/koios/client/backend/api/asset/AssetService.java b/src/main/java/rest/koios/client/backend/api/asset/AssetService.java index 0c44584..97cf58f 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/AssetService.java +++ b/src/main/java/rest/koios/client/backend/api/asset/AssetService.java @@ -1,8 +1,9 @@ package rest.koios.client.backend.api.asset; -import rest.koios.client.backend.api.common.TxHash; import rest.koios.client.backend.api.asset.model.*; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.TxHash; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.options.Options; import rest.koios.client.utils.Tuple; @@ -56,22 +57,6 @@ public interface AssetService { */ Result> getAssetsAddresses(String assetPolicy, String assetName, Options options) throws ApiException; - /** - * Assets Address List with Filtering, Pagination, Ordering Options - * Get a list of all addresses for a given asset - *

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 assetPolicy Asset Policy ID in hexadecimal format (hex) (required) - * @param assetName Asset Name in hexadecimal format (hex) (required) - * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link AssetAddress} - * @throws ApiException if an error occurs while attempting to invoke the API - */ - @Deprecated(forRemoval = true) - Result> getAssetsAddressList(String assetPolicy, String assetName, Options options) throws ApiException; - /** * NFT Address * Get the address where specified NFT currently reside on. @@ -83,10 +68,10 @@ public interface AssetService { * @param assetPolicy Asset Policy ID in hexadecimal format (hex) (required) * @param assetName Asset Name in hexadecimal format (hex) (optional) * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link AssetAddress} holding the given token + * @return Result of Type List of {@link PaymentAddress} holding the given token * @throws ApiException if an error occurs while attempting to invoke the API */ - Result> getNFTAddress(String assetPolicy, String assetName, Options options) throws ApiException; + Result> getNFTAddress(String assetPolicy, String assetName, Options options) throws ApiException; /** * Asset Information @@ -117,6 +102,22 @@ public interface AssetService { */ Result getAssetInformationBulk(List> assetList, Options options) throws ApiException; + /** + * Asset UTxOs + * Get the UTXO information of a list of assets + *

200 - List of UTxOs for given asset list + *

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 assetList List of Tuple of policy ID and asset names (hex) + * @param extended Controls whether or not 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} for given asset list + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getAssetUTxOs(List> assetList, Boolean extended, Options options) throws ApiException; + /** * Asset History with Filtering, Pagination, Ordering Options * Get the mint/burn history of an asset @@ -147,21 +148,6 @@ public interface AssetService { */ Result> getPolicyAssetInformation(String assetPolicy, Options options) throws ApiException; - /** - * Asset Policy Information - * Get the information for all assets under the same policy - *

200 - Array of detailed information of assets under the same policy - *

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 assetPolicy Asset Policy ID in hexadecimal format (hex) (required) - * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link PolicyAssetInfo} - * @throws ApiException if an error occurs while attempting to invoke the API - */ - @Deprecated(forRemoval = true) - Result> getAssetPolicyInformation(String assetPolicy, Options options) throws ApiException; - /** * Policy Asset List * Get the list of asset under the given policy (including balances) diff --git a/src/main/java/rest/koios/client/backend/api/asset/api/AssetApi.java b/src/main/java/rest/koios/client/backend/api/asset/api/AssetApi.java index e399fe6..a872e44 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/api/AssetApi.java +++ b/src/main/java/rest/koios/client/backend/api/asset/api/AssetApi.java @@ -1,7 +1,8 @@ package rest.koios.client.backend.api.asset.api; -import rest.koios.client.backend.api.common.TxHash; import rest.koios.client.backend.api.asset.model.*; +import rest.koios.client.backend.api.base.common.TxHash; +import rest.koios.client.backend.api.base.common.UTxO; import retrofit2.Call; import retrofit2.http.*; @@ -46,7 +47,7 @@ public interface AssetApi { * @return List of payment addresses holding the given token */ @GET("asset_nft_address") - Call> getNFTAddress(String assetPolicy, String assetName, @QueryMap Map paramsMap); + Call> getNFTAddress(@Query("_asset_policy") String assetPolicy, @Query("_asset_name") String assetName, @QueryMap Map paramsMap); @GET("asset_info") Call> getAssetInformation(@Query("_asset_policy") String assetPolicy, @Query("_asset_name") String assetName); @@ -61,6 +62,16 @@ public interface AssetApi { @POST("asset_info") Call> getAssetInformationBulk(@Body Map assetList, @QueryMap Map paramsMap); + /** + * Get Asset UTxOs + * + * @param requestBody Json Body containing List of policy ID and asset names (hex) + * @param paramsMap Query Params + * @return List of account UTxOs associated with stake address + */ + @POST("asset_utxos") + Call> getAssetUTxOs(@Body Map requestBody, @QueryMap Map paramsMap); + @GET("asset_history") Call> getAssetHistory(@Query("_asset_policy") String assetPolicy, @Query("_asset_name") String assetName, @QueryMap Map paramsMap); diff --git a/src/main/java/rest/koios/client/backend/api/asset/impl/AssetServiceImpl.java b/src/main/java/rest/koios/client/backend/api/asset/impl/AssetServiceImpl.java index 9ad0585..5f8cf43 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/impl/AssetServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/asset/impl/AssetServiceImpl.java @@ -1,11 +1,12 @@ package rest.koios.client.backend.api.asset.impl; -import rest.koios.client.backend.api.common.TxHash; import rest.koios.client.backend.api.asset.AssetService; import rest.koios.client.backend.api.asset.api.AssetApi; import rest.koios.client.backend.api.asset.model.*; 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; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.options.Options; import rest.koios.client.utils.Tuple; @@ -72,17 +73,12 @@ public Result> getAssetsAddresses(String assetPolicy, String } @Override - public Result> getAssetsAddressList(String assetPolicy, String assetName, Options options) throws ApiException { - return this.getAssetsAddresses(assetPolicy, assetName, options); - } - - @Override - public Result> getNFTAddress(String assetPolicy, String assetName, Options options) throws ApiException { + public Result> getNFTAddress(String assetPolicy, String assetName, Options options) throws ApiException { validateHexFormat(assetPolicy); validateHexFormat(assetName); - Call> call = assetApi.getNFTAddress(assetPolicy, assetName, optionsToParamMap(options)); + Call> call = assetApi.getNFTAddress(assetPolicy, assetName, optionsToParamMap(options)); try { - Response> response = (Response) execute(call); + Response> response = (Response) execute(call); return processResponse(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); @@ -120,6 +116,24 @@ public Result getAssetInformationBulk(List> getAssetUTxOs(List> assetList, Boolean extended, Options options) throws ApiException { + if (assetList == null) { + return badRequestResult("The server cannot process the request due to invalid input"); + } + for (Tuple tuple : assetList) { + validateHexFormat(tuple._1); + validateHexFormat(tuple._2); + } + Call> call = assetApi.getAssetUTxOs(buildBodyUTxOs(assetList, extended), optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + @Override public Result> getAssetHistory(String assetPolicy, String assetName, Options options) throws ApiException { validateHexFormat(assetPolicy); @@ -145,11 +159,6 @@ public Result> getPolicyAssetInformation(String assetPolic } } - @Override - public Result> getAssetPolicyInformation(String assetPolicy, Options options) throws ApiException { - return getPolicyAssetInformation(assetPolicy, options); - } - @Override public Result> getPolicyAssetList(String assetPolicy, Options options) throws ApiException { validateHexFormat(assetPolicy); @@ -205,4 +214,18 @@ private Map buildBody(String arrayObjString, List buildBodyUTxOs(List> list, boolean extended) { + Map bodyMap = new HashMap<>(); + List> lists = new ArrayList<>(); + list.forEach(tuple -> { + List tupleList = new ArrayList<>(); + tupleList.add(tuple._1); + tupleList.add(tuple._2); + lists.add(tupleList); + }); + bodyMap.put("_asset_list", lists); + bodyMap.put("_extended", extended); + return bodyMap; + } } diff --git a/src/main/java/rest/koios/client/backend/api/asset/model/Asset.java b/src/main/java/rest/koios/client/backend/api/asset/model/Asset.java index fab32da..f868900 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/model/Asset.java +++ b/src/main/java/rest/koios/client/backend/api/asset/model/Asset.java @@ -20,7 +20,12 @@ public class Asset { private String policyId; /** - * AssetNames Object + * Asset Name (hex) */ - private AssetNames assetNames; + private String assetName; + + /** + * The CIP14 fingerprint of the asset + */ + private String fingerprint; } diff --git a/src/main/java/rest/koios/client/backend/api/asset/model/AssetAddress.java b/src/main/java/rest/koios/client/backend/api/asset/model/AssetAddress.java index 0286c15..ba39f2a 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/model/AssetAddress.java +++ b/src/main/java/rest/koios/client/backend/api/asset/model/AssetAddress.java @@ -15,12 +15,7 @@ @ToString @NoArgsConstructor @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -public class AssetAddress { - - /** - * A Cardano payment/base address (bech32 encoded) for transaction's input UTxO - */ - private String paymentAddress; +public class AssetAddress extends PaymentAddress { /** * Asset balance on the payment address diff --git a/src/main/java/rest/koios/client/backend/api/asset/model/AssetInformation.java b/src/main/java/rest/koios/client/backend/api/asset/model/AssetInformation.java index a40f73c..2be035e 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/model/AssetInformation.java +++ b/src/main/java/rest/koios/client/backend/api/asset/model/AssetInformation.java @@ -43,6 +43,11 @@ public class AssetInformation { */ private String mintingTxHash; + /** + * Total supply for the asset + */ + private String totalSupply; + /** * Count of total mint transactions */ @@ -54,22 +59,22 @@ public class AssetInformation { private Integer burnCnt; /** - * A JSON array containing details about metadata within transaction + * UNIX timestamp of the first asset mint */ - private JsonNode mintingTxMetadata; + private Long creationTime; /** - * Asset metadata registered on the Cardano Token Registry + * Latest minting transaction metadata (aligns with CIP-25) */ - private TokenRegistryMetadata tokenRegistryMetadata; + private JsonNode mintingTxMetadata; /** - * Total Supply + * Asset metadata registered on the Cardano Token Registry */ - private String totalSupply; + private TokenRegistryMetadata tokenRegistryMetadata; /** - * UNIX timestamp of the first asset mint + * CIP 68 metadata if present for asset */ - private Long creationTime; + private JsonNode cip68Metadata; } diff --git a/src/main/java/rest/koios/client/backend/api/asset/model/AssetNames.java b/src/main/java/rest/koios/client/backend/api/asset/model/PaymentAddress.java similarity index 53% rename from src/main/java/rest/koios/client/backend/api/asset/model/AssetNames.java rename to src/main/java/rest/koios/client/backend/api/asset/model/PaymentAddress.java index f7284cd..fabe080 100644 --- a/src/main/java/rest/koios/client/backend/api/asset/model/AssetNames.java +++ b/src/main/java/rest/koios/client/backend/api/asset/model/PaymentAddress.java @@ -2,27 +2,23 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; - -import java.util.ArrayList; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; /** - * Asset Names + * Asset Address */ @Getter @Setter @ToString @NoArgsConstructor @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -public class AssetNames { - - /** - * Asset Names (hex) - */ - private ArrayList hex; +public class PaymentAddress { /** - * Asset Names (ASCII) + * A Cardano payment/base address (bech32 encoded) for transaction's input UTxO */ - private ArrayList ascii; + private String paymentAddress; } diff --git a/src/main/java/rest/koios/client/backend/api/common/Asset.java b/src/main/java/rest/koios/client/backend/api/base/common/Asset.java similarity index 93% rename from src/main/java/rest/koios/client/backend/api/common/Asset.java rename to src/main/java/rest/koios/client/backend/api/base/common/Asset.java index 5cfc315..b9da0bc 100644 --- a/src/main/java/rest/koios/client/backend/api/common/Asset.java +++ b/src/main/java/rest/koios/client/backend/api/base/common/Asset.java @@ -1,4 +1,4 @@ -package rest.koios.client.backend.api.common; +package rest.koios.client.backend.api.base.common; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/src/main/java/rest/koios/client/backend/api/common/InlineDatum.java b/src/main/java/rest/koios/client/backend/api/base/common/InlineDatum.java similarity index 87% rename from src/main/java/rest/koios/client/backend/api/common/InlineDatum.java rename to src/main/java/rest/koios/client/backend/api/base/common/InlineDatum.java index 92fe738..e8ef896 100644 --- a/src/main/java/rest/koios/client/backend/api/common/InlineDatum.java +++ b/src/main/java/rest/koios/client/backend/api/base/common/InlineDatum.java @@ -1,4 +1,4 @@ -package rest.koios.client.backend.api.common; +package rest.koios.client.backend.api.base.common; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; @@ -19,7 +19,7 @@ public class InlineDatum { /** - * Datum (hex) + * Datum bytes (hex) */ private String bytes; diff --git a/src/main/java/rest/koios/client/backend/api/common/ReferenceScript.java b/src/main/java/rest/koios/client/backend/api/base/common/ReferenceScript.java similarity index 93% rename from src/main/java/rest/koios/client/backend/api/common/ReferenceScript.java rename to src/main/java/rest/koios/client/backend/api/base/common/ReferenceScript.java index 4123406..7cc41c3 100644 --- a/src/main/java/rest/koios/client/backend/api/common/ReferenceScript.java +++ b/src/main/java/rest/koios/client/backend/api/base/common/ReferenceScript.java @@ -1,4 +1,4 @@ -package rest.koios.client.backend.api.common; +package rest.koios.client.backend.api.base.common; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; diff --git a/src/main/java/rest/koios/client/backend/api/common/TxHash.java b/src/main/java/rest/koios/client/backend/api/base/common/TxHash.java similarity index 92% rename from src/main/java/rest/koios/client/backend/api/common/TxHash.java rename to src/main/java/rest/koios/client/backend/api/base/common/TxHash.java index 54d0774..be1ce49 100644 --- a/src/main/java/rest/koios/client/backend/api/common/TxHash.java +++ b/src/main/java/rest/koios/client/backend/api/base/common/TxHash.java @@ -1,4 +1,4 @@ -package rest.koios.client.backend.api.common; +package rest.koios.client.backend.api.base.common; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; diff --git a/src/main/java/rest/koios/client/backend/api/base/common/UTxO.java b/src/main/java/rest/koios/client/backend/api/base/common/UTxO.java new file mode 100644 index 0000000..cfd9ed3 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/base/common/UTxO.java @@ -0,0 +1,91 @@ +package rest.koios.client.backend.api.base.common; + +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 java.util.List; + +/** + * UTxO + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class UTxO { + + /** + * Hash identifier of the transaction + */ + private String txHash; + + /** + * Index of UTxO in the transaction + */ + private Integer txIndex; + + /** + * A Cardano payment/base address (bech32 encoded) + */ + private String address; + + /** + * Total sum of ADA on the UTxO + */ + private String value; + + /** + * Cardano staking address (reward account) in bech32 format + */ + private String stakeAddress; + + /** + * Payment credential + */ + private String paymentCred; + + /** + * Epoch number of the block + */ + private Integer epochNo; + + /** + * Block height + */ + private Integer blockHeight; + + /** + * UNIX timestamp of the block + */ + private Integer blockTime; + + /** + * The Hash of the Plutus Data + */ + private String datumHash; + + /** + * Allows datums to be attached to UTxO (CIP-32) + */ + private InlineDatum inlineDatum; + + /** + * Allow reference scripts to be used to satisfy script requirements during validation, rather than requiring the spending transaction to do so. (CIP-33) + */ + private ReferenceScript referenceScript; + + /** + * List of assets on the UTxO + */ + private List assetList; + + /** + * True if the UTXO has been spent + */ + private Boolean isSpent; +} 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 babe57b..81e386f 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 @@ -3,8 +3,8 @@ 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; -import rest.koios.client.backend.api.block.BlockService; import rest.koios.client.backend.api.block.api.BlockApi; +import rest.koios.client.backend.api.block.BlockService; 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.BlockTxHash; diff --git a/src/main/java/rest/koios/client/backend/api/block/model/Block.java b/src/main/java/rest/koios/client/backend/api/block/model/Block.java index c815b8e..868d317 100644 --- a/src/main/java/rest/koios/client/backend/api/block/model/Block.java +++ b/src/main/java/rest/koios/client/backend/api/block/model/Block.java @@ -2,7 +2,10 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; /** * Block @@ -60,14 +63,14 @@ public class Block { private String vrfKey = null; /** - * Counter value of the operational certificate used to create this block + * Pool ID in bech32 format */ - private Integer opCertCounter = null; + private String pool = null; /** - * Pool ID in bech32 format + * Counter value of the operational certificate used to create this block */ - private String pool = null; + private Integer opCertCounter = null; /** * The protocol major version diff --git a/src/main/java/rest/koios/client/backend/api/block/model/BlockInfo.java b/src/main/java/rest/koios/client/backend/api/block/model/BlockInfo.java index 2eb0836..1687fc7 100644 --- a/src/main/java/rest/koios/client/backend/api/block/model/BlockInfo.java +++ b/src/main/java/rest/koios/client/backend/api/block/model/BlockInfo.java @@ -2,7 +2,10 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; /** * Block Information diff --git a/src/main/java/rest/koios/client/backend/api/block/model/BlockTxHash.java b/src/main/java/rest/koios/client/backend/api/block/model/BlockTxHash.java index 3656512..dc0fd33 100644 --- a/src/main/java/rest/koios/client/backend/api/block/model/BlockTxHash.java +++ b/src/main/java/rest/koios/client/backend/api/block/model/BlockTxHash.java @@ -23,7 +23,22 @@ public class BlockTxHash { private String blockHash; /** - * Array of Hash identifiers of the transaction + * Hash identifier of the transaction */ - private String[] txHashes; + private String txHash; + + /** + * Epoch number of the block + */ + 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/epoch/helper/CostModelsDeserializer.java b/src/main/java/rest/koios/client/backend/api/epoch/helper/CostModelsDeserializer.java deleted file mode 100644 index 0f5f640..0000000 --- a/src/main/java/rest/koios/client/backend/api/epoch/helper/CostModelsDeserializer.java +++ /dev/null @@ -1,25 +0,0 @@ -package rest.koios.client.backend.api.epoch.helper; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.ObjectCodec; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.TextNode; - -import java.io.IOException; -import java.util.Map; - -/** - * Cost Models Json Deserializer - */ -public class CostModelsDeserializer extends JsonDeserializer>> { - - @Override - public Map> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { - ObjectCodec objectCodec = jsonParser.getCodec(); - TextNode textNode = objectCodec.readTree(jsonParser); - return ((ObjectMapper) objectCodec).readValue(textNode.asText(), new TypeReference<>() {}); - } -} diff --git a/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java b/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java index fd96aa4..9bc04e0 100644 --- a/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/epoch/impl/EpochServiceImpl.java @@ -4,10 +4,10 @@ import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.epoch.EpochService; -import rest.koios.client.backend.api.epoch.api.EpochApi; import rest.koios.client.backend.api.epoch.model.EpochBlockProtocols; import rest.koios.client.backend.api.epoch.model.EpochInfo; import rest.koios.client.backend.api.epoch.model.EpochParams; +import rest.koios.client.backend.api.epoch.api.EpochApi; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; import retrofit2.Call; diff --git a/src/main/java/rest/koios/client/backend/api/epoch/model/EpochParams.java b/src/main/java/rest/koios/client/backend/api/epoch/model/EpochParams.java index b9736ca..28389c0 100644 --- a/src/main/java/rest/koios/client/backend/api/epoch/model/EpochParams.java +++ b/src/main/java/rest/koios/client/backend/api/epoch/model/EpochParams.java @@ -1,16 +1,14 @@ package rest.koios.client.backend.api.epoch.model; +import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 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.epoch.helper.CostModelsDeserializer; import java.math.BigDecimal; -import java.util.Map; /** * Epoch Parameters @@ -27,11 +25,6 @@ public class EpochParams { */ private Integer epochNo = null; - /** - * Extra Entropy - */ - private String extraEntropy; - /** * The 'a' parameter to calculate the minimum transaction fee */ @@ -98,9 +91,9 @@ public class EpochParams { private BigDecimal decentralisation = null; /** - * The hash of 32-byte string of extra random-ness added into the protocol's entropy pool + * Extra Entropy */ - private String entropy = null; + private String extraEntropy; /** * The protocol major version @@ -135,8 +128,7 @@ public class EpochParams { /** * The per language cost models */ - @JsonDeserialize(using = CostModelsDeserializer.class) - private Map> costModels = null; + private JsonNode costModels = null; /** * The per word cost of script memory usage @@ -187,10 +179,4 @@ public class EpochParams { * The cost per UTxO size */ private String coinsPerUtxoSize = null; - - /** - * The cost per UTxO word - */ - @Deprecated - private String coinsPerUtxoWord = null; } 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 87fed85..8ef3f82 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 @@ -2,10 +2,7 @@ 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.Genesis; -import rest.koios.client.backend.api.network.model.ParamUpdateProposal; -import rest.koios.client.backend.api.network.model.Tip; -import rest.koios.client.backend.api.network.model.Totals; +import rest.koios.client.backend.api.network.model.*; import rest.koios.client.backend.factory.options.Options; import java.util.List; @@ -78,4 +75,34 @@ public interface NetworkService { * @throws ApiException if an error occurs while attempting to invoke the API */ Result> getParamUpdateProposals(Options options) throws ApiException; + + /** + * Reserve Withdrawals + * List of withdrawals from reserves against stake accounts + * + *

200 - List of withdrawals from reserves against stake accounts + *

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 and Pagination options (optional) + * @return Result of Type List of {@link Withdrawal} from reserves against stake accounts + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getReserveWithdrawals(Options options) throws ApiException; + + /** + * Treasury Withdrawals + * List of all withdrawals from treasury against stake accounts + * + *

200 - List of withdrawals from treasury against stake accounts + *

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 and Pagination options (optional) + * @return Result of Type List of {@link Withdrawal} from treasury against stake accounts + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getTreasuryWithdrawals(Options options) throws ApiException; } 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 d623395..d4f21ee 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,9 +1,6 @@ package rest.koios.client.backend.api.network.api; -import rest.koios.client.backend.api.network.model.Genesis; -import rest.koios.client.backend.api.network.model.ParamUpdateProposal; -import rest.koios.client.backend.api.network.model.Tip; -import rest.koios.client.backend.api.network.model.Totals; +import rest.koios.client.backend.api.network.model.*; import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Query; @@ -31,4 +28,10 @@ public interface NetworkApi { @GET("param_updates") Call> getParamUpdateProposals(@QueryMap Map paramsMap); + + @GET("reserve_withdrawals") + Call> getReserveWithdrawals(@QueryMap Map paramsMap); + + @GET("treasury_withdrawals") + Call> getTreasuryWithdrawals(@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 c8e3bac..dfa9a90 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 @@ -3,12 +3,9 @@ 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; -import rest.koios.client.backend.api.network.NetworkService; import rest.koios.client.backend.api.network.api.NetworkApi; -import rest.koios.client.backend.api.network.model.Genesis; -import rest.koios.client.backend.api.network.model.ParamUpdateProposal; -import rest.koios.client.backend.api.network.model.Tip; -import rest.koios.client.backend.api.network.model.Totals; +import rest.koios.client.backend.api.network.model.*; +import rest.koios.client.backend.api.network.NetworkService; import rest.koios.client.backend.factory.options.Options; import retrofit2.Call; import retrofit2.Response; @@ -89,4 +86,26 @@ public Result> getParamUpdateProposals(Options options throw new ApiException(e.getMessage(), e); } } + + @Override + public Result> getReserveWithdrawals(Options options) throws ApiException { + Call> call = networkApi.getReserveWithdrawals(optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getTreasuryWithdrawals(Options options) throws ApiException { + Call> call = networkApi.getTreasuryWithdrawals(optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } } 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 f69945f..9197c9d 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 @@ -2,7 +2,10 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; /** * Tip 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 7235e99..2b8b75f 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 @@ -2,7 +2,10 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; /** * Totals diff --git a/src/main/java/rest/koios/client/backend/api/network/model/Withdrawal.java b/src/main/java/rest/koios/client/backend/api/network/model/Withdrawal.java new file mode 100644 index 0000000..2aadbc4 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/network/model/Withdrawal.java @@ -0,0 +1,54 @@ +package rest.koios.client.backend.api.network.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; + +/** + * Withdrawal + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class Withdrawal { + + /** + * Epoch number + **/ + private Integer epochNo; + + /** + * Slot number of the block in epoch + **/ + private Integer epochSlot; + + /** + * Hash identifier of the transaction + **/ + private String txHash; + + /** + * Hash of the block + **/ + private String blockHash; + + /** + * Block height + **/ + private Integer blockHeight; + + /** + * Current delegator live stake (in lovelace) + **/ + private String amount; + + /** + * Cardano staking address (reward account) in bech32 format + **/ + private String stakeAddress; +} 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 bd09501..0ec7aff 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 @@ -167,6 +167,34 @@ public interface PoolService { */ Result> getPoolUpdates(Options options) throws ApiException; + /** + * Pool Registrations with Filtering, Pagination, Ordering Options + * Return all pool registrations initiated in the requested epoch + *

200 - List of pool registrations + *

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 epochNo Epoch Number to fetch details for + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link PoolStatus} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolRegistrations(Integer epochNo, Options options) throws ApiException; + + /** + * Pool Retirements with Filtering, Pagination, Ordering Options + * Return all pool retirements initiated in the requested epoch + *

200 - List of pool retirements + *

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 epochNo Epoch Number to fetch details for + * @param options Filtering and Pagination options (optional) + * @return Result of Type List of {@link PoolStatus} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getPoolRetirements(Integer epochNo, Options options) throws ApiException; + /** * Pool Relays with Filtering, Pagination, Ordering Options * A list of registered relays for all currently registered/retiring (not retired) pools 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 f846474..7c5233a 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 @@ -125,6 +125,26 @@ public interface PoolApi { @GET("pool_updates") Call> getPoolUpdates(@QueryMap Map paramsMap); + /** + * Pool Registrations + * Return all pool registrations initiated in the requested epoch + * + * @param paramsMap Options and Filters Map + * @return List of {@link PoolStatus} + */ + @GET("pool_registrations") + Call> getPoolRegistrations(@Query("_epoch_no") Integer epochNo, @QueryMap Map paramsMap); + + /** + * Pool Retirements + * Return all pool retirements initiated in the requested epoch + * + * @param paramsMap Options and Filters Map + * @return List of {@link PoolStatus} + */ + @GET("pool_retirements") + Call> getPoolRetirements(@Query("_epoch_no") Integer epochNo, @QueryMap Map paramsMap); + /** * A list of registered relays for all currently registered/retiring (not retired) pools * 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 cdfdb4b..8b3c9df 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 @@ -171,6 +171,28 @@ public Result> getPoolUpdates(Options options) throws ApiExcept } } + @Override + public Result> getPoolRegistrations(Integer epochNo, Options options) throws ApiException { + Call> call = poolApi.getPoolRegistrations(epochNo, optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + + @Override + public Result> getPoolRetirements(Integer epochNo, Options options) throws ApiException { + Call> call = poolApi.getPoolRetirements(epochNo, optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + @Override public Result> getPoolRelays(Options options) throws ApiException { Call> call = poolApi.getPoolRelays(optionsToParamMap(options)); 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 dbdfdf2..8cbcce2 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 @@ -2,7 +2,12 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; /** * Pool @@ -15,12 +20,73 @@ public class Pool { /** - * Bech32 representation of pool ID + * Pool ID (bech32 format) + */ + private String poolIdBech32; + + /** + * Pool ID (Hex format) + */ + private String poolIdHex; + + /** + * Epoch number in which the update becomes active + */ + private Integer activeEpochNo; + + /** + * Margin (decimal format) + */ + private Double margin; + + /** + * Pool fixed cost per epoch + */ + private String fixedCost; + + /** + * Pool pledge in lovelace + */ + private String pledge; + + /** + * Pool reward address */ - private String poolIdBech32 = null; + private String rewardAddr; + + /** + * List of Pool (co)owner address + */ + private List owners; + + /** + * List of Pool Relays + */ + private List relays; /** * Pool ticker */ private String ticker = null; + + /** + * Pool metadata URL + */ + private String metaUrl; + + /** + * Pool metadata hash + */ + private String metaHash; + + /** + * Pool status (registered | retiring | retired) + */ + private String poolStatus; + + /** + * Announced retiring epoch (nullable) + */ + private Integer retiringEpoch; + } diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolHistory.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolHistory.java index e6f88ed..1cec7be 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/model/PoolHistory.java +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolHistory.java @@ -67,6 +67,11 @@ public class PoolHistory { */ private String delegRewards; + /** + * Total amount of rewards earned by members (delegator - owner) in that epoch (in lovelaces) + */ + private String memberRewards; + /** * Annualized ROS (return on staking) for delegators for this epoch */ diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolInfo.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolInfo.java index fc353e6..b1f0008 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/model/PoolInfo.java +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolInfo.java @@ -2,9 +2,12 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; -import java.util.ArrayList; +import java.util.List; /** * Pool Information @@ -27,7 +30,7 @@ public class PoolInfo { private String poolIdHex; /** - * Block number on chain where transaction was included + * Epoch number in which the update becomes active */ private Integer activeEpochNo; @@ -59,12 +62,12 @@ public class PoolInfo { /** * List of Pool (co)owner address */ - private ArrayList owners; + private List owners; /** * List of Pool Relays */ - private ArrayList relays; + private List relays; /** * Pool metadata URL diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolMetadata.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolMetadata.java index 37fe079..c5ac057 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/model/PoolMetadata.java +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolMetadata.java @@ -14,11 +14,28 @@ @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class PoolMetadata { + /** + * Pool ID (bech32 format) + */ private String poolIdBech32; + /** + * Pool metadata URL + */ private String metaUrl; + /** + * Pool metadata hash + */ private String metaHash; + /** + * Metadata Json Object + */ private MetaJson metaJson; + + /** + * Pool Status: registered | retiring | retired + */ + private String poolStatus; } diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolRelay.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolRelay.java index cb90e5d..292c00a 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/model/PoolRelay.java +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolRelay.java @@ -16,7 +16,18 @@ @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public class PoolRelay { + /** + * Pool ID (bech32 format) + */ private String poolIdBech32; + /** + * Relays + */ private ArrayList relays; + + /** + * Pool Status: registered | retiring | retired + */ + private String poolStatus; } diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolStatus.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolStatus.java new file mode 100644 index 0000000..1c29b2c --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolStatus.java @@ -0,0 +1,54 @@ +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 Status + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class PoolStatus { + + /** + * Pool ID (bech32 format) + */ + private String poolIdBech32; + + /** + * Hash identifier of the transaction + */ + private String txHash; + + /** + * Hash of the block + */ + private String blockHash; + + /** + * Block height + */ + private Integer blockHeight; + + /** + * Epoch number + */ + private Integer epochNo; + + /** + * Slot number of the block in epoch + */ + private Integer epochSlot; + + /** + * Epoch number in which the update becomes active + */ + private Integer activeEpochNo; +} diff --git a/src/main/java/rest/koios/client/backend/api/pool/model/PoolUpdate.java b/src/main/java/rest/koios/client/backend/api/pool/model/PoolUpdate.java index 24b5179..affd35f 100644 --- a/src/main/java/rest/koios/client/backend/api/pool/model/PoolUpdate.java +++ b/src/main/java/rest/koios/client/backend/api/pool/model/PoolUpdate.java @@ -1,11 +1,13 @@ package rest.koios.client.backend.api.pool.model; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; -import java.util.ArrayList; +import java.util.List; /** * Pool Update @@ -55,12 +57,12 @@ public class PoolUpdate { /** * Pool fixed cost per epoch */ - private Long fixedCost; + private String fixedCost; /** * Pool pledge in lovelace */ - private Long pledge; + private String pledge; /** * Pool reward address @@ -70,12 +72,12 @@ public class PoolUpdate { /** * Pool (co)owner addresses */ - private ArrayList owners; + private List owners; /** * Relays */ - private ArrayList relays; + private List relays; /** * Pool metadata URL @@ -90,13 +92,13 @@ public class PoolUpdate { /** * Historical metadata information */ - private JsonNode metaJson; + private MetaJson metaJson; /** * Pool status - * Allowed: registered | retiring | retired + * Allowed: registration|deregistration */ - private String poolStatus; + private String updateType; /** * Announced retiring epoch (nullable) diff --git a/src/main/java/rest/koios/client/backend/api/script/ScriptService.java b/src/main/java/rest/koios/client/backend/api/script/ScriptService.java index 312d9bf..c1959d7 100644 --- a/src/main/java/rest/koios/client/backend/api/script/ScriptService.java +++ b/src/main/java/rest/koios/client/backend/api/script/ScriptService.java @@ -1,11 +1,9 @@ package rest.koios.client.backend.api.script; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; -import rest.koios.client.backend.api.script.model.PlutusScript; -import rest.koios.client.backend.api.script.model.ScriptRedeemer; +import rest.koios.client.backend.api.script.model.*; import rest.koios.client.backend.factory.options.Options; import java.util.List; @@ -15,6 +13,19 @@ */ public interface ScriptService { + /** + * Native Script List with Filtering, Pagination, Ordering Options + * List of all existing native script hashes along with their creation transaction hashes + *

200 - List of script and creation tx hash pairs + *

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 PlutusScript} + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getScriptInformation(List scriptHashes, Options options) throws ApiException; + /** * Native Script List with Filtering, Pagination, Ordering Options * List of all existing native script hashes along with their creation transaction hashes @@ -39,7 +50,7 @@ public interface ScriptService { * @return Result of Type {@link NativeScript} * @throws ApiException if an error occurs while attempting to invoke the API */ - Result getNativeScript(String scriptHash) throws ApiException; + Result getNativeScriptByScriptHash(String scriptHash) throws ApiException; /** * Plutus Script List with Filtering, Pagination, Ordering Options @@ -62,12 +73,27 @@ public interface ScriptService { *

404 - The server does not recognise the combination of endpoint and parameters provided * * @param scriptHash Script hash in hexadecimal format (hex) (required) - * @param options Filtering and Pagination options (optional) + * @param options Filtering and Pagination options (optional) * @return Result of Type List of all {@link ScriptRedeemer} for a given script hash * @throws ApiException if an error occurs while attempting to invoke the API */ Result> getScriptRedeemers(String scriptHash, Options options) throws ApiException; + /** + * Script UTXOs with Filtering, Pagination, Ordering Options + * List of all UTXOs for a given script hash + *

200 - List of UTXOs for a given script hash + *

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 scriptHash Script hash in hexadecimal format (hex) (required) + * @param extended Controls whether or not 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 all {@link UTxO} for a given script hash + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getScriptUTxOs(String scriptHash, Boolean extended, Options options) throws ApiException; + /** * Datum Information with Filtering, Pagination, Ordering Options * List of datum information for given datum hashes @@ -77,7 +103,7 @@ public interface ScriptService { *

404 - The server does not recognise the combination of endpoint and parameters provided * * @param datumHashes List of Cardano datum hashes (required) - * @param options Filtering and Pagination options (optional) + * @param options Filtering and Pagination options (optional) * @return Result of Type List of all {@link DatumInfo} for a given script hash * @throws ApiException if an error occurs while attempting to invoke the API */ diff --git a/src/main/java/rest/koios/client/backend/api/script/api/ScriptApi.java b/src/main/java/rest/koios/client/backend/api/script/api/ScriptApi.java index 187ba7c..236d9f7 100644 --- a/src/main/java/rest/koios/client/backend/api/script/api/ScriptApi.java +++ b/src/main/java/rest/koios/client/backend/api/script/api/ScriptApi.java @@ -1,9 +1,7 @@ package rest.koios.client.backend.api.script.api; -import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; -import rest.koios.client.backend.api.script.model.PlutusScript; -import rest.koios.client.backend.api.script.model.ScriptRedeemer; +import rest.koios.client.backend.api.base.common.UTxO; +import rest.koios.client.backend.api.script.model.*; import retrofit2.Call; import retrofit2.http.*; @@ -15,6 +13,16 @@ */ public interface ScriptApi { + /** + * List of script information for given script hashes + * + * @param requestBody Array of Cardano script hashes + * @param paramsMap Options and Filters Map + * @return List of {@link ScriptInfo} + */ + @POST("script_info") + Call> getScriptInformation(@Body Map requestBody, @QueryMap Map paramsMap); + /** * List of all existing native script hashes along with their creation transaction hashes * @@ -43,11 +51,23 @@ public interface ScriptApi { @GET("script_redeemers") Call> getScriptRedeemers(@Query("_script_hash") String scriptHash, @QueryMap Map paramsMap); + /** + * Script UTXOs + * List of all UTXOs for a given script hash + * + * @param scriptHash Script hash in hexadecimal format (hex) + * @param extended Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call + * @param paramsMap Options and Filters Map + * @return List of {@link ScriptRedeemer} + */ + @GET("script_utxos") + Call> getScriptUTxOs(@Query("_script_hash") String scriptHash, @Query("_extended") Boolean extended, @QueryMap Map paramsMap); + /** * Get Datum Information * * @param requestBody Array of Cardano datum hashes - * @param paramsMap Query Params + * @param paramsMap Query Params * @return List of datum information for given datum hashes */ @POST("datum_info") diff --git a/src/main/java/rest/koios/client/backend/api/script/impl/ScriptServiceImpl.java b/src/main/java/rest/koios/client/backend/api/script/impl/ScriptServiceImpl.java index c20cc22..ceed554 100644 --- a/src/main/java/rest/koios/client/backend/api/script/impl/ScriptServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/script/impl/ScriptServiceImpl.java @@ -2,13 +2,11 @@ import rest.koios.client.backend.api.base.BaseService; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.script.ScriptService; +import rest.koios.client.backend.api.script.model.*; import rest.koios.client.backend.api.script.api.ScriptApi; -import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; -import rest.koios.client.backend.api.script.model.PlutusScript; -import rest.koios.client.backend.api.script.model.ScriptRedeemer; 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; @@ -38,6 +36,20 @@ public ScriptServiceImpl(String baseUrl, String apiToken) { scriptApi = getRetrofit().create(ScriptApi.class); } + @Override + public Result> getScriptInformation(List scriptHashes, Options options) throws ApiException { + for (String scriptHash : scriptHashes) { + validateHexFormat(scriptHash); + } + Call> call = scriptApi.getScriptInformation(buildBody("_script_hashes", scriptHashes), optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + @Override public Result> getNativeScriptList(Options options) throws ApiException { Call> call = scriptApi.getNativeScriptList(optionsToParamMap(options)); @@ -50,7 +62,7 @@ public Result> getNativeScriptList(Options options) throws Ap } @Override - public Result getNativeScript(String scriptHash) throws ApiException { + public Result getNativeScriptByScriptHash(String scriptHash) throws ApiException { Call> call = scriptApi.getNativeScriptList(optionsToParamMap(Options.builder() .option(Filter.of("script_hash", FilterType.EQ, scriptHash)) .build())); @@ -85,6 +97,18 @@ public Result> getScriptRedeemers(String scriptHash, Option } } + @Override + public Result> getScriptUTxOs(String scriptHash, Boolean extended, Options options) throws ApiException { + validateHexFormat(scriptHash); + Call> call = scriptApi.getScriptUTxOs(scriptHash, extended, optionsToParamMap(options)); + try { + Response> response = (Response) execute(call); + return processResponse(response); + } catch (IOException e) { + throw new ApiException(e.getMessage(), e); + } + } + @Override public Result> getDatumInformation(List datumHashes, Options options) throws ApiException { for (String datumHash : datumHashes) { diff --git a/src/main/java/rest/koios/client/backend/api/script/model/DatumInfo.java b/src/main/java/rest/koios/client/backend/api/script/model/DatumInfo.java index cf72fe6..d69c56d 100644 --- a/src/main/java/rest/koios/client/backend/api/script/model/DatumInfo.java +++ b/src/main/java/rest/koios/client/backend/api/script/model/DatumInfo.java @@ -21,7 +21,12 @@ public class DatumInfo { /** * The Hash of the Plutus Data */ - private String hash; + private String datumHash; + + /** + * Hash of the script creation transaction + */ + private String creationTxHash; /** * The actual data in json format @@ -29,7 +34,7 @@ public class DatumInfo { private JsonNode value; /** - * Datum bytes (hex) (CBOR) + * Script bytes (cborSeq) */ private String bytes; } diff --git a/src/main/java/rest/koios/client/backend/api/script/model/NativeScript.java b/src/main/java/rest/koios/client/backend/api/script/model/NativeScript.java index a9456f0..510c061 100644 --- a/src/main/java/rest/koios/client/backend/api/script/model/NativeScript.java +++ b/src/main/java/rest/koios/client/backend/api/script/model/NativeScript.java @@ -1,6 +1,5 @@ package rest.koios.client.backend.api.script.model; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.Getter; @@ -34,7 +33,7 @@ public class NativeScript { private NativeScriptType type; /** - * Script + * The size of the CBOR serialised script (in bytes) */ - private JsonNode script; + private Integer size; } diff --git a/src/main/java/rest/koios/client/backend/api/script/model/NativeScriptType.java b/src/main/java/rest/koios/client/backend/api/script/model/NativeScriptType.java index 4d2ca57..68c2221 100644 --- a/src/main/java/rest/koios/client/backend/api/script/model/NativeScriptType.java +++ b/src/main/java/rest/koios/client/backend/api/script/model/NativeScriptType.java @@ -5,6 +5,16 @@ */ public enum NativeScriptType { + /** + * Plutus Version 1 + */ + plutusV1, + + /** + * Plutus Version 2 + */ + plutusV2, + /** * Time Locked */ diff --git a/src/main/java/rest/koios/client/backend/api/script/model/PlutusScript.java b/src/main/java/rest/koios/client/backend/api/script/model/PlutusScript.java index a04f34b..38b9e7c 100644 --- a/src/main/java/rest/koios/client/backend/api/script/model/PlutusScript.java +++ b/src/main/java/rest/koios/client/backend/api/script/model/PlutusScript.java @@ -23,4 +23,14 @@ public class PlutusScript { * Hash of the script creation transaction */ private String creationTxHash; + + /** + * Type of the script + */ + private NativeScriptType type; + + /** + * The size of the CBOR serialised script (in bytes) + */ + private Integer size; } diff --git a/src/main/java/rest/koios/client/backend/api/script/model/ScriptInfo.java b/src/main/java/rest/koios/client/backend/api/script/model/ScriptInfo.java new file mode 100644 index 0000000..99b1148 --- /dev/null +++ b/src/main/java/rest/koios/client/backend/api/script/model/ScriptInfo.java @@ -0,0 +1,47 @@ +package rest.koios.client.backend.api.script.model; + +import com.fasterxml.jackson.databind.JsonNode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +/** + * Script Information + */ +@Getter +@Setter +@ToString +@NoArgsConstructor +public class ScriptInfo { + + /** + * Hash of a script + */ + private String scriptHash; + + /** + * Hash of the script creation transaction + */ + private String creationTxHash; + + /** + * Type of the script: plutusV1 | plutusV2 | timelock | multisig + */ + private NativeScriptType type; + + /** + * Script JSON Object; + */ + private JsonNode value; + + /** + * Script bytes (cborSeq) + */ + private String bytes; + + /** + * The size of the CBOR serialised script (in bytes) + */ + private Integer size; +} diff --git a/src/main/java/rest/koios/client/backend/api/script/model/ScriptInner.java b/src/main/java/rest/koios/client/backend/api/script/model/ScriptInner.java index 1eeceb1..8ef8dbf 100644 --- a/src/main/java/rest/koios/client/backend/api/script/model/ScriptInner.java +++ b/src/main/java/rest/koios/client/backend/api/script/model/ScriptInner.java @@ -1,17 +1,12 @@ package rest.koios.client.backend.api.script.model; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -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 java.util.ArrayList; -import java.util.Optional; /** * Script Inner diff --git a/src/main/java/rest/koios/client/backend/api/script/model/ScriptRedeemer.java b/src/main/java/rest/koios/client/backend/api/script/model/ScriptRedeemer.java index 0c13df8..e623cc0 100644 --- a/src/main/java/rest/koios/client/backend/api/script/model/ScriptRedeemer.java +++ b/src/main/java/rest/koios/client/backend/api/script/model/ScriptRedeemer.java @@ -19,7 +19,7 @@ public class ScriptRedeemer { /** * Hash of Transaction for which details are being shown */ - private String scriptHash = null; + private String scriptHash; /** * List of {@link Redeemer} diff --git a/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java b/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java index 5b52c11..e86363d 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/TransactionsService.java @@ -1,6 +1,7 @@ package rest.koios.client.backend.api.transactions; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.api.transactions.model.*; import rest.koios.client.backend.factory.options.Options; @@ -12,6 +13,20 @@ */ public interface TransactionsService { + /** + * UTxO Info + * Get UTxO set for requested UTxO references + *

200 - List of UTxO details + *

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 utxoRefs List of Cardano utxo references in the form "hash#index" + * @return Result of Type List of {@link TxInfo} detailed information about transaction(s) + * @throws ApiException if an error occurs while attempting to invoke the API + */ + Result> getUTxOInfo(List utxoRefs, boolean extended) throws ApiException; + + /** * Transaction Information for Specific Transaction * Get detailed information about transaction @@ -39,20 +54,6 @@ public interface TransactionsService { */ Result> getTransactionInformation(List txHashes, Options options) throws ApiException; - /** - * Transaction UTxOs - * Get UTxO set (inputs/outputs) of transactions. - *

200 - Array of inputs and outputs for given transaction(s) - *

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 txHashes List of Cardano Transaction hashes - * @param options Filtering and Pagination options (optional) - * @return Result of Type List of {@link TxUtxo} inputs and outputs for given transaction(s) - * @throws ApiException if an error occurs while attempting to invoke the API - */ - Result> getTransactionUTxOs(List txHashes, Options options) throws ApiException; - /** * Transaction Metadata * Get metadata information (if any) for given transaction(s) diff --git a/src/main/java/rest/koios/client/backend/api/transactions/api/TransactionApi.java b/src/main/java/rest/koios/client/backend/api/transactions/api/TransactionApi.java index 15f2c62..3b22002 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/api/TransactionApi.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/api/TransactionApi.java @@ -1,6 +1,7 @@ package rest.koios.client.backend.api.transactions.api; import okhttp3.RequestBody; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.transactions.model.*; import retrofit2.Call; import retrofit2.http.*; @@ -14,24 +15,24 @@ public interface TransactionApi { /** - * Get Transaction Information + * Get UTxO set for requested UTxO references * - * @param requestBody Json Body containing Array of Cardano Transaction hashes + * @param requestBody Json Body containing Array of Cardano utxo references in the form "hash#index" * @param paramsMap Filtering Options Query Parameters * @return detailed information about transaction(s) */ - @POST("tx_info") - Call> getTransactionInformation(@Body Map requestBody, @QueryMap Map paramsMap); + @POST("utxo_info") + Call> getUTxOInfo(@Body Map requestBody, @QueryMap Map paramsMap); /** - * Get Transaction UTxOs + * Get Transaction Information * * @param requestBody Json Body containing Array of Cardano Transaction hashes * @param paramsMap Filtering Options Query Parameters - * @return UTxO set (inputs/outputs) of transactions. + * @return detailed information about transaction(s) */ - @POST("tx_utxos") - Call> getTransactionUTxOs(@Body Map requestBody, @QueryMap Map paramsMap); + @POST("tx_info") + Call> getTransactionInformation(@Body Map requestBody, @QueryMap Map paramsMap); /** * Get Transaction Metadata diff --git a/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java b/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java index ee70871..c98cdbe 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/impl/TransactionsServiceImpl.java @@ -4,10 +4,11 @@ import okhttp3.RequestBody; import rest.koios.client.backend.api.base.BaseService; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.transactions.TransactionsService; import rest.koios.client.backend.api.transactions.api.TransactionApi; import rest.koios.client.backend.api.transactions.model.*; +import rest.koios.client.backend.api.transactions.TransactionsService; import rest.koios.client.backend.factory.options.Options; import retrofit2.Call; import retrofit2.Response; @@ -37,39 +38,36 @@ public TransactionsServiceImpl(String baseUrl, String apiToken) { } @Override - public Result getTransactionInformation(String txHash) throws ApiException { - validateHexFormat(txHash); - Call> call = transactionApi.getTransactionInformation(buildBody(List.of(txHash)), Collections.emptyMap()); + public Result> getUTxOInfo(List utxoRefs, boolean extended) throws ApiException { + Call> call = transactionApi.getUTxOInfo(buildBodyUTxOs(utxoRefs, extended), Collections.emptyMap()); try { - Response> response = (Response) execute(call); - return processResponseGetOne(response); + Response> response = (Response) execute(call); + return processResponse(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); } } @Override - public Result> getTransactionInformation(List txHashes, Options options) throws ApiException { - for (String tx : txHashes) { - validateHexFormat(tx); - } - Call> call = transactionApi.getTransactionInformation(buildBody(txHashes), optionsToParamMap(options)); + public Result getTransactionInformation(String txHash) throws ApiException { + validateHexFormat(txHash); + Call> call = transactionApi.getTransactionInformation(buildBody(List.of(txHash)), Collections.emptyMap()); try { Response> response = (Response) execute(call); - return processResponse(response); + return processResponseGetOne(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); } } @Override - public Result> getTransactionUTxOs(List txHashes, Options options) throws ApiException { + public Result> getTransactionInformation(List txHashes, Options options) throws ApiException { for (String tx : txHashes) { validateHexFormat(tx); } - Call> call = transactionApi.getTransactionUTxOs(buildBody(txHashes), optionsToParamMap(options)); + Call> call = transactionApi.getTransactionInformation(buildBody(txHashes), optionsToParamMap(options)); try { - Response> response = (Response) execute(call); + Response> response = (Response) execute(call); return processResponse(response); } catch (IOException e) { throw new ApiException(e.getMessage(), e); @@ -132,4 +130,11 @@ private Map buildBody(List txHashes) { bodyMap.put("_tx_hashes", txHashes); return bodyMap; } + + private Map buildBodyUTxOs(List utxoRefs, boolean extended) { + Map bodyMap = new HashMap<>(); + bodyMap.put("_utxo_refs", utxoRefs); + bodyMap.put("_extended", extended); + return bodyMap; + } } diff --git a/src/main/java/rest/koios/client/backend/api/transactions/model/TxIO.java b/src/main/java/rest/koios/client/backend/api/transactions/model/TxIO.java index 83207fd..4668c4c 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/model/TxIO.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/model/TxIO.java @@ -6,9 +6,9 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import rest.koios.client.backend.api.common.Asset; -import rest.koios.client.backend.api.common.InlineDatum; -import rest.koios.client.backend.api.common.ReferenceScript; +import rest.koios.client.backend.api.base.common.Asset; +import rest.koios.client.backend.api.base.common.InlineDatum; +import rest.koios.client.backend.api.base.common.ReferenceScript; import java.util.List; diff --git a/src/main/java/rest/koios/client/backend/api/transactions/model/TxInfo.java b/src/main/java/rest/koios/client/backend/api/transactions/model/TxInfo.java index 710ab73..99993ea 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/model/TxInfo.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/model/TxInfo.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; -import rest.koios.client.backend.api.common.Asset; +import rest.koios.client.backend.api.base.common.Asset; import java.util.List; diff --git a/src/main/java/rest/koios/client/backend/api/transactions/model/TxStatus.java b/src/main/java/rest/koios/client/backend/api/transactions/model/TxStatus.java index 03207e5..6b4f945 100644 --- a/src/main/java/rest/koios/client/backend/api/transactions/model/TxStatus.java +++ b/src/main/java/rest/koios/client/backend/api/transactions/model/TxStatus.java @@ -2,7 +2,10 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategies; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; /** * Transaction Status diff --git a/src/main/java/rest/koios/client/backend/api/transactions/model/TxUtxo.java b/src/main/java/rest/koios/client/backend/api/transactions/model/TxUtxo.java deleted file mode 100644 index aedeba1..0000000 --- a/src/main/java/rest/koios/client/backend/api/transactions/model/TxUtxo.java +++ /dev/null @@ -1,33 +0,0 @@ -package rest.koios.client.backend.api.transactions.model; - -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.*; - -import java.util.List; - -/** - * Transaction UTxO - */ -@Getter -@Setter -@ToString -@NoArgsConstructor -@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -public class TxUtxo { - - /** - * Hash of Transaction for which details are being shown - */ - private String txHash = null; - - /** - * An array with details about inputs used in a transaction - */ - private List inputs = null; - - /** - * An array with details about outputs from the transaction - */ - private List outputs = null; -} diff --git a/src/main/java/rest/koios/client/backend/factory/ApiVersion.java b/src/main/java/rest/koios/client/backend/factory/ApiVersion.java index 70e6e02..e6356c5 100644 --- a/src/main/java/rest/koios/client/backend/factory/ApiVersion.java +++ b/src/main/java/rest/koios/client/backend/factory/ApiVersion.java @@ -9,9 +9,9 @@ public enum ApiVersion { /** - * Version 0 + * Version 1 */ - VERSION_0("v0"); + VERSION_1("v1"); private final String version; diff --git a/src/main/java/rest/koios/client/backend/factory/BackendFactory.java b/src/main/java/rest/koios/client/backend/factory/BackendFactory.java index f5b93cd..836a05d 100644 --- a/src/main/java/rest/koios/client/backend/factory/BackendFactory.java +++ b/src/main/java/rest/koios/client/backend/factory/BackendFactory.java @@ -26,7 +26,7 @@ public static BackendService getKoiosMainnetService() { * @return {@link BackendService} */ public static BackendService getKoiosMainnetService(String apiToken) { - return getKoiosMainnetService(ApiVersion.VERSION_0, apiToken); + return getKoiosMainnetService(ApiVersion.VERSION_1, apiToken); } /** @@ -46,7 +46,7 @@ public static BackendService getKoiosMainnetService(ApiVersion apiVersion, Strin * @return {@link BackendService} */ public static BackendService getKoiosGuildService() { - return getKoiosGuildService(ApiVersion.VERSION_0, null); + return getKoiosGuildService(ApiVersion.VERSION_1, null); } /** @@ -56,7 +56,7 @@ public static BackendService getKoiosGuildService() { * @return {@link BackendService} */ public static BackendService getKoiosGuildService(String apiToken) { - return getKoiosGuildService(ApiVersion.VERSION_0, apiToken); + return getKoiosGuildService(ApiVersion.VERSION_1, apiToken); } /** @@ -85,7 +85,7 @@ public static BackendService getKoiosPreviewService() { * @return {@link BackendService} */ public static BackendService getKoiosPreviewService(String apiToken) { - return getKoiosPreviewService(ApiVersion.VERSION_0, apiToken); + return getKoiosPreviewService(ApiVersion.VERSION_1, apiToken); } /** @@ -115,7 +115,7 @@ public static BackendService getKoiosPreprodService() { * @return {@link BackendService} */ public static BackendService getKoiosPreprodService(String apiToken) { - return getKoiosPreprodService(ApiVersion.VERSION_0, apiToken); + return getKoiosPreprodService(ApiVersion.VERSION_1, apiToken); } /** diff --git a/src/main/java/rest/koios/client/backend/factory/impl/BackendServiceImpl.java b/src/main/java/rest/koios/client/backend/factory/impl/BackendServiceImpl.java index e51da66..ecff132 100644 --- a/src/main/java/rest/koios/client/backend/factory/impl/BackendServiceImpl.java +++ b/src/main/java/rest/koios/client/backend/factory/impl/BackendServiceImpl.java @@ -37,8 +37,8 @@ public class BackendServiceImpl implements BackendService { private final EpochService epochService; private final BlockService blockService; private final TransactionsService transactionsService; - private final AddressService addressService; private final AccountService accountService; + private final AddressService addressService; private final AssetService assetService; private final PoolService poolService; private final ScriptService scriptService; @@ -63,8 +63,8 @@ public BackendServiceImpl(String baseUrl, String apiToken) { this.epochService = new EpochServiceImpl(baseUrl, apiToken); this.blockService = new BlockServiceImpl(baseUrl, apiToken); this.transactionsService = new TransactionsServiceImpl(baseUrl, apiToken); - this.addressService = new AddressServiceImpl(baseUrl, apiToken); this.accountService = new AccountServiceImpl(baseUrl, apiToken); + this.addressService = new AddressServiceImpl(baseUrl, apiToken); this.assetService = new AssetServiceImpl(baseUrl, apiToken); this.poolService = new PoolServiceImpl(baseUrl, apiToken); this.scriptService = new ScriptServiceImpl(baseUrl, apiToken); 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 380250d..aba819d 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 @@ -7,6 +7,7 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.account.model.*; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; @@ -20,7 +21,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) class AccountServiceMainnetIntegrationTest { - private rest.koios.client.backend.api.account.AccountService accountService; + private AccountService accountService; @BeforeAll public void setup() { @@ -70,6 +71,38 @@ void getAccountInformationCachedBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAccountUTxOsTest() throws ApiException { + List stakeAddresses = List.of("stake1uyrx65wjqjgeeksd8hptmcgl5jfyrqkfq0xe8xlp367kphsckq250", "stake1uxpdrerp9wrxunfh6ukyv5267j70fzxgw0fr3z8zeac5vyqhf9jhy"); + Result> utxosResult = accountService.getAccountUTxOs(stakeAddresses, true, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + + @Test + void getAccountUTxOsBadRequestTest() { + List stakeAddresses = List.of("asd", "stake1uxpdrerp9wrxunfh6ukyv5267j70fzxgw0fr3z8zeac5vyqhf9jhy"); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUTxOs(stakeAddresses, true, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + + @Test + void getAccountTxsTest() throws ApiException { + String stakeAddress = "stake1u8yxtugdv63wxafy9d00nuz6hjyyp4qnggvc9a3vxh8yl0ckml2uz"; + Result> accountTxsResult = accountService.getAccountTxs(stakeAddress, null, Options.EMPTY); + Assertions.assertTrue(accountTxsResult.isSuccessful()); + Assertions.assertNotNull(accountTxsResult.getValue()); + log.info(accountTxsResult.getValue().toString()); + } + + @Test + void getAccountTxsBadRequestTest() { + String stakeAddress = "stake1u8yxtugdv63wxafy9d00nuz6hjyyp4qnggvc9a3vxh8yl0ckml2uz"; + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountTxs(stakeAddress, -2, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + @Test void getAccountRewardsTest() throws ApiException { int epochNo = 294; @@ -123,7 +156,7 @@ void getAccountAddressesBadRequestTest() { @Test void getAccountAssetsTest() throws ApiException { String address = "stake1u8yxtugdv63wxafy9d00nuz6hjyyp4qnggvc9a3vxh8yl0ckml2uz"; - Result> accountAssetsResult = accountService.getAccountAssets(List.of(address), null, Options.EMPTY); + Result> accountAssetsResult = accountService.getAccountAssets(List.of(address), null, Options.EMPTY); Assertions.assertTrue(accountAssetsResult.isSuccessful()); Assertions.assertNotNull(accountAssetsResult.getValue()); log.info(accountAssetsResult.getValue().toString()); 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 128d387..d65ec6e 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 @@ -7,6 +7,7 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.account.model.*; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; @@ -70,6 +71,38 @@ void getAccountInformationCachedBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAccountUTxOsTest() throws ApiException { + List stakeAddresses = List.of("stake_test1urq4rcynzj4uxqc74c852zky7wa6epgmn9r6k3j3gv7502q8jks0l", "stake_test1ur4t5nhceyn2amfuj7z74uxmmj8jf9fmgd2egqw8c98ve3cp2g4wx"); + Result> utxosResult = accountService.getAccountUTxOs(stakeAddresses, true, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + + @Test + void getAccountUTxOsBadRequestTest() { + List stakeAddresses = List.of("asd", "stake_test1ur4t5nhceyn2amfuj7z74uxmmj8jf9fmgd2egqw8c98ve3cp2g4wx"); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUTxOs(stakeAddresses, true, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + + @Test + void getAccountTxsTest() throws ApiException { + String stakeAddress = "stake_test1urkzeud48zxwnjc54emzmmc3gkg2r6d6tm2sd799jxjnqxqlfzmvk"; + Result> accountTxsResult = accountService.getAccountTxs(stakeAddress, null, Options.EMPTY); + Assertions.assertTrue(accountTxsResult.isSuccessful()); + Assertions.assertNotNull(accountTxsResult.getValue()); + log.info(accountTxsResult.getValue().toString()); + } + + @Test + void getAccountTxsBadRequestTest() { + String stakeAddress = "stake_test1urkzeud48zxwnjc54emzmmc3gkg2r6d6tm2sd799jxjnqxqlfzmvk"; + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountTxs(stakeAddress, -2, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + @Test void getAccountRewardsTest() throws ApiException { int epochNo = 33; @@ -125,7 +158,7 @@ void getAccountAddressesBadRequestTest() { @Test void getAccountAssetsTest() throws ApiException { String address = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountAssetsResult = accountService.getAccountAssets(List.of(address), null, Options.EMPTY); + Result> accountAssetsResult = accountService.getAccountAssets(List.of(address), null, Options.EMPTY); Assertions.assertTrue(accountAssetsResult.isSuccessful()); Assertions.assertNotNull(accountAssetsResult.getValue()); log.info(accountAssetsResult.getValue().toString()); 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 ee5ba0d..7c829e0 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 @@ -7,6 +7,7 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.account.model.*; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; @@ -70,6 +71,38 @@ void getAccountInformationCachedBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAccountUTxOsTest() throws ApiException { + List stakeAddresses = List.of("stake_test1urqntq4wexjylnrdnp97qq79qkxxvrsa9lcnwr7ckjd6w0cr04y4p", "stake_test1up6wqzrw2h9vvjy5zfkjn0dwtymy5r29zyhf8fyhm6fat9c2am5hl"); + Result> utxosResult = accountService.getAccountUTxOs(stakeAddresses, true, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + + @Test + void getAccountUTxOsBadRequestTest() { + List stakeAddresses = List.of("asd", "stake_test1urqntq4wexjylnrdnp97qq79qkxxvrsa9lcnwr7ckjd6w0cr04y4p"); + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountUTxOs(stakeAddresses, true, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + + @Test + void getAccountTxsTest() throws ApiException { + String stakeAddress = "stake_test1uzs5rxys8qy5jnr9g0mkj860ms5n92nrykmrgyumpf2ytmsejj4m6"; + Result> accountTxsResult = accountService.getAccountTxs(stakeAddress, null, Options.EMPTY); + Assertions.assertTrue(accountTxsResult.isSuccessful()); + Assertions.assertNotNull(accountTxsResult.getValue()); + log.info(accountTxsResult.getValue().toString()); + } + + @Test + void getAccountTxsBadRequestTest() { + String stakeAddress = "stake_test1uzs5rxys8qy5jnr9g0mkj860ms5n92nrykmrgyumpf2ytmsejj4m6"; + ApiException exception = assertThrows(ApiException.class, () -> accountService.getAccountTxs(stakeAddress, -2, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + @Test void getAccountRewardsTest() throws ApiException { int epochNo = 21; @@ -123,7 +156,7 @@ void getAccountAddressesBadRequestTest() { @Test void getAccountAssetsTest() throws ApiException { String address = "stake_test1uzcmuv8c6pj3ld9mrvml3jhxl7j4hvh4xskr6ce37dvpfdqjmdvh8"; - Result> accountAssetsResult = accountService.getAccountAssets(List.of(address), null, Options.EMPTY); + Result> accountAssetsResult = accountService.getAccountAssets(List.of(address), null, Options.EMPTY); Assertions.assertTrue(accountAssetsResult.isSuccessful()); Assertions.assertNotNull(accountAssetsResult.getValue()); log.info(accountAssetsResult.getValue().toString()); 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 43d1376..d5b96d1 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,10 +5,11 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import rest.koios.client.backend.api.common.TxHash; +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; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Options; @@ -45,6 +46,34 @@ void getAddressInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAddressUTxOsTest() throws ApiException { + List addresses = List.of("addr1qy2jt0qpqz2z2z9zx5w4xemekkce7yderz53kjue53lpqv90lkfa9sgrfjuz6uvt4uqtrqhl2kj0a9lnr9ndzutx32gqleeckv", + "addr1q9xvgr4ehvu5k5tmaly7ugpnvekpqvnxj8xy50pa7kyetlnhel389pa4rnq6fmkzwsaynmw0mnldhlmchn2sfd589fgsz9dd0y"); + Result> addressUTxOsResult = addressService.getAddressUTxOs(addresses, true, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + + @Test + void getAddressUTxOsBadRequestTest() { + List addresses = List.of("asdf123", + "addr1q9xvgr4ehvu5k5tmaly7ugpnvekpqvnxj8xy50pa7kyetlnhel389pa4rnq6fmkzwsaynmw0mnldhlmchn2sfd589fgsz9dd0y"); + ApiException exception = assertThrows(ApiException.class, () -> addressService.getAddressUTxOs(addresses, false, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + + @Test + void getUTxOsFromPaymentCredentialsTest() throws ApiException { + List addresses = List.of("025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52", + "13f6870c5e4f3b242463e4dc1f2f56b02a032d3797d933816f15e555"); + Result> addressUTxOsResult = addressService.getUTxOsFromPaymentCredentials(addresses, true, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + @Test void getAddressTransactionsTest() throws ApiException { String address = "addr1qyp9kz50sh9c53hpmk3l4ewj9ur794t2hdqpngsjn3wkc5sztv9glpwt3frwrhdrltjaytc8ut2k4w6qrx3p98zad3fq07xe9g"; @@ -85,7 +114,7 @@ void getAddressAssetsBadRequestTest() { @Test void getTransactionsByPaymentCredentialsTest() throws ApiException { String paymentCredentials = "025b0a8f85cb8a46e1dda3fae5d22f07e2d56abb4019a2129c5d6c52"; - Result> txHashesResult = addressService.getTransactionsByPaymentCredentials(List.of(paymentCredentials), 250, Options.EMPTY); + Result> txHashesResult = addressService.getTransactionsByPaymentCredentials(List.of(paymentCredentials), Options.EMPTY); Assertions.assertTrue(txHashesResult.isSuccessful()); Assertions.assertNotNull(txHashesResult.getValue()); log.info(txHashesResult.getValue().toString()); diff --git a/src/test/java/rest/koios/client/backend/api/address/AddressServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/address/AddressServicePreprodIntegrationTest.java index 21dc319..a5639b9 100644 --- a/src/test/java/rest/koios/client/backend/api/address/AddressServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/address/AddressServicePreprodIntegrationTest.java @@ -8,8 +8,9 @@ import rest.koios.client.backend.api.address.model.AddressAsset; import rest.koios.client.backend.api.address.model.AddressInfo; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.common.TxHash; +import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Options; @@ -45,6 +46,34 @@ void getAddressInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAddressUTxOsTest() throws ApiException { + List addresses = List.of("addr_test1vzpwq95z3xyum8vqndgdd9mdnmafh3djcxnc6jemlgdmswcve6tkw", + "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc"); + Result> addressUTxOsResult = addressService.getAddressUTxOs(addresses, true, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + + @Test + void getAddressUTxOsBadRequestTest() { + List addresses = List.of("asdf123", + "addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc"); + ApiException exception = assertThrows(ApiException.class, () -> addressService.getAddressUTxOs(addresses, false, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + + @Test + void getUTxOsFromPaymentCredentialsTest() throws ApiException { + List addresses = List.of("b429738bd6cc58b5c7932d001aa2bd05cfea47020a556c8c753d4436", + "82e016828989cd9d809b50d6976d9efa9bc5b2c1a78d4b3bfa1bb83b"); + Result> addressUTxOsResult = addressService.getUTxOsFromPaymentCredentials(addresses, true, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + @Test void getAddressTransactionsTest() throws ApiException { String address = "addr_test1qzr0g2kvyknzhyez3aatyjwpaw5z5n65cwfxc5ctcqq28ed3hcc035r9r76tkxehlr9wdla9twe02dpv843nru6czj6qycpamy"; @@ -85,7 +114,7 @@ void getAddressAssetsBadRequestTest() { @Test void getTransactionsByPaymentCredentialsTest() throws ApiException { String paymentCredentials = "b429738bd6cc58b5c7932d001aa2bd05cfea47020a556c8c753d4436"; - Result> txHashesResult = addressService.getTransactionsByPaymentCredentials(List.of(paymentCredentials),250, Options.EMPTY); + Result> txHashesResult = addressService.getTransactionsByPaymentCredentials(List.of(paymentCredentials), Options.EMPTY); Assertions.assertTrue(txHashesResult.isSuccessful()); Assertions.assertNotNull(txHashesResult.getValue()); log.info(txHashesResult.getValue().toString()); diff --git a/src/test/java/rest/koios/client/backend/api/address/AddressServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/address/AddressServicePreviewIntegrationTest.java index 9912b3c..b2415b3 100644 --- a/src/test/java/rest/koios/client/backend/api/address/AddressServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/address/AddressServicePreviewIntegrationTest.java @@ -5,10 +5,11 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import rest.koios.client.backend.api.common.TxHash; +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; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Options; @@ -44,6 +45,34 @@ void getAddressInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAddressUTxOsTest() throws ApiException { + List addresses = List.of("addr_test1vpfwv0ezc5g8a4mkku8hhy3y3vp92t7s3ul8g778g5yegsgalc6gc", + "addr_test1vqneq3v0dqh3x3muv6ee3lt8e5729xymnxuavx6tndcjc2cv24ef9"); + Result> addressUTxOsResult = addressService.getAddressUTxOs(addresses, true, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + + @Test + void getAddressUTxOsBadRequestTest() { + List addresses = List.of("asdf123", + "addr_test1vqneq3v0dqh3x3muv6ee3lt8e5729xymnxuavx6tndcjc2cv24ef9"); + ApiException exception = assertThrows(ApiException.class, () -> addressService.getAddressUTxOs(addresses, false, Options.EMPTY)); + assertInstanceOf(ApiException.class, exception); + } + + @Test + void getUTxOsFromPaymentCredentialsTest() throws ApiException { + List addresses = List.of("33c378cee41b2e15ac848f7f6f1d2f78155ab12d93b713de898d855f", + "52e63f22c5107ed776b70f7b92248b02552fd08f3e747bc745099441"); + Result> addressUTxOsResult = addressService.getUTxOsFromPaymentCredentials(addresses, true, Options.EMPTY); + Assertions.assertTrue(addressUTxOsResult.isSuccessful()); + Assertions.assertNotNull(addressUTxOsResult.getValue()); + log.info(addressUTxOsResult.getValue().toString()); + } + @Test void getAddressTransactionsTest() throws ApiException { String address = "addr_test1qrvaadv0h7atv366u6966u4rft2svjlf5uajy8lkpsgdrc24rnskuetxz2u3m5ac22s3njvftxcl2fc8k8kjr088ge0qz98xmv"; @@ -84,7 +113,7 @@ void getAddressAssetsBadRequestTest() { @Test void getTransactionsByPaymentCredentialsTest() throws ApiException { String paymentCredentials = "33c378cee41b2e15ac848f7f6f1d2f78155ab12d93b713de898d855f"; - Result> txHashesResult = addressService.getTransactionsByPaymentCredentials(List.of(paymentCredentials),250, Options.EMPTY); + Result> txHashesResult = addressService.getTransactionsByPaymentCredentials(List.of(paymentCredentials), Options.EMPTY); Assertions.assertTrue(txHashesResult.isSuccessful()); Assertions.assertNotNull(txHashesResult.getValue()); log.info(txHashesResult.getValue().toString()); 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 3578686..e075798 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,15 +5,17 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import rest.koios.client.backend.api.common.TxHash; 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; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; 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 rest.koios.client.utils.Tuple; import java.math.BigInteger; import java.util.List; @@ -41,6 +43,15 @@ void getAssetListLimitTest() throws ApiException { assertEquals(10, assetsResult.getValue().size()); } + @Test + void getPolicyAssetListTest() throws ApiException { + String assetPolicy = "750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501"; + Result> policyAssetListResult = assetService.getPolicyAssetList(assetPolicy, Options.EMPTY); + Assertions.assertTrue(policyAssetListResult.isSuccessful()); + Assertions.assertNotNull(policyAssetListResult.getValue()); + log.info(policyAssetListResult.getValue().toString()); + } + @Test void getAssetTokenRegistryFilteredTest() throws ApiException { Options options = Options.builder() @@ -73,6 +84,16 @@ void getAssetsAddressListBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getNFTAddressTest() throws ApiException { + String assetPolicy = "f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"; + String assetNameHex = "68616e646c65"; + Result> assetAddressesResult = assetService.getNFTAddress(assetPolicy, assetNameHex, Options.EMPTY); + Assertions.assertTrue(assetAddressesResult.isSuccessful()); + Assertions.assertNotNull(assetAddressesResult.getValue()); + log.info(assetAddressesResult.getValue().toString()); + } + @Test void getAssetInformationTest() throws ApiException { String assetPolicy = "d3501d9531fcc25e3ca4b6429318c2cc374dbdbcf5e99c1c1e5da1ff"; @@ -102,6 +123,26 @@ void getAssetInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAssetInformationBulkTest() throws ApiException { + List> tupleList = List.of(new Tuple<>("750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501", "424f4f4b"), + new Tuple<>("f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a", "6b6f696f732e72657374")); + Result assetInformationBulkResult = assetService.getAssetInformationBulk(tupleList, Options.EMPTY); + Assertions.assertTrue(assetInformationBulkResult.isSuccessful()); + Assertions.assertNotNull(assetInformationBulkResult.getValue()); + log.info(assetInformationBulkResult.getValue().toString()); + } + + @Test + void getAssetUTxOsTest() throws ApiException { + List> tupleList = List.of(new Tuple<>("750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501", "424f4f4b"), + new Tuple<>("f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a", "6b6f696f732e72657374")); + Result> utxosResult = assetService.getAssetUTxOs(tupleList, true, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + @Test void getAssetHistoryTest() throws ApiException { String assetPolicy = "d3501d9531fcc25e3ca4b6429318c2cc374dbdbcf5e99c1c1e5da1ff"; diff --git a/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreprodIntegrationTest.java index 81c6584..e1a43bc 100644 --- a/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreprodIntegrationTest.java @@ -7,11 +7,13 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.asset.model.*; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.common.TxHash; +import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; +import rest.koios.client.utils.Tuple; import java.math.BigInteger; import java.util.List; @@ -39,6 +41,15 @@ void getAssetListLimitTest() throws ApiException { assertEquals(10, assetsResult.getValue().size()); } + @Test + void getPolicyAssetListTest() throws ApiException { + String assetPolicy = "c6e65ba7878b2f8ea0ad39287d3e2fd256dc5c4160fc19bdf4c4d87e"; + Result> policyAssetListResult = assetService.getPolicyAssetList(assetPolicy, Options.EMPTY); + Assertions.assertTrue(policyAssetListResult.isSuccessful()); + Assertions.assertNotNull(policyAssetListResult.getValue()); + log.info(policyAssetListResult.getValue().toString()); + } + @Test void getAssetsAddressListTest() throws ApiException { String assetPolicy = "80de4ee0ffde8ba05726707f2adba0e65963eff5aaba164af358e71b"; @@ -58,6 +69,16 @@ void getAssetsAddressListBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getNFTAddressTest() throws ApiException { + String assetPolicy = "002126e5e7cb2f5b6ac52ef2cdb9308ff58bf6e3b62e29df447cec72"; + String assetNameHex = "74657374"; + Result> assetAddressesResult = assetService.getNFTAddress(assetPolicy, assetNameHex, Options.EMPTY); + Assertions.assertTrue(assetAddressesResult.isSuccessful()); + Assertions.assertNotNull(assetAddressesResult.getValue()); + log.info(assetAddressesResult.getValue().toString()); + } + @Test void getAssetInformationTest() throws ApiException { String assetPolicy = "80de4ee0ffde8ba05726707f2adba0e65963eff5aaba164af358e71b"; @@ -89,6 +110,26 @@ void getAssetInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAssetInformationBulkTest() throws ApiException { + List> tupleList = List.of(new Tuple<>("c6e65ba7878b2f8ea0ad39287d3e2fd256dc5c4160fc19bdf4c4d87e", "7447454e53"), + new Tuple<>("777e6b4903dab74963ae581d39875c5dac16c09bb1f511c0af1ddda8", "6141414441")); + Result assetInformationBulkResult = assetService.getAssetInformationBulk(tupleList, Options.EMPTY); + Assertions.assertTrue(assetInformationBulkResult.isSuccessful()); + Assertions.assertNotNull(assetInformationBulkResult.getValue()); + log.info(assetInformationBulkResult.getValue().toString()); + } + + @Test + void getAssetUTxOsTest() throws ApiException { + List> tupleList = List.of(new Tuple<>("c6e65ba7878b2f8ea0ad39287d3e2fd256dc5c4160fc19bdf4c4d87e", "7447454e53"), + new Tuple<>("777e6b4903dab74963ae581d39875c5dac16c09bb1f511c0af1ddda8", "6141414441")); + Result> utxosResult = assetService.getAssetUTxOs(tupleList, true, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + @Test void getAssetHistoryTest() throws ApiException { String assetPolicy = "80de4ee0ffde8ba05726707f2adba0e65963eff5aaba164af358e71b"; diff --git a/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreviewIntegrationTest.java index 2e0638a..e20a6f6 100644 --- a/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/asset/AssetServicePreviewIntegrationTest.java @@ -5,13 +5,15 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; -import rest.koios.client.backend.api.common.TxHash; 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; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; +import rest.koios.client.utils.Tuple; import java.math.BigInteger; import java.util.List; @@ -39,6 +41,15 @@ void getAssetListLimitTest() throws ApiException { assertEquals(10, assetsResult.getValue().size()); } + @Test + void getPolicyAssetListTest() throws ApiException { + String assetPolicy = "065270479316f1d92e00f7f9f095ebeaac9d009c878dc35ce36d3404"; + Result> policyAssetListResult = assetService.getPolicyAssetList(assetPolicy, Options.EMPTY); + Assertions.assertTrue(policyAssetListResult.isSuccessful()); + Assertions.assertNotNull(policyAssetListResult.getValue()); + log.info(policyAssetListResult.getValue().toString()); + } + @Test void getAssetsAddressListTest() throws ApiException { String assetPolicy = "9a50f458ebffb4c3f9d6f9f3d45426b2de6cf2512254f4bfa3d8f410"; @@ -58,6 +69,16 @@ void getAssetsAddressListBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getNFTAddressTest() throws ApiException { + String assetPolicy = "005b8ca355aec6125531ebea89bf9ef8df90121ea5717f0c55027e35"; + String assetNameHex = "4d43"; + Result> assetAddressesResult = assetService.getNFTAddress(assetPolicy, assetNameHex, Options.EMPTY); + Assertions.assertTrue(assetAddressesResult.isSuccessful()); + Assertions.assertNotNull(assetAddressesResult.getValue()); + log.info(assetAddressesResult.getValue().toString()); + } + @Test void getAssetInformationTest() throws ApiException { String assetPolicy = "9a50f458ebffb4c3f9d6f9f3d45426b2de6cf2512254f4bfa3d8f410"; @@ -89,6 +110,26 @@ void getAssetInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getAssetInformationBulkTest() throws ApiException { + List> tupleList = List.of(new Tuple<>("065270479316f1d92e00f7f9f095ebeaac9d009c878dc35ce36d3404", "433374"), + new Tuple<>("189e2c53985411addb8df0f3e09f70e343da69f06746c408aba672a8", "15fc257714a51769e192761d674db2ee2e80137428e522f9b914debb5f785301")); + Result assetInformationBulkResult = assetService.getAssetInformationBulk(tupleList, Options.EMPTY); + Assertions.assertTrue(assetInformationBulkResult.isSuccessful()); + Assertions.assertNotNull(assetInformationBulkResult.getValue()); + log.info(assetInformationBulkResult.getValue().toString()); + } + + @Test + void getAssetUTxOsTest() throws ApiException { + List> tupleList = List.of(new Tuple<>("065270479316f1d92e00f7f9f095ebeaac9d009c878dc35ce36d3404", "433374"), + new Tuple<>("189e2c53985411addb8df0f3e09f70e343da69f06746c408aba672a8", "15fc257714a51769e192761d674db2ee2e80137428e522f9b914debb5f785301")); + Result> utxosResult = assetService.getAssetUTxOs(tupleList, true, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + @Test void getAssetHistoryTest() throws ApiException { String assetPolicy = "9a50f458ebffb4c3f9d6f9f3d45426b2de6cf2512254f4bfa3d8f410"; diff --git a/src/test/java/rest/koios/client/backend/api/epoch/EpochServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/epoch/EpochServiceMainnetIntegrationTest.java index 8e9d98b..b09c98a 100644 --- a/src/test/java/rest/koios/client/backend/api/epoch/EpochServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/epoch/EpochServiceMainnetIntegrationTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; +import rest.koios.client.backend.api.epoch.model.EpochBlockProtocols; import rest.koios.client.backend.api.epoch.model.EpochInfo; import rest.koios.client.backend.api.epoch.model.EpochParams; import rest.koios.client.backend.factory.BackendFactory; @@ -35,7 +36,7 @@ void getEpochInformationTest() throws ApiException { Assertions.assertTrue(epochInformationResult.isSuccessful()); Assertions.assertNotNull(epochInformationResult.getValue()); log.info(epochInformationResult.getValue().toString()); - Assertions.assertEquals(epochNo, epochInformationResult.getValue().getEpochNo()); + assertEquals(epochNo, epochInformationResult.getValue().getEpochNo()); } @Test @@ -63,7 +64,7 @@ void getEpochParametersTest() throws ApiException { Assertions.assertTrue(epochParametersResult.isSuccessful()); Assertions.assertNotNull(epochParametersResult.getValue()); log.info(epochParametersResult.getValue().toString()); - Assertions.assertEquals(epochNo, epochParametersResult.getValue().getEpochNo()); + assertEquals(epochNo, epochParametersResult.getValue().getEpochNo()); } @Test @@ -83,4 +84,23 @@ void getEpochParametersLimitTest() throws ApiException { log.info(epochParametersResult.getValue().toString()); assertEquals(10, epochParametersResult.getValue().size()); } + + @Test + void getEpochBlockProtocolsByEpochTest() throws ApiException { + Integer epochNo = 294; + Integer blocks = 13704; + Result epochBlockProtocolsResult = epochService.getEpochBlockProtocolsByEpoch(epochNo); + Assertions.assertTrue(epochBlockProtocolsResult.isSuccessful()); + Assertions.assertNotNull(epochBlockProtocolsResult.getValue()); + log.info(epochBlockProtocolsResult.getValue().toString()); + assertEquals(blocks, epochBlockProtocolsResult.getValue().getBlocks()); + } + + @Test + void getEpochBlocksProtocolsTest() throws ApiException { + Result> epochBlockProtocolsResult = epochService.getEpochBlockProtocols(Options.EMPTY); + Assertions.assertTrue(epochBlockProtocolsResult.isSuccessful()); + Assertions.assertNotNull(epochBlockProtocolsResult.getValue()); + log.info(epochBlockProtocolsResult.getValue().toString()); + } } diff --git a/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreprodIntegrationTest.java index 693121d..36e81ea 100644 --- a/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreprodIntegrationTest.java @@ -7,6 +7,7 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; +import rest.koios.client.backend.api.epoch.model.EpochBlockProtocols; import rest.koios.client.backend.api.epoch.model.EpochInfo; import rest.koios.client.backend.api.epoch.model.EpochParams; import rest.koios.client.backend.factory.BackendFactory; @@ -37,7 +38,7 @@ void getEpochInformationTest() throws ApiException { Assertions.assertTrue(epochInformationResult.isSuccessful()); Assertions.assertNotNull(epochInformationResult.getValue()); log.info(epochInformationResult.getValue().toString()); - Assertions.assertEquals(epochNo, epochInformationResult.getValue().getEpochNo()); + assertEquals(epochNo, epochInformationResult.getValue().getEpochNo()); } @Test @@ -65,7 +66,7 @@ void getEpochParametersTest() throws ApiException { Assertions.assertTrue(epochParametersResult.isSuccessful()); Assertions.assertNotNull(epochParametersResult.getValue()); log.info(epochParametersResult.getValue().toString()); - Assertions.assertEquals(epochNo, epochParametersResult.getValue().getEpochNo()); + assertEquals(epochNo, epochParametersResult.getValue().getEpochNo()); } @Test @@ -85,4 +86,23 @@ void getEpochParametersLimitTest() throws ApiException { log.info(epochParametersResult.getValue().toString()); assertEquals(10, epochParametersResult.getValue().size()); } + + @Test + void getEpochBlockProtocolsByEpochTest() throws ApiException { + Integer epochNo = 31; + Integer blocks = 8211; + Result epochBlockProtocolsResult = epochService.getEpochBlockProtocolsByEpoch(epochNo); + Assertions.assertTrue(epochBlockProtocolsResult.isSuccessful()); + Assertions.assertNotNull(epochBlockProtocolsResult.getValue()); + log.info(epochBlockProtocolsResult.getValue().toString()); + assertEquals(blocks, epochBlockProtocolsResult.getValue().getBlocks()); + } + + @Test + void getEpochBlocksProtocolsTest() throws ApiException { + Result> epochBlockProtocolsResult = epochService.getEpochBlockProtocols(Options.EMPTY); + Assertions.assertTrue(epochBlockProtocolsResult.isSuccessful()); + Assertions.assertNotNull(epochBlockProtocolsResult.getValue()); + log.info(epochBlockProtocolsResult.getValue().toString()); + } } diff --git a/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreviewIntegrationTest.java index ee0e276..58d3983 100644 --- a/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/epoch/EpochServicePreviewIntegrationTest.java @@ -7,10 +7,14 @@ import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; +import rest.koios.client.backend.api.epoch.model.EpochBlockProtocols; import rest.koios.client.backend.api.epoch.model.EpochInfo; import rest.koios.client.backend.api.epoch.model.EpochParams; import rest.koios.client.backend.factory.BackendFactory; -import rest.koios.client.backend.factory.options.*; +import rest.koios.client.backend.factory.options.Limit; +import rest.koios.client.backend.factory.options.Options; +import rest.koios.client.backend.factory.options.Order; +import rest.koios.client.backend.factory.options.SortType; import java.util.List; @@ -34,7 +38,7 @@ void getEpochInformationTest() throws ApiException { Assertions.assertTrue(epochInformationResult.isSuccessful()); Assertions.assertNotNull(epochInformationResult.getValue()); log.info(epochInformationResult.getValue().toString()); - Assertions.assertEquals(epochNo, epochInformationResult.getValue().getEpochNo()); + assertEquals(epochNo, epochInformationResult.getValue().getEpochNo()); } @Test @@ -62,7 +66,7 @@ void getEpochParametersTest() throws ApiException { Assertions.assertTrue(epochParametersResult.isSuccessful()); Assertions.assertNotNull(epochParametersResult.getValue()); log.info(epochParametersResult.getValue().toString()); - Assertions.assertEquals(epochNo, epochParametersResult.getValue().getEpochNo()); + assertEquals(epochNo, epochParametersResult.getValue().getEpochNo()); } @Test @@ -83,4 +87,23 @@ void getEpochParametersLimitTest() throws ApiException { log.info(epochParametersResult.getValue().toString()); assertEquals(10, epochParametersResult.getValue().size()); } + + @Test + void getEpochBlockProtocolsByEpochTest() throws ApiException { + Integer epochNo = 12; + Integer blocks = 105; + Result epochBlockProtocolsResult = epochService.getEpochBlockProtocolsByEpoch(epochNo); + Assertions.assertTrue(epochBlockProtocolsResult.isSuccessful()); + Assertions.assertNotNull(epochBlockProtocolsResult.getValue()); + log.info(epochBlockProtocolsResult.getValue().toString()); + assertEquals(blocks, epochBlockProtocolsResult.getValue().getBlocks()); + } + + @Test + void getEpochBlocksProtocolsTest() throws ApiException { + Result> epochBlockProtocolsResult = epochService.getEpochBlockProtocols(Options.EMPTY); + Assertions.assertTrue(epochBlockProtocolsResult.isSuccessful()); + Assertions.assertNotNull(epochBlockProtocolsResult.getValue()); + log.info(epochBlockProtocolsResult.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 45403f3..4da11c4 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 @@ -7,9 +7,7 @@ import org.junit.jupiter.api.TestInstance; 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.Genesis; -import rest.koios.client.backend.api.network.model.Tip; -import rest.koios.client.backend.api.network.model.Totals; +import rest.koios.client.backend.api.network.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -54,7 +52,7 @@ void getHistoricalTokenomicStatsTest() throws ApiException { Assertions.assertTrue(historicalTokenomicStatsResult.isSuccessful()); Assertions.assertNotNull(historicalTokenomicStatsResult.getValue()); log.info(historicalTokenomicStatsResult.getValue().toString()); - Assertions.assertEquals(epochNo,historicalTokenomicStatsResult.getValue().getEpochNo()); + Assertions.assertEquals(epochNo, historicalTokenomicStatsResult.getValue().getEpochNo()); } @Test @@ -64,7 +62,7 @@ void getHistoricalTokenomicStatsLimitTest() throws ApiException { Assertions.assertTrue(historicalTokenomicStatsResult.isSuccessful()); Assertions.assertNotNull(historicalTokenomicStatsResult.getValue()); log.info(historicalTokenomicStatsResult.getValue().toString()); - Assertions.assertEquals(10,historicalTokenomicStatsResult.getValue().size()); + Assertions.assertEquals(10, historicalTokenomicStatsResult.getValue().size()); } @Test @@ -72,4 +70,34 @@ void getHistoricalTokenomicStatsBadRequestTest() { ApiException exception = assertThrows(ApiException.class, () -> networkService.getHistoricalTokenomicStatsByEpoch(-5)); assertInstanceOf(ApiException.class, exception); } + + @Test + void getParamUpdateProposalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> paramUpdateProposalsResult = networkService.getParamUpdateProposals(options); + Assertions.assertTrue(paramUpdateProposalsResult.isSuccessful()); + Assertions.assertNotNull(paramUpdateProposalsResult.getValue()); + log.info(paramUpdateProposalsResult.getValue().toString()); + Assertions.assertEquals(10, paramUpdateProposalsResult.getValue().size()); + } + + @Test + void getReserveWithdrawalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> withdrawalsResult = networkService.getReserveWithdrawals(options); + Assertions.assertTrue(withdrawalsResult.isSuccessful()); + Assertions.assertNotNull(withdrawalsResult.getValue()); + log.info(withdrawalsResult.getValue().toString()); + Assertions.assertEquals(10, withdrawalsResult.getValue().size()); + } + + @Test + void getTreasuryWithdrawalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> withdrawalsResult = networkService.getTreasuryWithdrawals(options); + Assertions.assertTrue(withdrawalsResult.isSuccessful()); + Assertions.assertNotNull(withdrawalsResult.getValue()); + log.info(withdrawalsResult.getValue().toString()); + Assertions.assertEquals(10, withdrawalsResult.getValue().size()); + } } diff --git a/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreprodIntegrationTest.java index cb51203..8d9fbcd 100644 --- a/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreprodIntegrationTest.java @@ -7,9 +7,7 @@ import org.junit.jupiter.api.TestInstance; 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.Genesis; -import rest.koios.client.backend.api.network.model.Tip; -import rest.koios.client.backend.api.network.model.Totals; +import rest.koios.client.backend.api.network.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -72,4 +70,32 @@ void getHistoricalTokenomicStatsBadRequestTest() { ApiException exception = assertThrows(ApiException.class, () -> networkService.getHistoricalTokenomicStatsByEpoch(-5)); assertInstanceOf(ApiException.class, exception); } + + @Test + void getParamUpdateProposalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> paramUpdateProposalsResult = networkService.getParamUpdateProposals(options); + Assertions.assertTrue(paramUpdateProposalsResult.isSuccessful()); + Assertions.assertNotNull(paramUpdateProposalsResult.getValue()); + log.info(paramUpdateProposalsResult.getValue().toString()); + Assertions.assertEquals(10, paramUpdateProposalsResult.getValue().size()); + } + + @Test + void getReserveWithdrawalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> withdrawalsResult = networkService.getReserveWithdrawals(options); + Assertions.assertTrue(withdrawalsResult.isSuccessful()); + Assertions.assertNotNull(withdrawalsResult.getValue()); + log.info(withdrawalsResult.getValue().toString()); + } + + @Test + void getTreasuryWithdrawalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> withdrawalsResult = networkService.getTreasuryWithdrawals(options); + Assertions.assertTrue(withdrawalsResult.isSuccessful()); + Assertions.assertNotNull(withdrawalsResult.getValue()); + log.info(withdrawalsResult.getValue().toString()); + } } diff --git a/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreviewIntegrationTest.java index d8c94e6..156ae7d 100644 --- a/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/network/NetworkServicePreviewIntegrationTest.java @@ -7,9 +7,7 @@ import org.junit.jupiter.api.TestInstance; 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.Genesis; -import rest.koios.client.backend.api.network.model.Tip; -import rest.koios.client.backend.api.network.model.Totals; +import rest.koios.client.backend.api.network.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -72,4 +70,32 @@ void getHistoricalTokenomicStatsBadRequestTest() { ApiException exception = assertThrows(ApiException.class, () -> networkService.getHistoricalTokenomicStatsByEpoch(-5)); assertInstanceOf(ApiException.class, exception); } + + @Test + void getParamUpdateProposalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> paramUpdateProposalsResult = networkService.getParamUpdateProposals(options); + Assertions.assertTrue(paramUpdateProposalsResult.isSuccessful()); + Assertions.assertNotNull(paramUpdateProposalsResult.getValue()); + log.info(paramUpdateProposalsResult.getValue().toString()); + Assertions.assertEquals(10, paramUpdateProposalsResult.getValue().size()); + } + + @Test + void getReserveWithdrawalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> withdrawalsResult = networkService.getReserveWithdrawals(options); + Assertions.assertTrue(withdrawalsResult.isSuccessful()); + Assertions.assertNotNull(withdrawalsResult.getValue()); + log.info(withdrawalsResult.getValue().toString()); + } + + @Test + void getTreasuryWithdrawalsTest() throws ApiException { + Options options = Options.builder().option(Limit.of(10)).build(); + Result> withdrawalsResult = networkService.getTreasuryWithdrawals(options); + Assertions.assertTrue(withdrawalsResult.isSuccessful()); + Assertions.assertNotNull(withdrawalsResult.getValue()); + log.info(withdrawalsResult.getValue().toString()); + } } 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 f5a37a6..39a4d98 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 @@ -178,6 +178,24 @@ void getPoolUpdatesBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getPoolRegistrationsTest() throws ApiException { + Integer epochNo = 320; + Result> poolRegistrationsResult = poolService.getPoolRegistrations(epochNo, Options.EMPTY); + Assertions.assertTrue(poolRegistrationsResult.isSuccessful()); + Assertions.assertNotNull(poolRegistrationsResult.getValue()); + log.info(poolRegistrationsResult.getValue().toString()); + } + + @Test + void getPoolRetirementsTest() throws ApiException { + Integer epochNo = 320; + Result> poolRegistrationsResult = poolService.getPoolRetirements(epochNo, Options.EMPTY); + Assertions.assertTrue(poolRegistrationsResult.isSuccessful()); + Assertions.assertNotNull(poolRegistrationsResult.getValue()); + log.info(poolRegistrationsResult.getValue().toString()); + } + @Test void getPoolRelaysLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); diff --git a/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreprodIntegrationTest.java index 7b8ef71..02199b9 100644 --- a/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreprodIntegrationTest.java @@ -166,6 +166,24 @@ void getPoolUpdatesBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getPoolRegistrationsTest() throws ApiException { + Integer epochNo = 31; + Result> poolRegistrationsResult = poolService.getPoolRegistrations(epochNo, Options.EMPTY); + Assertions.assertTrue(poolRegistrationsResult.isSuccessful()); + Assertions.assertNotNull(poolRegistrationsResult.getValue()); + log.info(poolRegistrationsResult.getValue().toString()); + } + + @Test + void getPoolRetirementsTest() throws ApiException { + Integer epochNo = 31; + Result> poolRegistrationsResult = poolService.getPoolRetirements(epochNo, Options.EMPTY); + Assertions.assertTrue(poolRegistrationsResult.isSuccessful()); + Assertions.assertNotNull(poolRegistrationsResult.getValue()); + log.info(poolRegistrationsResult.getValue().toString()); + } + @Test void getPoolRelaysLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); diff --git a/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreviewIntegrationTest.java index ed380f0..3e1b1d1 100644 --- a/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/pool/PoolServicePreviewIntegrationTest.java @@ -166,6 +166,24 @@ void getPoolUpdatesBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getPoolRegistrationsTest() throws ApiException { + Integer epochNo = 12; + Result> poolRegistrationsResult = poolService.getPoolRegistrations(epochNo, Options.EMPTY); + Assertions.assertTrue(poolRegistrationsResult.isSuccessful()); + Assertions.assertNotNull(poolRegistrationsResult.getValue()); + log.info(poolRegistrationsResult.getValue().toString()); + } + + @Test + void getPoolRetirementsTest() throws ApiException { + Integer epochNo = 12; + Result> poolRegistrationsResult = poolService.getPoolRetirements(epochNo, Options.EMPTY); + Assertions.assertTrue(poolRegistrationsResult.isSuccessful()); + Assertions.assertNotNull(poolRegistrationsResult.getValue()); + log.info(poolRegistrationsResult.getValue().toString()); + } + @Test void getPoolRelaysLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); diff --git a/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServiceMainnetIntegrationTest.java index 4a40a08..ec08111 100644 --- a/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServiceMainnetIntegrationTest.java @@ -6,11 +6,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; -import rest.koios.client.backend.api.script.model.PlutusScript; -import rest.koios.client.backend.api.script.model.ScriptRedeemer; +import rest.koios.client.backend.api.script.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -30,6 +28,15 @@ public void setup() { scriptService = BackendFactory.getKoiosMainnetService().getScriptService(); } + @Test + void getScriptInformationTest() throws ApiException { + List scriptHashes = List.of("bd2119ee2bfb8c8d7c427e8af3c35d537534281e09e23013bca5b138","c0c671fba483641a71bb92d3a8b7c52c90bf1c01e2b83116ad7d4536"); + Result> scriptInformationResult = scriptService.getScriptInformation(scriptHashes, Options.EMPTY); + Assertions.assertTrue(scriptInformationResult.isSuccessful()); + Assertions.assertNotNull(scriptInformationResult.getValue()); + log.info(scriptInformationResult.getValue().toString()); + } + @Test void getNativeScriptListLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); @@ -43,7 +50,7 @@ void getNativeScriptListLimitTest() throws ApiException { @Test void getNativeScriptByScriptHashTest() throws ApiException { String scriptHash = "65c197d565e88a20885e535f93755682444d3c02fd44dd70883fe89e"; - Result scriptResult = scriptService.getNativeScript(scriptHash); + Result scriptResult = scriptService.getNativeScriptByScriptHash(scriptHash); Assertions.assertTrue(scriptResult.isSuccessful()); Assertions.assertNotNull(scriptResult.getValue()); log.info(scriptResult.getValue().toString()); @@ -77,6 +84,15 @@ void getScriptRedeemersBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getScriptUTxOsTest() throws ApiException { + String scriptHash = "d8480dc869b94b80e81ec91b0abe307279311fe0e7001a9488f61ff8"; + Result> utxosResult = scriptService.getScriptUTxOs(scriptHash, false, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + @Test void getDatumInformationTest() throws ApiException { String hash1 = "818ee3db3bbbd04f9f2ce21778cac3ac605802a4fcb00c8b3a58ee2dafc17d46"; diff --git a/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreprodIntegrationTest.java index 8b216c1..481e05f 100644 --- a/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreprodIntegrationTest.java @@ -6,11 +6,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; -import rest.koios.client.backend.api.script.model.PlutusScript; -import rest.koios.client.backend.api.script.model.ScriptRedeemer; +import rest.koios.client.backend.api.script.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -30,6 +28,15 @@ public void setup() { scriptService = BackendFactory.getKoiosPreprodService().getScriptService(); } + @Test + void getScriptInformationTest() throws ApiException { + List scriptHashes = List.of("a8e9f8f34fd631b1d5b9f41a90f4abc0d3935cea7baba0bb34c96f59","b4fd6dfe4a643aeec5d75dbb1f27198fc2aabf30bf92ed5470253792"); + Result> scriptInformationResult = scriptService.getScriptInformation(scriptHashes, Options.EMPTY); + Assertions.assertTrue(scriptInformationResult.isSuccessful()); + Assertions.assertNotNull(scriptInformationResult.getValue()); + log.info(scriptInformationResult.getValue().toString()); + } + @Test void getNativeScriptListLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); @@ -43,7 +50,7 @@ void getNativeScriptListLimitTest() throws ApiException { @Test void getNativeScriptByScriptHashTest() throws ApiException { String scriptHash = "2f4e0f59b09f77dff4ab0664c12806fff5316f6bdf0484594439fe39"; - Result scriptResult = scriptService.getNativeScript(scriptHash); + Result scriptResult = scriptService.getNativeScriptByScriptHash(scriptHash); Assertions.assertTrue(scriptResult.isSuccessful()); Assertions.assertNotNull(scriptResult.getValue()); log.info(scriptResult.getValue().toString()); @@ -77,6 +84,15 @@ void getScriptRedeemersBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getScriptUTxOsTest() throws ApiException { + String scriptHash = "590555d7b5760e98ae2bdd29b356247776251dfab0a207bfce98a485"; + Result> utxosResult = scriptService.getScriptUTxOs(scriptHash, false, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + @Test void getDatumInformationTest() throws ApiException { String hash1 = "5571e2c3549f15934a38382d1318707a86751fb70827f4cbd29b104480f1be9b"; diff --git a/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreviewIntegrationTest.java index d01fd93..e5de8dd 100644 --- a/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/script/PlutusScriptServicePreviewIntegrationTest.java @@ -6,11 +6,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import rest.koios.client.backend.api.base.Result; +import rest.koios.client.backend.api.base.common.UTxO; import rest.koios.client.backend.api.base.exception.ApiException; -import rest.koios.client.backend.api.script.model.DatumInfo; -import rest.koios.client.backend.api.script.model.NativeScript; -import rest.koios.client.backend.api.script.model.PlutusScript; -import rest.koios.client.backend.api.script.model.ScriptRedeemer; +import rest.koios.client.backend.api.script.model.*; import rest.koios.client.backend.factory.BackendFactory; import rest.koios.client.backend.factory.options.Limit; import rest.koios.client.backend.factory.options.Options; @@ -30,6 +28,15 @@ public void setup() { scriptService = BackendFactory.getKoiosPreviewService().getScriptService(); } + @Test + void getScriptInformationTest() throws ApiException { + List scriptHashes = List.of("c6d963e8892916ab8753d3c342037cd122123c4dd783a07af21f8dac","c0c671fba483641a71bb92d3a8b7c52c90bf1c01e2b83116ad7d4536"); + Result> scriptInformationResult = scriptService.getScriptInformation(scriptHashes, Options.EMPTY); + Assertions.assertTrue(scriptInformationResult.isSuccessful()); + Assertions.assertNotNull(scriptInformationResult.getValue()); + log.info(scriptInformationResult.getValue().toString()); + } + @Test void getNativeScriptListLimitTest() throws ApiException { Options options = Options.builder().option(Limit.of(10)).build(); @@ -43,7 +50,7 @@ void getNativeScriptListLimitTest() throws ApiException { @Test void getNativeScriptByScriptHashTest() throws ApiException { String scriptHash = "6c969320597b755454ff3653ad09725d590c570827a129aeb4385526"; - Result scriptResult = scriptService.getNativeScript(scriptHash); + Result scriptResult = scriptService.getNativeScriptByScriptHash(scriptHash); Assertions.assertTrue(scriptResult.isSuccessful()); Assertions.assertNotNull(scriptResult.getValue()); log.info(scriptResult.getValue().toString()); @@ -77,6 +84,15 @@ void getScriptRedeemersBadRequestTest() { assertInstanceOf(ApiException.class, exception); } + @Test + void getScriptUTxOsTest() throws ApiException { + String scriptHash = "f758cf422ca0cbed7d9d6fad1eb5a3c70537d62e661ad450dd2a3810"; + Result> utxosResult = scriptService.getScriptUTxOs(scriptHash, false, Options.EMPTY); + Assertions.assertTrue(utxosResult.isSuccessful()); + Assertions.assertNotNull(utxosResult.getValue()); + log.info(utxosResult.getValue().toString()); + } + @Test void getDatumInformationTest() throws ApiException { String hash1 = "6181b3dc623cd8812caf027a3507e9b3095388a7cf3db65983e1fddd3a84c88c"; diff --git a/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServiceMainnetIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServiceMainnetIntegrationTest.java index 51c8d2f..d15fd5b 100644 --- a/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServiceMainnetIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServiceMainnetIntegrationTest.java @@ -53,22 +53,6 @@ void getTransactionInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } - @Test - void getTransactionUTxOsTest() throws ApiException { - String txHash = "f144a8264acf4bdfe2e1241170969c930d64ab6b0996a4a45237b623f1dd670e"; - Result> transactionUTxOsResult = transactionsService.getTransactionUTxOs(List.of(txHash), Options.EMPTY); - Assertions.assertTrue(transactionUTxOsResult.isSuccessful()); - Assertions.assertNotNull(transactionUTxOsResult.getValue()); - log.info(transactionUTxOsResult.getValue().toString()); - } - - @Test - void getTransactionUTxOsBadRequestTest() { - String txHash = "test"; - ApiException exception = assertThrows(ApiException.class, () -> transactionsService.getTransactionUTxOs(List.of(txHash), Options.EMPTY)); - assertInstanceOf(ApiException.class, exception); - } - @Test void getTransactionMetadataTest() throws ApiException { String txHash = "0b8ba3bed976fa4913f19adc9f6dd9063138db5b4dd29cecde369456b5155e94"; diff --git a/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreprodIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreprodIntegrationTest.java index 1dfe5c8..38810ec 100644 --- a/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreprodIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreprodIntegrationTest.java @@ -55,22 +55,6 @@ void getTransactionInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } - @Test - void getTransactionUTxOsTest() throws ApiException { - String txHash = "b241c8c466c64ca7f7e33a3c4a0df5ce079a719b1c6a3b2dfe72780192235417"; - Result> transactionUTxOsResult = transactionsService.getTransactionUTxOs(List.of(txHash), Options.EMPTY); - Assertions.assertTrue(transactionUTxOsResult.isSuccessful()); - Assertions.assertNotNull(transactionUTxOsResult.getValue()); - log.info(transactionUTxOsResult.getValue().toString()); - } - - @Test - void getTransactionUTxOsBadRequestTest() { - String txHash = "test"; - ApiException exception = assertThrows(ApiException.class, () -> transactionsService.getTransactionUTxOs(List.of(txHash), Options.EMPTY)); - assertInstanceOf(ApiException.class, exception); - } - @Test void getTransactionMetadataTest() throws ApiException { String txHash = "928613735664d63c27003fb9e517f956c838d19f641238c92a6e1a3a3361255c"; diff --git a/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreviewIntegrationTest.java b/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreviewIntegrationTest.java index 433f2e5..4e7cfce 100644 --- a/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreviewIntegrationTest.java +++ b/src/test/java/rest/koios/client/backend/api/transactions/TransactionsServicePreviewIntegrationTest.java @@ -55,22 +55,6 @@ void getTransactionInformationBadRequestTest() { assertInstanceOf(ApiException.class, exception); } - @Test - void getTransactionUTxOsTest() throws ApiException { - String txHash = "7395c56ce76d7e6e1155ba71cc2a9dc9b37d58d162dbc1eb9fb35267bb76054d"; - Result> transactionUTxOsResult = transactionsService.getTransactionUTxOs(List.of(txHash), Options.EMPTY); - Assertions.assertTrue(transactionUTxOsResult.isSuccessful()); - Assertions.assertNotNull(transactionUTxOsResult.getValue()); - log.info(transactionUTxOsResult.getValue().toString()); - } - - @Test - void getTransactionUTxOsBadRequestTest() { - String txHash = "test"; - ApiException exception = assertThrows(ApiException.class, () -> transactionsService.getTransactionUTxOs(List.of(txHash), Options.EMPTY)); - assertInstanceOf(ApiException.class, exception); - } - @Test void getTransactionMetadataTest() throws ApiException { String txHash = "7395c56ce76d7e6e1155ba71cc2a9dc9b37d58d162dbc1eb9fb35267bb76054d"; diff --git a/src/test/java/rest/koios/client/backend/factory/options/OptionsPreviewTest.java b/src/test/java/rest/koios/client/backend/factory/options/OptionsPreviewTest.java index c8a8dd5..0b5b72d 100644 --- a/src/test/java/rest/koios/client/backend/factory/options/OptionsPreviewTest.java +++ b/src/test/java/rest/koios/client/backend/factory/options/OptionsPreviewTest.java @@ -4,7 +4,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.common.TxHash; +import rest.koios.client.backend.api.base.common.TxHash; import rest.koios.client.backend.api.address.AddressService; import rest.koios.client.backend.api.base.Result; import rest.koios.client.backend.api.base.exception.ApiException; @@ -89,7 +89,7 @@ void MixedWithNotOperatorOptionsTest() throws ApiException { assertTrue(transactionsResult.isSuccessful()); assertNotNull(transactionsResult.getValue()); log.info(transactionsResult.getValue().toString()); - assertEquals(16, transactionsResult.getValue().size()); + assertEquals(39, transactionsResult.getValue().size()); assertEquals("8a1f7811d7c3c46c3421e5b6515239c8cd7cce21c371bb0d5c107d0296fab29d", transactionsResult.getValue().get(0).getTxHash()); assertNotEquals(0, transactionsResult.getValue().get(0).getBlockHeight()); assertNotNull(transactionsResult.getValue().get(0).getBlockTime());