diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e7704d48..1e5bae5cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 1.13.0-beta-1 +- Unlimited assets regenerated code. (#302) + # 1.12.0 - Add new key reg txn field (#266) - C2C Feature and Testing (#290) @@ -103,14 +106,14 @@ # 1.2.0 # Added - Added support for Algorand Standardized Assets (ASA) -- Added support for Algorand Smart Contracts (ASC) - - Added support for Hashed Time Lock Contract (HTLC) +- Added support for Algorand Smart Contracts (ASC) + - Added support for Hashed Time Lock Contract (HTLC) - Added support for Split contract - Added support for Group Transactions - Added support for leases # 1.1.6 ## Changed -- IMPORTANT - This version modifies one of the mnemonic words. Please let your users to know that if they have the word "setupIfNeeded" in their mmnemonic, they should change it to "setup". Everything else remains the same. +- IMPORTANT - This version modifies one of the mnemonic words. Please let your users to know that if they have the word "setupIfNeeded" in their mmnemonic, they should change it to "setup". Everything else remains the same. # 1.1.5 ## Added - signing and verifying signatures for arbitrary bytes diff --git a/Makefile b/Makefile index e72b8646f..417da9061 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ unit: - mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.atomic_transaction_composer or @unit.transactions.payment" + mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring" integration: mvn test -Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey or @applications.verified or @applications or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c" diff --git a/README.md b/README.md index 63d310733..62f422c7c 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Maven: com.algorand algosdk - 1.12.0 + 1.13.0-beta-1 ``` @@ -170,7 +170,7 @@ public class Main { # Documentation -Javadoc can be found at [https://algorand.github.io/java-algorand-sdk](https://algorand.github.io/java-algorand-sdk).
+Javadoc can be found at [https://algorand.github.io/java-algorand-sdk](https://algorand.github.io/java-algorand-sdk).
Additional resources and code samples are located at [https://developer.algorand.org](https://developer.algorand.org). # Cryptography diff --git a/pom.xml b/pom.xml index 48854e9a2..2e1c95aed 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.algorand algosdk - 1.12.0 + 1.13.0-beta-1 jar ${project.groupId}:${project.artifactId} diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/AccountApplicationInformation.java b/src/main/java/com/algorand/algosdk/v2/client/algod/AccountApplicationInformation.java new file mode 100644 index 000000000..37dd2a795 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/AccountApplicationInformation.java @@ -0,0 +1,76 @@ +package com.algorand.algosdk.v2.client.algod; + +import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.v2.client.common.Client; +import com.algorand.algosdk.v2.client.common.HttpMethod; +import com.algorand.algosdk.v2.client.common.Query; +import com.algorand.algosdk.v2.client.common.QueryData; +import com.algorand.algosdk.v2.client.common.Response; +import com.algorand.algosdk.v2.client.model.AccountApplicationResponse; + + +/** + * Given a specific account public key and application ID, this call returns the + * account's application local state and global state (AppLocalState and AppParams, + * if either exists). Global state will only be returned if the provided address is + * the application's creator. + * /v2/accounts/{address}/applications/{application-id} + */ +public class AccountApplicationInformation extends Query { + + private Address address; + private Long applicationId; + + /** + * @param address An account public key + * @param applicationId An application identifier + */ + public AccountApplicationInformation(Client client, Address address, Long applicationId) { + super(client, new HttpMethod("get")); + this.address = address; + this.applicationId = applicationId; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(AccountApplicationResponse.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(AccountApplicationResponse.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.address == null) { + throw new RuntimeException("address is not set. It is a required parameter."); + } + if (this.applicationId == null) { + throw new RuntimeException("application-id is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("accounts")); + addPathSegment(String.valueOf(address)); + addPathSegment(String.valueOf("applications")); + addPathSegment(String.valueOf(applicationId)); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/AccountAssetInformation.java b/src/main/java/com/algorand/algosdk/v2/client/algod/AccountAssetInformation.java new file mode 100644 index 000000000..97ca5216f --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/AccountAssetInformation.java @@ -0,0 +1,75 @@ +package com.algorand.algosdk.v2.client.algod; + +import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.v2.client.common.Client; +import com.algorand.algosdk.v2.client.common.HttpMethod; +import com.algorand.algosdk.v2.client.common.Query; +import com.algorand.algosdk.v2.client.common.QueryData; +import com.algorand.algosdk.v2.client.common.Response; +import com.algorand.algosdk.v2.client.model.AccountAssetResponse; + + +/** + * Given a specific account public key and asset ID, this call returns the + * account's asset holding and asset parameters (if either exist). Asset parameters + * will only be returned if the provided address is the asset's creator. + * /v2/accounts/{address}/assets/{asset-id} + */ +public class AccountAssetInformation extends Query { + + private Address address; + private Long assetId; + + /** + * @param address An account public key + * @param assetId An asset identifier + */ + public AccountAssetInformation(Client client, Address address, Long assetId) { + super(client, new HttpMethod("get")); + this.address = address; + this.assetId = assetId; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(AccountAssetResponse.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(AccountAssetResponse.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.address == null) { + throw new RuntimeException("address is not set. It is a required parameter."); + } + if (this.assetId == null) { + throw new RuntimeException("asset-id is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("accounts")); + addPathSegment(String.valueOf(address)); + addPathSegment(String.valueOf("assets")); + addPathSegment(String.valueOf(assetId)); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/AccountInformation.java b/src/main/java/com/algorand/algosdk/v2/client/algod/AccountInformation.java index e5fce1631..efdb465c5 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/algod/AccountInformation.java +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/AccountInformation.java @@ -7,6 +7,7 @@ import com.algorand.algosdk.v2.client.common.QueryData; import com.algorand.algosdk.v2.client.common.Response; import com.algorand.algosdk.v2.client.model.Account; +import com.algorand.algosdk.v2.client.model.Enums; /** @@ -26,6 +27,15 @@ public AccountInformation(Client client, Address address) { this.address = address; } + /** + * When set to `all` will exclude asset holdings, application local state, created + * asset parameters, any created application parameters. Defaults to `none`. + */ + public AccountInformation exclude(Enums.Exclude exclude) { + addQuery("exclude", String.valueOf(exclude)); + return this; + } + /** * Execute the query. * @return the query response object. diff --git a/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java b/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java index 715be0133..c0be5ea34 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java +++ b/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java @@ -6,6 +6,8 @@ import com.algorand.algosdk.v2.client.algod.SwaggerJSON; import com.algorand.algosdk.v2.client.algod.GetVersion; import com.algorand.algosdk.v2.client.algod.AccountInformation; +import com.algorand.algosdk.v2.client.algod.AccountAssetInformation; +import com.algorand.algosdk.v2.client.algod.AccountApplicationInformation; import com.algorand.algosdk.v2.client.algod.GetPendingTransactionsByAddress; import com.algorand.algosdk.v2.client.algod.GetBlock; import com.algorand.algosdk.v2.client.algod.GetProof; @@ -95,6 +97,29 @@ public AccountInformation AccountInformation(Address address) { return new AccountInformation((Client) this, address); } + /** + * Given a specific account public key and asset ID, this call returns the + * account's asset holding and asset parameters (if either exist). Asset parameters + * will only be returned if the provided address is the asset's creator. + * /v2/accounts/{address}/assets/{asset-id} + */ + public AccountAssetInformation AccountAssetInformation(Address address, + Long assetId) { + return new AccountAssetInformation((Client) this, address, assetId); + } + + /** + * Given a specific account public key and application ID, this call returns the + * account's application local state and global state (AppLocalState and AppParams, + * if either exists). Global state will only be returned if the provided address is + * the application's creator. + * /v2/accounts/{address}/applications/{application-id} + */ + public AccountApplicationInformation AccountApplicationInformation(Address address, + Long applicationId) { + return new AccountApplicationInformation((Client) this, address, applicationId); + } + /** * Get the list of pending transactions by address, sorted by priority, in * decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending diff --git a/src/main/java/com/algorand/algosdk/v2/client/common/IndexerClient.java b/src/main/java/com/algorand/algosdk/v2/client/common/IndexerClient.java index d53151ff1..b2486a905 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/common/IndexerClient.java +++ b/src/main/java/com/algorand/algosdk/v2/client/common/IndexerClient.java @@ -3,6 +3,10 @@ import com.algorand.algosdk.v2.client.indexer.MakeHealthCheck; import com.algorand.algosdk.v2.client.indexer.SearchForAccounts; import com.algorand.algosdk.v2.client.indexer.LookupAccountByID; +import com.algorand.algosdk.v2.client.indexer.LookupAccountAssets; +import com.algorand.algosdk.v2.client.indexer.LookupAccountCreatedAssets; +import com.algorand.algosdk.v2.client.indexer.LookupAccountAppLocalStates; +import com.algorand.algosdk.v2.client.indexer.LookupAccountCreatedApplications; import com.algorand.algosdk.v2.client.indexer.LookupAccountTransactions; import com.algorand.algosdk.v2.client.indexer.SearchForApplications; import com.algorand.algosdk.v2.client.indexer.LookupApplicationByID; @@ -72,6 +76,39 @@ public LookupAccountByID lookupAccountByID(Address accountId) { return new LookupAccountByID((Client) this, accountId); } + /** + * Lookup an account's asset holdings, optionally for a specific ID. + * /v2/accounts/{account-id}/assets + */ + public LookupAccountAssets lookupAccountAssets(Address accountId) { + return new LookupAccountAssets((Client) this, accountId); + } + + /** + * Lookup an account's created asset parameters, optionally for a specific ID. + * /v2/accounts/{account-id}/created-assets + */ + public LookupAccountCreatedAssets lookupAccountCreatedAssets(Address accountId) { + return new LookupAccountCreatedAssets((Client) this, accountId); + } + + /** + * Lookup an account's asset holdings, optionally for a specific ID. + * /v2/accounts/{account-id}/apps-local-state + */ + public LookupAccountAppLocalStates lookupAccountAppLocalStates(Address accountId) { + return new LookupAccountAppLocalStates((Client) this, accountId); + } + + /** + * Lookup an account's created application parameters, optionally for a specific + * ID. + * /v2/accounts/{account-id}/created-applications + */ + public LookupAccountCreatedApplications lookupAccountCreatedApplications(Address accountId) { + return new LookupAccountCreatedApplications((Client) this, accountId); + } + /** * Lookup account transactions. * /v2/accounts/{account-id}/transactions diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountAppLocalStates.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountAppLocalStates.java new file mode 100644 index 000000000..933fbc02d --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountAppLocalStates.java @@ -0,0 +1,100 @@ +package com.algorand.algosdk.v2.client.indexer; + +import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.v2.client.common.Client; +import com.algorand.algosdk.v2.client.common.HttpMethod; +import com.algorand.algosdk.v2.client.common.Query; +import com.algorand.algosdk.v2.client.common.QueryData; +import com.algorand.algosdk.v2.client.common.Response; +import com.algorand.algosdk.v2.client.model.ApplicationLocalStatesResponse; + + +/** + * Lookup an account's asset holdings, optionally for a specific ID. + * /v2/accounts/{account-id}/apps-local-state + */ +public class LookupAccountAppLocalStates extends Query { + + private Address accountId; + + /** + * @param accountId account string + */ + public LookupAccountAppLocalStates(Client client, Address accountId) { + super(client, new HttpMethod("get")); + this.accountId = accountId; + } + + /** + * Application ID + */ + public LookupAccountAppLocalStates applicationId(Long applicationId) { + addQuery("application-id", String.valueOf(applicationId)); + return this; + } + + /** + * Include all items including closed accounts, deleted applications, destroyed + * assets, opted-out asset holdings, and closed-out application localstates. + */ + public LookupAccountAppLocalStates includeAll(Boolean includeAll) { + addQuery("include-all", String.valueOf(includeAll)); + return this; + } + + /** + * Maximum number of results to return. There could be additional pages even if the + * limit is not reached. + */ + public LookupAccountAppLocalStates limit(Long limit) { + addQuery("limit", String.valueOf(limit)); + return this; + } + + /** + * The next page of results. Use the next token provided by the previous results. + */ + public LookupAccountAppLocalStates next(String next) { + addQuery("next", String.valueOf(next)); + return this; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(ApplicationLocalStatesResponse.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(ApplicationLocalStatesResponse.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.accountId == null) { + throw new RuntimeException("account-id is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("accounts")); + addPathSegment(String.valueOf(accountId)); + addPathSegment(String.valueOf("apps-local-state")); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountAssets.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountAssets.java new file mode 100644 index 000000000..d881baa47 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountAssets.java @@ -0,0 +1,100 @@ +package com.algorand.algosdk.v2.client.indexer; + +import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.v2.client.common.Client; +import com.algorand.algosdk.v2.client.common.HttpMethod; +import com.algorand.algosdk.v2.client.common.Query; +import com.algorand.algosdk.v2.client.common.QueryData; +import com.algorand.algosdk.v2.client.common.Response; +import com.algorand.algosdk.v2.client.model.AssetHoldingsResponse; + + +/** + * Lookup an account's asset holdings, optionally for a specific ID. + * /v2/accounts/{account-id}/assets + */ +public class LookupAccountAssets extends Query { + + private Address accountId; + + /** + * @param accountId account string + */ + public LookupAccountAssets(Client client, Address accountId) { + super(client, new HttpMethod("get")); + this.accountId = accountId; + } + + /** + * Asset ID + */ + public LookupAccountAssets assetId(Long assetId) { + addQuery("asset-id", String.valueOf(assetId)); + return this; + } + + /** + * Include all items including closed accounts, deleted applications, destroyed + * assets, opted-out asset holdings, and closed-out application localstates. + */ + public LookupAccountAssets includeAll(Boolean includeAll) { + addQuery("include-all", String.valueOf(includeAll)); + return this; + } + + /** + * Maximum number of results to return. There could be additional pages even if the + * limit is not reached. + */ + public LookupAccountAssets limit(Long limit) { + addQuery("limit", String.valueOf(limit)); + return this; + } + + /** + * The next page of results. Use the next token provided by the previous results. + */ + public LookupAccountAssets next(String next) { + addQuery("next", String.valueOf(next)); + return this; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(AssetHoldingsResponse.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(AssetHoldingsResponse.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.accountId == null) { + throw new RuntimeException("account-id is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("accounts")); + addPathSegment(String.valueOf(accountId)); + addPathSegment(String.valueOf("assets")); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountByID.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountByID.java index 245cfe0c5..fc760b3ce 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountByID.java +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountByID.java @@ -1,5 +1,9 @@ package com.algorand.algosdk.v2.client.indexer; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + import com.algorand.algosdk.crypto.Address; import com.algorand.algosdk.v2.client.common.Client; import com.algorand.algosdk.v2.client.common.HttpMethod; @@ -7,6 +11,7 @@ import com.algorand.algosdk.v2.client.common.QueryData; import com.algorand.algosdk.v2.client.common.Response; import com.algorand.algosdk.v2.client.model.AccountResponse; +import com.algorand.algosdk.v2.client.model.Enums; /** @@ -25,6 +30,16 @@ public LookupAccountByID(Client client, Address accountId) { this.accountId = accountId; } + /** + * Exclude additional items such as asset holdings, application local data stored + * for this account, asset parameters created by this account, and application + * parameters created by this account. + */ + public LookupAccountByID exclude(List exclude) { + addQuery("exclude", StringUtils.join(exclude, ",")); + return this; + } + /** * Include all items including closed accounts, deleted applications, destroyed * assets, opted-out asset holdings, and closed-out application localstates. diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountCreatedApplications.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountCreatedApplications.java new file mode 100644 index 000000000..056659b79 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountCreatedApplications.java @@ -0,0 +1,101 @@ +package com.algorand.algosdk.v2.client.indexer; + +import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.v2.client.common.Client; +import com.algorand.algosdk.v2.client.common.HttpMethod; +import com.algorand.algosdk.v2.client.common.Query; +import com.algorand.algosdk.v2.client.common.QueryData; +import com.algorand.algosdk.v2.client.common.Response; +import com.algorand.algosdk.v2.client.model.ApplicationsResponse; + + +/** + * Lookup an account's created application parameters, optionally for a specific + * ID. + * /v2/accounts/{account-id}/created-applications + */ +public class LookupAccountCreatedApplications extends Query { + + private Address accountId; + + /** + * @param accountId account string + */ + public LookupAccountCreatedApplications(Client client, Address accountId) { + super(client, new HttpMethod("get")); + this.accountId = accountId; + } + + /** + * Application ID + */ + public LookupAccountCreatedApplications applicationId(Long applicationId) { + addQuery("application-id", String.valueOf(applicationId)); + return this; + } + + /** + * Include all items including closed accounts, deleted applications, destroyed + * assets, opted-out asset holdings, and closed-out application localstates. + */ + public LookupAccountCreatedApplications includeAll(Boolean includeAll) { + addQuery("include-all", String.valueOf(includeAll)); + return this; + } + + /** + * Maximum number of results to return. There could be additional pages even if the + * limit is not reached. + */ + public LookupAccountCreatedApplications limit(Long limit) { + addQuery("limit", String.valueOf(limit)); + return this; + } + + /** + * The next page of results. Use the next token provided by the previous results. + */ + public LookupAccountCreatedApplications next(String next) { + addQuery("next", String.valueOf(next)); + return this; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(ApplicationsResponse.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(ApplicationsResponse.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.accountId == null) { + throw new RuntimeException("account-id is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("accounts")); + addPathSegment(String.valueOf(accountId)); + addPathSegment(String.valueOf("created-applications")); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountCreatedAssets.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountCreatedAssets.java new file mode 100644 index 000000000..ad900271a --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAccountCreatedAssets.java @@ -0,0 +1,100 @@ +package com.algorand.algosdk.v2.client.indexer; + +import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.v2.client.common.Client; +import com.algorand.algosdk.v2.client.common.HttpMethod; +import com.algorand.algosdk.v2.client.common.Query; +import com.algorand.algosdk.v2.client.common.QueryData; +import com.algorand.algosdk.v2.client.common.Response; +import com.algorand.algosdk.v2.client.model.AssetsResponse; + + +/** + * Lookup an account's created asset parameters, optionally for a specific ID. + * /v2/accounts/{account-id}/created-assets + */ +public class LookupAccountCreatedAssets extends Query { + + private Address accountId; + + /** + * @param accountId account string + */ + public LookupAccountCreatedAssets(Client client, Address accountId) { + super(client, new HttpMethod("get")); + this.accountId = accountId; + } + + /** + * Asset ID + */ + public LookupAccountCreatedAssets assetId(Long assetId) { + addQuery("asset-id", String.valueOf(assetId)); + return this; + } + + /** + * Include all items including closed accounts, deleted applications, destroyed + * assets, opted-out asset holdings, and closed-out application localstates. + */ + public LookupAccountCreatedAssets includeAll(Boolean includeAll) { + addQuery("include-all", String.valueOf(includeAll)); + return this; + } + + /** + * Maximum number of results to return. There could be additional pages even if the + * limit is not reached. + */ + public LookupAccountCreatedAssets limit(Long limit) { + addQuery("limit", String.valueOf(limit)); + return this; + } + + /** + * The next page of results. Use the next token provided by the previous results. + */ + public LookupAccountCreatedAssets next(String next) { + addQuery("next", String.valueOf(next)); + return this; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(AssetsResponse.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(AssetsResponse.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.accountId == null) { + throw new RuntimeException("account-id is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("accounts")); + addPathSegment(String.valueOf(accountId)); + addPathSegment(String.valueOf("created-assets")); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAssetBalances.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAssetBalances.java index c7a446404..72c9e5273 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAssetBalances.java +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/LookupAssetBalances.java @@ -69,14 +69,6 @@ public LookupAssetBalances next(String next) { return this; } - /** - * Include results for the specified round. - */ - public LookupAssetBalances round(Long round) { - addQuery("round", String.valueOf(round)); - return this; - } - /** * Execute the query. * @return the query response object. diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForAccounts.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForAccounts.java index 2dbc35222..13b069ece 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForAccounts.java +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForAccounts.java @@ -1,5 +1,9 @@ package com.algorand.algosdk.v2.client.indexer; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; + import com.algorand.algosdk.crypto.Address; import com.algorand.algosdk.v2.client.common.Client; import com.algorand.algosdk.v2.client.common.HttpMethod; @@ -7,6 +11,7 @@ import com.algorand.algosdk.v2.client.common.QueryData; import com.algorand.algosdk.v2.client.common.Response; import com.algorand.algosdk.v2.client.model.AccountsResponse; +import com.algorand.algosdk.v2.client.model.Enums; /** @@ -62,6 +67,16 @@ public SearchForAccounts currencyLessThan(Long currencyLessThan) { return this; } + /** + * Exclude additional items such as asset holdings, application local data stored + * for this account, asset parameters created by this account, and application + * parameters created by this account. + */ + public SearchForAccounts exclude(List exclude) { + addQuery("exclude", StringUtils.join(exclude, ",")); + return this; + } + /** * Include all items including closed accounts, deleted applications, destroyed * assets, opted-out asset holdings, and closed-out application localstates. diff --git a/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForApplications.java b/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForApplications.java index 34064661a..d32761b1c 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForApplications.java +++ b/src/main/java/com/algorand/algosdk/v2/client/indexer/SearchForApplications.java @@ -26,6 +26,14 @@ public SearchForApplications applicationId(Long applicationId) { return this; } + /** + * Filter just applications with the given creator address. + */ + public SearchForApplications creator(String creator) { + addQuery("creator", String.valueOf(creator)); + return this; + } + /** * Include all items including closed accounts, deleted applications, destroyed * assets, opted-out asset holdings, and closed-out application localstates. diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Account.java b/src/main/java/com/algorand/algosdk/v2/client/model/Account.java index bdd0f19d9..8c11e9905 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Account.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Account.java @@ -180,6 +180,32 @@ public String authAddr() throws NoSuchAlgorithmException { @JsonProperty("status") public String status; + /** + * The count of all applications that have been opted in, equivalent to the count + * of application local data (AppLocalState objects) stored in this account. + */ + @JsonProperty("total-apps-opted-in") + public Long totalAppsOptedIn; + + /** + * The count of all assets that have been opted in, equivalent to the count of + * AssetHolding objects held by this account. + */ + @JsonProperty("total-assets-opted-in") + public Long totalAssetsOptedIn; + + /** + * The count of all apps (AppParams objects) created by this account. + */ + @JsonProperty("total-created-apps") + public Long totalCreatedApps; + + /** + * The count of all assets (AssetParams objects) created by this account. + */ + @JsonProperty("total-created-assets") + public Long totalCreatedAssets; + @Override public boolean equals(Object o) { @@ -207,6 +233,10 @@ public boolean equals(Object o) { if (!Objects.deepEquals(this.round, other.round)) return false; if (!Objects.deepEquals(this.sigType, other.sigType)) return false; if (!Objects.deepEquals(this.status, other.status)) return false; + if (!Objects.deepEquals(this.totalAppsOptedIn, other.totalAppsOptedIn)) return false; + if (!Objects.deepEquals(this.totalAssetsOptedIn, other.totalAssetsOptedIn)) return false; + if (!Objects.deepEquals(this.totalCreatedApps, other.totalCreatedApps)) return false; + if (!Objects.deepEquals(this.totalCreatedAssets, other.totalCreatedAssets)) return false; return true; } diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AccountApplicationResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/AccountApplicationResponse.java new file mode 100644 index 000000000..f3dbe2e02 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AccountApplicationResponse.java @@ -0,0 +1,50 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * AccountApplicationResponse describes the account's application local state and + * global state (AppLocalState and AppParams, if either exists) for a specific + * application ID. Global state will only be returned if the provided address is + * the application's creator. + */ +public class AccountApplicationResponse extends PathResponse { + + /** + * (appl) the application local data stored in this account. + * The raw account uses `AppLocalState` for this type. + */ + @JsonProperty("app-local-state") + public ApplicationLocalState appLocalState; + + /** + * (appp) parameters of the application created by this account including app + * global data. + * The raw account uses `AppParams` for this type. + */ + @JsonProperty("created-app") + public ApplicationParams createdApp; + + /** + * The round for which this information is relevant. + */ + @JsonProperty("round") + public Long round; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + AccountApplicationResponse other = (AccountApplicationResponse) o; + if (!Objects.deepEquals(this.appLocalState, other.appLocalState)) return false; + if (!Objects.deepEquals(this.createdApp, other.createdApp)) return false; + if (!Objects.deepEquals(this.round, other.round)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetResponse.java new file mode 100644 index 000000000..f3708c3f7 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetResponse.java @@ -0,0 +1,48 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * AccountAssetResponse describes the account's asset holding and asset parameters + * (if either exist) for a specific asset ID. Asset parameters will only be + * returned if the provided address is the asset's creator. + */ +public class AccountAssetResponse extends PathResponse { + + /** + * (asset) Details about the asset held by this account. + * The raw account uses `AssetHolding` for this type. + */ + @JsonProperty("asset-holding") + public AssetHolding assetHolding; + + /** + * (apar) parameters of the asset created by this account. + * The raw account uses `AssetParams` for this type. + */ + @JsonProperty("created-asset") + public AssetParams createdAsset; + + /** + * The round for which this information is relevant. + */ + @JsonProperty("round") + public Long round; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + AccountAssetResponse other = (AccountAssetResponse) o; + if (!Objects.deepEquals(this.assetHolding, other.assetHolding)) return false; + if (!Objects.deepEquals(this.createdAsset, other.createdAsset)) return false; + if (!Objects.deepEquals(this.round, other.round)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalStatesResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalStatesResponse.java new file mode 100644 index 000000000..e1995e1e3 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalStatesResponse.java @@ -0,0 +1,41 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class ApplicationLocalStatesResponse extends PathResponse { + + @JsonProperty("apps-local-states") + public List appsLocalStates = new ArrayList(); + + /** + * Round at which the results were computed. + */ + @JsonProperty("current-round") + public Long currentRound; + + /** + * Used for pagination, when making another request provide this token with the + * next parameter. + */ + @JsonProperty("next-token") + public String nextToken; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + ApplicationLocalStatesResponse other = (ApplicationLocalStatesResponse) o; + if (!Objects.deepEquals(this.appsLocalStates, other.appsLocalStates)) return false; + if (!Objects.deepEquals(this.currentRound, other.currentRound)) return false; + if (!Objects.deepEquals(this.nextToken, other.nextToken)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java b/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java index 5c64c38d7..b312c0a54 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java @@ -24,14 +24,6 @@ public class AssetHolding extends PathResponse { @JsonProperty("asset-id") public Long assetId; - /** - * Address that created this asset. This is the address where the parameters for - * this asset can be found, and also the address where unwanted asset units can be - * sent in the worst case. - */ - @JsonProperty("creator") - public String creator; - /** * Whether or not the asset holding is currently deleted from its account. */ @@ -65,7 +57,6 @@ public boolean equals(Object o) { AssetHolding other = (AssetHolding) o; if (!Objects.deepEquals(this.amount, other.amount)) return false; if (!Objects.deepEquals(this.assetId, other.assetId)) return false; - if (!Objects.deepEquals(this.creator, other.creator)) return false; if (!Objects.deepEquals(this.deleted, other.deleted)) return false; if (!Objects.deepEquals(this.isFrozen, other.isFrozen)) return false; if (!Objects.deepEquals(this.optedInAtRound, other.optedInAtRound)) return false; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AssetHoldingsResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/AssetHoldingsResponse.java new file mode 100644 index 000000000..05ea830ce --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AssetHoldingsResponse.java @@ -0,0 +1,41 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class AssetHoldingsResponse extends PathResponse { + + @JsonProperty("assets") + public List assets = new ArrayList(); + + /** + * Round at which the results were computed. + */ + @JsonProperty("current-round") + public Long currentRound; + + /** + * Used for pagination, when making another request provide this token with the + * next parameter. + */ + @JsonProperty("next-token") + public String nextToken; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + AssetHoldingsResponse other = (AssetHoldingsResponse) o; + if (!Objects.deepEquals(this.assets, other.assets)) return false; + if (!Objects.deepEquals(this.currentRound, other.currentRound)) return false; + if (!Objects.deepEquals(this.nextToken, other.nextToken)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java b/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java index a103f1048..b2515301c 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java @@ -23,6 +23,30 @@ public String toString() { } } + /** + * Exclude additional items such as asset holdings, application local data stored + * for this account, asset parameters created by this account, and application + * parameters created by this account. + */ + public enum Exclude { + @JsonProperty("all") ALL("all"), + @JsonProperty("assets") ASSETS("assets"), + @JsonProperty("created-assets") CREATEDASSETS("created-assets"), + @JsonProperty("apps-local-state") APPSLOCALSTATE("apps-local-state"), + @JsonProperty("created-apps") CREATEDAPPS("created-apps"), + @JsonProperty("none") NONE("none"); + + final String serializedName; + Exclude(String name) { + this.serializedName = name; + } + + @Override + public String toString() { + return this.serializedName; + } + } + /** * (apan) defines the what additional actions occur with the transaction. * Valid types: diff --git a/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java b/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java index e5237fa82..611f622a1 100644 --- a/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java +++ b/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java @@ -1,6 +1,7 @@ package com.algorand.algosdk.unit; import com.algorand.algosdk.crypto.Address; +import com.algorand.algosdk.unit.utils.QueryMapper; import com.algorand.algosdk.unit.utils.TestingUtils; import com.algorand.algosdk.v2.client.algod.*; import com.algorand.algosdk.v2.client.common.AlgodClient; @@ -63,4 +64,21 @@ public void getAssetByID(Long id) { public void getApplicationByID(Long id) { ps.q = algodClient.GetApplicationByID(id); } + + @When("we make an Account Application Information call against account {string} applicationID {int}") + public void accountApplicationInformation(String string, Integer int1) throws NoSuchAlgorithmException { + ps.q = algodClient.AccountApplicationInformation(new Address(string), (long)int1.intValue()); + } + + @When("we make an Account Asset Information call against account {string} assetID {int}") + public void accountAssetInformation(String string, Integer int1) throws NoSuchAlgorithmException { + ps.q = algodClient.AccountAssetInformation(new Address(string), (long)int1.intValue()); + } + + @When("we make an Account Information call against account {string} with exclude {string}") + public void accountInformation(String string, String string2) throws NoSuchAlgorithmException { + AccountInformation aiq = algodClient.AccountInformation(new Address(string)); + if (TestingUtils.notEmpty(string2)) aiq.exclude(QueryMapper.getExclude(string2)); + ps.q = aiq; + } } diff --git a/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java b/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java index a7620ce25..bdcec1fd9 100644 --- a/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java +++ b/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java @@ -7,12 +7,12 @@ import com.algorand.algosdk.v2.client.common.IndexerClient; import com.algorand.algosdk.v2.client.common.Utils; import com.algorand.algosdk.v2.client.indexer.*; -import io.cucumber.java.en.Then; -import io.cucumber.java.en.When; -import org.assertj.core.api.Assertions; +import com.algorand.algosdk.v2.client.model.Enums; +import io.cucumber.java.en.When; import java.security.NoSuchAlgorithmException; import java.text.ParseException; +import java.util.ArrayList; public class IndexerPaths { IndexerClient indexerClient = new IndexerClient("localhost", 1234, "");; @@ -25,13 +25,11 @@ public IndexerPaths(PathsShared ps) { @When("we make a Lookup Asset Balances call against asset index {long} " + "with limit {long} " + "afterAddress {string} " - + "round {long} " + "currencyGreaterThan {long} " + "currencyLessThan {long}") - public void lookupAssetBalances(Long assetId, Long limit, String afterAddress, Long round, Long currenGT, Long currencyLT) { + public void lookupAssetBalances(Long assetId, Long limit, String afterAddress, Long currenGT, Long currencyLT) { LookupAssetBalances q = indexerClient.lookupAssetBalances(assetId); if (TestingUtils.notEmpty(limit)) q.limit(limit); - if (TestingUtils.notEmpty(round)) q.round(round); if (TestingUtils.notEmpty(currenGT)) q.currencyGreaterThan(currenGT); if (TestingUtils.notEmpty(currencyLT)) q.currencyLessThan(currencyLT); ps.q = q; @@ -208,9 +206,9 @@ public void searchAccounts(Long assetId, Long limit, Long currencyGT, Long curre @When("we make a Search For Transactions call with account {string} NotePrefix {string} TxType {string} SigType {string} txid {string} round {long} minRound {long} maxRound {long} limit {long} beforeTime {string} afterTime {string} currencyGreaterThan {long} currencyLessThan {long} assetIndex {long} addressRole {string} ExcluseCloseTo {string} rekeyTo {string}") public void searchForTransactions(String address, String notePrefix, String txType, String sigType, - String txid, Long round, Long minRound, Long maxRound, Long limit, - String beforeTime, String afterTime, Long currencyGT, Long currencyLT, Long assetID, - String addressRole, String excludeCloseTo, String rekeyTo) throws ParseException, NoSuchAlgorithmException { + String txid, Long round, Long minRound, Long maxRound, Long limit, + String beforeTime, String afterTime, Long currencyGT, Long currencyLT, Long assetID, + String addressRole, String excludeCloseTo, String rekeyTo) throws ParseException, NoSuchAlgorithmException { SearchForTransactions q = this.indexerClient.searchForTransactions(); if (TestingUtils.notEmpty(address)) q.address(new Address(address)); @@ -256,4 +254,84 @@ public void lookupApplicationLogs(Long appID, Long limit, Long minRound, Long ma if (TestingUtils.notEmpty(txID)) q.txid(txID); ps.q = q; } + + @When("we make a LookupAccountAppLocalStates call with accountID {string} applicationID {int} includeAll {string} limit {int} next {string}") + public void lookupAccountAppLocalStates(String string, Integer int1, String string2, Integer int2, String string3) throws NoSuchAlgorithmException { + LookupAccountAppLocalStates q = this.indexerClient.lookupAccountAppLocalStates(new Address(string)); + if (string2.contentEquals("true")) q.includeAll(true); + if (TestingUtils.notEmpty((long)int1)) q.applicationId((long)int1); + if (TestingUtils.notEmpty((long)int2)) q.limit((long)int2); + if (TestingUtils.notEmpty(string3)) q.next(string3); + ps.q = q; + } + + @When("we make a LookupAccountAssets call with accountID {string} assetID {int} includeAll {string} limit {int} next {string}") + public void lookupAccountAssets(String string, Integer int1, String string2, Integer int2, String string3) throws NoSuchAlgorithmException { + LookupAccountAssets q = null; + q = this.indexerClient.lookupAccountAssets(new Address(string)); + if (TestingUtils.notEmpty((long)int1)) q.assetId((long)int1); + if (string2.contentEquals("true")) q.includeAll(true); + if (TestingUtils.notEmpty((long)int2)) q.limit((long)int2); + if (string3.compareTo("") != 0) + q.next(string3); + ps.q = q; + } + + @When("we make a Lookup Account by ID call against account {string} with exclude {string}") + public void lookupAccountByID(String string, String string2) throws NoSuchAlgorithmException { + LookupAccountByID q = null; + q = this.indexerClient.lookupAccountByID(new Address(string)); + + if (TestingUtils.notEmpty(string2)) { + ArrayList excludes = new ArrayList(); + for (String excld : string2.split(",")) { + excludes.add(QueryMapper.getExclude(excld)); + } + q.exclude(excludes); + } + ps.q = q; + } + + @When("we make a LookupAccountCreatedApplications call with accountID {string} applicationID {int} includeAll {string} limit {int} next {string}") + public void lookupAccountCreatedApplications(String string, Integer int1, String string2, Integer int2, String string3) throws NoSuchAlgorithmException { + LookupAccountCreatedApplications q = null; + q = this.indexerClient.lookupAccountCreatedApplications(new Address(string)); + if (TestingUtils.notEmpty((long)int1)) q.applicationId((long)int1); + if (string2.contentEquals("true")) q.includeAll(true); + if (TestingUtils.notEmpty((long)int2)) q.limit((long)int2); + if (TestingUtils.notEmpty(string3)) q.next(string3); + ps.q = q; + } + + @When("we make a LookupAccountCreatedAssets call with accountID {string} assetID {int} includeAll {string} limit {int} next {string}") + public void lookupAccountCreatedAssets(String string, Integer int1, String string2, Integer int2, String string3) throws NoSuchAlgorithmException { + LookupAccountCreatedAssets q = null; + q = this.indexerClient.lookupAccountCreatedAssets(new Address(string)); + if (TestingUtils.notEmpty((long)int1)) q.assetId((long)int1); + if (string2.contentEquals("true")) q.includeAll(true); + if (TestingUtils.notEmpty((long)int2)) q.limit((long)int2); + if (TestingUtils.notEmpty(string3)) q.next(string3); + ps.q = q; + } + + @When("we make a Search Accounts call with exclude {string}") + public void searchForAccounts(String string) { + SearchForAccounts q = this.indexerClient.searchForAccounts(); + if (TestingUtils.notEmpty(string)) { + ArrayList excludes = new ArrayList(); + for (String excld : string.split(",")) { + excludes.add(QueryMapper.getExclude(excld)); + } + q.exclude(excludes); + } + ps.q = q; + } + + @When("we make a SearchForApplications call with creator {string}") + public void searchForApplications(String string) { + SearchForApplications q = this.indexerClient.searchForApplications(); + if (TestingUtils.notEmpty(string)) q.creator(string); + ps.q = q; + } + } diff --git a/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java b/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java index 75f479ab5..adc7fb65a 100644 --- a/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java +++ b/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java @@ -19,6 +19,7 @@ public class ResponsesShared { public File bodyFile; + @SuppressWarnings("rawtypes") public Response response; public AlgodClient algod = new AlgodClient("localhost", 123, ""); @@ -90,6 +91,24 @@ public void we_make_any_call_to(String client, String endpoint) throws Exception case "lookupAssetTransactions": response = indexer.lookupAssetTransactions(10L).execute(); break; + case "lookupAccountAppLocalStates": + response = indexer.lookupAccountAppLocalStates(new Address()).execute(); + break; + case "lookupApplicationLogsByID": + response = indexer.lookupApplicationLogsByID(10L).execute(); + break; + case "lookupAccountCreatedApplications": + response = indexer.lookupAccountCreatedApplications(new Address()).execute(); + break; + case "lookupAccountAssets": + response = indexer.lookupAccountAssets(new Address()).execute(); + break; + case "lookupAccountCreatedAssets": + response = indexer.lookupAccountCreatedAssets(new Address()).execute(); + break; + case "lookupTransaction": + response = indexer.lookupTransaction("TXID").execute(); + break; case "searchForTransactions": case "any": // error case, everything uses the same error message response = indexer.searchForTransactions().execute(); @@ -141,6 +160,15 @@ public void we_make_any_call_to(String client, String endpoint) throws Exception case "Proof": response = algod.GetProof(0L, "").execute(); break; + case "AccountInformation": + response = algod.AccountInformation(new Address()).execute(); + break; + case "AccountApplicationInformation": + response = algod.AccountApplicationInformation(new Address(), 0L).execute(); + break; + case "AccountAssetInformation": + response = algod.AccountAssetInformation(new Address(), 0L).execute(); + break; default: Assertions.fail("Unsupported algod endpoint: " + endpoint); } diff --git a/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java b/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java index 19d06380a..15f18b1a1 100644 --- a/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java +++ b/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java @@ -1,7 +1,13 @@ +/* + * THIS FILE IS GENERATED BY QueryMapperGenerator!!!!!!!!!!!!!!!! + */ package com.algorand.algosdk.unit.utils; import java.security.NoSuchAlgorithmException; +import com.fasterxml.jackson.core.JsonProcessingException; import java.text.ParseException; +import java.util.ArrayList; + import com.algorand.algosdk.v2.client.common.Utils; import com.algorand.algosdk.crypto.Address; @@ -21,8 +27,22 @@ public static Query getClass(String name, IndexerClient client, String args[]) t return client.searchForAccounts(); case "lookupAccountByID": return client.lookupAccountByID(new Address(args[0])); + case "lookupAccountAssets": + return client.lookupAccountAssets(new Address(args[0])); + case "lookupAccountCreatedAssets": + return client.lookupAccountCreatedAssets(new Address(args[0])); + case "lookupAccountAppLocalStates": + return client.lookupAccountAppLocalStates(new Address(args[0])); + case "lookupAccountCreatedApplications": + return client.lookupAccountCreatedApplications(new Address(args[0])); case "lookupAccountTransactions": return client.lookupAccountTransactions(new Address(args[0])); + case "searchForApplications": + return client.searchForApplications(); + case "lookupApplicationByID": + return client.lookupApplicationByID(Long.valueOf(args[0])); + case "lookupApplicationLogsByID": + return client.lookupApplicationLogsByID(Long.valueOf(args[0])); case "searchForAssets": return client.searchForAssets(); case "lookupAssetByID": @@ -33,6 +53,8 @@ public static Query getClass(String name, IndexerClient client, String args[]) t return client.lookupAssetTransactions(Long.valueOf(args[0])); case "lookupBlock": return client.lookupBlock(Long.valueOf(args[0])); + case "lookupTransaction": + return client.lookupTransaction(args[0]); case "searchForTransactions": return client.searchForTransactions(); } @@ -45,14 +67,24 @@ public static Query getClass(String name, AlgodClient client, String args[]) thr return client.HealthCheck(); case "Metrics": return client.Metrics(); + case "GetGenesis": + return client.GetGenesis(); case "SwaggerJSON": return client.SwaggerJSON(); + case "GetVersion": + return client.GetVersion(); case "AccountInformation": return client.AccountInformation(new Address(args[0])); + case "AccountAssetInformation": + return client.AccountAssetInformation(new Address(args[0]), Long.valueOf(args[1])); + case "AccountApplicationInformation": + return client.AccountApplicationInformation(new Address(args[0]), Long.valueOf(args[1])); case "GetPendingTransactionsByAddress": return client.GetPendingTransactionsByAddress(new Address(args[0])); case "GetBlock": return client.GetBlock(Long.valueOf(args[0])); + case "GetProof": + return client.GetProof(Long.valueOf(args[0]), args[1]); case "GetSupply": return client.GetSupply(); case "GetStatus": @@ -67,11 +99,19 @@ public static Query getClass(String name, AlgodClient client, String args[]) thr return client.GetPendingTransactions(); case "PendingTransactionInformation": return client.PendingTransactionInformation(args[0]); + case "GetApplicationByID": + return client.GetApplicationByID(Long.valueOf(args[0])); + case "GetAssetByID": + return client.GetAssetByID(Long.valueOf(args[0])); + case "TealCompile": + return client.TealCompile(); + case "TealDryrun": + return client.TealDryrun(); } return null; } - public static void setValue(Query q, String className, String property, String value) throws ParseException, NoSuchAlgorithmException { + public static void setValue(Query q, String className, String property, String value) throws ParseException, NoSuchAlgorithmException, JsonProcessingException { switch (className) { case "makeHealthCheck": switch (property) { @@ -79,15 +119,31 @@ public static void setValue(Query q, String className, String property, String v break; case "searchForAccounts": switch (property) { + case "application-id": + ((SearchForAccounts)q).applicationId(Long.valueOf(value)); + break; case "asset-id": ((SearchForAccounts)q).assetId(Long.valueOf(value)); break; + case "auth-addr": + ((SearchForAccounts)q).authAddr(new Address(value)); + break; case "currency-greater-than": ((SearchForAccounts)q).currencyGreaterThan(Long.valueOf(value)); break; case "currency-less-than": ((SearchForAccounts)q).currencyLessThan(Long.valueOf(value)); break; + case "exclude": + ArrayList vals = new ArrayList(); + for (String t : value.split(",")) { + vals.add(getExclude(t)); + } + ((SearchForAccounts)q).exclude(vals); + break; + case "include-all": + ((SearchForAccounts)q).includeAll(Boolean.valueOf(value)); + break; case "limit": ((SearchForAccounts)q).limit(Long.valueOf(value)); break; @@ -101,11 +157,85 @@ public static void setValue(Query q, String className, String property, String v break; case "lookupAccountByID": switch (property) { + case "exclude": + ArrayList vals = new ArrayList(); + for (String t : value.split(",")) { + vals.add(getExclude(t)); + } + ((SearchForAccounts)q).exclude(vals); + break; + case "include-all": + ((LookupAccountByID)q).includeAll(Boolean.valueOf(value)); + break; case "round": ((LookupAccountByID)q).round(Long.valueOf(value)); break; } break; + case "lookupAccountAssets": + switch (property) { + case "asset-id": + ((LookupAccountAssets)q).assetId(Long.valueOf(value)); + break; + case "include-all": + ((LookupAccountAssets)q).includeAll(Boolean.valueOf(value)); + break; + case "limit": + ((LookupAccountAssets)q).limit(Long.valueOf(value)); + break; + case "next": + ((LookupAccountAssets)q).next(value); + break; + } + break; + case "lookupAccountCreatedAssets": + switch (property) { + case "asset-id": + ((LookupAccountCreatedAssets)q).assetId(Long.valueOf(value)); + break; + case "include-all": + ((LookupAccountCreatedAssets)q).includeAll(Boolean.valueOf(value)); + break; + case "limit": + ((LookupAccountCreatedAssets)q).limit(Long.valueOf(value)); + break; + case "next": + ((LookupAccountCreatedAssets)q).next(value); + break; + } + break; + case "lookupAccountAppLocalStates": + switch (property) { + case "application-id": + ((LookupAccountAppLocalStates)q).applicationId(Long.valueOf(value)); + break; + case "include-all": + ((LookupAccountAppLocalStates)q).includeAll(Boolean.valueOf(value)); + break; + case "limit": + ((LookupAccountAppLocalStates)q).limit(Long.valueOf(value)); + break; + case "next": + ((LookupAccountAppLocalStates)q).next(value); + break; + } + break; + case "lookupAccountCreatedApplications": + switch (property) { + case "application-id": + ((LookupAccountCreatedApplications)q).applicationId(Long.valueOf(value)); + break; + case "include-all": + ((LookupAccountCreatedApplications)q).includeAll(Boolean.valueOf(value)); + break; + case "limit": + ((LookupAccountCreatedApplications)q).limit(Long.valueOf(value)); + break; + case "next": + ((LookupAccountCreatedApplications)q).next(value); + break; + } + break; case "lookupAccountTransactions": switch (property) { case "after-time": @@ -138,6 +268,9 @@ public static void setValue(Query q, String className, String property, String v case "note-prefix": ((LookupAccountTransactions)q).notePrefix(Encoder.decodeFromBase64(value)); break; + case "rekey-to": + ((LookupAccountTransactions)q).rekeyTo(Boolean.valueOf(value)); + break; case "round": ((LookupAccountTransactions)q).round(Long.valueOf(value)); break; @@ -152,6 +285,54 @@ public static void setValue(Query q, String className, String property, String v break; } break; + case "searchForApplications": + switch (property) { + case "application-id": + ((SearchForApplications)q).applicationId(Long.valueOf(value)); + break; + case "creator": + ((SearchForApplications)q).creator(value); + break; + case "include-all": + ((SearchForApplications)q).includeAll(Boolean.valueOf(value)); + break; + case "limit": + ((SearchForApplications)q).limit(Long.valueOf(value)); + break; + case "next": + ((SearchForApplications)q).next(value); + break; + } + break; + case "lookupApplicationByID": + switch (property) { + case "include-all": + ((LookupApplicationByID)q).includeAll(Boolean.valueOf(value)); + break; + } + break; + case "lookupApplicationLogsByID": + switch (property) { + case "limit": + ((LookupApplicationLogsByID)q).limit(Long.valueOf(value)); + break; + case "max-round": + ((LookupApplicationLogsByID)q).maxRound(Long.valueOf(value)); + break; + case "min-round": + ((LookupApplicationLogsByID)q).minRound(Long.valueOf(value)); + break; + case "next": + ((LookupApplicationLogsByID)q).next(value); + break; + case "sender-address": + ((LookupApplicationLogsByID)q).senderAddress(new Address(value)); + break; + case "txid": + ((LookupApplicationLogsByID)q).txid(value); + break; + } + break; case "searchForAssets": switch (property) { case "asset-id": @@ -160,6 +341,9 @@ public static void setValue(Query q, String className, String property, String v case "creator": ((SearchForAssets)q).creator(value); break; + case "include-all": + ((SearchForAssets)q).includeAll(Boolean.valueOf(value)); + break; case "limit": ((SearchForAssets)q).limit(Long.valueOf(value)); break; @@ -176,6 +360,9 @@ public static void setValue(Query q, String className, String property, String v break; case "lookupAssetByID": switch (property) { + case "include-all": + ((LookupAssetByID)q).includeAll(Boolean.valueOf(value)); + break; } break; case "lookupAssetBalances": @@ -186,15 +373,15 @@ public static void setValue(Query q, String className, String property, String v case "currency-less-than": ((LookupAssetBalances)q).currencyLessThan(Long.valueOf(value)); break; + case "include-all": + ((LookupAssetBalances)q).includeAll(Boolean.valueOf(value)); + break; case "limit": ((LookupAssetBalances)q).limit(Long.valueOf(value)); break; case "next": ((LookupAssetBalances)q).next(value); break; - case "round": - ((LookupAssetBalances)q).round(Long.valueOf(value)); - break; } break; case "lookupAssetTransactions": @@ -235,6 +422,9 @@ public static void setValue(Query q, String className, String property, String v case "note-prefix": ((LookupAssetTransactions)q).notePrefix(Encoder.decodeFromBase64(value)); break; + case "rekey-to": + ((LookupAssetTransactions)q).rekeyTo(Boolean.valueOf(value)); + break; case "round": ((LookupAssetTransactions)q).round(Long.valueOf(value)); break; @@ -253,6 +443,10 @@ public static void setValue(Query q, String className, String property, String v switch (property) { } break; + case "lookupTransaction": + switch (property) { + } + break; case "searchForTransactions": switch (property) { case "address": @@ -264,6 +458,9 @@ public static void setValue(Query q, String className, String property, String v case "after-time": ((SearchForTransactions)q).afterTime(Utils.parseDate(value)); break; + case "application-id": + ((SearchForTransactions)q).applicationId(Long.valueOf(value)); + break; case "asset-id": ((SearchForTransactions)q).assetId(Long.valueOf(value)); break; @@ -294,6 +491,9 @@ public static void setValue(Query q, String className, String property, String v case "note-prefix": ((SearchForTransactions)q).notePrefix(Encoder.decodeFromBase64(value)); break; + case "rekey-to": + ((SearchForTransactions)q).rekeyTo(Boolean.valueOf(value)); + break; case "round": ((SearchForTransactions)q).round(Long.valueOf(value)); break; @@ -316,11 +516,30 @@ public static void setValue(Query q, String className, String property, String v switch (property) { } break; + case "GetGenesis": + switch (property) { + } + break; case "SwaggerJSON": switch (property) { } break; + case "GetVersion": + switch (property) { + } + break; case "AccountInformation": + switch (property) { + case "exclude": + ((AccountInformation)q).exclude(getExclude(value)); + break; + } + break; + case "AccountAssetInformation": + switch (property) { + } + break; + case "AccountApplicationInformation": switch (property) { } break; @@ -335,6 +554,10 @@ public static void setValue(Query q, String className, String property, String v switch (property) { } break; + case "GetProof": + switch (property) { + } + break; case "GetSupply": switch (property) { } @@ -369,6 +592,28 @@ public static void setValue(Query q, String className, String property, String v switch (property) { } break; + case "GetApplicationByID": + switch (property) { + } + break; + case "GetAssetByID": + switch (property) { + } + break; + case "TealCompile": + switch (property) { + case "source": + ((TealCompile)q).source(Encoder.decodeFromBase64(value)); + break; + } + break; + case "TealDryrun": + switch (property) { + case "request": + ((TealDryrun)q).request(null); + break; + } + break; } } @@ -417,8 +662,28 @@ public static Enums.TxType getTxType(String val) { return Enums.TxType.AXFER; case "AFRZ": return Enums.TxType.AFRZ; + case "APPL": + return Enums.TxType.APPL; + default: + throw new RuntimeException("Enum value not recognized: " + val +"!"); + } + } + public static Enums.Exclude getExclude(String val) { + switch(val.toUpperCase().replaceAll("-", "")) { + case "ALL": + return Enums.Exclude.ALL; + case "ASSETS": + return Enums.Exclude.ASSETS; + case "CREATEDASSETS": + return Enums.Exclude.CREATEDASSETS; + case "APPSLOCALSTATE": + return Enums.Exclude.APPSLOCALSTATE; + case "CREATEDAPPS": + return Enums.Exclude.CREATEDAPPS; + case "NONE": + return Enums.Exclude.NONE; default: throw new RuntimeException("Enum value not recognized: " + val +"!"); } } -} +} \ No newline at end of file