From 893c47a2b0f477953586c315e94d7702d92324a7 Mon Sep 17 00:00:00 2001 From: Hang Su <87964331+ahangsu@users.noreply.github.com> Date: Tue, 13 Dec 2022 17:49:03 -0500 Subject: [PATCH 1/4] Enhancement: Sourcemap `mapping` field deprecation (#441) --- src/test/java/com/algorand/algosdk/integration/Stepdefs.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/algorand/algosdk/integration/Stepdefs.java b/src/test/java/com/algorand/algosdk/integration/Stepdefs.java index 2af3ba244..2f7aa8c9d 100644 --- a/src/test/java/com/algorand/algosdk/integration/Stepdefs.java +++ b/src/test/java/com/algorand/algosdk/integration/Stepdefs.java @@ -1171,12 +1171,14 @@ public void i_compile_a_teal_program_with_mapping_enabled(String tealPath) throw @Then("the resulting source map is the same as the json {string}") public void the_resulting_source_map_is_the_same_as_the_json(String jsonPath) throws Exception { - String[] fields = {"version", "sources", "names", "mapping", "mappings"}; + String[] fields = {"version", "sources", "names", "mappings"}; String srcMapStr = new String(ResourceUtils.readResource(jsonPath), StandardCharsets.UTF_8); HashMap expectedMap = new HashMap<>(Encoder.decodeFromJson(srcMapStr, Map.class)); HashMap actualMap = this.compileResponse.body().sourcemap; + assertThat(expectedMap.size()).isEqualTo(actualMap.size()); + for(String field: fields){ assertThat(actualMap.get(field)).isEqualTo(expectedMap.get(field)); } From 8b5e8cff19904c360d7ea8f4bc405d8c7a7c21f4 Mon Sep 17 00:00:00 2001 From: Hang Su <87964331+ahangsu@users.noreply.github.com> Date: Tue, 13 Dec 2022 22:18:14 -0500 Subject: [PATCH 2/4] Enhancement: Remove v1 algod endpoint (#443) --- .../algosdk/algod/client/AlgodClient.java | 5 - .../algosdk/algod/client/ApiCallback.java | 64 - .../algosdk/algod/client/ApiClient.java | 1207 --------- .../algosdk/algod/client/ApiException.java | 91 - .../algosdk/algod/client/ApiResponse.java | 61 - .../algosdk/algod/client/Configuration.java | 39 - .../algod/client/GzipRequestInterceptor.java | 82 - .../algorand/algosdk/algod/client/JSON.java | 387 --- .../algod/client/ProgressRequestBody.java | 78 - .../algod/client/ProgressResponseBody.java | 77 - .../algosdk/algod/client/StringUtil.java | 55 - .../algosdk/algod/client/api/AlgodApi.java | 21 - .../algosdk/algod/client/api/DefaultApi.java | 2213 ----------------- .../algosdk/algod/client/auth/ApiKeyAuth.java | 75 - .../algod/client/auth/Authentication.java | 30 - .../algod/client/auth/HttpBasicAuth.java | 52 - .../algosdk/algod/client/auth/OAuth.java | 39 - .../algosdk/algod/client/auth/OAuthFlow.java | 19 - .../algosdk/algod/client/lib/Pair.java | 52 - .../algosdk/algod/client/model/Account.java | 300 --- .../algod/client/model/AssetHolding.java | 58 - .../algod/client/model/AssetParams.java | 340 --- .../algosdk/algod/client/model/Block.java | 503 ---- .../algod/client/model/NodeStatus.java | 227 -- .../algod/client/model/Participation.java | 186 -- .../client/model/PaymentTransactionType.java | 204 -- .../client/model/PendingTransactions.java | 112 - .../algosdk/algod/client/model/Supply.java | 135 - .../algod/client/model/Transaction.java | 390 --- .../algod/client/model/TransactionFee.java | 89 - .../algod/client/model/TransactionID.java | 89 - .../algod/client/model/TransactionList.java | 97 - .../algod/client/model/TransactionParams.java | 181 -- .../client/model/TransactionResults.java | 94 - .../algosdk/algod/client/model/Version.java | 143 -- .../TransactionParametersBuilder.java | 41 +- .../algosdk/transaction/MethodCallParams.java | 147 -- .../algorand/algosdk/util/TestEncoder.java | 1 - 38 files changed, 1 insertion(+), 7983 deletions(-) delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/AlgodClient.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/ApiCallback.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/ApiClient.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/ApiException.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/ApiResponse.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/Configuration.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/GzipRequestInterceptor.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/JSON.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/ProgressRequestBody.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/ProgressResponseBody.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/StringUtil.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/api/AlgodApi.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/api/DefaultApi.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/auth/ApiKeyAuth.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/auth/Authentication.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/auth/HttpBasicAuth.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/auth/OAuth.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/auth/OAuthFlow.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/lib/Pair.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/Account.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/AssetHolding.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/AssetParams.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/Block.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/NodeStatus.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/Participation.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/PaymentTransactionType.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/PendingTransactions.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/Supply.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/Transaction.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/TransactionFee.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/TransactionID.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/TransactionList.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/TransactionParams.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/TransactionResults.java delete mode 100644 src/main/java/com/algorand/algosdk/algod/client/model/Version.java diff --git a/src/main/java/com/algorand/algosdk/algod/client/AlgodClient.java b/src/main/java/com/algorand/algosdk/algod/client/AlgodClient.java deleted file mode 100644 index 7a9864ff1..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/AlgodClient.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.algorand.algosdk.algod.client; - -@Deprecated -public class AlgodClient extends ApiClient { -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/ApiCallback.java b/src/main/java/com/algorand/algosdk/algod/client/ApiCallback.java deleted file mode 100644 index 2c9ca7ec8..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/ApiCallback.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import java.io.IOException; - -import java.util.Map; -import java.util.List; - -/** - * Callback for asynchronous API call. - * - * @param The return type - * @deprecated Use the equivalent in v2 algod client - */ -@Deprecated -public interface ApiCallback { - /** - * This is called when the API call fails. - * - * @param e The exception causing the failure - * @param statusCode Status code of the response if available, otherwise it would be 0 - * @param responseHeaders Headers of the response if available, otherwise it would be null - */ - void onFailure(ApiException e, int statusCode, Map> responseHeaders); - - /** - * This is called when the API call succeeded. - * - * @param result The result deserialized from response - * @param statusCode Status code of the response - * @param responseHeaders Headers of the response - */ - void onSuccess(T result, int statusCode, Map> responseHeaders); - - /** - * This is called when the API upload processing. - * - * @param bytesWritten bytes Written - * @param contentLength content length of request body - * @param done write end - */ - void onUploadProgress(long bytesWritten, long contentLength, boolean done); - - /** - * This is called when the API downlond processing. - * - * @param bytesRead bytes Read - * @param contentLength content lenngth of the response - * @param done Read end - */ - void onDownloadProgress(long bytesRead, long contentLength, boolean done); -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/ApiClient.java b/src/main/java/com/algorand/algosdk/algod/client/ApiClient.java deleted file mode 100644 index da2cf99b9..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/ApiClient.java +++ /dev/null @@ -1,1207 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import com.algorand.algosdk.algod.client.auth.ApiKeyAuth; -import com.algorand.algosdk.algod.client.auth.Authentication; -import com.algorand.algosdk.algod.client.auth.HttpBasicAuth; -import com.algorand.algosdk.algod.client.auth.OAuth; -import com.algorand.algosdk.algod.client.lib.Pair; -import com.squareup.okhttp.*; -import com.squareup.okhttp.internal.http.HttpMethod; -import com.squareup.okhttp.logging.HttpLoggingInterceptor; -import com.squareup.okhttp.logging.HttpLoggingInterceptor.Level; -import okio.BufferedSink; -import okio.Okio; -import org.threeten.bp.LocalDate; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.format.DateTimeFormatter; - -import javax.net.ssl.*; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Type; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.security.GeneralSecurityException; -import java.security.KeyStore; -import java.security.SecureRandom; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.text.DateFormat; -import java.util.*; -import java.util.Map.Entry; -import java.util.concurrent.TimeUnit; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@Deprecated -public class ApiClient { - - private String basePath = "http://localhost"; - private boolean debugging = false; - private Map defaultHeaderMap = new HashMap(); - private String tempFolderPath = null; - - private Map authentications; - - private DateFormat dateFormat; - private DateFormat datetimeFormat; - private boolean lenientDatetimeFormat; - private int dateLength; - - private InputStream sslCaCert; - private boolean verifyingSsl; - private KeyManager[] keyManagers; - - private OkHttpClient httpClient; - private JSON json; - - private HttpLoggingInterceptor loggingInterceptor; - - /* - * Constructor for ApiClient - */ - public ApiClient() { - httpClient = new OkHttpClient(); - - - verifyingSsl = true; - - json = new JSON(); - - // Set default User-Agent. - setUserAgent("Swagger-Codegen/1.0.0/java"); - - // Setup authentications (key: authentication name, value: authentication). - authentications = new HashMap(); - authentications.put("api_key", new ApiKeyAuth("header", "X-Algo-API-Token")); - // Prevent the authentications from being modified. - authentications = Collections.unmodifiableMap(authentications); - } - - /** - * Get base path - * - * @return Baes path - */ - public String getBasePath() { - return basePath; - } - - /** - * Set base path - * - * @param basePath Base path of the URL (e.g http://localhost - * @return An instance of OkHttpClient - */ - public ApiClient setBasePath(String basePath) { - this.basePath = basePath; - return this; - } - - /** - * Get HTTP client - * - * @return An instance of OkHttpClient - */ - public OkHttpClient getHttpClient() { - return httpClient; - } - - /** - * Set HTTP client - * - * @param httpClient An instance of OkHttpClient - * @return Api Client - */ - public ApiClient setHttpClient(OkHttpClient httpClient) { - this.httpClient = httpClient; - return this; - } - - /** - * Get JSON - * - * @return JSON object - */ - public JSON getJSON() { - return json; - } - - /** - * Set JSON - * - * @param json JSON object - * @return Api client - */ - public ApiClient setJSON(JSON json) { - this.json = json; - return this; - } - - /** - * True if isVerifyingSsl flag is on - * - * @return True if isVerifySsl flag is on - */ - public boolean isVerifyingSsl() { - return verifyingSsl; - } - - /** - * Configure whether to verify certificate and hostname when making https requests. - * Default to true. - * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. - * - * @param verifyingSsl True to verify TLS/SSL connection - * @return ApiClient - */ - public ApiClient setVerifyingSsl(boolean verifyingSsl) { - this.verifyingSsl = verifyingSsl; - applySslSettings(); - return this; - } - - /** - * Get SSL CA cert. - * - * @return Input stream to the SSL CA cert - */ - public InputStream getSslCaCert() { - return sslCaCert; - } - - /** - * Configure the CA certificate to be trusted when making https requests. - * Use null to reset to default. - * - * @param sslCaCert input stream for SSL CA cert - * @return ApiClient - */ - public ApiClient setSslCaCert(InputStream sslCaCert) { - this.sslCaCert = sslCaCert; - applySslSettings(); - return this; - } - - public KeyManager[] getKeyManagers() { - return keyManagers; - } - - /** - * Configure client keys to use for authorization in an SSL session. - * Use null to reset to default. - * - * @param managers The KeyManagers to use - * @return ApiClient - */ - public ApiClient setKeyManagers(KeyManager[] managers) { - this.keyManagers = managers; - applySslSettings(); - return this; - } - - public DateFormat getDateFormat() { - return dateFormat; - } - - public ApiClient setDateFormat(DateFormat dateFormat) { - this.json.setDateFormat(dateFormat); - return this; - } - - public ApiClient setSqlDateFormat(DateFormat dateFormat) { - this.json.setSqlDateFormat(dateFormat); - return this; - } - - public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - this.json.setOffsetDateTimeFormat(dateFormat); - return this; - } - - public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { - this.json.setLocalDateFormat(dateFormat); - return this; - } - - public ApiClient setLenientOnJson(boolean lenientOnJson) { - this.json.setLenientOnJson(lenientOnJson); - return this; - } - - /** - * Get authentications (key: authentication name, value: authentication). - * - * @return Map of authentication objects - */ - public Map getAuthentications() { - return authentications; - } - - /** - * Get authentication for the given name. - * - * @param authName The authentication name - * @return The authentication, null if not found - */ - public Authentication getAuthentication(String authName) { - return authentications.get(authName); - } - - /** - * Helper method to set username for the first HTTP basic authentication. - * - * @param username Username - */ - public void setUsername(String username) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setUsername(username); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set password for the first HTTP basic authentication. - * - * @param password Password - */ - public void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set API key value for the first API key authentication. - * - * @param apiKey API key - */ - public void setApiKey(String apiKey) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKey(apiKey); - return; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set API key prefix for the first API key authentication. - * - * @param apiKeyPrefix API key prefix - */ - public void setApiKeyPrefix(String apiKeyPrefix) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); - return; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set access token for the first OAuth2 authentication. - * - * @param accessToken Access token - */ - public void setAccessToken(String accessToken) { - for (Authentication auth : authentications.values()) { - if (auth instanceof OAuth) { - ((OAuth) auth).setAccessToken(accessToken); - return; - } - } - throw new RuntimeException("No OAuth2 authentication configured!"); - } - - /** - * Set the User-Agent header's value (by adding to the default header map). - * - * @param userAgent HTTP request's user agent - * @return ApiClient - */ - public ApiClient setUserAgent(String userAgent) { - addDefaultHeader("User-Agent", userAgent); - return this; - } - - /** - * Add a default header. - * - * @param key The header's key - * @param value The header's value - * @return ApiClient - */ - public ApiClient addDefaultHeader(String key, String value) { - defaultHeaderMap.put(key, value); - return this; - } - - /** - * Check that whether debugging is enabled for this API client. - * - * @return True if debugging is enabled, false otherwise. - */ - public boolean isDebugging() { - return debugging; - } - - /** - * Enable/disable debugging for this API client. - * - * @param debugging To enable (true) or disable (false) debugging - * @return ApiClient - */ - public ApiClient setDebugging(boolean debugging) { - if (debugging != this.debugging) { - if (debugging) { - loggingInterceptor = new HttpLoggingInterceptor(); - loggingInterceptor.setLevel(Level.BODY); - httpClient.interceptors().add(loggingInterceptor); - } else { - httpClient.interceptors().remove(loggingInterceptor); - loggingInterceptor = null; - } - } - this.debugging = debugging; - return this; - } - - /** - * The path of temporary folder used to store downloaded files from endpoints - * with file response. The default value is null, i.e. using - * the system's default tempopary folder. - * - * @see createTempFile - * @return Temporary folder path - */ - public String getTempFolderPath() { - return tempFolderPath; - } - - /** - * Set the temporary folder path (for downloading files) - * - * @param tempFolderPath Temporary folder path - * @return ApiClient - */ - public ApiClient setTempFolderPath(String tempFolderPath) { - this.tempFolderPath = tempFolderPath; - return this; - } - - /** - * Get connection timeout (in milliseconds). - * - * @return Timeout in milliseconds - */ - public int getConnectTimeout() { - return httpClient.getConnectTimeout(); - } - - /** - * Sets the connect timeout (in milliseconds). - * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link Integer#MAX_VALUE}. - * - * @param connectionTimeout connection timeout in milliseconds - * @return Api client - */ - public ApiClient setConnectTimeout(int connectionTimeout) { - httpClient.setConnectTimeout(connectionTimeout, TimeUnit.MILLISECONDS); - return this; - } - - /** - * Get read timeout (in milliseconds). - * - * @return Timeout in milliseconds - */ - public int getReadTimeout() { - return httpClient.getReadTimeout(); - } - - /** - * Sets the read timeout (in milliseconds). - * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link Integer#MAX_VALUE}. - * - * @param readTimeout read timeout in milliseconds - * @return Api client - */ - public ApiClient setReadTimeout(int readTimeout) { - httpClient.setReadTimeout(readTimeout, TimeUnit.MILLISECONDS); - return this; - } - - /** - * Get write timeout (in milliseconds). - * - * @return Timeout in milliseconds - */ - public int getWriteTimeout() { - return httpClient.getWriteTimeout(); - } - - /** - * Sets the write timeout (in milliseconds). - * A value of 0 means no timeout, otherwise values must be between 1 and - * {@link Integer#MAX_VALUE}. - * - * @param writeTimeout connection timeout in milliseconds - * @return Api client - */ - public ApiClient setWriteTimeout(int writeTimeout) { - httpClient.setWriteTimeout(writeTimeout, TimeUnit.MILLISECONDS); - return this; - } - - /** - * Format the given parameter object into string. - * - * @param param Parameter - * @return String representation of the parameter - */ - public String parameterToString(Object param) { - if (param == null) { - return ""; - } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { - //Serialize to json string and remove the " enclosing characters - String jsonStr = json.serialize(param); - return jsonStr.substring(1, jsonStr.length() - 1); - } else if (param instanceof Collection) { - StringBuilder b = new StringBuilder(); - for (Object o : (Collection)param) { - if (b.length() > 0) { - b.append(","); - } - b.append(String.valueOf(o)); - } - return b.toString(); - } else { - return String.valueOf(param); - } - } - - /** - * Formats the specified query parameter to a list containing a single {@code Pair} object. - * - * Note that {@code value} must not be a collection. - * - * @param name The name of the parameter. - * @param value The value of the parameter. - * @return A list containing a single {@code Pair} object. - */ - public List parameterToPair(String name, Object value) { - List params = new ArrayList(); - - // preconditions - if (name == null || name.isEmpty() || value == null || value instanceof Collection) return params; - - params.add(new Pair(name, parameterToString(value))); - return params; - } - - /** - * Formats the specified collection query parameters to a list of {@code Pair} objects. - * - * Note that the values of each of the returned Pair objects are percent-encoded. - * - * @param collectionFormat The collection format of the parameter. - * @param name The name of the parameter. - * @param value The value of the parameter. - * @return A list of {@code Pair} objects. - */ - public List parameterToPairs(String collectionFormat, String name, Collection value) { - List params = new ArrayList(); - - // preconditions - if (name == null || name.isEmpty() || value == null || value.isEmpty()) { - return params; - } - - // create the params based on the collection format - if ("multi".equals(collectionFormat)) { - for (Object item : value) { - params.add(new Pair(name, escapeString(parameterToString(item)))); - } - return params; - } - - // collectionFormat is assumed to be "csv" by default - String delimiter = ","; - - // escape all delimiters except commas, which are URI reserved - // characters - if ("ssv".equals(collectionFormat)) { - delimiter = escapeString(" "); - } else if ("tsv".equals(collectionFormat)) { - delimiter = escapeString("\t"); - } else if ("pipes".equals(collectionFormat)) { - delimiter = escapeString("|"); - } - - StringBuilder sb = new StringBuilder() ; - for (Object item : value) { - sb.append(delimiter); - sb.append(escapeString(parameterToString(item))); - } - - params.add(new Pair(name, sb.substring(delimiter.length()))); - - return params; - } - - /** - * Sanitize filename by removing path. - * e.g. ../../sun.gif becomes sun.gif - * - * @param filename The filename to be sanitized - * @return The sanitized filename - */ - public String sanitizeFilename(String filename) { - return filename.replaceAll(".*[/\\\\]", ""); - } - - /** - * Check if the given MIME is a JSON MIME. - * JSON MIME examples: - * application/json - * application/json; charset=UTF8 - * APPLICATION/JSON - * application/vnd.company+json - * "* / *" is also default to JSON - * @param mime MIME (Multipurpose Internet Mail Extensions) - * @return True if the given MIME is JSON, false otherwise. - */ - public boolean isJsonMime(String mime) { - String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; - return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); - } - - /** - * Select the Accept header's value from the given accepts array: - * if JSON exists in the given array, use it; - * otherwise use all of them (joining into a string) - * - * @param accepts The accepts array to select from - * @return The Accept header to use. If the given array is empty, - * null will be returned (not to set the Accept header explicitly). - */ - public String selectHeaderAccept(String[] accepts) { - if (accepts.length == 0) { - return null; - } - for (String accept : accepts) { - if (isJsonMime(accept)) { - return accept; - } - } - return StringUtil.join(accepts, ","); - } - - /** - * Select the Content-Type header's value from the given array: - * if JSON exists in the given array, use it; - * otherwise use the first one of the array. - * - * @param contentTypes The Content-Type array to select from - * @return The Content-Type header to use. If the given array is empty, - * or matches "any", JSON will be used. - */ - public String selectHeaderContentType(String[] contentTypes) { - if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) { - return "application/json"; - } - for (String contentType : contentTypes) { - if (isJsonMime(contentType)) { - return contentType; - } - } - return contentTypes[0]; - } - - /** - * Escape the given string to be used as URL query value. - * - * @param str String to be escaped - * @return Escaped string - */ - public String escapeString(String str) { - try { - return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); - } catch (UnsupportedEncodingException e) { - return str; - } - } - - /** - * Deserialize response body to Java object, according to the return type and - * the Content-Type response header. - * - * @param Type - * @param response HTTP response - * @param returnType The type of the Java object - * @return The deserialized Java object - * @throws ApiException If fail to deserialize response body, i.e. cannot read response body - * or the Content-Type of the response is not supported. - */ - @SuppressWarnings("unchecked") - public T deserialize(Response response, Type returnType) throws ApiException { - if (response == null || returnType == null) { - return null; - } - - if ("byte[]".equals(returnType.toString())) { - // Handle binary response (byte array). - try { - return (T) response.body().bytes(); - } catch (IOException e) { - throw new ApiException(e); - } - } else if (returnType.equals(File.class)) { - // Handle file downloading. - return (T) downloadFileFromResponse(response); - } - - String respBody; - try { - if (response.body() != null) - respBody = response.body().string(); - else - respBody = null; - } catch (IOException e) { - throw new ApiException(e); - } - - if (respBody == null || "".equals(respBody)) { - return null; - } - - String contentType = response.headers().get("Content-Type"); - if (contentType == null) { - // ensuring a default content type - contentType = "application/json"; - } - if (isJsonMime(contentType)) { - return json.deserialize(respBody, returnType); - } else if (returnType.equals(String.class)) { - // Expecting string, return the raw response body. - return (T) respBody; - } else { - throw new ApiException( - "Content type \"" + contentType + "\" is not supported for type: " + returnType, - response.code(), - response.headers().toMultimap(), - respBody); - } - } - - /** - * Serialize the given Java object into request body according to the object's - * class and the request Content-Type. - * - * @param obj The Java object - * @param contentType The request Content-Type - * @return The serialized request body - * @throws ApiException If fail to serialize the given object - */ - public RequestBody serialize(Object obj, String contentType) throws ApiException { - if (obj instanceof byte[]) { - // Binary (byte array) body parameter support. - return RequestBody.create(MediaType.parse(contentType), (byte[]) obj); - } else if (obj instanceof File) { - // File body parameter support. - return RequestBody.create(MediaType.parse(contentType), (File) obj); - } else if (isJsonMime(contentType)) { - String content; - if (obj != null) { - content = json.serialize(obj); - } else { - content = null; - } - return RequestBody.create(MediaType.parse(contentType), content); - } else { - throw new ApiException("Content type \"" + contentType + "\" is not supported"); - } - } - - /** - * Download file from the given response. - * - * @param response An instance of the Response object - * @throws ApiException If fail to read file content from response and write to disk - * @return Downloaded file - */ - public File downloadFileFromResponse(Response response) throws ApiException { - try { - File file = prepareDownloadFile(response); - BufferedSink sink = Okio.buffer(Okio.sink(file)); - sink.writeAll(response.body().source()); - sink.close(); - return file; - } catch (IOException e) { - throw new ApiException(e); - } - } - - /** - * Prepare file for download - * - * @param response An instance of the Response object - * @throws IOException If fail to prepare file for download - * @return Prepared file for the download - */ - public File prepareDownloadFile(Response response) throws IOException { - String filename = null; - String contentDisposition = response.header("Content-Disposition"); - if (contentDisposition != null && !"".equals(contentDisposition)) { - // Get filename from the Content-Disposition header. - Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); - Matcher matcher = pattern.matcher(contentDisposition); - if (matcher.find()) { - filename = sanitizeFilename(matcher.group(1)); - } - } - - String prefix = null; - String suffix = null; - if (filename == null) { - prefix = "download-"; - suffix = ""; - } else { - int pos = filename.lastIndexOf("."); - if (pos == -1) { - prefix = filename + "-"; - } else { - prefix = filename.substring(0, pos) + "-"; - suffix = filename.substring(pos); - } - // File.createTempFile requires the prefix to be at least three characters long - if (prefix.length() < 3) - prefix = "download-"; - } - - if (tempFolderPath == null) - return File.createTempFile(prefix, suffix); - else - return File.createTempFile(prefix, suffix, new File(tempFolderPath)); - } - - /** - * {@link #execute(Call, Type)} - * - * @param Type - * @param call An instance of the Call object - * @throws ApiException If fail to execute the call - * @return ApiResponse<T> - */ - public ApiResponse execute(Call call) throws ApiException { - return execute(call, null); - } - - /** - * Execute HTTP call and deserialize the HTTP response body into the given return type. - * - * @param returnType The return type used to deserialize HTTP response body - * @param The return type corresponding to (same with) returnType - * @param call Call - * @return ApiResponse object containing response status, headers and - * data, which is a Java object deserialized from response body and would be null - * when returnType is null. - * @throws ApiException If fail to execute the call - */ - public ApiResponse execute(Call call, Type returnType) throws ApiException { - try { - Response response = call.execute(); - T data = handleResponse(response, returnType); - return new ApiResponse(response.code(), response.headers().toMultimap(), data); - } catch (IOException e) { - throw new ApiException(e); - } - } - - /** - * {@link #executeAsync(Call, Type, ApiCallback)} - * - * @param Type - * @param call An instance of the Call object - * @param callback ApiCallback<T> - */ - public void executeAsync(Call call, ApiCallback callback) { - executeAsync(call, null, callback); - } - - /** - * Execute HTTP call asynchronously. - * - * @see #execute(Call, Type) - * @param Type - * @param call The callback to be executed when the API call finishes - * @param returnType Return type - * @param callback ApiCallback - */ - @SuppressWarnings("unchecked") - public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { - call.enqueue(new Callback() { - @Override - public void onFailure(Request request, IOException e) { - callback.onFailure(new ApiException(e), 0, null); - } - - @Override - public void onResponse(Response response) throws IOException { - T result; - try { - result = (T) handleResponse(response, returnType); - } catch (ApiException e) { - callback.onFailure(e, response.code(), response.headers().toMultimap()); - return; - } - callback.onSuccess(result, response.code(), response.headers().toMultimap()); - } - }); - } - - /** - * Handle the given response, return the deserialized object when the response is successful. - * - * @param Type - * @param response Response - * @param returnType Return type - * @throws ApiException If the response has a unsuccessful status code or - * fail to deserialize the response body - * @return Type - */ - public T handleResponse(Response response, Type returnType) throws ApiException { - if (response.isSuccessful()) { - if (returnType == null || response.code() == 204) { - // returning null if the returnType is not defined, - // or the status code is 204 (No Content) - if (response.body() != null) { - try { - response.body().close(); - } catch (IOException e) { - throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); - } - } - return null; - } else { - return deserialize(response, returnType); - } - } else { - String respBody = null; - if (response.body() != null) { - try { - respBody = response.body().string(); - } catch (IOException e) { - throw new ApiException(response.message(), e, response.code(), response.headers().toMultimap()); - } - } - throw new ApiException(response.message(), response.code(), response.headers().toMultimap(), respBody); - } - } - - /** - * Build HTTP call with the given options. - * - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param formParams The form parameters - * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener - * @return The HTTP call - * @throws ApiException If fail to serialize the request body object - */ - public Call buildCall(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Request request = buildRequest(path, method, queryParams, collectionQueryParams, body, headerParams, formParams, authNames, progressRequestListener); - - return httpClient.newCall(request); - } - - /** - * Build an HTTP request with the given options. - * - * @param path The sub-path of the HTTP URL - * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @param body The request body object - * @param headerParams The header parameters - * @param formParams The form parameters - * @param authNames The authentications to apply - * @param progressRequestListener Progress request listener - * @return The HTTP request - * @throws ApiException If fail to serialize the request body object - */ - public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - updateParamsForAuth(authNames, queryParams, headerParams); - - final String url = buildUrl(path, queryParams, collectionQueryParams); - final Request.Builder reqBuilder = new Request.Builder().url(url); - processHeaderParams(headerParams, reqBuilder); - - String contentType = (String) headerParams.get("Content-Type"); - // ensuring a default content type - if (contentType == null) { - contentType = "application/json"; - } - - RequestBody reqBody; - if (!HttpMethod.permitsRequestBody(method)) { - reqBody = null; - } else if ("application/x-www-form-urlencoded".equals(contentType)) { - reqBody = buildRequestBodyFormEncoding(formParams); - } else if ("multipart/form-data".equals(contentType)) { - reqBody = buildRequestBodyMultipart(formParams); - } else if (body == null) { - if ("DELETE".equals(method)) { - // allow calling DELETE without sending a request body - reqBody = null; - } else { - // use an empty request body (for POST, PUT and PATCH) - reqBody = RequestBody.create(MediaType.parse(contentType), ""); - } - } else { - reqBody = serialize(body, contentType); - } - - Request request = null; - - if(progressRequestListener != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, progressRequestListener); - request = reqBuilder.method(method, progressRequestBody).build(); - } else { - request = reqBuilder.method(method, reqBody).build(); - } - - return request; - } - - /** - * Build full URL by concatenating base path, the given sub path and query parameters. - * - * @param path The sub path - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @return The full URL - */ - public String buildUrl(String path, List queryParams, List collectionQueryParams) { - final StringBuilder url = new StringBuilder(); - url.append(basePath).append(path); - - if (queryParams != null && !queryParams.isEmpty()) { - // support (constant) query string in `path`, e.g. "/posts?draft=1" - String prefix = path.contains("?") ? "&" : "?"; - for (Pair param : queryParams) { - if (param.getValue() != null) { - if (prefix != null) { - url.append(prefix); - prefix = null; - } else { - url.append("&"); - } - String value = parameterToString(param.getValue()); - url.append(escapeString(param.getName())).append("=").append(escapeString(value)); - } - } - } - - if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { - String prefix = url.toString().contains("?") ? "&" : "?"; - for (Pair param : collectionQueryParams) { - if (param.getValue() != null) { - if (prefix != null) { - url.append(prefix); - prefix = null; - } else { - url.append("&"); - } - String value = parameterToString(param.getValue()); - // collection query parameter value already escaped as part of parameterToPairs - url.append(escapeString(param.getName())).append("=").append(value); - } - } - } - - return url.toString(); - } - - /** - * Set header parameters to the request builder, including default headers. - * - * @param headerParams Header parameters in the ofrm of Map - * @param reqBuilder Reqeust.Builder - */ - public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { - for (Entry param : headerParams.entrySet()) { - reqBuilder.header(param.getKey(), parameterToString(param.getValue())); - } - for (Entry header : defaultHeaderMap.entrySet()) { - if (!headerParams.containsKey(header.getKey())) { - reqBuilder.header(header.getKey(), parameterToString(header.getValue())); - } - } - } - - /** - * Update query and header parameters based on authentication settings. - * - * @param authNames The authentications to apply - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - */ - public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams) { - for (String authName : authNames) { - Authentication auth = authentications.get(authName); - if (auth == null) throw new RuntimeException("Authentication undefined: " + authName); - auth.applyToParams(queryParams, headerParams); - } - } - - /** - * Build a form-encoding request body with the given form parameters. - * - * @param formParams Form parameters in the form of Map - * @return RequestBody - */ - public RequestBody buildRequestBodyFormEncoding(Map formParams) { - FormEncodingBuilder formBuilder = new FormEncodingBuilder(); - for (Entry param : formParams.entrySet()) { - formBuilder.add(param.getKey(), parameterToString(param.getValue())); - } - return formBuilder.build(); - } - - /** - * Build a multipart (file uploading) request body with the given form parameters, - * which could contain text fields and file fields. - * - * @param formParams Form parameters in the form of Map - * @return RequestBody - */ - public RequestBody buildRequestBodyMultipart(Map formParams) { - MultipartBuilder mpBuilder = new MultipartBuilder().type(MultipartBuilder.FORM); - for (Entry param : formParams.entrySet()) { - if (param.getValue() instanceof File) { - File file = (File) param.getValue(); - Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); - MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); - mpBuilder.addPart(partHeaders, RequestBody.create(mediaType, file)); - } else { - Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); - mpBuilder.addPart(partHeaders, RequestBody.create(null, parameterToString(param.getValue()))); - } - } - return mpBuilder.build(); - } - - /** - * Guess Content-Type header from the given file (defaults to "application/octet-stream"). - * - * @param file The given file - * @return The guessed Content-Type - */ - public String guessContentTypeFromFile(File file) { - String contentType = URLConnection.guessContentTypeFromName(file.getName()); - if (contentType == null) { - return "application/octet-stream"; - } else { - return contentType; - } - } - - /** - * Apply SSL related settings to httpClient according to the current values of - * verifyingSsl and sslCaCert. - */ - private void applySslSettings() { - try { - TrustManager[] trustManagers = null; - HostnameVerifier hostnameVerifier = null; - if (!verifyingSsl) { - TrustManager trustAll = new X509TrustManager() { - @Override - public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {} - @Override - public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {} - @Override - public X509Certificate[] getAcceptedIssuers() { return null; } - }; - SSLContext sslContext = SSLContext.getInstance("TLS"); - trustManagers = new TrustManager[]{ trustAll }; - hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { return true; } - }; - } else if (sslCaCert != null) { - char[] password = null; // Any password will work. - CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); - Collection certificates = certificateFactory.generateCertificates(sslCaCert); - if (certificates.isEmpty()) { - throw new IllegalArgumentException("expected non-empty set of trusted certificates"); - } - KeyStore caKeyStore = newEmptyKeyStore(password); - int index = 0; - for (Certificate certificate : certificates) { - String certificateAlias = "ca" + Integer.toString(index++); - caKeyStore.setCertificateEntry(certificateAlias, certificate); - } - TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init(caKeyStore); - trustManagers = trustManagerFactory.getTrustManagers(); - } - - if (keyManagers != null || trustManagers != null) { - SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(keyManagers, trustManagers, new SecureRandom()); - httpClient.setSslSocketFactory(sslContext.getSocketFactory()); - } else { - httpClient.setSslSocketFactory(null); - } - httpClient.setHostnameVerifier(hostnameVerifier); - } catch (GeneralSecurityException e) { - throw new RuntimeException(e); - } - } - - private KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { - try { - KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); - keyStore.load(null, password); - return keyStore; - } catch (IOException e) { - throw new AssertionError(e); - } - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/ApiException.java b/src/main/java/com/algorand/algosdk/algod/client/ApiException.java deleted file mode 100644 index 887ce32e7..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/ApiException.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import java.util.Map; -import java.util.List; - -@Deprecated -public class ApiException extends Exception { - private int code = 0; - private Map> responseHeaders = null; - private String responseBody = null; - - public ApiException() {} - - public ApiException(Throwable throwable) { - super(throwable); - } - - public ApiException(String message) { - super(message); - } - - public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { - super(message + " : " + responseBody, throwable); - this.code = code; - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - public ApiException(String message, int code, Map> responseHeaders, String responseBody) { - this(message, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { - this(message, throwable, code, responseHeaders, null); - } - - public ApiException(int code, Map> responseHeaders, String responseBody) { - this((String) null, (Throwable) null, code, responseHeaders, responseBody); - } - - public ApiException(int code, String message) { - super(message); - this.code = code; - } - - public ApiException(int code, String message, Map> responseHeaders, String responseBody) { - this(code, message); - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - * Get the HTTP status code. - * - * @return HTTP status code - */ - public int getCode() { - return code; - } - - /** - * Get the HTTP response headers. - * - * @return A map of list of string - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - - /** - * Get the HTTP response body. - * - * @return Response body in the form of string - */ - public String getResponseBody() { - return responseBody; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/ApiResponse.java b/src/main/java/com/algorand/algosdk/algod/client/ApiResponse.java deleted file mode 100644 index a6d0c839f..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/ApiResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import java.util.List; -import java.util.Map; - -/** - * API response returned by API call. - * - * @param The type of data that is deserialized from response body - * @deprecated Use the equivalent in v2 algod client - */ -@Deprecated -public class ApiResponse { - final private int statusCode; - final private Map> headers; - final private T data; - - /** - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - */ - public ApiResponse(int statusCode, Map> headers) { - this(statusCode, headers, null); - } - - /** - * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - * @param data The object deserialized from response bod - */ - public ApiResponse(int statusCode, Map> headers, T data) { - this.statusCode = statusCode; - this.headers = headers; - this.data = data; - } - - public int getStatusCode() { - return statusCode; - } - - public Map> getHeaders() { - return headers; - } - - public T getData() { - return data; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/Configuration.java b/src/main/java/com/algorand/algosdk/algod/client/Configuration.java deleted file mode 100644 index d6f969014..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/Configuration.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -@Deprecated -public class Configuration { - private static ApiClient defaultApiClient = new ApiClient(); - - /** - * Get the default API client, which would be used when creating API - * instances without providing an API client. - * - * @return Default API client - */ - public static ApiClient getDefaultApiClient() { - return defaultApiClient; - } - - /** - * Set the default API client, which would be used when creating API - * instances without providing an API client. - * - * @param apiClient API client - */ - public static void setDefaultApiClient(ApiClient apiClient) { - defaultApiClient = apiClient; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/GzipRequestInterceptor.java b/src/main/java/com/algorand/algosdk/algod/client/GzipRequestInterceptor.java deleted file mode 100644 index b048ed735..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/GzipRequestInterceptor.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import com.squareup.okhttp.*; -import okio.Buffer; -import okio.BufferedSink; -import okio.GzipSink; -import okio.Okio; - -import java.io.IOException; - -/** - * Encodes request bodies using gzip. - * - * Taken from https://github.com/square/okhttp/issues/350 - */ -@Deprecated -class GzipRequestInterceptor implements Interceptor { - @Override public Response intercept(Chain chain) throws IOException { - Request originalRequest = chain.request(); - if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { - return chain.proceed(originalRequest); - } - - Request compressedRequest = originalRequest.newBuilder() - .header("Content-Encoding", "gzip") - .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) - .build(); - return chain.proceed(compressedRequest); - } - - private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { - final Buffer buffer = new Buffer(); - requestBody.writeTo(buffer); - return new RequestBody() { - @Override - public MediaType contentType() { - return requestBody.contentType(); - } - - @Override - public long contentLength() { - return buffer.size(); - } - - @Override - public void writeTo(BufferedSink sink) throws IOException { - sink.write(buffer.snapshot()); - } - }; - } - - private RequestBody gzip(final RequestBody body) { - return new RequestBody() { - @Override public MediaType contentType() { - return body.contentType(); - } - - @Override public long contentLength() { - return -1; // We don't know the compressed length in advance! - } - - @Override public void writeTo(BufferedSink sink) throws IOException { - BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); - body.writeTo(gzipSink); - gzipSink.close(); - } - }; - } -} \ No newline at end of file diff --git a/src/main/java/com/algorand/algosdk/algod/client/JSON.java b/src/main/java/com/algorand/algosdk/algod/client/JSON.java deleted file mode 100644 index 1591623cc..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/JSON.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import com.google.gson.*; -import com.google.gson.internal.bind.util.ISO8601Utils; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import io.gsonfire.GsonFireBuilder; -import okio.ByteString; -import org.threeten.bp.LocalDate; -import org.threeten.bp.OffsetDateTime; -import org.threeten.bp.format.DateTimeFormatter; - -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.Type; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.ParsePosition; -import java.util.Date; -import java.util.Map; - -@Deprecated -public class JSON { - private Gson gson; - private boolean isLenientOnJson = false; - private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); - private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); - private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); - private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); - private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); - - public static GsonBuilder createGson() { - GsonFireBuilder fireBuilder = new GsonFireBuilder() - ; - GsonBuilder builder = fireBuilder.createGsonBuilder(); - return builder; - } - - private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { - JsonElement element = readElement.getAsJsonObject().get(discriminatorField); - if(null == element) { - throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); - } - return element.getAsString(); - } - - private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { - Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue.toUpperCase()); - if(null == clazz) { - throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); - } - return clazz; - } - - public JSON() { - gson = createGson() - .registerTypeAdapter(Date.class, dateTypeAdapter) - .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) - .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) - .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) - .registerTypeAdapter(byte[].class, byteArrayAdapter) - .create(); - } - - /** - * Get Gson. - * - * @return Gson - */ - public Gson getGson() { - return gson; - } - - /** - * Set Gson. - * - * @param gson Gson - * @return JSON - */ - public JSON setGson(Gson gson) { - this.gson = gson; - return this; - } - - public JSON setLenientOnJson(boolean lenientOnJson) { - isLenientOnJson = lenientOnJson; - return this; - } - - /** - * Serialize the given Java object into JSON string. - * - * @param obj Object - * @return String representation of the JSON - */ - public String serialize(Object obj) { - return gson.toJson(obj); - } - - /** - * Deserialize the given JSON string to Java object. - * - * @param Type - * @param body The JSON string - * @param returnType The type to deserialize into - * @return The deserialized Java object - */ - @SuppressWarnings("unchecked") - public T deserialize(String body, Type returnType) { - try { - if (isLenientOnJson) { - JsonReader jsonReader = new JsonReader(new StringReader(body)); - // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) - jsonReader.setLenient(true); - return gson.fromJson(jsonReader, returnType); - } else { - return gson.fromJson(body, returnType); - } - } catch (JsonParseException e) { - // Fallback processing when failed to parse JSON form response body: - // return the response body string directly for the String return type; - if (returnType.equals(String.class)) - return (T) body; - else throw (e); - } - } - - /** - * Gson TypeAdapter for Byte Array type - */ - public class ByteArrayAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, byte[] value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(ByteString.of(value).base64()); - } - } - - @Override - public byte[] read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String bytesAsBase64 = in.nextString(); - ByteString byteString = ByteString.decodeBase64(bytesAsBase64); - return byteString.toByteArray(); - } - } - } - - /** - * Gson TypeAdapter for JSR310 OffsetDateTime type - */ - public static class OffsetDateTimeTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public OffsetDateTimeTypeAdapter() { - this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); - } - - public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, OffsetDateTime date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } - - @Override - public OffsetDateTime read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - if (date.endsWith("+0000")) { - date = date.substring(0, date.length()-5) + "Z"; - } - return OffsetDateTime.parse(date, formatter); - } - } - } - - /** - * Gson TypeAdapter for JSR310 LocalDate type - */ - public class LocalDateTypeAdapter extends TypeAdapter { - - private DateTimeFormatter formatter; - - public LocalDateTypeAdapter() { - this(DateTimeFormatter.ISO_LOCAL_DATE); - } - - public LocalDateTypeAdapter(DateTimeFormatter formatter) { - this.formatter = formatter; - } - - public void setFormat(DateTimeFormatter dateFormat) { - this.formatter = dateFormat; - } - - @Override - public void write(JsonWriter out, LocalDate date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - out.value(formatter.format(date)); - } - } - - @Override - public LocalDate read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - return LocalDate.parse(date, formatter); - } - } - } - - public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { - offsetDateTimeTypeAdapter.setFormat(dateFormat); - return this; - } - - public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { - localDateTypeAdapter.setFormat(dateFormat); - return this; - } - - /** - * Gson TypeAdapter for java.sql.Date type - * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used - * (more efficient than SimpleDateFormat). - */ - public static class SqlDateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public SqlDateTypeAdapter() { - } - - public SqlDateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, java.sql.Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = date.toString(); - } - out.value(value); - } - } - - @Override - public java.sql.Date read(JsonReader in) throws IOException { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return new java.sql.Date(dateFormat.parse(date).getTime()); - } - return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } - } - - /** - * Gson TypeAdapter for java.util.Date type - * If the dateFormat is null, ISO8601Utils will be used. - */ - public static class DateTypeAdapter extends TypeAdapter { - - private DateFormat dateFormat; - - public DateTypeAdapter() { - } - - public DateTypeAdapter(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - public void setFormat(DateFormat dateFormat) { - this.dateFormat = dateFormat; - } - - @Override - public void write(JsonWriter out, Date date) throws IOException { - if (date == null) { - out.nullValue(); - } else { - String value; - if (dateFormat != null) { - value = dateFormat.format(date); - } else { - value = ISO8601Utils.format(date, true); - } - out.value(value); - } - } - - @Override - public Date read(JsonReader in) throws IOException { - try { - switch (in.peek()) { - case NULL: - in.nextNull(); - return null; - default: - String date = in.nextString(); - try { - if (dateFormat != null) { - return dateFormat.parse(date); - } - return ISO8601Utils.parse(date, new ParsePosition(0)); - } catch (ParseException e) { - throw new JsonParseException(e); - } - } - } catch (IllegalArgumentException e) { - throw new JsonParseException(e); - } - } - } - - public JSON setDateFormat(DateFormat dateFormat) { - dateTypeAdapter.setFormat(dateFormat); - return this; - } - - public JSON setSqlDateFormat(DateFormat dateFormat) { - sqlDateTypeAdapter.setFormat(dateFormat); - return this; - } - -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/ProgressRequestBody.java b/src/main/java/com/algorand/algosdk/algod/client/ProgressRequestBody.java deleted file mode 100644 index ee41e3e8c..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/ProgressRequestBody.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import com.squareup.okhttp.MediaType; -import com.squareup.okhttp.RequestBody; - -import java.io.IOException; - -import okio.Buffer; -import okio.BufferedSink; -import okio.ForwardingSink; -import okio.Okio; -import okio.Sink; - -@Deprecated -public class ProgressRequestBody extends RequestBody { - - public interface ProgressRequestListener { - void onRequestProgress(long bytesWritten, long contentLength, boolean done); - } - - private final RequestBody requestBody; - - private final ProgressRequestListener progressListener; - - public ProgressRequestBody(RequestBody requestBody, ProgressRequestListener progressListener) { - this.requestBody = requestBody; - this.progressListener = progressListener; - } - - @Override - public MediaType contentType() { - return requestBody.contentType(); - } - - @Override - public long contentLength() throws IOException { - return requestBody.contentLength(); - } - - @Override - public void writeTo(BufferedSink sink) throws IOException { - BufferedSink bufferedSink = Okio.buffer(sink(sink)); - requestBody.writeTo(bufferedSink); - bufferedSink.flush(); - } - - private Sink sink(Sink sink) { - return new ForwardingSink(sink) { - - long bytesWritten = 0L; - long contentLength = 0L; - - @Override - public void write(Buffer source, long byteCount) throws IOException { - super.write(source, byteCount); - if (contentLength == 0) { - contentLength = contentLength(); - } - - bytesWritten += byteCount; - progressListener.onRequestProgress(bytesWritten, contentLength, bytesWritten == contentLength); - } - }; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/ProgressResponseBody.java b/src/main/java/com/algorand/algosdk/algod/client/ProgressResponseBody.java deleted file mode 100644 index 354c94ca5..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/ProgressResponseBody.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -import com.squareup.okhttp.MediaType; -import com.squareup.okhttp.ResponseBody; - -import java.io.IOException; - -import okio.Buffer; -import okio.BufferedSource; -import okio.ForwardingSource; -import okio.Okio; -import okio.Source; - -@Deprecated -public class ProgressResponseBody extends ResponseBody { - - public interface ProgressListener { - void update(long bytesRead, long contentLength, boolean done); - } - - private final ResponseBody responseBody; - private final ProgressListener progressListener; - private BufferedSource bufferedSource; - - public ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) { - this.responseBody = responseBody; - this.progressListener = progressListener; - } - - @Override - public MediaType contentType() { - return responseBody.contentType(); - } - - @Override - public long contentLength() throws IOException { - return responseBody.contentLength(); - } - - @Override - public BufferedSource source() throws IOException { - if (bufferedSource == null) { - bufferedSource = Okio.buffer(source(responseBody.source())); - } - return bufferedSource; - } - - private Source source(Source source) { - return new ForwardingSource(source) { - long totalBytesRead = 0L; - - @Override - public long read(Buffer sink, long byteCount) throws IOException { - long bytesRead = super.read(sink, byteCount); - // read() returns the number of bytes read, or -1 if this source is exhausted. - totalBytesRead += bytesRead != -1 ? bytesRead : 0; - progressListener.update(totalBytesRead, responseBody.contentLength(), bytesRead == -1); - return bytesRead; - } - }; - } -} - - diff --git a/src/main/java/com/algorand/algosdk/algod/client/StringUtil.java b/src/main/java/com/algorand/algosdk/algod/client/StringUtil.java deleted file mode 100644 index f296916b6..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/StringUtil.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client; - -@Deprecated -public class StringUtil { - /** - * Check if the given array contains the given value (with case-insensitive comparison). - * - * @param array The array - * @param value The value to search - * @return true if the array contains the value - */ - public static boolean containsIgnoreCase(String[] array, String value) { - for (String str : array) { - if (value == null && str == null) return true; - if (value != null && value.equalsIgnoreCase(str)) return true; - } - return false; - } - - /** - * Join an array of strings with the given separator. - *

- * Note: This might be replaced by utility method from commons-lang or guava someday - * if one of those libraries is added as dependency. - *

- * - * @param array The array of strings - * @param separator The separator - * @return the resulting string - */ - public static String join(String[] array, String separator) { - int len = array.length; - if (len == 0) return ""; - - StringBuilder out = new StringBuilder(); - out.append(array[0]); - for (int i = 1; i < len; i++) { - out.append(separator).append(array[i]); - } - return out.toString(); - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/api/AlgodApi.java b/src/main/java/com/algorand/algosdk/algod/client/api/AlgodApi.java deleted file mode 100644 index 02342465b..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/api/AlgodApi.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.algorand.algosdk.algod.client.api; - -import com.algorand.algosdk.algod.client.AlgodClient; -import com.algorand.algosdk.algod.client.ApiClient; -import com.algorand.algosdk.algod.client.Configuration; - -/** - * @deprecated Use the equivalent in v2 algod client - */ -@Deprecated -public class AlgodApi extends DefaultApi { - - public AlgodApi() { - super(); - } - - public AlgodApi(ApiClient apiClient) { - super(apiClient); - } - -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/api/DefaultApi.java b/src/main/java/com/algorand/algosdk/algod/client/api/DefaultApi.java deleted file mode 100644 index 40c8471ae..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/api/DefaultApi.java +++ /dev/null @@ -1,2213 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.api; - -import com.algorand.algosdk.algod.client.*; -import com.algorand.algosdk.algod.client.lib.Pair; -import com.algorand.algosdk.algod.client.model.*; -import com.google.gson.reflect.TypeToken; -import org.threeten.bp.LocalDate; - -import java.io.IOException; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @deprecated Use the equivalent in v2 algod client - */ -@Deprecated -public class DefaultApi { - private ApiClient apiClient; - - public DefaultApi() { - this(Configuration.getDefaultApiClient()); - } - - public DefaultApi(ApiClient apiClient) { - this.apiClient = apiClient; - } - - public ApiClient getApiClient() { - return apiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.apiClient = apiClient; - } - - /** - * Build call for accountInformation - * @param address An account public key (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call accountInformationCall(String address, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/account/{address}" - .replaceAll("\\{" + "address" + "\\}", apiClient.escapeString(address.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call accountInformationValidateBeforeCall(String address, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'address' is set - if (address == null) { - throw new ApiException("Missing the required parameter 'address' when calling accountInformation(Async)"); - } - - - com.squareup.okhttp.Call call = accountInformationCall(address, progressListener, progressRequestListener); - return call; - - } - - /** - * Get account information. - * Given a specific account public key, this call returns the accounts status, balance and spendable amounts - * @param address An account public key (required) - * @return Account - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Account accountInformation(String address) throws ApiException { - ApiResponse resp = accountInformationWithHttpInfo(address); - return resp.getData(); - } - - /** - * Get account information. - * Given a specific account public key, this call returns the accounts status, balance and spendable amounts - * @param address An account public key (required) - * @return ApiResponse<Account> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse accountInformationWithHttpInfo(String address) throws ApiException { - com.squareup.okhttp.Call call = accountInformationValidateBeforeCall(address, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get account information. (asynchronously) - * Given a specific account public key, this call returns the accounts status, balance and spendable amounts - * @param address An account public key (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call accountInformationAsync(String address, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = accountInformationValidateBeforeCall(address, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for assetInformation - * @param index Asset index (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call assetInformationCall(java.math.BigInteger index, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/asset/{index}" - .replaceAll("\\{" + "index" + "\\}", apiClient.escapeString(index.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call assetInformationValidateBeforeCall(java.math.BigInteger index, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'index' is set - if (index == null) { - throw new ApiException("Missing the required parameter 'index' when calling assetInformation(Async)"); - } - - - com.squareup.okhttp.Call call = assetInformationCall(index, progressListener, progressRequestListener); - return call; - - } - - /** - * Get asset information. - * Given the asset's unique index, this call returns the asset's creator, manager, reserve, freeze, and clawback addresses - * @param index Asset index (required) - * @return AssetParams - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public AssetParams assetInformation(java.math.BigInteger index) throws ApiException { - ApiResponse resp = assetInformationWithHttpInfo(index); - return resp.getData(); - } - - /** - * Get asset information. - * Given the asset's unique index, this call returns the asset's creator, manager, reserve, freeze, and clawback addresses - * @param index Asset index (required) - * @return ApiResponse<AssetParams> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse assetInformationWithHttpInfo(java.math.BigInteger index) throws ApiException { - com.squareup.okhttp.Call call = assetInformationValidateBeforeCall(index, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get asset information. (asynchronously) - * Given the asset's unique index, this call returns the asset's creator, manager, reserve, freeze, and clawback addresses - * @param index Asset index (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call assetInformationAsync(java.math.BigInteger index, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = assetInformationValidateBeforeCall(index, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for getBlock - * @param round The round from which to fetch block information. (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call getBlockCall(java.math.BigInteger round, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/block/{round}" - .replaceAll("\\{" + "round" + "\\}", apiClient.escapeString(round.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call getBlockValidateBeforeCall(java.math.BigInteger round, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'round' is set - if (round == null) { - throw new ApiException("Missing the required parameter 'round' when calling getBlock(Async)"); - } - - - com.squareup.okhttp.Call call = getBlockCall(round, progressListener, progressRequestListener); - return call; - - } - - /** - * Get the block for the given round. - * - * @param round The round from which to fetch block information. (required) - * @return Block - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Block getBlock(java.math.BigInteger round) throws ApiException { - ApiResponse resp = getBlockWithHttpInfo(round); - return resp.getData(); - } - - /** - * Get the block for the given round. - * - * @param round The round from which to fetch block information. (required) - * @return ApiResponse<Block> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getBlockWithHttpInfo(java.math.BigInteger round) throws ApiException { - com.squareup.okhttp.Call call = getBlockValidateBeforeCall(round, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get the block for the given round. (asynchronously) - * - * @param round The round from which to fetch block information. (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call getBlockAsync(java.math.BigInteger round, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = getBlockValidateBeforeCall(round, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for getPendingTransactions - * @param max Truncated number of transactions to display. If max=0, returns all pending txns. (optional) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call getPendingTransactionsCall(java.math.BigInteger max, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/transactions/pending"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (max != null) - localVarQueryParams.addAll(apiClient.parameterToPair("max", max)); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call getPendingTransactionsValidateBeforeCall(java.math.BigInteger max, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = getPendingTransactionsCall(max, progressListener, progressRequestListener); - return call; - - } - - /** - * Get a list of unconfirmed transactions currently in the transaction pool. - * Get the list of pending transactions, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions. - * @param max Truncated number of transactions to display. If max=0, returns all pending txns. (optional) - * @return PendingTransactions - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public PendingTransactions getPendingTransactions(java.math.BigInteger max) throws ApiException { - ApiResponse resp = getPendingTransactionsWithHttpInfo(max); - return resp.getData(); - } - - /** - * Get a list of unconfirmed transactions currently in the transaction pool. - * Get the list of pending transactions, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions. - * @param max Truncated number of transactions to display. If max=0, returns all pending txns. (optional) - * @return ApiResponse<PendingTransactions> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getPendingTransactionsWithHttpInfo(java.math.BigInteger max) throws ApiException { - com.squareup.okhttp.Call call = getPendingTransactionsValidateBeforeCall(max, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get a list of unconfirmed transactions currently in the transaction pool. (asynchronously) - * Get the list of pending transactions, sorted by priority, in decreasing order, truncated at the end at MAX. If MAX = 0, returns all pending transactions. - * @param max Truncated number of transactions to display. If max=0, returns all pending txns. (optional) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call getPendingTransactionsAsync(java.math.BigInteger max, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = getPendingTransactionsValidateBeforeCall(max, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for getStatus - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call getStatusCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/status"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call getStatusValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = getStatusCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Gets the current node status. - * - * @return NodeStatus - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public NodeStatus getStatus() throws ApiException { - ApiResponse resp = getStatusWithHttpInfo(); - return resp.getData(); - } - - /** - * Gets the current node status. - * - * @return ApiResponse<NodeStatus> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getStatusWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = getStatusValidateBeforeCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Gets the current node status. (asynchronously) - * - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call getStatusAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = getStatusValidateBeforeCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for getSupply - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call getSupplyCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/ledger/supply"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call getSupplyValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = getSupplyCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Get the current supply reported by the ledger. - * - * @return Supply - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Supply getSupply() throws ApiException { - ApiResponse resp = getSupplyWithHttpInfo(); - return resp.getData(); - } - - /** - * Get the current supply reported by the ledger. - * - * @return ApiResponse<Supply> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getSupplyWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = getSupplyValidateBeforeCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get the current supply reported by the ledger. (asynchronously) - * - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call getSupplyAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = getSupplyValidateBeforeCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for getVersion - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call getVersionCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/versions"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call getVersionValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = getVersionCall(progressListener, progressRequestListener); - return call; - - } - - /** - * - * Retrieves the current version - * @return Version - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Version getVersion() throws ApiException { - ApiResponse resp = getVersionWithHttpInfo(); - return resp.getData(); - } - - /** - * - * Retrieves the current version - * @return ApiResponse<Version> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse getVersionWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = getVersionValidateBeforeCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * (asynchronously) - * Retrieves the current version - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call getVersionAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = getVersionValidateBeforeCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for healthCheck - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call healthCheckCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/health"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call healthCheckValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = healthCheckCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Returns OK if healthy. - * - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public void healthCheck() throws ApiException { - healthCheckWithHttpInfo(); - } - - /** - * Returns OK if healthy. - * - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse healthCheckWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = healthCheckValidateBeforeCall(null, null); - return apiClient.execute(call); - } - - /** - * Returns OK if healthy. (asynchronously) - * - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call healthCheckAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = healthCheckValidateBeforeCall(progressListener, progressRequestListener); - apiClient.executeAsync(call, callback); - return call; - } - /** - * Build call for metrics - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call metricsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/metrics"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "text/plain" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call metricsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = metricsCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Return metrics about algod functioning. - * - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public void metrics() throws ApiException { - metricsWithHttpInfo(); - } - - /** - * Return metrics about algod functioning. - * - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse metricsWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = metricsValidateBeforeCall(null, null); - return apiClient.execute(call); - } - - /** - * Return metrics about algod functioning. (asynchronously) - * - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call metricsAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = metricsValidateBeforeCall(progressListener, progressRequestListener); - apiClient.executeAsync(call, callback); - return call; - } - /** - * Build call for pendingTransactionInformation - * @param txid A transaction id (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call pendingTransactionInformationCall(String txid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/transactions/pending/{txid}" - .replaceAll("\\{" + "txid" + "\\}", apiClient.escapeString(txid.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call pendingTransactionInformationValidateBeforeCall(String txid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'txid' is set - if (txid == null) { - throw new ApiException("Missing the required parameter 'txid' when calling pendingTransactionInformation(Async)"); - } - - - com.squareup.okhttp.Call call = pendingTransactionInformationCall(txid, progressListener, progressRequestListener); - return call; - - } - - /** - * Get a specific pending transaction. - * Given a transaction id of a recently submitted transaction, it returns information about it. There are several cases when this might succeed: - transaction committed (committed round > 0) - transaction still in the pool (committed round = 0, pool error = \"\") - transaction removed from pool due to error (committed round = 0, pool error != \"\") Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error. - * @param txid A transaction id (required) - * @return Transaction - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Transaction pendingTransactionInformation(String txid) throws ApiException { - ApiResponse resp = pendingTransactionInformationWithHttpInfo(txid); - return resp.getData(); - } - - /** - * Get a specific pending transaction. - * Given a transaction id of a recently submitted transaction, it returns information about it. There are several cases when this might succeed: - transaction committed (committed round > 0) - transaction still in the pool (committed round = 0, pool error = \"\") - transaction removed from pool due to error (committed round = 0, pool error != \"\") Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error. - * @param txid A transaction id (required) - * @return ApiResponse<Transaction> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse pendingTransactionInformationWithHttpInfo(String txid) throws ApiException { - com.squareup.okhttp.Call call = pendingTransactionInformationValidateBeforeCall(txid, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get a specific pending transaction. (asynchronously) - * Given a transaction id of a recently submitted transaction, it returns information about it. There are several cases when this might succeed: - transaction committed (committed round > 0) - transaction still in the pool (committed round = 0, pool error = \"\") - transaction removed from pool due to error (committed round = 0, pool error != \"\") Or the transaction may have happened sufficiently long ago that the node no longer remembers it, and this will return an error. - * @param txid A transaction id (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call pendingTransactionInformationAsync(String txid, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = pendingTransactionInformationValidateBeforeCall(txid, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for rawTransaction - * @param rawtxn The byte encoded signed transaction to broadcast to network (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call rawTransactionCall(byte[] rawtxn, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = rawtxn; - - // create path and map variables - String localVarPath = "/v1/transactions"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/x-binary" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call rawTransactionValidateBeforeCall(byte[] rawtxn, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'rawtxn' is set - if (rawtxn == null) { - throw new ApiException("Missing the required parameter 'rawtxn' when calling rawTransaction(Async)"); - } - - - com.squareup.okhttp.Call call = rawTransactionCall(rawtxn, progressListener, progressRequestListener); - return call; - - } - - /** - * Broadcasts a raw transaction to the network. - * - * @param rawtxn The byte encoded signed transaction to broadcast to network (required) - * @return TransactionID - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public TransactionID rawTransaction(byte[] rawtxn) throws ApiException { - ApiResponse resp = rawTransactionWithHttpInfo(rawtxn); - return resp.getData(); - } - - /** - * Broadcasts a raw transaction to the network. - * - * @param rawtxn The byte encoded signed transaction to broadcast to network (required) - * @return ApiResponse<TransactionID> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse rawTransactionWithHttpInfo(byte[] rawtxn) throws ApiException { - com.squareup.okhttp.Call call = rawTransactionValidateBeforeCall(rawtxn, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Broadcasts a raw transaction to the network. (asynchronously) - * - * @param rawtxn The byte encoded signed transaction to broadcast to network (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call rawTransactionAsync(byte[] rawtxn, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = rawTransactionValidateBeforeCall(rawtxn, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for suggestedFee - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call suggestedFeeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/transactions/fee"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call suggestedFeeValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = suggestedFeeCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Get the suggested fee - * Suggested Fee is returned in units of micro-Algos per byte. Suggested Fee may fall to zero but submitted transactions must still have a fee of at least MinTxnFee for the current network protocol. - * @return TransactionFee - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public TransactionFee suggestedFee() throws ApiException { - ApiResponse resp = suggestedFeeWithHttpInfo(); - return resp.getData(); - } - - /** - * Get the suggested fee - * Suggested Fee is returned in units of micro-Algos per byte. Suggested Fee may fall to zero but submitted transactions must still have a fee of at least MinTxnFee for the current network protocol. - * @return ApiResponse<TransactionFee> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse suggestedFeeWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = suggestedFeeValidateBeforeCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get the suggested fee (asynchronously) - * Suggested Fee is returned in units of micro-Algos per byte. Suggested Fee may fall to zero but submitted transactions must still have a fee of at least MinTxnFee for the current network protocol. - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call suggestedFeeAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = suggestedFeeValidateBeforeCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for swaggerJSON - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call swaggerJSONCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/swagger.json"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call swaggerJSONValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = swaggerJSONCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Gets the current swagger spec. - * Returns the entire swagger spec in json. - * @return String - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public String swaggerJSON() throws ApiException { - ApiResponse resp = swaggerJSONWithHttpInfo(); - return resp.getData(); - } - - /** - * Gets the current swagger spec. - * Returns the entire swagger spec in json. - * @return ApiResponse<String> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse swaggerJSONWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = swaggerJSONValidateBeforeCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Gets the current swagger spec. (asynchronously) - * Returns the entire swagger spec in json. - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call swaggerJSONAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = swaggerJSONValidateBeforeCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for transaction - * @param txid A transaction id (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call transactionCall(String txid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/transaction/{txid}" - .replaceAll("\\{" + "txid" + "\\}", apiClient.escapeString(txid.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call transactionValidateBeforeCall(String txid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'txid' is set - if (txid == null) { - throw new ApiException("Missing the required parameter 'txid' when calling transaction(Async)"); - } - - - com.squareup.okhttp.Call call = transactionCall(txid, progressListener, progressRequestListener); - return call; - - } - - /** - * Get an information of a single transaction. - * Returns the transaction information of the given txid. Works only if the indexer is enabled. - * @param txid A transaction id (required) - * @return Transaction - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Transaction transaction(String txid) throws ApiException { - ApiResponse resp = transactionWithHttpInfo(txid); - return resp.getData(); - } - - /** - * Get an information of a single transaction. - * Returns the transaction information of the given txid. Works only if the indexer is enabled. - * @param txid A transaction id (required) - * @return ApiResponse<Transaction> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse transactionWithHttpInfo(String txid) throws ApiException { - com.squareup.okhttp.Call call = transactionValidateBeforeCall(txid, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get an information of a single transaction. (asynchronously) - * Returns the transaction information of the given txid. Works only if the indexer is enabled. - * @param txid A transaction id (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call transactionAsync(String txid, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = transactionValidateBeforeCall(txid, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for transactionInformation - * @param address An account public key (required) - * @param txid A transaction id (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call transactionInformationCall(String address, String txid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/account/{address}/transaction/{txid}" - .replaceAll("\\{" + "address" + "\\}", apiClient.escapeString(address.toString())) - .replaceAll("\\{" + "txid" + "\\}", apiClient.escapeString(txid.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call transactionInformationValidateBeforeCall(String address, String txid, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'address' is set - if (address == null) { - throw new ApiException("Missing the required parameter 'address' when calling transactionInformation(Async)"); - } - - // verify the required parameter 'txid' is set - if (txid == null) { - throw new ApiException("Missing the required parameter 'txid' when calling transactionInformation(Async)"); - } - - - com.squareup.okhttp.Call call = transactionInformationCall(address, txid, progressListener, progressRequestListener); - return call; - - } - - /** - * Get a specific confirmed transaction. - * Given a wallet address and a transaction id, it returns the confirmed transaction information. This call scans up to <CurrentProtocol>.MaxTxnLife blocks in the past. - * @param address An account public key (required) - * @param txid A transaction id (required) - * @return Transaction - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public Transaction transactionInformation(String address, String txid) throws ApiException { - ApiResponse resp = transactionInformationWithHttpInfo(address, txid); - return resp.getData(); - } - - /** - * Get a specific confirmed transaction. - * Given a wallet address and a transaction id, it returns the confirmed transaction information. This call scans up to <CurrentProtocol>.MaxTxnLife blocks in the past. - * @param address An account public key (required) - * @param txid A transaction id (required) - * @return ApiResponse<Transaction> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse transactionInformationWithHttpInfo(String address, String txid) throws ApiException { - com.squareup.okhttp.Call call = transactionInformationValidateBeforeCall(address, txid, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get a specific confirmed transaction. (asynchronously) - * Given a wallet address and a transaction id, it returns the confirmed transaction information. This call scans up to <CurrentProtocol>.MaxTxnLife blocks in the past. - * @param address An account public key (required) - * @param txid A transaction id (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call transactionInformationAsync(String address, String txid, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = transactionInformationValidateBeforeCall(address, txid, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for transactionParams - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call transactionParamsCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/transactions/params"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call transactionParamsValidateBeforeCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - - com.squareup.okhttp.Call call = transactionParamsCall(progressListener, progressRequestListener); - return call; - - } - - /** - * Get parameters for constructing a new transaction - * - * @return TransactionParams - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public TransactionParams transactionParams() throws ApiException { - ApiResponse resp = transactionParamsWithHttpInfo(); - return resp.getData(); - } - - /** - * Get parameters for constructing a new transaction - * - * @return ApiResponse<TransactionParams> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse transactionParamsWithHttpInfo() throws ApiException { - com.squareup.okhttp.Call call = transactionParamsValidateBeforeCall(null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get parameters for constructing a new transaction (asynchronously) - * - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call transactionParamsAsync(final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = transactionParamsValidateBeforeCall(progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for transactions - * @param address An account public key (required) - * @param firstRound Do not fetch any transactions before this round. (optional) - * @param lastRound Do not fetch any transactions after this round. (optional) - * @param fromDate Do not fetch any transactions before this date. (enabled only with indexer) (optional) - * @param toDate Do not fetch any transactions after this date. (enabled only with indexer) (optional) - * @param max maximum transactions to show (default to 100) (optional) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call transactionsCall(String address, java.math.BigInteger firstRound, java.math.BigInteger lastRound, LocalDate fromDate, LocalDate toDate, java.math.BigInteger max, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/account/{address}/transactions" - .replaceAll("\\{" + "address" + "\\}", apiClient.escapeString(address.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - if (firstRound != null) - localVarQueryParams.addAll(apiClient.parameterToPair("firstRound", firstRound)); - if (lastRound != null) - localVarQueryParams.addAll(apiClient.parameterToPair("lastRound", lastRound)); - if (fromDate != null) - localVarQueryParams.addAll(apiClient.parameterToPair("fromDate", fromDate)); - if (toDate != null) - localVarQueryParams.addAll(apiClient.parameterToPair("toDate", toDate)); - if (max != null) - localVarQueryParams.addAll(apiClient.parameterToPair("max", max)); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call transactionsValidateBeforeCall(String address, java.math.BigInteger firstRound, java.math.BigInteger lastRound, LocalDate fromDate, LocalDate toDate, java.math.BigInteger max, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'address' is set - if (address == null) { - throw new ApiException("Missing the required parameter 'address' when calling transactions(Async)"); - } - - - com.squareup.okhttp.Call call = transactionsCall(address, firstRound, lastRound, fromDate, toDate, max, progressListener, progressRequestListener); - return call; - - } - - /** - * Get a list of confirmed transactions. - * Returns the list of confirmed transactions between within a date range. This call is available only when the indexer is running. - * @param address An account public key (required) - * @param firstRound Do not fetch any transactions before this round. (optional) - * @param lastRound Do not fetch any transactions after this round. (optional) - * @param fromDate Do not fetch any transactions before this date. (enabled only with indexer) (optional) - * @param toDate Do not fetch any transactions after this date. (enabled only with indexer) (optional) - * @param max maximum transactions to show (default to 100) (optional) - * @return TransactionList - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public TransactionList transactions(String address, java.math.BigInteger firstRound, java.math.BigInteger lastRound, LocalDate fromDate, LocalDate toDate, java.math.BigInteger max) throws ApiException { - ApiResponse resp = transactionsWithHttpInfo(address, firstRound, lastRound, fromDate, toDate, max); - return resp.getData(); - } - - /** - * Get a list of confirmed transactions. - * Returns the list of confirmed transactions between within a date range. This call is available only when the indexer is running. - * @param address An account public key (required) - * @param firstRound Do not fetch any transactions before this round. (optional) - * @param lastRound Do not fetch any transactions after this round. (optional) - * @param fromDate Do not fetch any transactions before this date. (enabled only with indexer) (optional) - * @param toDate Do not fetch any transactions after this date. (enabled only with indexer) (optional) - * @param max maximum transactions to show (default to 100) (optional) - * @return ApiResponse<TransactionList> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse transactionsWithHttpInfo(String address, java.math.BigInteger firstRound, java.math.BigInteger lastRound, LocalDate fromDate, LocalDate toDate, java.math.BigInteger max) throws ApiException { - com.squareup.okhttp.Call call = transactionsValidateBeforeCall(address, firstRound, lastRound, fromDate, toDate, max, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Get a list of confirmed transactions. (asynchronously) - * Returns the list of confirmed transactions between within a date range. This call is available only when the indexer is running. - * @param address An account public key (required) - * @param firstRound Do not fetch any transactions before this round. (optional) - * @param lastRound Do not fetch any transactions after this round. (optional) - * @param fromDate Do not fetch any transactions before this date. (enabled only with indexer) (optional) - * @param toDate Do not fetch any transactions after this date. (enabled only with indexer) (optional) - * @param max maximum transactions to show (default to 100) (optional) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call transactionsAsync(String address, java.math.BigInteger firstRound, java.math.BigInteger lastRound, LocalDate fromDate, LocalDate toDate, java.math.BigInteger max, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = transactionsValidateBeforeCall(address, firstRound, lastRound, fromDate, toDate, max, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } - /** - * Build call for waitForBlock - * @param round The round to wait until returning status (required) - * @param progressListener Progress listener - * @param progressRequestListener Progress request listener - * @return Call to execute - * @throws ApiException If fail to serialize the request body object - */ - public com.squareup.okhttp.Call waitForBlockCall(java.math.BigInteger round, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/v1/status/wait-for-block-after/{round}/" - .replaceAll("\\{" + "round" + "\\}", apiClient.escapeString(round.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - - Map localVarHeaderParams = new HashMap(); - - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { - "application/json" - }; - final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept); - - final String[] localVarContentTypes = { - "application/json" - }; - final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); - localVarHeaderParams.put("Content-Type", localVarContentType); - - if(progressListener != null) { - apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() { - @Override - public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException { - com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request()); - return originalResponse.newBuilder() - .body(new ProgressResponseBody(originalResponse.body(), progressListener)) - .build(); - } - }); - } - - String[] localVarAuthNames = new String[] { "api_key" }; - return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener); - } - - @SuppressWarnings("rawtypes") - private com.squareup.okhttp.Call waitForBlockValidateBeforeCall(java.math.BigInteger round, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { - - // verify the required parameter 'round' is set - if (round == null) { - throw new ApiException("Missing the required parameter 'round' when calling waitForBlock(Async)"); - } - - - com.squareup.okhttp.Call call = waitForBlockCall(round, progressListener, progressRequestListener); - return call; - - } - - /** - * Gets the node status after waiting for the given round. - * Waits for a block to appear after round {round} and returns the node's status at the time. - * @param round The round to wait until returning status (required) - * @return NodeStatus - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public NodeStatus waitForBlock(java.math.BigInteger round) throws ApiException { - ApiResponse resp = waitForBlockWithHttpInfo(round); - return resp.getData(); - } - - /** - * Gets the node status after waiting for the given round. - * Waits for a block to appear after round {round} and returns the node's status at the time. - * @param round The round to wait until returning status (required) - * @return ApiResponse<NodeStatus> - * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body - */ - public ApiResponse waitForBlockWithHttpInfo(java.math.BigInteger round) throws ApiException { - com.squareup.okhttp.Call call = waitForBlockValidateBeforeCall(round, null, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return apiClient.execute(call, localVarReturnType); - } - - /** - * Gets the node status after waiting for the given round. (asynchronously) - * Waits for a block to appear after round {round} and returns the node's status at the time. - * @param round The round to wait until returning status (required) - * @param callback The callback to be executed when the API call finishes - * @return The request call - * @throws ApiException If fail to process the API call, e.g. serializing the request body object - */ - public com.squareup.okhttp.Call waitForBlockAsync(java.math.BigInteger round, final ApiCallback callback) throws ApiException { - - ProgressResponseBody.ProgressListener progressListener = null; - ProgressRequestBody.ProgressRequestListener progressRequestListener = null; - - if (callback != null) { - progressListener = new ProgressResponseBody.ProgressListener() { - @Override - public void update(long bytesRead, long contentLength, boolean done) { - callback.onDownloadProgress(bytesRead, contentLength, done); - } - }; - - progressRequestListener = new ProgressRequestBody.ProgressRequestListener() { - @Override - public void onRequestProgress(long bytesWritten, long contentLength, boolean done) { - callback.onUploadProgress(bytesWritten, contentLength, done); - } - }; - } - - com.squareup.okhttp.Call call = waitForBlockValidateBeforeCall(round, progressListener, progressRequestListener); - Type localVarReturnType = new TypeToken(){}.getType(); - apiClient.executeAsync(call, localVarReturnType, callback); - return call; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/auth/ApiKeyAuth.java b/src/main/java/com/algorand/algosdk/algod/client/auth/ApiKeyAuth.java deleted file mode 100644 index d11d0dfaa..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/auth/ApiKeyAuth.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.auth; - -import com.algorand.algosdk.algod.client.lib.Pair; - -import java.util.List; -import java.util.Map; - -@Deprecated -public class ApiKeyAuth implements Authentication { - private final String location; - private final String paramName; - - private String apiKey; - private String apiKeyPrefix; - - public ApiKeyAuth(String location, String paramName) { - this.location = location; - this.paramName = paramName; - } - - public String getLocation() { - return location; - } - - public String getParamName() { - return paramName; - } - - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getApiKeyPrefix() { - return apiKeyPrefix; - } - - public void setApiKeyPrefix(String apiKeyPrefix) { - this.apiKeyPrefix = apiKeyPrefix; - } - - @Override - public void applyToParams(List queryParams, Map headerParams) { - if (apiKey == null) { - return; - } - String value; - if (apiKeyPrefix != null) { - value = apiKeyPrefix + " " + apiKey; - } else { - value = apiKey; - } - if ("query".equals(location)) { - queryParams.add(new Pair(paramName, value)); - } else if ("header".equals(location)) { - headerParams.put(paramName, value); - } - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/auth/Authentication.java b/src/main/java/com/algorand/algosdk/algod/client/auth/Authentication.java deleted file mode 100644 index a9b916404..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/auth/Authentication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.auth; - -import com.algorand.algosdk.algod.client.lib.Pair; - -import java.util.List; -import java.util.Map; - -@Deprecated -public interface Authentication { - /** - * Apply authentication settings to header and query params. - * - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - */ - void applyToParams(List queryParams, Map headerParams); -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/auth/HttpBasicAuth.java b/src/main/java/com/algorand/algosdk/algod/client/auth/HttpBasicAuth.java deleted file mode 100644 index 6e72de595..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/auth/HttpBasicAuth.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.auth; - -import com.algorand.algosdk.algod.client.lib.Pair; -import com.squareup.okhttp.Credentials; - -import java.util.List; -import java.util.Map; - -@Deprecated -public class HttpBasicAuth implements Authentication { - private String username; - private String password; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @Override - public void applyToParams(List queryParams, Map headerParams) { - if (username == null && password == null) { - return; - } - headerParams.put("Authorization", Credentials.basic( - username == null ? "" : username, - password == null ? "" : password)); - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/auth/OAuth.java b/src/main/java/com/algorand/algosdk/algod/client/auth/OAuth.java deleted file mode 100644 index 4e7678c2b..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/auth/OAuth.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.auth; - -import com.algorand.algosdk.algod.client.lib.Pair; - -import java.util.List; -import java.util.Map; - -@Deprecated -public class OAuth implements Authentication { - private String accessToken; - - public String getAccessToken() { - return accessToken; - } - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - @Override - public void applyToParams(List queryParams, Map headerParams) { - if (accessToken != null) { - headerParams.put("Authorization", "Bearer " + accessToken); - } - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/auth/OAuthFlow.java b/src/main/java/com/algorand/algosdk/algod/client/auth/OAuthFlow.java deleted file mode 100644 index f7a56a0e1..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/auth/OAuthFlow.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.auth; - -@Deprecated -public enum OAuthFlow { - accessCode, implicit, password, application -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/lib/Pair.java b/src/main/java/com/algorand/algosdk/algod/client/lib/Pair.java deleted file mode 100644 index 31189fb43..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/lib/Pair.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.lib; - -@Deprecated -public class Pair { - private String name = ""; - private String value = ""; - - public Pair (String name, String value) { - setName(name); - setValue(value); - } - - private void setName(String name) { - if (!isValidString(name)) return; - - this.name = name; - } - - private void setValue(String value) { - if (!isValidString(value)) return; - - this.value = value; - } - - public String getName() { - return this.name; - } - - public String getValue() { - return this.value; - } - - private boolean isValidString(String arg) { - if (arg == null) return false; - if (arg.trim().isEmpty()) return false; - - return true; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/Account.java b/src/main/java/com/algorand/algosdk/algod/client/model/Account.java deleted file mode 100644 index 3e8b60460..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/Account.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.util.Map; - -import org.apache.commons.lang3.ObjectUtils; - -/** - * Account Description - */ -@ApiModel(description = "Account Description") - -@Deprecated -public class Account { - @SerializedName("address") - private String address = null; - - @SerializedName("amount") - private java.math.BigInteger amount = null; - - @SerializedName("amountwithoutpendingrewards") - private java.math.BigInteger amountwithoutpendingrewards = null; - - @SerializedName("assets") - private Map assets = null; - - @SerializedName("participation") - private Participation participation = null; - - @SerializedName("pendingrewards") - private java.math.BigInteger pendingrewards = null; - - @SerializedName("rewards") - private java.math.BigInteger rewards = null; - - @SerializedName("round") - private java.math.BigInteger round = null; - - @SerializedName("status") - private String status = null; - - @SerializedName("thisassettotal") - private Map thisassettotal = null; - - public Account address(String address) { - this.address = address; - return this; - } - - /** - * Address indicates the account public key - * @return address - **/ - @ApiModelProperty(required = true, value = "Address indicates the account public key") - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public Account amount(java.math.BigInteger amount) { - this.amount = amount; - return this; - } - - /** - * Amount indicates the total number of MicroAlgos in the account - * @return amount - **/ - @ApiModelProperty(required = true, value = "Amount indicates the total number of MicroAlgos in the account") - public java.math.BigInteger getAmount() { - return amount; - } - - public void setAmount(java.math.BigInteger amount) { - this.amount = amount; - } - - public Account amountwithoutpendingrewards(java.math.BigInteger amountwithoutpendingrewards) { - this.amountwithoutpendingrewards = amountwithoutpendingrewards; - return this; - } - - /** - * AmountWithoutPendingRewards specifies the amount of MicroAlgos in the account, without the pending rewards. - * @return amountwithoutpendingrewards - **/ - @ApiModelProperty(required = true, value = "AmountWithoutPendingRewards specifies the amount of MicroAlgos in the account, without the pending rewards.") - public java.math.BigInteger getAmountwithoutpendingrewards() { - return amountwithoutpendingrewards; - } - - public void setAmountwithoutpendingrewards(java.math.BigInteger amountwithoutpendingrewards) { - this.amountwithoutpendingrewards = amountwithoutpendingrewards; - } - - public Account assets(Map assets) { - this.assets = assets; - return this; - } - - /** - * Assets specifies the holdings of assets by this account, indexed by the asset ID. - * @return assets - **/ - @ApiModelProperty(value = "Assets specifies the holdings of assets by this account, indexed by the asset ID.") - public AssetHolding getHolding(java.math.BigInteger assetIndex) { - return assets.get(assetIndex); - } - - public void setAssets(Map assets) { - this.assets = assets; - } - - public Account participation(Participation participation) { - this.participation = participation; - return this; - } - - /** - * Get participation - * @return participation - **/ - @ApiModelProperty(value = "") - public Participation getParticipation() { - return participation; - } - - public void setParticipation(Participation participation) { - this.participation = participation; - } - - public Account pendingrewards(java.math.BigInteger pendingrewards) { - this.pendingrewards = pendingrewards; - return this; - } - - /** - * PendingRewards specifies the amount of MicroAlgos of pending rewards in this account. - * @return pendingrewards - **/ - @ApiModelProperty(required = true, value = "PendingRewards specifies the amount of MicroAlgos of pending rewards in this account.") - public java.math.BigInteger getPendingrewards() { - return pendingrewards; - } - - public void setPendingrewards(java.math.BigInteger pendingrewards) { - this.pendingrewards = pendingrewards; - } - - public Account rewards(java.math.BigInteger rewards) { - this.rewards = rewards; - return this; - } - - /** - * Rewards indicates the total rewards of MicroAlgos the account has received, including pending rewards. - * @return rewards - **/ - @ApiModelProperty(required = true, value = "Rewards indicates the total rewards of MicroAlgos the account has received, including pending rewards.") - public java.math.BigInteger getRewards() { - return rewards; - } - - public void setRewards(java.math.BigInteger rewards) { - this.rewards = rewards; - } - - public Account round(java.math.BigInteger round) { - this.round = round; - return this; - } - - /** - * Round indicates the round for which this information is relevant - * @return round - **/ - @ApiModelProperty(required = true, value = "Round indicates the round for which this information is relevant") - public java.math.BigInteger getRound() { - return round; - } - - public void setRound(java.math.BigInteger round) { - this.round = round; - } - - public Account status(String status) { - this.status = status; - return this; - } - - /** - * Status indicates the delegation status of the account's MicroAlgos Offline - indicates that the associated account is delegated. Online - indicates that the associated account used as part of the delegation pool. NotParticipating - indicates that the associated account is neither a delegator nor a delegate. - * @return status - **/ - @ApiModelProperty(required = true, value = "Status indicates the delegation status of the account's MicroAlgos Offline - indicates that the associated account is delegated. Online - indicates that the associated account used as part of the delegation pool. NotParticipating - indicates that the associated account is neither a delegator nor a delegate.") - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Account thisassettotal(Map thisassettotal) { - this.thisassettotal = thisassettotal; - return this; - } - - /** - * AssetParams specifies the parameters of assets created by this account. - * @return thisassettotal - **/ - @ApiModelProperty(value = "AssetParams specifies the parameters of assets created by this account.") - public Map getThisassettotal() { - return thisassettotal; - } - - public void setThisassettotal(Map thisassettotal) { - this.thisassettotal = thisassettotal; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Account account = (Account) o; - return ObjectUtils.equals(this.address, account.address) && - ObjectUtils.equals(this.amount, account.amount) && - ObjectUtils.equals(this.amountwithoutpendingrewards, account.amountwithoutpendingrewards) && - ObjectUtils.equals(this.assets, account.assets) && - ObjectUtils.equals(this.participation, account.participation) && - ObjectUtils.equals(this.pendingrewards, account.pendingrewards) && - ObjectUtils.equals(this.rewards, account.rewards) && - ObjectUtils.equals(this.round, account.round) && - ObjectUtils.equals(this.status, account.status) && - ObjectUtils.equals(this.thisassettotal, account.thisassettotal); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(address, amount, amountwithoutpendingrewards, assets, participation, pendingrewards, rewards, round, status, thisassettotal); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Account {\n"); - - sb.append(" address: ").append(toIndentedString(address)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" amountwithoutpendingrewards: ").append(toIndentedString(amountwithoutpendingrewards)).append("\n"); - sb.append(" assets: ").append(toIndentedString(assets)).append("\n"); - sb.append(" participation: ").append(toIndentedString(participation)).append("\n"); - sb.append(" pendingrewards: ").append(toIndentedString(pendingrewards)).append("\n"); - sb.append(" rewards: ").append(toIndentedString(rewards)).append("\n"); - sb.append(" round: ").append(toIndentedString(round)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" thisassettotal: ").append(toIndentedString(thisassettotal)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/AssetHolding.java b/src/main/java/com/algorand/algosdk/algod/client/model/AssetHolding.java deleted file mode 100644 index 2417055fc..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/AssetHolding.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - */ - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel(description = "AssetParams specifies the holdings of a particular asset.") -@Deprecated -public class AssetHolding { - @SerializedName("creator") - private String creator = null; - - @SerializedName("amount") - private java.math.BigInteger amount = null; - - @SerializedName("frozen") - private Boolean frozen = null; - - - /** - * Creator specifies the 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. - * @return creator - */ - @ApiModelProperty(value = "Creator specifies the 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.") - public String getCreator() { - return creator; - } - - /** - * Amount specifies the number of units held. - * @return amount - */ - @ApiModelProperty(value = "Amount specifies the number of units held.") - public java.math.BigInteger getAmount() { - return amount; - } - - /** - * Frozen specifies whether this holding is frozen. - * @return frozen - */ - @ApiModelProperty(value = "Frozen specifies whether this holding is frozen.") - public Boolean getFrozen() { - return frozen; - } -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/AssetParams.java b/src/main/java/com/algorand/algosdk/algod/client/model/AssetParams.java deleted file mode 100644 index 27fd76eee..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/AssetParams.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package com.algorand.algosdk.algod.client.model; - -import org.apache.commons.lang3.ObjectUtils; -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -/** - * AssetParams specifies the parameteres for an asset - */ - -@ApiModel(description = "AssetParams specifies the parameters for an asset") -@Deprecated -public class AssetParams { - @SerializedName("assetname") - private String assetname = null; - - @SerializedName("clawbackaddr") - private String clawbackaddr = null; - - @SerializedName("creator") - private String creator = null; - - @SerializedName("decimals") - private Integer decimals = null; - - @SerializedName("defaultfrozen") - private Boolean defaultfrozen = null; - - @SerializedName("freezeaddr") - private String freezeaddr = null; - - @SerializedName("managerkey") - private String managerkey = null; - - @SerializedName("metadatahash") - private byte[] metadatahash = null; - - @SerializedName("reserveaddr") - private String reserveaddr = null; - - @SerializedName("total") - private Integer total = null; - - @SerializedName("unitname") - private String unitname = null; - - @SerializedName("url") - private String url = null; - - public AssetParams assetname(String assetname) { - this.assetname = assetname; - return this; - } - - /** - * AssetName specifies the name of this asset, as supplied by the creator. - * @return assetname - **/ - @ApiModelProperty(value = "AssetName specifies the name of this asset, as supplied by the creator.") - public String getAssetname() { - return assetname; - } - - public void setAssetname(String assetname) { - this.assetname = assetname; - } - - public AssetParams clawbackaddr(String clawbackaddr) { - this.clawbackaddr = clawbackaddr; - return this; - } - - /** - * ClawbackAddr specifies the address used to clawback holdings of this asset. If empty, clawback is not permitted. - * @return clawbackaddr - **/ - @ApiModelProperty(value = "ClawbackAddr specifies the address used to clawback holdings of this asset. If empty, clawback is not permitted.") - public String getClawbackaddr() { - return clawbackaddr; - } - - public void setClawbackaddr(String clawbackaddr) { - this.clawbackaddr = clawbackaddr; - } - - public AssetParams creator(String creator) { - this.creator = creator; - return this; - } - - /** - * Creator specifies the 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. - * @return creator - **/ - @ApiModelProperty(required = true, value = "Creator specifies the 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.") - public String getCreator() { - return creator; - } - - public void setCreator(String creator) { - this.creator = creator; - } - - public AssetParams decimals(Integer decimals) { - this.decimals = decimals; - return this; - } - - /** - * Decimals specifies the decimal precision of units of this asset. - * @return decimals - **/ - @ApiModelProperty(required = true, value = "Decimals specifies the decimal precision of units of this asset.") - public Integer getDecimals() { - return decimals; - } - - public void setDecimals(Integer decimals) { - this.decimals = decimals; - } - - public AssetParams defaultfrozen(Boolean defaultfrozen) { - this.defaultfrozen = defaultfrozen; - return this; - } - - /** - * DefaultFrozen specifies whether holdings in this asset are frozen by default. - * @return defaultfrozen - **/ - @ApiModelProperty(value = "DefaultFrozen specifies whether holdings in this asset are frozen by default.") - public Boolean isDefaultfrozen() { - return defaultfrozen; - } - - public void setDefaultfrozen(Boolean defaultfrozen) { - this.defaultfrozen = defaultfrozen; - } - - public AssetParams freezeaddr(String freezeaddr) { - this.freezeaddr = freezeaddr; - return this; - } - - /** - * FreezeAddr specifies the address used to freeze holdings of this asset. If empty, freezing is not permitted. - * @return freezeaddr - **/ - @ApiModelProperty(value = "FreezeAddr specifies the address used to freeze holdings of this asset. If empty, freezing is not permitted.") - public String getFreezeaddr() { - return freezeaddr; - } - - public void setFreezeaddr(String freezeaddr) { - this.freezeaddr = freezeaddr; - } - - public AssetParams managerkey(String managerkey) { - this.managerkey = managerkey; - return this; - } - - /** - * ManagerAddr specifies the address used to manage the keys of this asset and to destroy it. - * @return managerkey - **/ - @ApiModelProperty(value = "ManagerAddr specifies the address used to manage the keys of this asset and to destroy it.") - public String getManagerkey() { - return managerkey; - } - - public void setManagerkey(String managerkey) { - this.managerkey = managerkey; - } - - public AssetParams metadatahash(byte[] metadatahash) { - this.metadatahash = metadatahash; - return this; - } - - /** - * MetadataHash specifies a commitment to some unspecified asset metadata. The format of this metadata is up to the application. - * @return metadatahash - **/ - @ApiModelProperty(value = "MetadataHash specifies a commitment to some unspecified asset metadata. The format of this metadata is up to the application.") - public byte[] getMetadatahash() { - return metadatahash; - } - - public void setMetadatahash(byte[] metadatahash) { - this.metadatahash = metadatahash; - } - - public AssetParams reserveaddr(String reserveaddr) { - this.reserveaddr = reserveaddr; - return this; - } - - /** - * ReserveAddr specifies the address holding reserve (non-minted) units of this asset. - * @return reserveaddr - **/ - @ApiModelProperty(value = "ReserveAddr specifies the address holding reserve (non-minted) units of this asset.") - public String getReserveaddr() { - return reserveaddr; - } - - public void setReserveaddr(String reserveaddr) { - this.reserveaddr = reserveaddr; - } - - public AssetParams total(Integer total) { - this.total = total; - return this; - } - - /** - * Total specifies the total number of units of this asset. - * @return total - **/ - @ApiModelProperty(required = true, value = "Total specifies the total number of units of this asset.") - public Integer getTotal() { - return total; - } - - public void setTotal(Integer total) { - this.total = total; - } - - public AssetParams unitname(String unitname) { - this.unitname = unitname; - return this; - } - - /** - * UnitName specifies the name of a unit of this asset, as supplied by the creator. - * @return unitname - **/ - @ApiModelProperty(value = "UnitName specifies the name of a unit of this asset, as supplied by the creator.") - public String getUnitname() { - return unitname; - } - - public void setUnitname(String unitname) { - this.unitname = unitname; - } - - public AssetParams url(String url) { - this.url = url; - return this; - } - - /** - * URL specifies a URL where more information about the asset can be retrieved - * @return url - **/ - @ApiModelProperty(value = "URL specifies a URL where more information about the asset can be retrieved") - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - AssetParams assetParams = (AssetParams) o; - return ObjectUtils.equals(this.assetname, assetParams.assetname) && - ObjectUtils.equals(this.clawbackaddr, assetParams.clawbackaddr) && - ObjectUtils.equals(this.creator, assetParams.creator) && - ObjectUtils.equals(this.decimals, assetParams.decimals) && - ObjectUtils.equals(this.defaultfrozen, assetParams.defaultfrozen) && - ObjectUtils.equals(this.freezeaddr, assetParams.freezeaddr) && - ObjectUtils.equals(this.managerkey, assetParams.managerkey) && - ObjectUtils.equals(this.metadatahash, assetParams.metadatahash) && - ObjectUtils.equals(this.reserveaddr, assetParams.reserveaddr) && - ObjectUtils.equals(this.total, assetParams.total) && - ObjectUtils.equals(this.unitname, assetParams.unitname) && - ObjectUtils.equals(this.url, assetParams.url); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(assetname, clawbackaddr, creator, decimals, defaultfrozen, freezeaddr, managerkey, metadatahash, reserveaddr, total, unitname, url); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class AssetParams {\n"); - - sb.append(" assetname: ").append(toIndentedString(assetname)).append("\n"); - sb.append(" clawbackaddr: ").append(toIndentedString(clawbackaddr)).append("\n"); - // creator is skipped to match with Transaction.AssetParams - sb.append(" decimals: ").append(toIndentedString(decimals)).append("\n"); - sb.append(" defaultfrozen: ").append(toIndentedString(defaultfrozen)).append("\n"); - sb.append(" freezeaddr: ").append(toIndentedString(freezeaddr)).append("\n"); - sb.append(" managerkey: ").append(toIndentedString(managerkey)).append("\n"); - sb.append(" metadatahash: ").append(toIndentedString(metadatahash)).append("\n"); - sb.append(" reserveaddr: ").append(toIndentedString(reserveaddr)).append("\n"); - sb.append(" total: ").append(toIndentedString(total)).append("\n"); - sb.append(" unitname: ").append(toIndentedString(unitname)).append("\n"); - sb.append(" url: ").append(toIndentedString(url)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/Block.java b/src/main/java/com/algorand/algosdk/algod/client/model/Block.java deleted file mode 100644 index 16aeeddea..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/Block.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * Block contains a block information - */ -@ApiModel(description = "Block contains a block information") -@Deprecated -public class Block { - @SerializedName("currentProtocol") - private String currentProtocol = null; - - @SerializedName("frac") - private java.math.BigInteger frac = null; - - @SerializedName("hash") - private String hash = null; - - @SerializedName("nextProtocol") - private String nextProtocol = null; - - @SerializedName("nextProtocolApprovals") - private java.math.BigInteger nextProtocolApprovals = null; - - @SerializedName("nextProtocolSwitchOn") - private java.math.BigInteger nextProtocolSwitchOn = null; - - @SerializedName("nextProtocolVoteBefore") - private java.math.BigInteger nextProtocolVoteBefore = null; - - @SerializedName("period") - private java.math.BigInteger period = null; - - @SerializedName("previousBlockHash") - private String previousBlockHash = null; - - @SerializedName("proposer") - private String proposer = null; - - @SerializedName("rate") - private java.math.BigInteger rate = null; - - @SerializedName("reward") - private java.math.BigInteger reward = null; - - @SerializedName("round") - private java.math.BigInteger round = null; - - @SerializedName("seed") - private String seed = null; - - @SerializedName("timestamp") - private java.math.BigInteger timestamp = null; - - @SerializedName("txnRoot") - private String txnRoot = null; - - @SerializedName("txns") - private TransactionList txns = null; - - @SerializedName("upgradeApprove") - private Boolean upgradeApprove = null; - - @SerializedName("upgradePropose") - private String upgradePropose = null; - - public Block currentProtocol(String currentProtocol) { - this.currentProtocol = currentProtocol; - return this; - } - - /** - * CurrentProtocol is a string that represents the current protocol - * @return currentProtocol - **/ - @ApiModelProperty(required = true, value = "CurrentProtocol is a string that represents the current protocol") - public String getCurrentProtocol() { - return currentProtocol; - } - - public void setCurrentProtocol(String currentProtocol) { - this.currentProtocol = currentProtocol; - } - - public Block frac(java.math.BigInteger frac) { - this.frac = frac; - return this; - } - - /** - * The number of leftover MicroAlgos after the distribution of RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round. - * @return frac - **/ - @ApiModelProperty(value = "The number of leftover MicroAlgos after the distribution of RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round.") - public java.math.BigInteger getFrac() { - return frac; - } - - public void setFrac(java.math.BigInteger frac) { - this.frac = frac; - } - - public Block hash(String hash) { - this.hash = hash; - return this; - } - - /** - * Hash is the current block hash - * @return hash - **/ - @ApiModelProperty(required = true, value = "Hash is the current block hash") - public String getHash() { - return hash; - } - - public void setHash(String hash) { - this.hash = hash; - } - - public Block nextProtocol(String nextProtocol) { - this.nextProtocol = nextProtocol; - return this; - } - - /** - * NextProtocol is a string that represents the next proposed protocol - * @return nextProtocol - **/ - @ApiModelProperty(required = true, value = "NextProtocol is a string that represents the next proposed protocol") - public String getNextProtocol() { - return nextProtocol; - } - - public void setNextProtocol(String nextProtocol) { - this.nextProtocol = nextProtocol; - } - - public Block nextProtocolApprovals(java.math.BigInteger nextProtocolApprovals) { - this.nextProtocolApprovals = nextProtocolApprovals; - return this; - } - - /** - * NextProtocolApprovals is the number of blocks which approved the protocol upgrade - * @return nextProtocolApprovals - **/ - @ApiModelProperty(required = true, value = "NextProtocolApprovals is the number of blocks which approved the protocol upgrade") - public java.math.BigInteger getNextProtocolApprovals() { - return nextProtocolApprovals; - } - - public void setNextProtocolApprovals(java.math.BigInteger nextProtocolApprovals) { - this.nextProtocolApprovals = nextProtocolApprovals; - } - - public Block nextProtocolSwitchOn(java.math.BigInteger nextProtocolSwitchOn) { - this.nextProtocolSwitchOn = nextProtocolSwitchOn; - return this; - } - - /** - * NextProtocolSwitchOn is the round on which the protocol upgrade will take effect - * @return nextProtocolSwitchOn - **/ - @ApiModelProperty(required = true, value = "NextProtocolSwitchOn is the round on which the protocol upgrade will take effect") - public java.math.BigInteger getNextProtocolSwitchOn() { - return nextProtocolSwitchOn; - } - - public void setNextProtocolSwitchOn(java.math.BigInteger nextProtocolSwitchOn) { - this.nextProtocolSwitchOn = nextProtocolSwitchOn; - } - - public Block nextProtocolVoteBefore(java.math.BigInteger nextProtocolVoteBefore) { - this.nextProtocolVoteBefore = nextProtocolVoteBefore; - return this; - } - - /** - * NextProtocolVoteBefore is the deadline round for this protocol upgrade (No votes will be consider after this round) - * @return nextProtocolVoteBefore - **/ - @ApiModelProperty(required = true, value = "NextProtocolVoteBefore is the deadline round for this protocol upgrade (No votes will be consider after this round)") - public java.math.BigInteger getNextProtocolVoteBefore() { - return nextProtocolVoteBefore; - } - - public void setNextProtocolVoteBefore(java.math.BigInteger nextProtocolVoteBefore) { - this.nextProtocolVoteBefore = nextProtocolVoteBefore; - } - - public Block period(java.math.BigInteger period) { - this.period = period; - return this; - } - - /** - * Period is the period on which the block was confirmed - * @return period - **/ - @ApiModelProperty(required = true, value = "Period is the period on which the block was confirmed") - public java.math.BigInteger getPeriod() { - return period; - } - - public void setPeriod(java.math.BigInteger period) { - this.period = period; - } - - public Block previousBlockHash(String previousBlockHash) { - this.previousBlockHash = previousBlockHash; - return this; - } - - /** - * PreviousBlockHash is the previous block hash - * @return previousBlockHash - **/ - @ApiModelProperty(required = true, value = "PreviousBlockHash is the previous block hash") - public String getPreviousBlockHash() { - return previousBlockHash; - } - - public void setPreviousBlockHash(String previousBlockHash) { - this.previousBlockHash = previousBlockHash; - } - - public Block proposer(String proposer) { - this.proposer = proposer; - return this; - } - - /** - * Proposer is the address of this block proposer - * @return proposer - **/ - @ApiModelProperty(required = true, value = "Proposer is the address of this block proposer") - public String getProposer() { - return proposer; - } - - public void setProposer(String proposer) { - this.proposer = proposer; - } - - public Block rate(java.math.BigInteger rate) { - this.rate = rate; - return this; - } - - /** - * The number of new MicroAlgos added to the participation stake from rewards at the next round. - * @return rate - **/ - @ApiModelProperty(value = "The number of new MicroAlgos added to the participation stake from rewards at the next round.") - public java.math.BigInteger getRate() { - return rate; - } - - public void setRate(java.math.BigInteger rate) { - this.rate = rate; - } - - public Block reward(java.math.BigInteger reward) { - this.reward = reward; - return this; - } - - /** - * RewardsLevel specifies how many rewards, in MicroAlgos, have been distributed to each config.Protocol.RewardUnit of MicroAlgos since genesis. - * @return reward - **/ - @ApiModelProperty(value = "RewardsLevel specifies how many rewards, in MicroAlgos, have been distributed to each config.Protocol.RewardUnit of MicroAlgos since genesis.") - public java.math.BigInteger getReward() { - return reward; - } - - public void setReward(java.math.BigInteger reward) { - this.reward = reward; - } - - public Block round(java.math.BigInteger round) { - this.round = round; - return this; - } - - /** - * Round is the current round on which this block was appended to the chain - * @return round - **/ - @ApiModelProperty(required = true, value = "Round is the current round on which this block was appended to the chain") - public java.math.BigInteger getRound() { - return round; - } - - public void setRound(java.math.BigInteger round) { - this.round = round; - } - - public Block seed(String seed) { - this.seed = seed; - return this; - } - - /** - * Seed is the sortition seed - * @return seed - **/ - @ApiModelProperty(required = true, value = "Seed is the sortition seed") - public String getSeed() { - return seed; - } - - public void setSeed(String seed) { - this.seed = seed; - } - - public Block timestamp(java.math.BigInteger timestamp) { - this.timestamp = timestamp; - return this; - } - - /** - * TimeStamp in seconds since epoch - * @return timestamp - **/ - @ApiModelProperty(required = true, value = "TimeStamp in seconds since epoch") - public java.math.BigInteger getTimestamp() { - return timestamp; - } - - public void setTimestamp(java.math.BigInteger timestamp) { - this.timestamp = timestamp; - } - - public Block txnRoot(String txnRoot) { - this.txnRoot = txnRoot; - return this; - } - - /** - * TransactionsRoot authenticates the set of transactions appearing in the block. More specifically, it's the root of a merkle tree whose leaves are the block's Txids, in lexicographic order. For the empty block, it's 0. Note that the TxnRoot does not authenticate the signatures on the transactions, only the transactions themselves. Two blocks with the same transactions but in a different order and with different signatures will have the same TxnRoot. - * @return txnRoot - **/ - @ApiModelProperty(required = true, value = "TransactionsRoot authenticates the set of transactions appearing in the block. More specifically, it's the root of a merkle tree whose leaves are the block's Txids, in lexicographic order. For the empty block, it's 0. Note that the TxnRoot does not authenticate the signatures on the transactions, only the transactions themselves. Two blocks with the same transactions but in a different order and with different signatures will have the same TxnRoot.") - public String getTxnRoot() { - return txnRoot; - } - - public void setTxnRoot(String txnRoot) { - this.txnRoot = txnRoot; - } - - public Block txns(TransactionList txns) { - this.txns = txns; - return this; - } - - /** - * Get txns - * @return txns - **/ - @ApiModelProperty(value = "") - public TransactionList getTxns() { - return txns; - } - - public void setTxns(TransactionList txns) { - this.txns = txns; - } - - public Block upgradeApprove(Boolean upgradeApprove) { - this.upgradeApprove = upgradeApprove; - return this; - } - - /** - * UpgradeApprove indicates a yes vote for the current proposal - * @return upgradeApprove - **/ - @ApiModelProperty(required = true, value = "UpgradeApprove indicates a yes vote for the current proposal") - public Boolean isUpgradeApprove() { - return upgradeApprove; - } - - public void setUpgradeApprove(Boolean upgradeApprove) { - this.upgradeApprove = upgradeApprove; - } - - public Block upgradePropose(String upgradePropose) { - this.upgradePropose = upgradePropose; - return this; - } - - /** - * UpgradePropose indicates a proposed upgrade - * @return upgradePropose - **/ - @ApiModelProperty(required = true, value = "UpgradePropose indicates a proposed upgrade") - public String getUpgradePropose() { - return upgradePropose; - } - - public void setUpgradePropose(String upgradePropose) { - this.upgradePropose = upgradePropose; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Block block = (Block) o; - return ObjectUtils.equals(this.currentProtocol, block.currentProtocol) && - ObjectUtils.equals(this.frac, block.frac) && - ObjectUtils.equals(this.hash, block.hash) && - ObjectUtils.equals(this.nextProtocol, block.nextProtocol) && - ObjectUtils.equals(this.nextProtocolApprovals, block.nextProtocolApprovals) && - ObjectUtils.equals(this.nextProtocolSwitchOn, block.nextProtocolSwitchOn) && - ObjectUtils.equals(this.nextProtocolVoteBefore, block.nextProtocolVoteBefore) && - ObjectUtils.equals(this.period, block.period) && - ObjectUtils.equals(this.previousBlockHash, block.previousBlockHash) && - ObjectUtils.equals(this.proposer, block.proposer) && - ObjectUtils.equals(this.rate, block.rate) && - ObjectUtils.equals(this.reward, block.reward) && - ObjectUtils.equals(this.round, block.round) && - ObjectUtils.equals(this.seed, block.seed) && - ObjectUtils.equals(this.timestamp, block.timestamp) && - ObjectUtils.equals(this.txnRoot, block.txnRoot) && - ObjectUtils.equals(this.txns, block.txns) && - ObjectUtils.equals(this.upgradeApprove, block.upgradeApprove) && - ObjectUtils.equals(this.upgradePropose, block.upgradePropose); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(currentProtocol, frac, hash, nextProtocol, nextProtocolApprovals, nextProtocolSwitchOn, nextProtocolVoteBefore, period, previousBlockHash, proposer, rate, reward, round, seed, timestamp, txnRoot, txns, upgradeApprove, upgradePropose); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Block {\n"); - - sb.append(" currentProtocol: ").append(toIndentedString(currentProtocol)).append("\n"); - sb.append(" frac: ").append(toIndentedString(frac)).append("\n"); - sb.append(" hash: ").append(toIndentedString(hash)).append("\n"); - sb.append(" nextProtocol: ").append(toIndentedString(nextProtocol)).append("\n"); - sb.append(" nextProtocolApprovals: ").append(toIndentedString(nextProtocolApprovals)).append("\n"); - sb.append(" nextProtocolSwitchOn: ").append(toIndentedString(nextProtocolSwitchOn)).append("\n"); - sb.append(" nextProtocolVoteBefore: ").append(toIndentedString(nextProtocolVoteBefore)).append("\n"); - sb.append(" period: ").append(toIndentedString(period)).append("\n"); - sb.append(" previousBlockHash: ").append(toIndentedString(previousBlockHash)).append("\n"); - sb.append(" proposer: ").append(toIndentedString(proposer)).append("\n"); - sb.append(" rate: ").append(toIndentedString(rate)).append("\n"); - sb.append(" reward: ").append(toIndentedString(reward)).append("\n"); - sb.append(" round: ").append(toIndentedString(round)).append("\n"); - sb.append(" seed: ").append(toIndentedString(seed)).append("\n"); - sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" txnRoot: ").append(toIndentedString(txnRoot)).append("\n"); - sb.append(" txns: ").append(toIndentedString(txns)).append("\n"); - sb.append(" upgradeApprove: ").append(toIndentedString(upgradeApprove)).append("\n"); - sb.append(" upgradePropose: ").append(toIndentedString(upgradePropose)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/NodeStatus.java b/src/main/java/com/algorand/algosdk/algod/client/model/NodeStatus.java deleted file mode 100644 index 32f76c808..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/NodeStatus.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * NodeStatus contains the information about a node status - */ -@ApiModel(description = "NodeStatus contains the information about a node status") -@Deprecated -public class NodeStatus { - @SerializedName("catchupTime") - private java.math.BigInteger catchupTime = null; - - @SerializedName("lastConsensusVersion") - private String lastConsensusVersion = null; - - @SerializedName("lastRound") - private java.math.BigInteger lastRound = null; - - @SerializedName("nextConsensusVersion") - private String nextConsensusVersion = null; - - @SerializedName("nextConsensusVersionRound") - private java.math.BigInteger nextConsensusVersionRound = null; - - @SerializedName("nextConsensusVersionSupported") - private Boolean nextConsensusVersionSupported = null; - - @SerializedName("timeSinceLastRound") - private java.math.BigInteger timeSinceLastRound = null; - - public NodeStatus catchupTime(java.math.BigInteger catchupTime) { - this.catchupTime = catchupTime; - return this; - } - - /** - * CatchupTime in nanoseconds - * @return catchupTime - **/ - @ApiModelProperty(required = true, value = "CatchupTime in nanoseconds") - public java.math.BigInteger getCatchupTime() { - return catchupTime; - } - - public void setCatchupTime(java.math.BigInteger catchupTime) { - this.catchupTime = catchupTime; - } - - public NodeStatus lastConsensusVersion(String lastConsensusVersion) { - this.lastConsensusVersion = lastConsensusVersion; - return this; - } - - /** - * LastVersion indicates the last consensus version supported - * @return lastConsensusVersion - **/ - @ApiModelProperty(required = true, value = "LastVersion indicates the last consensus version supported") - public String getLastConsensusVersion() { - return lastConsensusVersion; - } - - public void setLastConsensusVersion(String lastConsensusVersion) { - this.lastConsensusVersion = lastConsensusVersion; - } - - public NodeStatus lastRound(java.math.BigInteger lastRound) { - this.lastRound = lastRound; - return this; - } - - /** - * LastRound indicates the last round seen - * @return lastRound - **/ - @ApiModelProperty(required = true, value = "LastRound indicates the last round seen") - public java.math.BigInteger getLastRound() { - return lastRound; - } - - public void setLastRound(java.math.BigInteger lastRound) { - this.lastRound = lastRound; - } - - public NodeStatus nextConsensusVersion(String nextConsensusVersion) { - this.nextConsensusVersion = nextConsensusVersion; - return this; - } - - /** - * NextVersion of consensus protocol to use - * @return nextConsensusVersion - **/ - @ApiModelProperty(required = true, value = "NextVersion of consensus protocol to use") - public String getNextConsensusVersion() { - return nextConsensusVersion; - } - - public void setNextConsensusVersion(String nextConsensusVersion) { - this.nextConsensusVersion = nextConsensusVersion; - } - - public NodeStatus nextConsensusVersionRound(java.math.BigInteger nextConsensusVersionRound) { - this.nextConsensusVersionRound = nextConsensusVersionRound; - return this; - } - - /** - * NextVersionRound is the round at which the next consensus version will apply - * @return nextConsensusVersionRound - **/ - @ApiModelProperty(required = true, value = "NextVersionRound is the round at which the next consensus version will apply") - public java.math.BigInteger getNextConsensusVersionRound() { - return nextConsensusVersionRound; - } - - public void setNextConsensusVersionRound(java.math.BigInteger nextConsensusVersionRound) { - this.nextConsensusVersionRound = nextConsensusVersionRound; - } - - public NodeStatus nextConsensusVersionSupported(Boolean nextConsensusVersionSupported) { - this.nextConsensusVersionSupported = nextConsensusVersionSupported; - return this; - } - - /** - * NextVersionSupported indicates whether the next consensus version is supported by this node - * @return nextConsensusVersionSupported - **/ - @ApiModelProperty(required = true, value = "NextVersionSupported indicates whether the next consensus version is supported by this node") - public Boolean isNextConsensusVersionSupported() { - return nextConsensusVersionSupported; - } - - public void setNextConsensusVersionSupported(Boolean nextConsensusVersionSupported) { - this.nextConsensusVersionSupported = nextConsensusVersionSupported; - } - - public NodeStatus timeSinceLastRound(java.math.BigInteger timeSinceLastRound) { - this.timeSinceLastRound = timeSinceLastRound; - return this; - } - - /** - * TimeSinceLastRound in nanoseconds - * @return timeSinceLastRound - **/ - @ApiModelProperty(required = true, value = "TimeSinceLastRound in nanoseconds") - public java.math.BigInteger getTimeSinceLastRound() { - return timeSinceLastRound; - } - - public void setTimeSinceLastRound(java.math.BigInteger timeSinceLastRound) { - this.timeSinceLastRound = timeSinceLastRound; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NodeStatus nodeStatus = (NodeStatus) o; - return ObjectUtils.equals(this.catchupTime, nodeStatus.catchupTime) && - ObjectUtils.equals(this.lastConsensusVersion, nodeStatus.lastConsensusVersion) && - ObjectUtils.equals(this.lastRound, nodeStatus.lastRound) && - ObjectUtils.equals(this.nextConsensusVersion, nodeStatus.nextConsensusVersion) && - ObjectUtils.equals(this.nextConsensusVersionRound, nodeStatus.nextConsensusVersionRound) && - ObjectUtils.equals(this.nextConsensusVersionSupported, nodeStatus.nextConsensusVersionSupported) && - ObjectUtils.equals(this.timeSinceLastRound, nodeStatus.timeSinceLastRound); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(catchupTime, lastConsensusVersion, lastRound, nextConsensusVersion, nextConsensusVersionRound, nextConsensusVersionSupported, timeSinceLastRound); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NodeStatus {\n"); - - sb.append(" catchupTime: ").append(toIndentedString(catchupTime)).append("\n"); - sb.append(" lastConsensusVersion: ").append(toIndentedString(lastConsensusVersion)).append("\n"); - sb.append(" lastRound: ").append(toIndentedString(lastRound)).append("\n"); - sb.append(" nextConsensusVersion: ").append(toIndentedString(nextConsensusVersion)).append("\n"); - sb.append(" nextConsensusVersionRound: ").append(toIndentedString(nextConsensusVersionRound)).append("\n"); - sb.append(" nextConsensusVersionSupported: ").append(toIndentedString(nextConsensusVersionSupported)).append("\n"); - sb.append(" timeSinceLastRound: ").append(toIndentedString(timeSinceLastRound)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/Participation.java b/src/main/java/com/algorand/algosdk/algod/client/model/Participation.java deleted file mode 100644 index 867597e8c..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/Participation.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import org.apache.commons.lang3.ObjectUtils; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -/** - * Participation Description - */ -@ApiModel(description = "Participation Description") -@Deprecated -public class Participation { - @SerializedName("partpkb64") - private byte[] partpkb64 = null; - - @SerializedName("votefst") - private Integer votefst = null; - - @SerializedName("votekd") - private Integer votekd = null; - - @SerializedName("votelst") - private Integer votelst = null; - - @SerializedName("vrfpkb64") - private byte[] vrfpkb64 = null; - - public Participation partpkb64(byte[] partpkb64) { - this.partpkb64 = partpkb64; - return this; - } - - /** - * ParticipationPK is the root participation public key (if any) currently registered for this round - * @return partpkb64 - **/ - @ApiModelProperty(required = true, value = "ParticipationPK is the root participation public key (if any) currently registered for this round") - public byte[] getPartpkb64() { - return partpkb64; - } - - public void setPartpkb64(byte[] partpkb64) { - this.partpkb64 = partpkb64; - } - - public Participation votefst(Integer votefst) { - this.votefst = votefst; - return this; - } - - /** - * VoteFirst is the first round for which this participation is valid. - * @return votefst - **/ - @ApiModelProperty(required = true, value = "VoteFirst is the first round for which this participation is valid.") - public Integer getVotefst() { - return votefst; - } - - public void setVotefst(Integer votefst) { - this.votefst = votefst; - } - - public Participation votekd(Integer votekd) { - this.votekd = votekd; - return this; - } - - /** - * VoteKeyDilution is the number of subkeys in for each batch of participation keys. - * @return votekd - **/ - @ApiModelProperty(required = true, value = "VoteKeyDilution is the number of subkeys in for each batch of participation keys.") - public Integer getVotekd() { - return votekd; - } - - public void setVotekd(Integer votekd) { - this.votekd = votekd; - } - - public Participation votelst(Integer votelst) { - this.votelst = votelst; - return this; - } - - /** - * VoteLast is the last round for which this participation is valid. - * @return votelst - **/ - @ApiModelProperty(required = true, value = "VoteLast is the last round for which this participation is valid.") - public Integer getVotelst() { - return votelst; - } - - public void setVotelst(Integer votelst) { - this.votelst = votelst; - } - - public Participation vrfpkb64(byte[] vrfpkb64) { - this.vrfpkb64 = vrfpkb64; - return this; - } - - /** - * VRFPK is the selection public key (if any) currently registered for this round - * @return vrfpkb64 - **/ - @ApiModelProperty(required = true, value = "VRFPK is the selection public key (if any) currently registered for this round") - public byte[] getVrfpkb64() { - return vrfpkb64; - } - - public void setVrfpkb64(byte[] vrfpkb64) { - this.vrfpkb64 = vrfpkb64; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Participation participation = (Participation) o; - return ObjectUtils.equals(this.partpkb64, participation.partpkb64) && - ObjectUtils.equals(this.votefst, participation.votefst) && - ObjectUtils.equals(this.votekd, participation.votekd) && - ObjectUtils.equals(this.votelst, participation.votelst) && - ObjectUtils.equals(this.vrfpkb64, participation.vrfpkb64); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(partpkb64, votefst, votekd, votelst, vrfpkb64); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Participation {\n"); - - sb.append(" partpkb64: ").append(toIndentedString(partpkb64)).append("\n"); - sb.append(" votefst: ").append(toIndentedString(votefst)).append("\n"); - sb.append(" votekd: ").append(toIndentedString(votekd)).append("\n"); - sb.append(" votelst: ").append(toIndentedString(votelst)).append("\n"); - sb.append(" vrfpkb64: ").append(toIndentedString(vrfpkb64)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/PaymentTransactionType.java b/src/main/java/com/algorand/algosdk/algod/client/model/PaymentTransactionType.java deleted file mode 100644 index 34f59bb4a..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/PaymentTransactionType.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * PaymentTransactionType contains the additional fields for a payment Transaction - */ -@ApiModel(description = "PaymentTransactionType contains the additional fields for a payment Transaction") -@Deprecated -public class PaymentTransactionType { - @SerializedName("amount") - private java.math.BigInteger amount = null; - - @SerializedName("close") - private String close = null; - - @SerializedName("closeamount") - private java.math.BigInteger closeamount = null; - - @SerializedName("closerewards") - private java.math.BigInteger closerewards = null; - - @SerializedName("to") - private String to = null; - - @SerializedName("torewards") - private java.math.BigInteger torewards = null; - - public PaymentTransactionType amount(java.math.BigInteger amount) { - this.amount = amount; - return this; - } - - /** - * Amount is the amount of MicroAlgos intended to be transferred - * @return amount - **/ - @ApiModelProperty(required = true, value = "Amount is the amount of MicroAlgos intended to be transferred") - public java.math.BigInteger getAmount() { - return amount; - } - - public void setAmount(java.math.BigInteger amount) { - this.amount = amount; - } - - public PaymentTransactionType close(String close) { - this.close = close; - return this; - } - - /** - * CloseRemainderTo is the address the sender closed to - * @return close - **/ - @ApiModelProperty(value = "CloseRemainderTo is the address the sender closed to") - public String getClose() { - return close; - } - - public void setClose(String close) { - this.close = close; - } - - public PaymentTransactionType closeamount(java.math.BigInteger closeamount) { - this.closeamount = closeamount; - return this; - } - - /** - * CloseAmount is the amount sent to CloseRemainderTo, for committed transaction - * @return closeamount - **/ - @ApiModelProperty(value = "CloseAmount is the amount sent to CloseRemainderTo, for committed transaction") - public java.math.BigInteger getCloseamount() { - return closeamount; - } - - public void setCloseamount(java.math.BigInteger closeamount) { - this.closeamount = closeamount; - } - - public PaymentTransactionType closerewards(java.math.BigInteger closerewards) { - this.closerewards = closerewards; - return this; - } - - /** - * CloseRewards is the amount of pending rewards applied to the CloseRemainderTo account as part of this transaction. - * @return closerewards - **/ - @ApiModelProperty(value = "CloseRewards is the amount of pending rewards applied to the CloseRemainderTo account as part of this transaction.") - public java.math.BigInteger getCloserewards() { - return closerewards; - } - - public void setCloserewards(java.math.BigInteger closerewards) { - this.closerewards = closerewards; - } - - public PaymentTransactionType to(String to) { - this.to = to; - return this; - } - - /** - * To is the receiver's address - * @return to - **/ - @ApiModelProperty(required = true, value = "To is the receiver's address") - public String getTo() { - return to; - } - - public void setTo(String to) { - this.to = to; - } - - public PaymentTransactionType torewards(java.math.BigInteger torewards) { - this.torewards = torewards; - return this; - } - - /** - * ToRewards is the amount of pending rewards applied to the To account as part of this transaction. - * @return torewards - **/ - @ApiModelProperty(value = "ToRewards is the amount of pending rewards applied to the To account as part of this transaction.") - public java.math.BigInteger getTorewards() { - return torewards; - } - - public void setTorewards(java.math.BigInteger torewards) { - this.torewards = torewards; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PaymentTransactionType paymentTransactionType = (PaymentTransactionType) o; - return ObjectUtils.equals(this.amount, paymentTransactionType.amount) && - ObjectUtils.equals(this.close, paymentTransactionType.close) && - ObjectUtils.equals(this.closeamount, paymentTransactionType.closeamount) && - ObjectUtils.equals(this.closerewards, paymentTransactionType.closerewards) && - ObjectUtils.equals(this.to, paymentTransactionType.to) && - ObjectUtils.equals(this.torewards, paymentTransactionType.torewards); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(amount, close, closeamount, closerewards, to, torewards); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PaymentTransactionType {\n"); - - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append(" close: ").append(toIndentedString(close)).append("\n"); - sb.append(" closeamount: ").append(toIndentedString(closeamount)).append("\n"); - sb.append(" closerewards: ").append(toIndentedString(closerewards)).append("\n"); - sb.append(" to: ").append(toIndentedString(to)).append("\n"); - sb.append(" torewards: ").append(toIndentedString(torewards)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/PendingTransactions.java b/src/main/java/com/algorand/algosdk/algod/client/model/PendingTransactions.java deleted file mode 100644 index 29c35bffd..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/PendingTransactions.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * PendingTransactions represents a potentially truncated list of transactions currently in the node's transaction pool. - */ -@ApiModel(description = "PendingTransactions represents a potentially truncated list of transactions currently in the node's transaction pool.") -@Deprecated -public class PendingTransactions { - @SerializedName("totalTxns") - private java.math.BigInteger totalTxns = null; - - @SerializedName("truncatedTxns") - private TransactionList truncatedTxns = null; - - public PendingTransactions totalTxns(java.math.BigInteger totalTxns) { - this.totalTxns = totalTxns; - return this; - } - - /** - * TotalTxns - * @return totalTxns - **/ - @ApiModelProperty(required = true, value = "TotalTxns") - public java.math.BigInteger getTotalTxns() { - return totalTxns; - } - - public void setTotalTxns(java.math.BigInteger totalTxns) { - this.totalTxns = totalTxns; - } - - public PendingTransactions truncatedTxns(TransactionList truncatedTxns) { - this.truncatedTxns = truncatedTxns; - return this; - } - - /** - * Get truncatedTxns - * @return truncatedTxns - **/ - @ApiModelProperty(required = true, value = "") - public TransactionList getTruncatedTxns() { - return truncatedTxns; - } - - public void setTruncatedTxns(TransactionList truncatedTxns) { - this.truncatedTxns = truncatedTxns; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PendingTransactions pendingTransactions = (PendingTransactions) o; - return ObjectUtils.equals(this.totalTxns, pendingTransactions.totalTxns) && - ObjectUtils.equals(this.truncatedTxns, pendingTransactions.truncatedTxns); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(totalTxns, truncatedTxns); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PendingTransactions {\n"); - - sb.append(" totalTxns: ").append(toIndentedString(totalTxns)).append("\n"); - sb.append(" truncatedTxns: ").append(toIndentedString(truncatedTxns)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/Supply.java b/src/main/java/com/algorand/algosdk/algod/client/model/Supply.java deleted file mode 100644 index c740c5313..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/Supply.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * Supply represents the current supply of MicroAlgos in the system - */ -@ApiModel(description = "Supply represents the current supply of MicroAlgos in the system") -@Deprecated -public class Supply { - @SerializedName("onlineMoney") - private java.math.BigInteger onlineMoney = null; - - @SerializedName("round") - private java.math.BigInteger round = null; - - @SerializedName("totalMoney") - private java.math.BigInteger totalMoney = null; - - public Supply onlineMoney(java.math.BigInteger onlineMoney) { - this.onlineMoney = onlineMoney; - return this; - } - - /** - * OnlineMoney - * @return onlineMoney - **/ - @ApiModelProperty(required = true, value = "OnlineMoney") - public java.math.BigInteger getOnlineMoney() { - return onlineMoney; - } - - public void setOnlineMoney(java.math.BigInteger onlineMoney) { - this.onlineMoney = onlineMoney; - } - - public Supply round(java.math.BigInteger round) { - this.round = round; - return this; - } - - /** - * Round - * @return round - **/ - @ApiModelProperty(required = true, value = "Round") - public java.math.BigInteger getRound() { - return round; - } - - public void setRound(java.math.BigInteger round) { - this.round = round; - } - - public Supply totalMoney(java.math.BigInteger totalMoney) { - this.totalMoney = totalMoney; - return this; - } - - /** - * TotalMoney - * @return totalMoney - **/ - @ApiModelProperty(required = true, value = "TotalMoney") - public java.math.BigInteger getTotalMoney() { - return totalMoney; - } - - public void setTotalMoney(java.math.BigInteger totalMoney) { - this.totalMoney = totalMoney; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Supply supply = (Supply) o; - return ObjectUtils.equals(this.onlineMoney, supply.onlineMoney) && - ObjectUtils.equals(this.round, supply.round) && - ObjectUtils.equals(this.totalMoney, supply.totalMoney); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(onlineMoney, round, totalMoney); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Supply {\n"); - - sb.append(" onlineMoney: ").append(toIndentedString(onlineMoney)).append("\n"); - sb.append(" round: ").append(toIndentedString(round)).append("\n"); - sb.append(" totalMoney: ").append(toIndentedString(totalMoney)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/Transaction.java b/src/main/java/com/algorand/algosdk/algod/client/model/Transaction.java deleted file mode 100644 index 499e4053a..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/Transaction.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.algorand.algosdk.algod.client.model.TransactionResults; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * Transaction contains all fields common to all transactions and serves as an envelope to all transactions type - */ -@ApiModel(description = "Transaction contains all fields common to all transactions and serves as an envelope to all transactions type") -@Deprecated -public class Transaction { - @SerializedName("fee") - private java.math.BigInteger fee = null; - - @SerializedName("first-round") - private java.math.BigInteger firstRound = null; - - @SerializedName("from") - private String from = null; - - @SerializedName("fromrewards") - private java.math.BigInteger fromrewards = null; - - @SerializedName("genesisID") - private String genesisID = null; - - @SerializedName("genesishashb64") - private byte[] genesishashb64 = null; - - @SerializedName("last-round") - private java.math.BigInteger lastRound = null; - - @SerializedName("noteb64") - private byte[] noteb64 = null; - - @SerializedName("payment") - private PaymentTransactionType payment = null; - - @SerializedName("poolerror") - private String poolerror = null; - - @SerializedName("round") - private java.math.BigInteger round = null; - - @SerializedName("tx") - private String tx = null; - - @SerializedName("txresults") - private TransactionResults txresults = null; - - @SerializedName("type") - private String type = null; - - public Transaction fee(java.math.BigInteger fee) { - this.fee = fee; - return this; - } - - /** - * Fee is the transaction fee - * @return fee - **/ - @ApiModelProperty(required = true, value = "Fee is the transaction fee") - public java.math.BigInteger getFee() { - return fee; - } - - public void setFee(java.math.BigInteger fee) { - this.fee = fee; - } - - public Transaction firstRound(java.math.BigInteger firstRound) { - this.firstRound = firstRound; - return this; - } - - /** - * FirstRound indicates the first valid round for this transaction - * @return firstRound - **/ - @ApiModelProperty(required = true, value = "FirstRound indicates the first valid round for this transaction") - public java.math.BigInteger getFirstRound() { - return firstRound; - } - - public void setFirstRound(java.math.BigInteger firstRound) { - this.firstRound = firstRound; - } - - public Transaction from(String from) { - this.from = from; - return this; - } - - /** - * From is the sender's address - * @return from - **/ - @ApiModelProperty(required = true, value = "From is the sender's address") - public String getFrom() { - return from; - } - - public void setFrom(String from) { - this.from = from; - } - - public Transaction fromrewards(java.math.BigInteger fromrewards) { - this.fromrewards = fromrewards; - return this; - } - - /** - * FromRewards is the amount of pending rewards applied to the From account as part of this transaction. - * @return fromrewards - **/ - @ApiModelProperty(value = "FromRewards is the amount of pending rewards applied to the From account as part of this transaction.") - public java.math.BigInteger getFromrewards() { - return fromrewards; - } - - public void setFromrewards(java.math.BigInteger fromrewards) { - this.fromrewards = fromrewards; - } - - public Transaction genesisID(String genesisID) { - this.genesisID = genesisID; - return this; - } - - /** - * Genesis ID - * @return genesisID - **/ - @ApiModelProperty(required = true, value = "Genesis ID") - public String getGenesisID() { - return genesisID; - } - - public void setGenesisID(String genesisID) { - this.genesisID = genesisID; - } - - public Transaction genesishashb64(byte[] genesishashb64) { - this.genesishashb64 = genesishashb64; - return this; - } - - /** - * Genesis hash - * @return genesishashb64 - **/ - @ApiModelProperty(required = true, value = "Genesis hash") - public byte[] getGenesishashb64() { - return genesishashb64; - } - - public void setGenesishashb64(byte[] genesishashb64) { - this.genesishashb64 = genesishashb64; - } - - public Transaction lastRound(java.math.BigInteger lastRound) { - this.lastRound = lastRound; - return this; - } - - /** - * LastRound indicates the last valid round for this transaction - * @return lastRound - **/ - @ApiModelProperty(required = true, value = "LastRound indicates the last valid round for this transaction") - public java.math.BigInteger getLastRound() { - return lastRound; - } - - public void setLastRound(java.math.BigInteger lastRound) { - this.lastRound = lastRound; - } - - public Transaction noteb64(byte[] noteb64) { - this.noteb64 = noteb64; - return this; - } - - /** - * Note is a free form data - * @return noteb64 - **/ - @ApiModelProperty(value = "Note is a free form data") - public byte[] getNoteb64() { - return noteb64; - } - - public void setNoteb64(byte[] noteb64) { - this.noteb64 = noteb64; - } - - public Transaction payment(PaymentTransactionType payment) { - this.payment = payment; - return this; - } - - /** - * Get payment - * @return payment - **/ - @ApiModelProperty(value = "") - public PaymentTransactionType getPayment() { - return payment; - } - - public void setPayment(PaymentTransactionType payment) { - this.payment = payment; - } - - public Transaction poolerror(String poolerror) { - this.poolerror = poolerror; - return this; - } - - /** - * PoolError indicates the transaction was evicted from this node's transaction pool (if non-empty). A non-empty PoolError does not guarantee that the transaction will never be committed; other nodes may not have evicted the transaction and may attempt to commit it in the future. - * @return poolerror - **/ - @ApiModelProperty(value = "PoolError indicates the transaction was evicted from this node's transaction pool (if non-empty). A non-empty PoolError does not guarantee that the transaction will never be committed; other nodes may not have evicted the transaction and may attempt to commit it in the future.") - public String getPoolerror() { - return poolerror; - } - - public void setPoolerror(String poolerror) { - this.poolerror = poolerror; - } - - public Transaction round(java.math.BigInteger round) { - this.round = round; - return this; - } - - /** - * ConfirmedRound indicates the block number this transaction appeared in - * @return round - **/ - @ApiModelProperty(value = "ConfirmedRound indicates the block number this transaction appeared in") - public java.math.BigInteger getRound() { - return round; - } - - public void setRound(java.math.BigInteger round) { - this.round = round; - } - - public Transaction tx(String tx) { - this.tx = tx; - return this; - } - - /** - * TxID is the transaction ID - * @return tx - **/ - @ApiModelProperty(required = true, value = "TxID is the transaction ID") - public String getTx() { - return tx; - } - - public void setTx(String tx) { - this.tx = tx; - } - - public Transaction txresults(TransactionResults txresults) { - this.txresults = txresults; - return this; - } - - /** - * Get txresults - * @return txresults - **/ - @ApiModelProperty(value = "") - public TransactionResults getTxresults() { - return txresults; - } - - public void setTxresults(TransactionResults txresults) { - this.txresults = txresults; - } - - public Transaction type(String type) { - this.type = type; - return this; - } - - /** - * Get type - * @return type - **/ - @ApiModelProperty(required = true, value = "") - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Transaction transaction = (Transaction) o; - return ObjectUtils.equals(this.fee, transaction.fee) && - ObjectUtils.equals(this.firstRound, transaction.firstRound) && - ObjectUtils.equals(this.from, transaction.from) && - ObjectUtils.equals(this.fromrewards, transaction.fromrewards) && - ObjectUtils.equals(this.genesisID, transaction.genesisID) && - ObjectUtils.equals(this.genesishashb64, transaction.genesishashb64) && - ObjectUtils.equals(this.lastRound, transaction.lastRound) && - ObjectUtils.equals(this.noteb64, transaction.noteb64) && - ObjectUtils.equals(this.payment, transaction.payment) && - ObjectUtils.equals(this.poolerror, transaction.poolerror) && - ObjectUtils.equals(this.round, transaction.round) && - ObjectUtils.equals(this.tx, transaction.tx) && - ObjectUtils.equals(this.txresults, transaction.txresults) && - ObjectUtils.equals(this.type, transaction.type); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(fee, firstRound, from, fromrewards, genesisID, genesishashb64, lastRound, noteb64, payment, poolerror, round, tx, txresults, type); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Transaction {\n"); - - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" firstRound: ").append(toIndentedString(firstRound)).append("\n"); - sb.append(" from: ").append(toIndentedString(from)).append("\n"); - sb.append(" fromrewards: ").append(toIndentedString(fromrewards)).append("\n"); - sb.append(" genesisID: ").append(toIndentedString(genesisID)).append("\n"); - sb.append(" genesishashb64: ").append(toIndentedString(genesishashb64)).append("\n"); - sb.append(" lastRound: ").append(toIndentedString(lastRound)).append("\n"); - sb.append(" noteb64: ").append(toIndentedString(noteb64)).append("\n"); - sb.append(" payment: ").append(toIndentedString(payment)).append("\n"); - sb.append(" poolerror: ").append(toIndentedString(poolerror)).append("\n"); - sb.append(" round: ").append(toIndentedString(round)).append("\n"); - sb.append(" tx: ").append(toIndentedString(tx)).append("\n"); - sb.append(" txresults: ").append(toIndentedString(txresults)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionFee.java b/src/main/java/com/algorand/algosdk/algod/client/model/TransactionFee.java deleted file mode 100644 index 788dd13ad..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionFee.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * TransactionFee contains the suggested fee - */ -@ApiModel(description = "TransactionFee contains the suggested fee") -@Deprecated -public class TransactionFee { - @SerializedName("fee") - private java.math.BigInteger fee = null; - - public TransactionFee fee(java.math.BigInteger fee) { - this.fee = fee; - return this; - } - - /** - * Fee is transaction fee Fee is in units of micro-Algos per byte. Fee may fall to zero but transactions must still have a fee of at least MinTxnFee for the current network protocol. - * @return fee - **/ - @ApiModelProperty(required = true, value = "Fee is transaction fee Fee is in units of micro-Algos per byte. Fee may fall to zero but transactions must still have a fee of at least MinTxnFee for the current network protocol.") - public java.math.BigInteger getFee() { - return fee; - } - - public void setFee(java.math.BigInteger fee) { - this.fee = fee; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionFee transactionFee = (TransactionFee) o; - return ObjectUtils.equals(this.fee, transactionFee.fee); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(fee); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionFee {\n"); - - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionID.java b/src/main/java/com/algorand/algosdk/algod/client/model/TransactionID.java deleted file mode 100644 index b93448950..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionID.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * TransactionID Description - */ -@ApiModel(description = "TransactionID Description") -@Deprecated -public class TransactionID { - @SerializedName("txId") - private String txId = null; - - public TransactionID txId(String txId) { - this.txId = txId; - return this; - } - - /** - * TxId is the string encoding of the transaction hash - * @return txId - **/ - @ApiModelProperty(required = true, value = "TxId is the string encoding of the transaction hash") - public String getTxId() { - return txId; - } - - public void setTxId(String txId) { - this.txId = txId; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionID transactionID = (TransactionID) o; - return ObjectUtils.equals(this.txId, transactionID.txId); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(txId); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionID {\n"); - - sb.append(" txId: ").append(toIndentedString(txId)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionList.java b/src/main/java/com/algorand/algosdk/algod/client/model/TransactionList.java deleted file mode 100644 index d9c5fe413..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionList.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * TransactionList contains a list of transactions - */ -@ApiModel(description = "TransactionList contains a list of transactions") -@Deprecated -public class TransactionList { - @SerializedName("transactions") - private List transactions = new ArrayList(); - - public TransactionList transactions(List transactions) { - this.transactions = transactions; - return this; - } - - public TransactionList addTransactionsItem(Transaction transactionsItem) { - this.transactions.add(transactionsItem); - return this; - } - - /** - * TransactionList is a list of transactions - * @return transactions - **/ - @ApiModelProperty(required = true, value = "TransactionList is a list of transactions") - public List getTransactions() { - return transactions; - } - - public void setTransactions(List transactions) { - this.transactions = transactions; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionList transactionList = (TransactionList) o; - return ObjectUtils.equals(this.transactions, transactionList.transactions); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(transactions); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionList {\n"); - - sb.append(" transactions: ").append(toIndentedString(transactions)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionParams.java b/src/main/java/com/algorand/algosdk/algod/client/model/TransactionParams.java deleted file mode 100644 index e83f3f562..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionParams.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -/** - * TransactionParams contains the parameters that help a client construct a new transaction. - */ -@ApiModel(description = "TransactionParams contains the parameters that help a client construct a new transaction.") -@Deprecated -public class TransactionParams { - @SerializedName("consensusVersion") - private String consensusVersion = null; - - @SerializedName("fee") - private java.math.BigInteger fee = null; - - @SerializedName("genesisID") - private String genesisID = null; - - @SerializedName("genesishashb64") - private byte[] genesishashb64 = null; - - @SerializedName("lastRound") - private java.math.BigInteger lastRound = null; - - public TransactionParams consensusVersion(String consensusVersion) { - this.consensusVersion = consensusVersion; - return this; - } - - /** - * ConsensusVersion indicates the consensus protocol version as of LastRound. - * @return consensusVersion - **/ - @ApiModelProperty(required = true, value = "ConsensusVersion indicates the consensus protocol version as of LastRound.") - public String getConsensusVersion() { - return consensusVersion; - } - - public void setConsensusVersion(String consensusVersion) { - this.consensusVersion = consensusVersion; - } - - public TransactionParams fee(java.math.BigInteger fee) { - this.fee = fee; - return this; - } - - /** - * Fee is the suggested transaction fee Fee is in units of micro-Algos per byte. Fee may fall to zero but transactions must still have a fee of at least MinTxnFee for the current network protocol. - * @return fee - **/ - @ApiModelProperty(required = true, value = "Fee is the suggested transaction fee Fee is in units of micro-Algos per byte. Fee may fall to zero but transactions must still have a fee of at least MinTxnFee for the current network protocol.") - public java.math.BigInteger getFee() { - return fee; - } - - public void setFee(java.math.BigInteger fee) { - this.fee = fee; - } - - public TransactionParams genesisID(String genesisID) { - this.genesisID = genesisID; - return this; - } - - /** - * Genesis ID - * @return genesisID - **/ - @ApiModelProperty(required = true, value = "Genesis ID") - public String getGenesisID() { - return genesisID; - } - - public void setGenesisID(String genesisID) { - this.genesisID = genesisID; - } - - public TransactionParams genesishashb64(byte[] genesishashb64) { - this.genesishashb64 = genesishashb64; - return this; - } - - /** - * Genesis hash - * @return genesishashb64 - **/ - @ApiModelProperty(required = true, value = "Genesis hash") - public byte[] getGenesishashb64() { - return genesishashb64; - } - - public void setGenesishashb64(byte[] genesishashb64) { - this.genesishashb64 = genesishashb64; - } - - public TransactionParams lastRound(java.math.BigInteger lastRound) { - this.lastRound = lastRound; - return this; - } - - /** - * LastRound indicates the last round seen - * @return lastRound - **/ - @ApiModelProperty(required = true, value = "LastRound indicates the last round seen") - public java.math.BigInteger getLastRound() { - return lastRound; - } - - public void setLastRound(java.math.BigInteger lastRound) { - this.lastRound = lastRound; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionParams transactionParams = (TransactionParams) o; - return ObjectUtils.equals(this.consensusVersion, transactionParams.consensusVersion) && - ObjectUtils.equals(this.fee, transactionParams.fee) && - ObjectUtils.equals(this.genesisID, transactionParams.genesisID) && - ObjectUtils.equals(this.genesishashb64, transactionParams.genesishashb64) && - ObjectUtils.equals(this.lastRound, transactionParams.lastRound); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(consensusVersion, fee, genesisID, genesishashb64, lastRound); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionParams {\n"); - - sb.append(" consensusVersion: ").append(toIndentedString(consensusVersion)).append("\n"); - sb.append(" fee: ").append(toIndentedString(fee)).append("\n"); - sb.append(" genesisID: ").append(toIndentedString(genesisID)).append("\n"); - sb.append(" genesishashb64: ").append(toIndentedString(genesishashb64)).append("\n"); - sb.append(" lastRound: ").append(toIndentedString(lastRound)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionResults.java b/src/main/java/com/algorand/algosdk/algod/client/model/TransactionResults.java deleted file mode 100644 index f206f6a2b..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/TransactionResults.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import org.apache.commons.lang3.ObjectUtils; -import com.google.gson.TypeAdapter; -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import java.io.IOException; - -/** - * TransactionResults contains information about the side effects of a transaction - */ -@ApiModel(description = "TransactionResults contains information about the side effects of a transaction") -@Deprecated -public class TransactionResults { - @SerializedName("createdasset") - private java.math.BigInteger createdasset = null; - - public TransactionResults createdasset(java.math.BigInteger createdasset) { - this.createdasset = createdasset; - return this; - } - - /** - * CreatedAssetIndex indicates the asset index of an asset created by this txn - * @return createdasset - **/ - @ApiModelProperty(value = "CreatedAssetIndex indicates the asset index of an asset created by this txn") - public java.math.BigInteger getCreatedasset() { - return createdasset; - } - - public void setCreatedasset(java.math.BigInteger createdasset) { - this.createdasset = createdasset; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - TransactionResults transactionResults = (TransactionResults) o; - return ObjectUtils.equals(this.createdasset, transactionResults.createdasset); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(createdasset); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class TransactionResults {\n"); - - sb.append(" createdasset: ").append(toIndentedString(createdasset)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/algod/client/model/Version.java b/src/main/java/com/algorand/algosdk/algod/client/model/Version.java deleted file mode 100644 index ab1334182..000000000 --- a/src/main/java/com/algorand/algosdk/algod/client/model/Version.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Algod REST API. - * API Endpoint for AlgoD Operations. - * - * OpenAPI spec version: 0.0.1 - * Contact: contact@algorand.com - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - - -package com.algorand.algosdk.algod.client.model; - -import com.google.gson.annotations.SerializedName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.ObjectUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * Note that we annotate this as a model so that legacy clients can directly import a swagger generated Version model. - */ -@ApiModel(description = "Note that we annotate this as a model so that legacy clients can directly import a swagger generated Version model.") -@Deprecated -public class Version { - @SerializedName("genesis_hash_b64") - private byte[] genesisHashB64 = null; - - @SerializedName("genesis_id") - private String genesisId = null; - - @SerializedName("versions") - private List versions = new ArrayList(); - - public Version genesisHashB64(byte[] genesisHashB64) { - this.genesisHashB64 = genesisHashB64; - return this; - } - - /** - * Get genesisHashB64 - * @return genesisHashB64 - **/ - @ApiModelProperty(required = true, value = "") - public byte[] getGenesisHashB64() { - return genesisHashB64; - } - - public void setGenesisHashB64(byte[] genesisHashB64) { - this.genesisHashB64 = genesisHashB64; - } - - public Version genesisId(String genesisId) { - this.genesisId = genesisId; - return this; - } - - /** - * Get genesisId - * @return genesisId - **/ - @ApiModelProperty(required = true, value = "") - public String getGenesisId() { - return genesisId; - } - - public void setGenesisId(String genesisId) { - this.genesisId = genesisId; - } - - public Version versions(List versions) { - this.versions = versions; - return this; - } - - public Version addVersionsItem(String versionsItem) { - this.versions.add(versionsItem); - return this; - } - - /** - * Get versions - * @return versions - **/ - @ApiModelProperty(required = true, value = "") - public List getVersions() { - return versions; - } - - public void setVersions(List versions) { - this.versions = versions; - } - - - @Override - public boolean equals(java.lang.Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Version version = (Version) o; - return ObjectUtils.equals(this.genesisHashB64, version.genesisHashB64) && - ObjectUtils.equals(this.genesisId, version.genesisId) && - ObjectUtils.equals(this.versions, version.versions); - } - - @Override - public int hashCode() { - return ObjectUtils.hashCodeMulti(genesisHashB64, genesisId, versions); - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Version {\n"); - - sb.append(" genesisHashB64: ").append(toIndentedString(genesisHashB64)).append("\n"); - sb.append(" genesisId: ").append(toIndentedString(genesisId)).append("\n"); - sb.append(" versions: ").append(toIndentedString(versions)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private String toIndentedString(java.lang.Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - -} - diff --git a/src/main/java/com/algorand/algosdk/builder/transaction/TransactionParametersBuilder.java b/src/main/java/com/algorand/algosdk/builder/transaction/TransactionParametersBuilder.java index 0b3d2b9ba..b9b768dd3 100644 --- a/src/main/java/com/algorand/algosdk/builder/transaction/TransactionParametersBuilder.java +++ b/src/main/java/com/algorand/algosdk/builder/transaction/TransactionParametersBuilder.java @@ -1,8 +1,5 @@ package com.algorand.algosdk.builder.transaction; -import com.algorand.algosdk.algod.client.ApiException; -import com.algorand.algosdk.algod.client.api.AlgodApi; -import com.algorand.algosdk.algod.client.model.TransactionParams; import com.algorand.algosdk.crypto.Address; import com.algorand.algosdk.crypto.Digest; import com.algorand.algosdk.transaction.Lease; @@ -28,48 +25,12 @@ public abstract class TransactionParametersBuilder params = client.TransactionParams().execute(); diff --git a/src/main/java/com/algorand/algosdk/transaction/MethodCallParams.java b/src/main/java/com/algorand/algosdk/transaction/MethodCallParams.java index 21d5fd542..ae435eaac 100644 --- a/src/main/java/com/algorand/algosdk/transaction/MethodCallParams.java +++ b/src/main/java/com/algorand/algosdk/transaction/MethodCallParams.java @@ -5,14 +5,11 @@ import com.algorand.algosdk.abi.TypeAddress; import com.algorand.algosdk.abi.TypeTuple; import com.algorand.algosdk.abi.TypeUint; -import com.algorand.algosdk.algod.client.model.TransactionParams; import com.algorand.algosdk.builder.transaction.ApplicationCallTransactionBuilder; -import com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder; import com.algorand.algosdk.crypto.Address; import com.algorand.algosdk.crypto.Digest; import com.algorand.algosdk.crypto.TEALProgram; import com.algorand.algosdk.logic.StateSchema; -import com.algorand.algosdk.v2.client.model.TransactionParametersResponse; import java.math.BigInteger; import java.util.ArrayList; @@ -119,27 +116,6 @@ protected MethodCallParams(Long appID, Method method, List methodArgs, A this.extraPages = extraPages; } - /** - * Deprecated - Use {@link com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder} - * to create a new MethodCallParams object instead. - */ - @Deprecated - public MethodCallParams(Long appID, Method method, List methodArgs, Address sender, - Transaction.OnCompletion onCompletion, byte[] note, byte[] lease, String genesisID, Digest genesisHash, - BigInteger firstValid, BigInteger lastValid, BigInteger fee, BigInteger flatFee, - Address rekeyTo, TxnSigner signer, - List
fAccounts, List fAssets, List fApps, - TEALProgram approvalProgram, TEALProgram clearProgram, - StateSchema globalStateSchema, StateSchema localStateSchema, Long extraPages) { - this(appID, method, methodArgs, sender, - onCompletion, note, lease, genesisID, genesisHash, - firstValid, lastValid, fee, flatFee, - rekeyTo, signer, - fAccounts, fAssets, fApps, new ArrayList(), - approvalProgram, clearProgram, - globalStateSchema, localStateSchema, extraPages); - } - /** * Create the transactions which will carry out the specified method call. *

@@ -285,127 +261,4 @@ private static int populateForeignArrayIndex(T objectToBeAdded, List obje objectArray.add(objectToBeAdded); return objectArray.size() - 1 + startFrom; } - - /** - * Deprecated, use {@link com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder#Builder()} instead. - */ - @Deprecated - public static class Builder extends MethodCallTransactionBuilder { - - public Builder setAppID(Long appID) { - return this.applicationId(appID); - } - - public Builder setMethod(Method method) { - return this.method(method); - } - - public Builder addMethodArgs(Object ma) { - return this.addMethodArgument(ma); - } - - public Builder setSender(String sender) { - return this.sender(sender); - } - - public Builder setSuggestedParams(TransactionParams sp) { - return this.suggestedParams(sp); - } - - public Builder setSuggestedParams(TransactionParametersResponse sp) { - return this.suggestedParams(sp); - } - - public Builder setOnComplete(Transaction.OnCompletion op) { - return this.onComplete(op); - } - - public Builder setNote(byte[] note) { - return this.note(note); - } - - public Builder setLease(byte[] lease) { - return this.lease(lease); - } - - public Builder setRekeyTo(String rekeyTo) { - return this.rekey(rekeyTo); - } - - public Builder setSigner(TxnSigner signer) { - return this.signer(signer); - } - - public Builder setFirstValid(BigInteger fv) { - return this.firstValid(fv); - } - - public Builder setLastValid(BigInteger lv) { - return this.lastValid(lv); - } - - public Builder setFee(BigInteger fee) { - return this.fee(fee); - } - - public Builder setFlatFee(BigInteger flatFee) { - return this.flatFee(flatFee); - } - - public Builder setForeignAccounts(List

fAccounts) { - return this.accounts(fAccounts); - } - - public Builder setForeignAssets(List fAssets) { - return this.foreignAssets(fAssets); - } - - public Builder setForeignApps(List fApps) { - return this.foreignApps(fApps); - } - - public Builder setApprovalProgram(TEALProgram approvalProgram) { - return this.approvalProgram(approvalProgram); - } - - public Builder setClearProgram(TEALProgram clearProgram) { - return this.clearStateProgram(clearProgram); - } - - public Builder setGlobalInts(Long globalInts) { - if (this.globalStateSchema == null) { - return this.globalStateSchema(new StateSchema(globalInts, 0L)); - } - this.globalStateSchema.numUint = BigInteger.valueOf(globalInts); - return this; - } - - public Builder setGlobalBytes(Long globalBytes) { - if (this.globalStateSchema == null) { - return this.globalStateSchema(new StateSchema(0L, globalBytes)); - } - this.globalStateSchema.numByteSlice = BigInteger.valueOf(globalBytes); - return this; - } - - public Builder setLocalInts(Long localInts) { - if (this.localStateSchema == null) { - return this.localStateSchema(new StateSchema(localInts, 0L)); - } - this.localStateSchema.numUint = BigInteger.valueOf(localInts); - return this; - } - - public Builder setLocalBytes(Long localBytes) { - if (this.localStateSchema == null) { - return this.localStateSchema(new StateSchema(0L, localBytes)); - } - this.localStateSchema.numByteSlice = BigInteger.valueOf(localBytes); - return this; - } - - public Builder setExtraPages(Long extraPages) { - return this.extraPages(extraPages); - } - } } diff --git a/src/test/java/com/algorand/algosdk/util/TestEncoder.java b/src/test/java/com/algorand/algosdk/util/TestEncoder.java index 15e4f726f..4524d2183 100644 --- a/src/test/java/com/algorand/algosdk/util/TestEncoder.java +++ b/src/test/java/com/algorand/algosdk/util/TestEncoder.java @@ -1,6 +1,5 @@ package com.algorand.algosdk.util; -import com.algorand.algosdk.algod.client.model.PaymentTransactionType; import com.algorand.algosdk.transaction.Transaction; import com.algorand.algosdk.v2.client.model.Account; import com.algorand.algosdk.v2.client.model.Enums; From 6ccc1a051c5949b282cad1881517a366838e3098 Mon Sep 17 00:00:00 2001 From: Hang Su <87964331+ahangsu@users.noreply.github.com> Date: Mon, 19 Dec 2022 09:50:00 -0500 Subject: [PATCH 3/4] v2: V1 to V2 breaking changes (#447) --- CHANGELOG.md | 16 + .../com/algorand/algosdk/account/Account.java | 31 +- .../transaction/TransactionBuilder.java | 2 +- .../algosdk/crypto/LogicsigSignature.java | 6 +- .../algorand/algosdk/crypto/TEALProgram.java | 1 - .../com/algorand/algosdk/logic/Logic.java | 403 -------- .../algosdk/templates/ContractTemplate.java | 181 ---- .../algosdk/templates/DynamicFee.java | 163 ---- .../com/algorand/algosdk/templates/HTLC.java | 152 --- .../algosdk/templates/LimitOrder.java | 167 ---- .../algosdk/templates/PeriodicPayment.java | 134 --- .../com/algorand/algosdk/templates/Split.java | 155 ---- .../algosdk/transaction/Transaction.java | 863 +----------------- .../algorand/algosdk/transaction/TxGroup.java | 19 +- .../client/model/CatchpointAbortResponse.java | 27 - .../client/model/CatchpointStartResponse.java | 27 - .../v2/client/model/DryrunTxnResult.java | 8 - src/main/resources/langspec.json | 1 - .../algosdk/crypto/TestLogicsigSignature.java | 4 +- .../com/algorand/algosdk/logic/TestLogic.java | 450 --------- 20 files changed, 31 insertions(+), 2779 deletions(-) delete mode 100644 src/main/java/com/algorand/algosdk/logic/Logic.java delete mode 100644 src/main/java/com/algorand/algosdk/templates/ContractTemplate.java delete mode 100644 src/main/java/com/algorand/algosdk/templates/DynamicFee.java delete mode 100644 src/main/java/com/algorand/algosdk/templates/HTLC.java delete mode 100644 src/main/java/com/algorand/algosdk/templates/LimitOrder.java delete mode 100644 src/main/java/com/algorand/algosdk/templates/PeriodicPayment.java delete mode 100644 src/main/java/com/algorand/algosdk/templates/Split.java delete mode 100644 src/main/java/com/algorand/algosdk/v2/client/model/CatchpointAbortResponse.java delete mode 100644 src/main/java/com/algorand/algosdk/v2/client/model/CatchpointStartResponse.java delete mode 100644 src/main/resources/langspec.json delete mode 100644 src/test/java/com/algorand/algosdk/logic/TestLogic.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0947e2dd1..3e6455228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# 2.0.0 + +## What's Changed +### Breaking changes + +* Remove `TxGroup.assignGroupID(Transaction[] txns, Address address)` in favor + of `TxGroup.assignGroupID(Address address, Transaction ...txns)`. +* Remove `Account.transactionWithSuggestedFeePerByte` in favor of `Account.setFeeByFeePerByte`. +* Remove deprecated methods in `Transaction.java`, mark public `Transaction` constructor as hidden in favor of `com.algorand.algosdk.builder.transaction`. +* Remove deprecated `Transaction.setFee` and `Transaction.setLease` methods. +* Remove v1 algod API (`com.algorand.algosdk.algod.client`) due to API end-of-life (2022-12-01). Instead, use v2 algod API (`com.algorand.algosdk.v2.client.algod`). +* Remove `cost` field in `DryrunTxnResult` in favor of 2 fields: `budget-added` and `budget-consumed`. `cost` can be derived by `budget-consumed - budget-added`. +* Remove logicsig templates, `com/algorand/algosdk/resource/langspec.json`, `com.algorand.algosdk.logic` and methods in `com.algorand.algosdk.crypto` depending on `langspec.json`. +* Remove the deprecated `MethodCallParams` public constructor in favor of `com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder`. +* Remove unused generated types: `CatchpointAbortResponse`, `CatchpointStartResponse`. + # 1.22.0 ### Bugfixes diff --git a/src/main/java/com/algorand/algosdk/account/Account.java b/src/main/java/com/algorand/algosdk/account/Account.java index 743445dfc..cda82cbfc 100644 --- a/src/main/java/com/algorand/algosdk/account/Account.java +++ b/src/main/java/com/algorand/algosdk/account/Account.java @@ -219,35 +219,6 @@ public SignedBid signBid(Bid bid) throws NoSuchAlgorithmException { } } - /** - * Creates a version of the given transaction with fee populated according to suggestedFeePerByte * estimateTxSize. - * @param copyTx transaction to populate fee field - * @param suggestedFeePerByte suggestedFee given by network - * @return transaction with proper fee set - * @throws NoSuchAlgorithmException could not estimate tx encoded size. - * @deprecated Replaced by {@link #setFeeByFeePerByte}. - * This is unsafe to use because the returned transaction is a shallow copy of copyTx. - */ - @Deprecated - static public Transaction transactionWithSuggestedFeePerByte(Transaction copyTx, BigInteger suggestedFeePerByte) throws NoSuchAlgorithmException{ - BigInteger newFee = suggestedFeePerByte.multiply(estimatedEncodedSize(copyTx)); - if (newFee.compareTo(MIN_TX_FEE_UALGOS) < 0) { - newFee = MIN_TX_FEE_UALGOS; - } - switch (copyTx.type) { - case Payment: - return new Transaction(copyTx.sender, newFee, copyTx.firstValid, copyTx.lastValid, copyTx.note, copyTx.genesisID, copyTx.genesisHash, - copyTx.amount, copyTx.receiver, copyTx.closeRemainderTo); - case KeyRegistration: - return new Transaction(copyTx.sender, newFee, copyTx.firstValid, copyTx.lastValid, copyTx.note, copyTx.genesisID, copyTx.genesisHash, - copyTx.votePK, copyTx.selectionPK, copyTx.voteFirst, copyTx.voteLast, copyTx.voteKeyDilution); - case Default: - throw new IllegalArgumentException("tx cannot have no type"); - default: - throw new RuntimeException("cannot reach"); - } - } - /** * Sets the transaction fee according to suggestedFeePerByte * estimateTxSize. * @param tx transaction to populate fee field @@ -276,7 +247,7 @@ static public void setFeeByFeePerByte(Transaction tx, BigInteger suggestedFeePer if (fee.compareTo(Account.MIN_TX_FEE_UALGOS) < 0) { fee = Account.MIN_TX_FEE_UALGOS; } - tx.setFee(fee); + tx.fee = fee; } /** diff --git a/src/main/java/com/algorand/algosdk/builder/transaction/TransactionBuilder.java b/src/main/java/com/algorand/algosdk/builder/transaction/TransactionBuilder.java index 8209f0e98..2fc124eb7 100644 --- a/src/main/java/com/algorand/algosdk/builder/transaction/TransactionBuilder.java +++ b/src/main/java/com/algorand/algosdk/builder/transaction/TransactionBuilder.java @@ -47,7 +47,7 @@ final public Transaction build() { if (rekeyTo != null) txn.rekeyTo = rekeyTo; if (genesisID != null) txn.genesisID = genesisID; if (genesisHash != null) txn.genesisHash = genesisHash; - + if (lease != null && lease.length != 0) { txn.setLease(new Lease(lease)); } diff --git a/src/main/java/com/algorand/algosdk/crypto/LogicsigSignature.java b/src/main/java/com/algorand/algosdk/crypto/LogicsigSignature.java index 7a3b92ffc..bc748d0b8 100644 --- a/src/main/java/com/algorand/algosdk/crypto/LogicsigSignature.java +++ b/src/main/java/com/algorand/algosdk/crypto/LogicsigSignature.java @@ -1,9 +1,7 @@ package com.algorand.algosdk.crypto; -import com.algorand.algosdk.logic.Logic; import com.algorand.algosdk.util.Digester; -import java.io.IOException; import java.nio.charset.StandardCharsets; import java.security.PublicKey; import java.security.NoSuchAlgorithmException; @@ -21,7 +19,9 @@ /** * Serializable logicsig class. * LogicsigSignature is constructed from a program and optional arguments. - * Signature sig and MultisigSignature msig property are available for modification by it's clients. + * Signature sig and MultisigSignature msig property are available for modification by its clients. + *

+ * LogicsigSignature cannot sign transactions in all cases. Instead, use LogicSigAccount as a safe, general purpose signing mechanism. Since LogicSig does not track the provided signature's public key, LogicSig cannot sign transactions when delegated to a non-multisig account _and_ the sender is not the delegating account. */ @JsonPropertyOrder(alphabetic = true) @JsonInclude(JsonInclude.Include.NON_DEFAULT) diff --git a/src/main/java/com/algorand/algosdk/crypto/TEALProgram.java b/src/main/java/com/algorand/algosdk/crypto/TEALProgram.java index 986e0f5b6..b3aa5389e 100644 --- a/src/main/java/com/algorand/algosdk/crypto/TEALProgram.java +++ b/src/main/java/com/algorand/algosdk/crypto/TEALProgram.java @@ -1,6 +1,5 @@ package com.algorand.algosdk.crypto; -import com.algorand.algosdk.logic.Logic; import com.algorand.algosdk.util.Encoder; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/src/main/java/com/algorand/algosdk/logic/Logic.java b/src/main/java/com/algorand/algosdk/logic/Logic.java deleted file mode 100644 index 42965e295..000000000 --- a/src/main/java/com/algorand/algosdk/logic/Logic.java +++ /dev/null @@ -1,403 +0,0 @@ -package com.algorand.algosdk.logic; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * Logic class provides static checkProgram function - * that can be used for client-side program validation for size and execution cost. - * - * @deprecated this class is deprecated for relying on metadata (`langspec.json`) that - * does not accurately represent opcode behavior across program versions. - */ -@Deprecated -public class Logic { - - private static final int MAX_COST = 20000; - private static final int MAX_LENGTH = 1000; - - private static final int INTCBLOCK_OPCODE = 32; - private static final int BYTECBLOCK_OPCODE = 38; - private static final int PUSHBYTES_OPCODE = 128; - private static final int PUSHINT_OPCODE = 129; - - private class LangSpec { - public int EvalMaxVersion; - public int LogicSigVersion; - public Operation[] Ops; - } - - private class Operation { - int Opcode; - String Name; - int Cost; - int Size; - String Returns; - String[] ArgEnum; - String ArgEnumTypes; - String Doc; - String ImmediateNote; - String[] Group; - } - - /** - * Metadata related to a teal program. - */ - public static class ProgramData { - public final boolean good; - public final List intBlock; - public final List byteBlock; - - private ProgramData(final boolean good, final List intBlock, final List byteBlock) { - this.good = good; - this.intBlock = intBlock; - this.byteBlock = byteBlock; - } - } - - /** - * Metadata related to a varint parsed from teal program data. - */ - public static class VarintResult { - final public int value; - final public int length; - - private VarintResult(int value, int length) { - this.value = value; - this.length = length; - } - - private VarintResult() { - this.value = 0; - this.length = 0; - } - } - - protected static class IntConstBlock { - public final int size; - public final List results; - - IntConstBlock(final int size, final List results) { - this.size = size; - this.results = results; - } - } - - protected static class ByteConstBlock { - public final int size; - public final List results; - - ByteConstBlock(int size, List results) { - this.size = size; - this.results = results; - } - } - - /** - * Varints are a method of serializing integers using one or more bytes. - * Smaller numbers take a smaller number of bytes. - * Each byte in a varint, except the last byte, has the most significant - * bit (msb) set – this indicates that there are further bytes to come. - * The lower 7 bits of each byte are used to store the two's complement - * representation of the number in groups of 7 bits, the least significant - * group first. - * https://developers.google.com/protocol-buffers/docs/encoding - * @param value being serialized - * @return byte array holding the serialized bits - */ - public static byte[] putUVarint(int value) { - assert value >= 0 : "putUVarint expects non-negative values."; - List buffer = new ArrayList<>(); - while (value >= 0x80) { - buffer.add((byte)((value & 0xFF) | 0x80 )); - value >>= 7; - } - buffer.add((byte)(value & 0xFF)); - byte [] out = new byte[buffer.size()]; - for (int x = 0; x < buffer.size(); ++x) { - out[x] = buffer.get(x); - } - return out; - } - - /** - * Given a varint, get the integer value - * @param buffer serialized varint - * @param bufferOffset position in the buffer to start reading from - * @return pair of values in an array: value, read size - */ - public static VarintResult getUVarint(byte [] buffer, int bufferOffset) { - int x = 0; - int s = 0; - for (int i = 0; i < buffer.length; i++) { - int b = buffer[bufferOffset+i] & 0xff; - if (b < 0x80) { - if (i > 9 || i == 9 && b > 1) { - return new VarintResult(0, -(i + 1)); - } - return new VarintResult(x | (b & 0xff) << s, i + 1); - } - x |= ((b & 0x7f) & 0xff) << s; - s += 7; - } - return new VarintResult(); - } - - private static LangSpec langSpec; - private static Operation[] opcodes; - - /** - * Performs basic program validation: instruction count and program cost - * - * @param program - * @param args - * @return - * @throws IOException - */ - public static boolean checkProgram(byte[] program, List args) throws IOException { - return readProgram(program, args).good; - } - - /** - * Performs basic program validation: instruction count and program cost - * - * @param program Program to validate - * @param args Program arguments to validate - * @return boolean - * @throws IOException - */ - public static ProgramData readProgram(byte[] program, List args) throws IOException { - List ints = new ArrayList<>(); - List bytes = new ArrayList<>(); - - if (langSpec == null) { - loadLangSpec(); - } - - VarintResult result = getUVarint(program, 0); - int vlen = result.length; - if (vlen <= 0) { - throw new IllegalArgumentException("version parsing error"); - } - - int version = result.value; - if (version > langSpec.EvalMaxVersion) { - throw new IllegalArgumentException("unsupported version"); - } - - if (args == null) { - args = new ArrayList<>(); - } - - int cost = 0; - int length = program.length; - for (int i = 0; i < args.size(); i++) { - length += args.get(i).length; - } - - if (length > MAX_LENGTH) { - throw new IllegalArgumentException("program too long"); - } - - if (opcodes == null) { - opcodes = new Operation[256]; - for (int i = 0; i < langSpec.Ops.length; i++) { - Operation op = langSpec.Ops[i]; - opcodes[op.Opcode] = op; - } - } - - int pc = vlen; - while (pc < program.length) { - int opcode = program[pc] & 0xFF; - Operation op = opcodes[opcode]; - if (op == null) { - throw new IllegalArgumentException("invalid instruction: " + opcode); - } - - cost += op.Cost; - int size = op.Size; - if (size == 0) { - switch (op.Opcode) { - case INTCBLOCK_OPCODE: - IntConstBlock intsBlock = readIntConstBlock(program, pc); - size += intsBlock.size; - ints.addAll(intsBlock.results); - break; - case BYTECBLOCK_OPCODE: - ByteConstBlock bytesBlock = readByteConstBlock(program, pc); - size += bytesBlock.size; - bytes.addAll(bytesBlock.results); - break; - case PUSHINT_OPCODE: - IntConstBlock pushInt = readPushIntOp(program, pc); - size += pushInt.size; - ints.addAll(pushInt.results); - break; - case PUSHBYTES_OPCODE: - ByteConstBlock pushBytes = readPushByteOp(program, pc); - size += pushBytes.size; - bytes.addAll(pushBytes.results); - break; - default: - throw new IllegalArgumentException("invalid instruction"); - } - } - pc += size; - } - // costs calculated dynamically starting in v4 - if (version < 4 && cost > MAX_COST) { - throw new IllegalArgumentException("program too costly for version < 4. consider using v4."); - } - - return new ProgramData(true, ints, bytes); - } - - /** - * Retrieves supported program version - * @return int - * @throws IOException - */ - public static int getLogicSigVersion() throws IOException { - if (langSpec == null) { - loadLangSpec(); - } - return langSpec.LogicSigVersion; - } - - /** - * Retrieves max supported program version of evaluator - * @return int - * @throws IOException - */ - public static int getEvalMaxVersion() throws IOException { - if (langSpec == null) { - loadLangSpec(); - } - return langSpec.EvalMaxVersion; - } - - private static void loadLangSpec() throws IOException { - if (langSpec != null) { - return; - } - - Reader reader; - try { - reader = new InputStreamReader( - Logic.class.getResourceAsStream("/langspec.json"), - "UTF-8" - ); - } catch (UnsupportedEncodingException ex) { - throw new IllegalStateException("langspec opening error"); - } - - Gson g = new GsonBuilder().create(); - - langSpec = g.fromJson(reader, LangSpec.class); - reader.close(); - } - - protected static IntConstBlock readIntConstBlock(byte[] program, int pc) { - ArrayList results = new ArrayList<>(); - - int size = 1; - VarintResult result = getUVarint(program, pc + size); - if (result.length <= 0) { - throw new IllegalArgumentException( - String.format("could not decode int const block at pc=%d", pc) - ); - } - size += result.length; - int numInts = result.value; - for (int i = 0; i < numInts; i++) { - if (pc + size >= program.length) { - throw new IllegalArgumentException("int const block exceeds program length"); - } - result = getUVarint(program, pc + size); - if (result.length <= 0) { - throw new IllegalArgumentException( - String.format("could not decode int const[%d] block at pc=%d", i, pc + size) - ); - } - size += result.length; - results.add(result.value); - } - return new IntConstBlock(size, results); - } - - protected static ByteConstBlock readByteConstBlock(byte[] program, int pc) { - ArrayList results = new ArrayList<>(); - int size = 1; - VarintResult result = getUVarint(program, pc + size); - if (result.length <= 0) { - throw new IllegalArgumentException( - String.format("could not decode byte[] const block at pc=%d", pc) - ); - } - size += result.length; - int numInts = result.value; - for (int i = 0; i < numInts; i++) { - if (pc + size >= program.length) { - throw new IllegalArgumentException("byte[] const block exceeds program length"); - } - result = getUVarint(program, pc + size); - if (result.length <= 0) { - throw new IllegalArgumentException( - String.format("could not decode byte[] const[%d] block at pc=%d", i, pc + size) - ); - } - size += result.length; - if (pc + size + result.value > program.length) { - throw new IllegalArgumentException("byte[] const block exceeds program length"); - } - byte[] buff = new byte[result.value]; - System.arraycopy(program, pc + size, buff, 0, result.value); - results.add(buff); - size += result.value; - } - return new ByteConstBlock(size, results); - } - - protected static IntConstBlock readPushIntOp(byte[] program, int pc) { - int size = 1; - VarintResult result = getUVarint(program, pc + size); - if (result.length <= 0) { - throw new IllegalArgumentException( - String.format("could not decode push int const at pc=%d", pc) - ); - } - size += result.length; - - return new IntConstBlock(size, Collections.singletonList(result.value)); - } - - protected static ByteConstBlock readPushByteOp(byte[] program, int pc) { - int size = 1; - VarintResult result = getUVarint(program, pc + size); - if (result.length <= 0) { - throw new IllegalArgumentException( - String.format("could not decode push []byte const size at pc=%d", pc) - ); - } - - size += result.length; - if (pc + size + result.value > program.length) { - throw new IllegalArgumentException("pushbytes ran past end of program"); - } - - byte[] buff = new byte[result.value]; - System.arraycopy(program, pc + size, buff, 0, result.value); - size += result.value; - - return new ByteConstBlock(size, Collections.singletonList(buff)); - } -} diff --git a/src/main/java/com/algorand/algosdk/templates/ContractTemplate.java b/src/main/java/com/algorand/algosdk/templates/ContractTemplate.java deleted file mode 100644 index a6363c42e..000000000 --- a/src/main/java/com/algorand/algosdk/templates/ContractTemplate.java +++ /dev/null @@ -1,181 +0,0 @@ -package com.algorand.algosdk.templates; - -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.List; - -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.crypto.LogicsigSignature; -import com.algorand.algosdk.logic.Logic; -import com.algorand.algosdk.transaction.Lease; -import com.algorand.algosdk.util.Encoder; - -@Deprecated -public class ContractTemplate { - - /** - * Values are appended to a program at specific offsets. Depending on the type the source template has placeholders - * of differing sizes. The values are used to generate a byte array appropriate for the type it represents, for - * example some values may include a length in addition to the data. In addition the value knows how large the - * placeholder value is, this placeholder size may differ between different Algorand SDK implementations. - * - * Placeholder sizes are the following: - * BASE64 : 2 bytes - * ADDRESS: 32 bytes - * INT : 1 byte - */ - abstract static class ParameterValue { - private final int offset; - private final byte[] value; - - protected ParameterValue(int offset, byte[] value) { - this.value = value; - this.offset = offset; - } - - public byte[] toBytes() { - return value; - } - - public int getOffset() { - return offset; - } - - abstract public int placeholderSize(); - } - - public static class IntParameterValue extends ParameterValue { - public IntParameterValue(int offset, int value) { - super(offset, Logic.putUVarint(value)); - } - - public int placeholderSize() { - return 1; - } - } - - public static class AddressParameterValue extends ParameterValue { - public AddressParameterValue(int offset, String value) throws NoSuchAlgorithmException { - super(offset, new Address(value).getBytes()); - } - - public AddressParameterValue(int offset, Address address) throws NoSuchAlgorithmException { - super(offset, address.getBytes()); - } - - public AddressParameterValue(int offset, byte[] value) throws NoSuchAlgorithmException { - super(offset, value); - } - - public int placeholderSize() { - return 32; - } - } - - public static class BytesParameterValue extends ParameterValue { - public BytesParameterValue(int offset, String value) { - this(offset, Encoder.decodeFromBase64(value)); - } - - public BytesParameterValue(int offset, byte[] value) { - super(offset, convertToBytes(value)); - } - - public BytesParameterValue(int offset, Lease value) { - this(offset, value.getBytes()); - } - - private static byte[] convertToBytes(byte[] value) { - byte[] len = Logic.putUVarint(value.length); - byte[] result = new byte[len.length + value.length]; - System.arraycopy(len, 0, result, 0, len.length); - System.arraycopy(value, 0, result, len.length, value.length); - return result; - } - - public int placeholderSize() { - return 2; - } - } - - public Address address; - public byte[] program; - - - /** - * Initialize a contract template. - * - * @param prog base64 encoded program. - */ - public ContractTemplate(String prog) throws NoSuchAlgorithmException { - this(Encoder.decodeFromBase64(prog)); - } - - /** - * Initialize a contract template. - * - * @param prog bytes of program. - */ - public ContractTemplate(byte[] prog) throws NoSuchAlgorithmException { - this(new LogicsigSignature(prog)); - } - - /** - * Initialize a contract template. - * - * @param lsig the contract's LogicsigSignature. - */ - public ContractTemplate(LogicsigSignature lsig) throws NoSuchAlgorithmException { - address = lsig.toAddress(); - program = lsig.logic; - } - - /** - * @param program is compiled TEAL program - * @param values of the program parameters to inject to the program bytecode - * @return ContractTemplate with the address and the program with the given parameter values - * @throws NoSuchAlgorithmException - */ - protected static ContractTemplate inject(byte [] program, List values) throws NoSuchAlgorithmException { - ArrayList updatedProgram = new ArrayList(); - - int progIdx = 0; - for (ParameterValue value : values) { - while (progIdx < value.getOffset()) { - updatedProgram.add(program[progIdx++]); - } - - for (byte b : value.toBytes()) { - updatedProgram.add(b); - } - progIdx += value.placeholderSize(); - } - // append remainder of program. - while (progIdx < program.length) { - updatedProgram.add(program[progIdx++]); - } - - byte [] updatedProgramByteArray = new byte[updatedProgram.size()]; - for (int x = 0; x < updatedProgram.size(); ++x) { - updatedProgramByteArray[x] = updatedProgram.get(x); - } - - return new ContractTemplate(updatedProgramByteArray); - } - - protected static Logic.ProgramData readAndVerifyContract(byte[] program, int numInts, int numByteArrays) { - Logic.ProgramData data; - - try { - data = Logic.readProgram(program, null); - } catch (Exception e) { - throw new IllegalArgumentException("Unable to parse contract."); - } - - if (!data.good || data.intBlock.size() != numInts || data.byteBlock.size() != numByteArrays) { - throw new IllegalArgumentException("Invalid contract detected."); - } - - return data; - } -} diff --git a/src/main/java/com/algorand/algosdk/templates/DynamicFee.java b/src/main/java/com/algorand/algosdk/templates/DynamicFee.java deleted file mode 100644 index b30e5acca..000000000 --- a/src/main/java/com/algorand/algosdk/templates/DynamicFee.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.algorand.algosdk.templates; - -import com.algorand.algosdk.account.Account; -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.crypto.Digest; -import com.algorand.algosdk.crypto.LogicsigSignature; -import com.algorand.algosdk.logic.Logic; -import com.algorand.algosdk.templates.ContractTemplate.AddressParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.BytesParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.IntParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.ParameterValue; -import com.algorand.algosdk.transaction.SignedTransaction; -import com.algorand.algosdk.transaction.Transaction; -import com.algorand.algosdk.transaction.TxGroup; -import com.algorand.algosdk.util.Encoder; -import com.algorand.algosdk.transaction.Lease; -import com.google.common.collect.ImmutableList; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.Objects; - -import static com.algorand.algosdk.templates.ContractTemplate.readAndVerifyContract; - -@Deprecated -public class DynamicFee { - protected static String referenceProgram = "ASAFAgEFBgcmAyD+vKC7FEpaTqe0OKRoGsgObKEFvLYH/FZTJclWlfaiEyDmmpYeby1feshmB5JlUr6YI17TM2PKiJGLuck4qRW2+QEGMgQiEjMAECMSEDMABzEAEhAzAAgxARIQMRYjEhAxECMSEDEHKBIQMQkpEhAxCCQSEDECJRIQMQQhBBIQMQYqEhA="; - - /** - * DynamicFee contract allows you to create a transaction without - * specifying the fee. The fee will be determined at the moment of - * transfer. - * - * @param receiver (str): address to receive the assets - * @param amount (int): amount of assets to transfer - * @param firstValid (int): first valid round for the transaction - * @param lastValid (int, optional): last valid round for the transaction (default to first_valid + 1000) - * @param closeRemainderAddress (str, optional): if you would like to close the account after the transfer, specify the address that would recieve the remainder - */ - public static ContractTemplate MakeDynamicFee(final Address receiver, final Integer amount, final Integer firstValid, final Integer lastValid, final Address closeRemainderAddress) throws NoSuchAlgorithmException { - return MakeDynamicFee(receiver, amount, firstValid, lastValid, closeRemainderAddress, null); - } - - protected static ContractTemplate MakeDynamicFee(final Address receiver, final Integer amount, final Integer firstValid, final Integer lastValid, final Address closeRemainderAddress, final Lease lease) throws NoSuchAlgorithmException { - Objects.requireNonNull(receiver); - Objects.requireNonNull(amount); - Objects.requireNonNull(firstValid); - - byte[] program = Encoder.decodeFromBase64(referenceProgram); - - List values = ImmutableList.of( - new IntParameterValue(5, amount), - new IntParameterValue(6, firstValid), - new IntParameterValue(7, lastValid == null ? firstValid + 1000 : lastValid), - new AddressParameterValue(11, receiver), - new AddressParameterValue(44, closeRemainderAddress == null ? new Address() : closeRemainderAddress), - new BytesParameterValue(76, lease == null ? new Lease() : lease) - ); - - return ContractTemplate.inject(program, values); - } - - /** - * Container class for the signed dynamic fee data returned by SignDynamicFee. - */ - public static class SignedDynamicFee { - public final Transaction txn; - public final LogicsigSignature lsig; - - private SignedDynamicFee(final Transaction txn, final LogicsigSignature lsig) { - this.txn = txn; - this.lsig = lsig; - } - } - - /** - * Return the main transaction and signed logic needed to complete the - * transfer. These should be sent to the fee payer, who can use - * get_transactions() to update fields and create the auxiliary - * transaction. - * - * The transaction and logicsig should be sent to the other party as base64 encoded objects: - * SignedDynamicFee sdf = DynamicFee.SignDynamicFee(...); - * String encodedLsig = Encoder.encodeToBase64(Encoder.encodeToMsgPack(sdf.lsig)); - * String encodedTxn = Encoder.encodeToBase64(Encoder.encodeToMsgPack(sdf.txn)); - * - * @param contract DynamicFee contract created with MakeDynamicFee. - * @param senderAccount sender account to sign the transaction. - * @param genesisHash Genesis hash for the network where the transaction will be submitted. - * @return - */ - public static SignedDynamicFee SignDynamicFee(final ContractTemplate contract, final Account senderAccount, final Digest genesisHash) throws IOException { - Logic.ProgramData data = readAndVerifyContract(contract.program, 5, 3); - - Address receiverAddress = new Address(data.byteBlock.get(0)); - Address closeToAddress = new Address(data.byteBlock.get(1)); - Lease lease = new Lease(data.byteBlock.get(2)); - - BigInteger amount = BigInteger.valueOf(data.intBlock.get(2)); - BigInteger firstValid = BigInteger.valueOf(data.intBlock.get(3)); - BigInteger lastValid = BigInteger.valueOf(data.intBlock.get(4)); - - Transaction txn = Transaction.PaymentTransactionBuilder() - .sender(senderAccount.getAddress()) - .flatFee(Account.MIN_TX_FEE_UALGOS) - .firstValid(firstValid) - .lastValid(lastValid) - .genesisHash(genesisHash) - .amount(amount) - .receiver(receiverAddress) - .closeRemainderTo(closeToAddress) - .lease(lease) - .build(); - - LogicsigSignature lsig = senderAccount.signLogicsig(new LogicsigSignature(contract.program)); - - return new SignedDynamicFee(txn, lsig); - } - - /** - * Create and sign the secondary dynamic fee transaction, update - * transaction fields, and sign as the fee payer; return both - * transactions ready to be sent. - * - * Create the Transaction and LogicsigSignature objects from base64 encoded objects: - * Encoder.decodeFromMsgPack(encodedTxn, Transaction.class), - * Encoder.decodeFromMsgPack(encodedLsig, LogicsigSignature.class), - * - * @param txn main transaction from payer - * @param lsig signed logic received from payer - * @param account an account initialized with a signing key. - * @param feePerByte fee per byte, for both transactions - */ - public static byte[] MakeReimbursementTransactions(final Transaction txn, final LogicsigSignature lsig, final Account account, final int feePerByte) throws NoSuchAlgorithmException, IOException { - Account.setFeeByFeePerByte(txn, BigInteger.valueOf(feePerByte)); - - // Reimbursement transaction - Transaction txn2 = Transaction.PaymentTransactionBuilder() - .sender(account.getAddress()) - .fee(feePerByte) - .firstValid(txn.firstValid) - .lastValid(txn.lastValid) - .genesisID(txn.genesisID) - .genesisHash(txn.genesisHash) - .amount(txn.fee) - .receiver(txn.sender) - .build(); - txn2.setLease(new Lease(txn.lease)); - Account.setFeeByFeePerByte(txn2, BigInteger.valueOf(feePerByte)); - - TxGroup.assignGroupID(txn2, txn); - SignedTransaction stx1 = new SignedTransaction(txn, lsig, txn.txID()); - SignedTransaction stx2 = account.signTransaction(txn2); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - baos.write(Encoder.encodeToMsgPack(stx2)); - baos.write(Encoder.encodeToMsgPack(stx1)); - return baos.toByteArray(); - } -} diff --git a/src/main/java/com/algorand/algosdk/templates/HTLC.java b/src/main/java/com/algorand/algosdk/templates/HTLC.java deleted file mode 100644 index b8f52b626..000000000 --- a/src/main/java/com/algorand/algosdk/templates/HTLC.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.algorand.algosdk.templates; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.List; - -import com.algorand.algosdk.account.Account; -import com.algorand.algosdk.builder.transaction.PaymentTransactionBuilder; -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.crypto.Digest; -import com.algorand.algosdk.crypto.LogicsigSignature; -import com.algorand.algosdk.logic.Logic; -import com.algorand.algosdk.templates.ContractTemplate.ParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.IntParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.AddressParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.BytesParameterValue; -import com.algorand.algosdk.transaction.SignedTransaction; -import com.algorand.algosdk.transaction.Transaction; -import com.algorand.algosdk.util.Digester; -import com.algorand.algosdk.util.Encoder; -import com.google.common.collect.ImmutableList; -import org.bouncycastle.jcajce.provider.digest.Keccak; -import org.bouncycastle.util.Arrays; - -import javax.annotation.Signed; - -import static com.algorand.algosdk.templates.ContractTemplate.readAndVerifyContract; - -@Deprecated -public class HTLC { - - private static String referenceProgram = "ASAEBQEABiYDIP68oLsUSlpOp7Q4pGgayA5soQW8tgf8VlMlyVaV9qITAQYg5pqWHm8tX3rIZgeSZVK+mCNe0zNjyoiRi7nJOKkVtvkxASIOMRAjEhAxBzIDEhAxCCQSEDEJKBItASkSEDEJKhIxAiUNEBEQ"; - /** - * Hash Time Locked Contract allows a user to recieve the Algo prior to a - * deadline (in terms of a round) by proving knowledge of a special value - * or to forfeit the ability to claim, returning it to the payer. - * This contract is usually used to perform cross-chained atomic swaps. - * - * More formally, algos can be transfered under only two circumstances: - * 1. To receiver if hash_function(arg_0) = hash_value - * 2. To owner if txn.FirstValid > expiry_round - * - * @param owner an address that can receive the asset after the expiry round - * @param receiver address to receive Algos - * @param hashFunction the hash function to be used (must be either sha256 or keccak256) - * @param hashImage the hash image in base64 - * @param expiryRound the round on which the assets can be transferred back to owner - * @param maxFee the maximum fee that can be paid to the network by the account - * @return ContractTemplate with the address and the program with the given parameter values - * @throws NoSuchAlgorithmException - */ - public static ContractTemplate MakeHTLC( - Address owner, - Address receiver, - String hashFunction, - String hashImage, - int expiryRound, - int maxFee) throws NoSuchAlgorithmException { - - int hashInject; - if (hashFunction.equals("sha256")) { - hashInject = 1; - } else if (hashFunction.equals("keccak256")) { - hashInject = 2; - } else { - throw new RuntimeException("invalid hash function supplied"); - } - - List values = ImmutableList.of( - new IntParameterValue(3, maxFee), - new IntParameterValue(6, expiryRound), - new AddressParameterValue(10, receiver), - new BytesParameterValue(42, hashImage), - new AddressParameterValue(45, owner), - new IntParameterValue(102, hashInject) - ); - return ContractTemplate.inject(Encoder.decodeFromBase64(referenceProgram), values); - } - - /** - * - * @param contract the contract created with HTLC.MakeHTLC - * @param preImage Base64 encoded pre-image string. - * @param firstValid first round where the transactions are valid - * @param lastValid last round where the transactions are valid - * @param feePerByte fee per byte multiplier - * @param genesisHash genesis hash - * @return - */ - public static SignedTransaction GetHTLCTransaction( - ContractTemplate contract, - String preImage, - int firstValid, - int lastValid, - Digest genesisHash, - int feePerByte) throws NoSuchAlgorithmException, IOException { - - // Read program data - Logic.ProgramData data = readAndVerifyContract(contract.program, 4, 3); - int maxFee = data.intBlock.get(0); - Address receiver = new Address(data.byteBlock.get(0)); - byte[] hashImage = data.byteBlock.get(1); - - int hashFunction = Integer.valueOf(contract.program[contract.program.length - 15]); - - // Validate hash function - if(hashFunction == 1) { - MessageDigest digest = MessageDigest.getInstance("SHA-256"); - byte[] computedImage = digest.digest(Encoder.decodeFromBase64(preImage)); - if(Arrays.compareUnsigned(computedImage, hashImage) != 0) { - throw new RuntimeException("Unable to verify SHA-256 preImage: sha256(preimage) != image"); - } - } - else if (hashFunction == 2) { - try { - Keccak.Digest256 digest = new Keccak.Digest256(); - byte[] computedImage = digest.digest(Encoder.decodeFromBase64(preImage)); - if (Arrays.compareUnsigned(computedImage, hashImage) != 0) { - throw new RuntimeException("Unable to verify Keccak-256 preImage: keccak256(preimage) != image"); - } - } catch (Exception e) { - // It's possible that the bouncy castle library is not loaded, in which case skip the validation. - } - } - else { - throw new RuntimeException("Invalid contract detected, unable to find a valid hash function ID."); - } - - Transaction txn = Transaction.PaymentTransactionBuilder() - .sender(contract.address) - .fee(0) - .firstValid(firstValid) - .lastValid(lastValid) - .genesisHash(genesisHash) - .amount(0) - .closeRemainderTo(receiver) - .build(); - - Account.setFeeByFeePerByte(txn, feePerByte); - - if (txn.fee.intValue() > maxFee) { - throw new RuntimeException("Transaction fee is too high: " + txn.fee.intValue() + " > " + maxFee); - } - - List args = ImmutableList.of(Encoder.decodeFromBase64(preImage)); - LogicsigSignature lsig = new LogicsigSignature(contract.program, args); - return new SignedTransaction(txn, lsig); - } -} diff --git a/src/main/java/com/algorand/algosdk/templates/LimitOrder.java b/src/main/java/com/algorand/algosdk/templates/LimitOrder.java deleted file mode 100644 index d63c62b8d..000000000 --- a/src/main/java/com/algorand/algosdk/templates/LimitOrder.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.algorand.algosdk.templates; - -import com.algorand.algosdk.account.Account; -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.crypto.Digest; -import com.algorand.algosdk.crypto.LogicsigSignature; -import com.algorand.algosdk.logic.Logic; -import com.algorand.algosdk.transaction.SignedTransaction; -import com.algorand.algosdk.transaction.Transaction; -import com.algorand.algosdk.transaction.TxGroup; -import com.algorand.algosdk.util.Encoder; -import com.google.common.collect.ImmutableList; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.Objects; - -import static com.algorand.algosdk.account.Account.setFeeByFeePerByte; -import static com.algorand.algosdk.templates.ContractTemplate.*; - -@Deprecated -public class LimitOrder { - protected static String referenceProgram = "ASAKAAEFAgYEBwgJCiYBIP68oLsUSlpOp7Q4pGgayA5soQW8tgf8VlMlyVaV9qITMRYiEjEQIxIQMQEkDhAyBCMSQABVMgQlEjEIIQQNEDEJMgMSEDMBECEFEhAzAREhBhIQMwEUKBIQMwETMgMSEDMBEiEHHTUCNQExCCEIHTUENQM0ATQDDUAAJDQBNAMSNAI0BA8QQAAWADEJKBIxAiEJDRAxBzIDEhAxCCISEBA="; - - /** - * MakeLimitOrder allows a user to exchange some number of assets for some number of algos. - * Fund the contract with some number of Algos to limit the maximum number of - * Algos you're willing to trade for some other asset. - * - * Works on two cases: - * - trading Algos for some other asset - * - closing out Algos back to the originator after a timeout - * - * trade case, a 2 transaction group: - * - gtxn[0] (this txn) Algos from Me to Other - * - gtxn[1] asset from Other to Me - * - * We want to get at least some amount of the other asset per our Algos - * gtxn[1].AssetAmount / gtxn[0].Amount >= N / D - * === - * gtxn[1].AssetAmount * D >= gtxn[0].Amount * N - * - * close-out case: - * - txn alone, close out value after timeout - * - * @param owner an address that can receive the asset after the expiry round - * @param assetId asset to be transfered - * @param ratn the numerator of the exchange rate - * @param ratd the denominator of the exchange rate - * @param expirationRound the round on which the assets can be transferred back to owner - * @param minTrade the minimum amount (of Algos) to be traded away - * @param maxFee the maximum fee that can be paid to the network by the account - */ - public static ContractTemplate MakeLimitOrder( - final Address owner, - final Integer assetId, - final Integer ratn, - final Integer ratd, - final Integer expirationRound, - final Integer minTrade, - final Integer maxFee - ) throws NoSuchAlgorithmException { - Objects.requireNonNull(owner); - Objects.requireNonNull(assetId); - Objects.requireNonNull(ratn); - Objects.requireNonNull(ratd); - Objects.requireNonNull(expirationRound); - Objects.requireNonNull(minTrade); - Objects.requireNonNull(maxFee); - - List values = ImmutableList.of( - new IntParameterValue(5, maxFee), - new IntParameterValue(7, minTrade), - new IntParameterValue(9, assetId), - new IntParameterValue(10, ratd), - new IntParameterValue(11, ratn), - new IntParameterValue(12, expirationRound), - new AddressParameterValue(16, owner) - ); - - byte[] program = Encoder.decodeFromBase64(referenceProgram); - return inject(program, values); - } - - /** - * Creates a group transaction array which transfer funds according to the contract's ratio - * - * @param contract previously created LimitOrder contract - * @param assetAmount amount of assets to be sent - * @param microAlgoAmount number of algos to transfer - * @param sender account to sign the payment transaction - * @param firstValid first round on which these txns will be valid - * @param lastValid last round on which these txns will be valid - * @param genesisHash Genesis hash for the network where the transaction will be submitted. - * @param feePerByte fee per byte used for the transactions - * @return - * @throws IOException - */ - public static byte[] MakeSwapAssetsTransaction( - ContractTemplate contract, - Integer assetAmount, - Integer microAlgoAmount, - Account sender, - Integer firstValid, - Integer lastValid, - Digest genesisHash, - Integer feePerByte - ) throws IOException, NoSuchAlgorithmException { - Logic.ProgramData data = readAndVerifyContract(contract.program, 10, 1); - - Address owner = new Address(data.byteBlock.get(0)); - int maxFee = data.intBlock.get(2); - int minTrade = data.intBlock.get(4); - int assetId = data.intBlock.get(6); - int ratd = data.intBlock.get(7); - int ratn = data.intBlock.get(8); - - // Verify the exchange rate ratio - if (assetAmount * ratd != microAlgoAmount * ratn) { - throw new IllegalArgumentException("The exchange ratio of assets to microalgos must be exactly " + ratn + " / " + ratd + ", received " + assetAmount + " / " + microAlgoAmount); - } - - // Verify minTrade amount - if (microAlgoAmount < minTrade) { - throw new IllegalArgumentException("At least " + minTrade + " microalgos must be requested."); - } - - Transaction tx1 = Transaction.PaymentTransactionBuilder() - .sender(contract.address) - .fee(feePerByte) - .firstValid(firstValid) - .lastValid(lastValid) - .genesisHash(genesisHash) - .amount(microAlgoAmount) - .receiver(sender.getAddress()) - .build(); - - Transaction tx2 = Transaction.AssetTransferTransactionBuilder() - .sender(sender.getAddress()) - .assetReceiver(owner) - .assetAmount(assetAmount) - .fee(feePerByte) - .firstValid(firstValid) - .lastValid(lastValid) - .genesisHash(genesisHash) - .assetIndex(assetId) - .build(); - - if (tx1.fee.longValue() > maxFee || tx2.fee.longValue() > maxFee) { - long fee = Math.max(tx1.fee.longValue(), tx2.fee.longValue()); - throw new RuntimeException("Transaction fee is greater than maxFee: " + fee + " > " + maxFee); - } - - TxGroup.assignGroupID(tx1, tx2); - LogicsigSignature lsig = new LogicsigSignature(contract.program); - SignedTransaction stx1 = new SignedTransaction(tx1, lsig, tx1.txID()); - SignedTransaction stx2 = sender.signTransaction(tx2); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - baos.write(Encoder.encodeToMsgPack(stx1)); - baos.write(Encoder.encodeToMsgPack(stx2)); - return baos.toByteArray(); - } -} diff --git a/src/main/java/com/algorand/algosdk/templates/PeriodicPayment.java b/src/main/java/com/algorand/algosdk/templates/PeriodicPayment.java deleted file mode 100644 index 55746cce1..000000000 --- a/src/main/java/com/algorand/algosdk/templates/PeriodicPayment.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.algorand.algosdk.templates; - -import com.algorand.algosdk.account.Account; -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.crypto.Digest; -import com.algorand.algosdk.crypto.LogicsigSignature; -import com.algorand.algosdk.logic.Logic; -import com.algorand.algosdk.transaction.SignedTransaction; -import com.algorand.algosdk.transaction.Transaction; -import com.algorand.algosdk.util.Encoder; -import com.algorand.algosdk.templates.ContractTemplate.ParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.IntParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.BytesParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.AddressParameterValue; -import com.algorand.algosdk.transaction.Lease; -import com.google.common.collect.ImmutableList; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.NoSuchAlgorithmException; -import java.util.List; - -import static com.algorand.algosdk.templates.ContractTemplate.readAndVerifyContract; - -@Deprecated -public class PeriodicPayment { - private static String referenceProgram = "ASAHAQoLAAwNDiYCAQYg/ryguxRKWk6ntDikaBrIDmyhBby2B/xWUyXJVpX2ohMxECISMQEjDhAxAiQYJRIQMQQhBDECCBIQMQYoEhAxCTIDEjEHKRIQMQghBRIQMQkpEjEHMgMSEDECIQYNEDEIJRIQERA="; - - /** - * PeriodicPayment contract enables creating an account which allows the - * withdrawal of a fixed amount of assets every fixed number of rounds to a - * specific Algrorand Address. In addition, the contract allows to add - * an expiryRound, after which the address can withdraw the rest of the assets. - * - * @param receiver address to receive the assets. - * @param amount amount of assets to transfer at every cycle. - * @param withdrawingWindow the number of blocks in which the user can withdraw the asset once the period start (must be < 1000). - * @param period how often the address can withdraw assets (in rounds). - * @param fee maximum fee per transaction. - * @param expiryRound a round in which the receiver can withdraw the rest of the funds after. - * - * @return PeriodicPayment contract. - */ - public static ContractTemplate MakePeriodicPayment( - final Address receiver, - final int amount, - final int withdrawingWindow, - final int period, - final int fee, - final int expiryRound - ) throws NoSuchAlgorithmException { - return MakePeriodicPayment(receiver, amount, withdrawingWindow, period, fee, expiryRound, null); - } - - /** - * Need a way to specify the lease for testing. - */ - protected static ContractTemplate MakePeriodicPayment( - final Address receiver, - final int amount, - final int withdrawingWindow, - final int period, - final int fee, - final int expiryRound, - final Lease lease - ) throws NoSuchAlgorithmException { - if (withdrawingWindow < 0 || withdrawingWindow > 1000) { - throw new IllegalArgumentException("The withdrawingWindow must be a positive number less than 1000"); - } - - List values = ImmutableList.of( - new IntParameterValue(4, fee), - new IntParameterValue(5, period), - new IntParameterValue(7, withdrawingWindow), - new IntParameterValue(8, amount), - new IntParameterValue(9, expiryRound), - new BytesParameterValue(12, lease == null ? new Lease() : lease), - new AddressParameterValue(15, receiver) - ); - - return ContractTemplate.inject(Encoder.decodeFromBase64(referenceProgram), values); - } - - /** - * Return the withdrawal transaction to be sent to the network. - * - * @param contract contract containing information, this should be provided by the payer. - * @param firstValid first round the transaction should be valid. - * @param genesisHash genesis hash in base64. - * @param feePerByte fee per byte to apply to transaction. - * @return Signed withdrawal transaction. - */ - public static SignedTransaction MakeWithdrawalTransaction( - final ContractTemplate contract, - final int firstValid, - final Digest genesisHash, - final int feePerByte - ) throws IOException, NoSuchAlgorithmException { - Logic.ProgramData data = readAndVerifyContract(contract.program, 7, 2); - - int maxFee = data.intBlock.get(1); - int period = data.intBlock.get(2); - int withdrawingWindow = data.intBlock.get(4); - int amount = data.intBlock.get(5); - Lease lease = new Lease(data.byteBlock.get(0)); - Address receiver = new Address(data.byteBlock.get(1)); - - if (firstValid % period != 0) { - throw new IllegalArgumentException("invalid contract: firstValid must be divisible by the period"); - } - - LogicsigSignature lsig = new LogicsigSignature(contract.program); - Transaction tx = Transaction.PaymentTransactionBuilder() - .sender(contract.address) - .receiver(receiver) - .fee(feePerByte) - .firstValid(firstValid) - .lastValid(firstValid + withdrawingWindow) - .amount(amount) - .genesisHash(genesisHash) - .lease(lease) - .build(); - - if (tx.fee.longValue() > maxFee) { - throw new RuntimeException("Withrawl transaction fee too high: " + tx.fee + " > " + maxFee); - } - - if (!lsig.verify(tx.sender)) { - throw new IllegalArgumentException("Failed to verify transaction."); - } - - return Account.signLogicsigTransaction(lsig, tx); - } -} diff --git a/src/main/java/com/algorand/algosdk/templates/Split.java b/src/main/java/com/algorand/algosdk/templates/Split.java deleted file mode 100644 index 685817e43..000000000 --- a/src/main/java/com/algorand/algosdk/templates/Split.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.algorand.algosdk.templates; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.NoSuchAlgorithmException; -import java.util.List; - -import com.algorand.algosdk.account.Account; -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.crypto.Digest; -import com.algorand.algosdk.crypto.LogicsigSignature; -import com.algorand.algosdk.logic.Logic; -import com.algorand.algosdk.templates.ContractTemplate.ParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.IntParameterValue; -import com.algorand.algosdk.templates.ContractTemplate.AddressParameterValue; -import com.algorand.algosdk.transaction.SignedTransaction; -import com.algorand.algosdk.transaction.Transaction; -import com.algorand.algosdk.transaction.TxGroup; -import com.algorand.algosdk.util.Encoder; -import com.google.common.collect.ImmutableList; - -import static com.algorand.algosdk.templates.ContractTemplate.readAndVerifyContract; - -@Deprecated -public class Split { - private static String referenceProgram = "ASAIAQUCAAYHCAkmAyDYHIR7TIW5eM/WAZcXdEDqv7BD+baMN6i2/A5JatGbNCDKsaoZHPQ3Zg8zZB/BZ1oDgt77LGo5np3rbto3/gloTyB40AS2H3I72YCbDk4hKpm7J7NnFy2Xrt39TJG0ORFg+zEQIhIxASMMEDIEJBJAABkxCSgSMQcyAxIQMQglEhAxAiEEDRAiQAAuMwAAMwEAEjEJMgMSEDMABykSEDMBByoSEDMACCEFCzMBCCEGCxIQMwAIIQcPEBA="; - - /** - * Split allows locking algos in an account which allows transfering to two - * predefined addresses in a specified ratio such that for the given ratn and - * ratd parameters we have: - * - * first_recipient_amount * rat_2 == second_recipient_amount * rat_1 - * - * Split also has an expiry round, after which the owner can transfer back - * the funds. - * - * @param owner the address to refund funds to on timeout - * @param receiver1 the first recipient in the split account - * @param receiver2 the second recipient in the split account - * @param rat1 how much receiver1 receives (proportionally) - * @param rat2 how much receiver2 receives (proportionally) - * @param expiryRound the round at which the account expires - * @param minPay minimum amount to be paid out of the account to receiver1 - * @param maxFee half of the maximum fee used by each split forwarding group transaction - * @return ContractTemplate with the address and the program with the given parameter values - * @throws NoSuchAlgorithmException - */ - public static ContractTemplate MakeSplit( - Address owner, - Address receiver1, - Address receiver2, - int rat1, - int rat2, - int expiryRound, - int minPay, - int maxFee) throws NoSuchAlgorithmException { - - List values = ImmutableList.of( - new IntParameterValue(4, maxFee), - new IntParameterValue(7, expiryRound), - new IntParameterValue(8, rat2), - new IntParameterValue(9, rat1), - new IntParameterValue(10, minPay), - new AddressParameterValue(14, owner), - new AddressParameterValue(47, receiver1), - new AddressParameterValue(80, receiver2) - ); - - return ContractTemplate.inject(Encoder.decodeFromBase64(referenceProgram), values); - } - - /** - * Generate group transactions to transfer funds according to the contract's ratio. - * - * @param contract the contract created with Split.MakeSplit - * @param amount amount to be transferred from the contract to the receivers according to the contract ratio. - * @param firstValid first round where the transactions are valid - * @param genesisHash genesis hash - * @param feePerByte fee per byte multiplier - * @return - */ - public static byte[] GetSplitTransactions( - ContractTemplate contract, - int amount, - int firstValid, - int lastValid, - int feePerByte, - Digest genesisHash) throws NoSuchAlgorithmException, IOException { - Logic.ProgramData data = readAndVerifyContract(contract.program, 8, 3); - - int maxFee = data.intBlock.get(1); - int rat1 = data.intBlock.get(6); - int rat2 = data.intBlock.get(5); - int minTrade = data.intBlock.get(7); - - Double fraction = Double.valueOf(rat1) / Double.valueOf(rat1+rat2); - int receiverOneAmount = Long.valueOf(Math.round(fraction * amount)).intValue(); - int receiverTwoAmount = Long.valueOf(Math.round((1.0 - fraction) * amount)).intValue(); - - // With proper rounding, this should hopefully never happen. - if (amount - receiverOneAmount - receiverTwoAmount != 0) { - throw new RuntimeException("Unable to exactly split " + amount + " using the contract ratio of " + rat1 + " / " + rat2); - } - - if (receiverOneAmount < minTrade) { - throw new RuntimeException("Receiver one must receive at least " + minTrade); - } - - BigInteger rcv1 = BigInteger.valueOf(receiverOneAmount).multiply(BigInteger.valueOf(rat2)); - BigInteger rcv2 = BigInteger.valueOf(receiverTwoAmount).multiply(BigInteger.valueOf(rat1)); - if (rcv1.equals(rcv2) == false) { - throw new RuntimeException("The token split must be exactly " + rat1 + " / " + rat2 + ", received " + receiverOneAmount + " / " + receiverTwoAmount); - } - - Address receiver1 = new Address(data.byteBlock.get(1)); - Address receiver2 = new Address(data.byteBlock.get(2)); - - Transaction tx1 = Transaction.PaymentTransactionBuilder() - .sender(contract.address) - .receiver(receiver1) - .fee(feePerByte) - .amount(receiverOneAmount) - .firstValid(firstValid) - .lastValid(lastValid) - .genesisHash(genesisHash) - .build(); - - Transaction tx2 = Transaction.PaymentTransactionBuilder() - .sender(contract.address) - .receiver(receiver2) - .fee(feePerByte) - .amount(receiverTwoAmount) - .firstValid(firstValid) - .lastValid(lastValid) - .genesisHash(genesisHash) - .build(); - - if (tx1.fee.longValue() > maxFee || tx2.fee.longValue() > maxFee) { - long fee = Math.max(tx1.fee.longValue(), tx2.fee.longValue()); - throw new RuntimeException("Transaction fee is greater than maxFee: " + fee + " > " + maxFee); - } - - LogicsigSignature lsig = new LogicsigSignature(contract.program); - TxGroup.assignGroupID(tx1, tx2); - SignedTransaction stx1 = new SignedTransaction(tx1, lsig, tx1.txID()); - SignedTransaction stx2 = new SignedTransaction(tx2, lsig, tx2.txID()); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - baos.write(Encoder.encodeToMsgPack(stx1)); - baos.write(Encoder.encodeToMsgPack(stx2)); - return baos.toByteArray(); - } -} diff --git a/src/main/java/com/algorand/algosdk/transaction/Transaction.java b/src/main/java/com/algorand/algosdk/transaction/Transaction.java index 518796dd6..aa00104ed 100644 --- a/src/main/java/com/algorand/algosdk/transaction/Transaction.java +++ b/src/main/java/com/algorand/algosdk/transaction/Transaction.java @@ -175,456 +175,6 @@ public class Transaction implements Serializable { @JsonProperty("spmsg") public Map stateProofMessage = null; - /** - * Create a payment transaction - * - * @param fromAddr source address - * @param toAddr destination address - * @param fee transaction fee - * @param amount payment amount - * @param firstRound first valid round - * @param lastRound last valid round - */ - @Deprecated - public Transaction(Address fromAddr, Address toAddr, BigInteger fee, BigInteger amount, BigInteger firstRound, - BigInteger lastRound) { - this(fromAddr, fee, firstRound, lastRound, null, amount, toAddr, "", new Digest()); - } - - @Deprecated - public Transaction(Address fromAddr, Address toAddr, BigInteger fee, BigInteger amount, BigInteger firstRound, - BigInteger lastRound, - String genesisID, Digest genesisHash) { - this(fromAddr, fee, firstRound, lastRound, null, amount, toAddr, genesisID, genesisHash); - } - - /** - * Create a payment transaction. Make sure to sign with a suggested fee. - * - * @param fromAddr source address - * @param toAddr destination address - * @param amount amount to send - * @param firstRound first valid round - * @param lastRound last valid round - * @param genesisID genesis id - * @param genesisHash genesis hash - */ - @Deprecated - public Transaction(Address fromAddr, Address toAddr, long amount, long firstRound, long lastRound, - String genesisID, Digest genesisHash) { - this(fromAddr, Account.MIN_TX_FEE_UALGOS, BigInteger.valueOf(firstRound), BigInteger.valueOf(lastRound), null, BigInteger.valueOf(amount), toAddr, genesisID, genesisHash); - } - - @Deprecated - public Transaction(Address sender, BigInteger fee, BigInteger firstValid, BigInteger lastValid, byte[] note, - BigInteger amount, Address receiver, String genesisID, Digest genesisHash) { - this(sender, fee, firstValid, lastValid, note, genesisID, genesisHash, amount, receiver, new Address()); - } - - @Deprecated - public Transaction(Address sender, BigInteger fee, BigInteger firstValid, BigInteger lastValid, byte[] note, String genesisID, Digest genesisHash, - BigInteger amount, Address receiver, Address closeRemainderTo) { - this.type = Type.Payment; - if (sender != null) this.sender = sender; - setFee(fee); - if (firstValid != null) this.firstValid = firstValid; - if (lastValid != null) this.lastValid = lastValid; - setNote(note); - if (genesisID != null) this.genesisID = genesisID; - if (genesisHash != null) this.genesisHash = genesisHash; - if (amount != null) this.amount = amount; - if (receiver != null) this.receiver = receiver; - if (closeRemainderTo != null) this.closeRemainderTo = closeRemainderTo; - } - - /** - * Create a payment transaction. - */ - @Deprecated - public static Transaction createPaymentTransaction(Address sender, BigInteger fee, BigInteger firstValid, - BigInteger lastValid, byte[] note, String genesisID, - Digest genesisHash, BigInteger amount, Address receiver, - Address closeRemainderTo) { - Objects.requireNonNull(sender, "sender is required."); - Objects.requireNonNull(firstValid, "firstValid is required."); - Objects.requireNonNull(lastValid, "lastValid is required."); - Objects.requireNonNull(genesisHash, "genesisHash is required."); - - if (receiver == null && closeRemainderTo == null) { - throw new IllegalArgumentException("Must set at least one of 'receiver' or 'closeRemainderTo'"); - } - - return new Transaction( - Type.Payment, - //header fields - sender, - fee, - firstValid, - lastValid, - note, - genesisID, - genesisHash, - null, - null, - null, - // payment fields - amount, - receiver, - closeRemainderTo, - // keyreg fields - null, - null, - null, - null, - // voteKeyDilution - null, - null, - false, - // asset creation and configuration - null, - null, - // asset transfer fields - null, - null, - null, - null, - null, - null, - null, - false, // default value which wont be included in the serialized object. - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null); - } - - /** - * Create a key registration transaction. No field can be null except the note field. - * - * @param sender source address - * @param fee transaction fee - * @param firstValid first valid round - * @param lastValid last valid round - * @param note optional notes field (can be null) - * @param votePK the new participation key to register - * @param vrfPK the sortition key to register - * @param voteFirst key reg valid first round - * @param voteLast key reg valid last round - * @param voteKeyDilution key reg dilution - */ - @Deprecated - public Transaction(Address sender, BigInteger fee, BigInteger firstValid, BigInteger lastValid, byte[] note, - String genesisID, Digest genesisHash, - ParticipationPublicKey votePK, VRFPublicKey vrfPK, - BigInteger voteFirst, BigInteger voteLast, BigInteger voteKeyDilution) { - this.type = Type.KeyRegistration; - if (sender != null) this.sender = sender; - setFee(fee); - if (firstValid != null) this.firstValid = firstValid; - if (lastValid != null) this.lastValid = lastValid; - setNote(note); - if (genesisID != null) this.genesisID = genesisID; - if (genesisHash != null) this.genesisHash = genesisHash; - if (votePK != null) this.votePK = votePK; - if (vrfPK != null) this.selectionPK = vrfPK; - if (voteFirst != null) this.voteFirst = voteFirst; - if (voteLast != null) this.voteLast = voteLast; - if (voteKeyDilution != null) this.voteKeyDilution = voteKeyDilution; - } - - /** - * Create a key registration transaction. - */ - @Deprecated - public static Transaction createKeyRegistrationTransaction(Address sender, BigInteger fee, BigInteger firstValid, - BigInteger lastValid, byte[] note, String genesisID, - Digest genesisHash, ParticipationPublicKey votePK, - VRFPublicKey vrfPK, BigInteger voteFirst, - BigInteger voteLast, BigInteger voteKeyDilution) { - Objects.requireNonNull(sender, "sender is required"); - Objects.requireNonNull(firstValid, "firstValid is required"); - Objects.requireNonNull(lastValid, "lastValid is required"); - Objects.requireNonNull(genesisHash, "genesisHash is required"); - /* - Objects.requireNonNull(votePK, "votePK is required"); - Objects.requireNonNull(vrfPK, "vrfPK is required"); - Objects.requireNonNull(voteFirst, "voteFirst is required"); - Objects.requireNonNull(voteLast, "voteLast is required"); - Objects.requireNonNull(voteKeyDilution, "voteKeyDilution is required"); - */ - - return new Transaction( - Type.KeyRegistration, - //header fields - sender, - fee, - firstValid, - lastValid, - note, - genesisID, - genesisHash, - null, - null, - null, - // payment fields - null, - null, - null, - // keyreg fields - votePK, - vrfPK, - voteFirst, - voteLast, - // voteKeyDilution - voteKeyDilution, - null, - // asset creation and configuration - null, - // asset transfer fields - null, - null, - null, - null, - null, - null, - null, - false, // default value which wont be included in the serialized object. - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null); - } - - /** - * Create an asset creation transaction. Note can be null. manager, reserve, freeze, and clawback can be zeroed. - * - * @param sender source address - * @param fee transaction fee - * @param firstValid first valid round - * @param lastValid last valid round - * @param note optional note field (can be null) - * @param genesisID - * @param genesisHash - * @param assetTotal total asset issuance - * @param assetDecimals asset decimal precision - * @param defaultFrozen whether accounts have this asset frozen by default - * @param assetUnitName name of unit of the asset - * @param assetName name of the asset - * @param url where more information about the asset can be retrieved - * @param metadataHash specifies a commitment to some unspecified asset metadata. The format of this metadata is up to the application - * @param manager account which can reconfigure the asset - * @param reserve account whose asset holdings count as non-minted - * @param freeze account which can freeze or unfreeze holder accounts - * @param clawback account which can issue clawbacks against holder accounts - */ - @Deprecated - private Transaction(Address sender, BigInteger fee, BigInteger firstValid, BigInteger lastValid, byte[] note, - String genesisID, Digest genesisHash, BigInteger assetTotal, Integer assetDecimals, boolean defaultFrozen, - String assetUnitName, String assetName, String url, byte[] metadataHash, - Address manager, Address reserve, Address freeze, Address clawback) { - this.type = Type.AssetConfig; - if (sender != null) this.sender = sender; - setFee(fee); - if (firstValid != null) this.firstValid = firstValid; - if (lastValid != null) this.lastValid = lastValid; - setNote(note); - if (genesisID != null) this.genesisID = genesisID; - if (genesisHash != null) this.genesisHash = genesisHash; - - this.assetParams = new AssetParams(assetTotal, assetDecimals, defaultFrozen, assetUnitName, assetName, url, metadataHash, manager, reserve, freeze, clawback); - } - - /** - * Create an asset creation transaction. Note can be null. manager, reserve, freeze, and clawback can be zeroed. - * - * @param sender source address - * @param fee transaction fee - * @param firstValid first valid round - * @param lastValid last valid round - * @param note optional note field (can be null) - * @param genesisID - * @param genesisHash - * @param assetTotal total asset issuance - * @param assetDecimals asset decimal precision - * @param defaultFrozen whether accounts have this asset frozen by default - * @param assetUnitName name of unit of the asset - * @param assetName name of the asset - * @param url where more information about the asset can be retrieved - * @param metadataHash specifies a commitment to some unspecified asset metadata. The format of this metadata is up to the application - * @param manager account which can reconfigure the asset - * @param reserve account whose asset holdings count as non-minted - * @param freeze account which can freeze or unfreeze holder accounts - * @param clawback account which can issue clawbacks against holder accounts - */ - @Deprecated - public static Transaction createAssetCreateTransaction(Address sender, BigInteger fee, BigInteger firstValid, BigInteger lastValid, byte[] note, - String genesisID, Digest genesisHash, BigInteger assetTotal, Integer assetDecimals, boolean defaultFrozen, - String assetUnitName, String assetName, String url, byte[] metadataHash, - Address manager, Address reserve, Address freeze, Address clawback) { - - Objects.requireNonNull(sender, "sender is required."); - Objects.requireNonNull(firstValid, "firstValid is required."); - Objects.requireNonNull(lastValid, "lastValid is required."); - Objects.requireNonNull(genesisHash, "genesisHash is required."); - Objects.requireNonNull(assetTotal, "assetTotal is required."); - Objects.requireNonNull(assetDecimals, "assetDecimals is required."); - - AssetParams params = new AssetParams(assetTotal, assetDecimals, defaultFrozen, assetUnitName, assetName, url, - metadataHash, manager, reserve, freeze, clawback); - return new Transaction( - Type.AssetConfig, - //header fields - sender, - fee, - firstValid, - lastValid, - note, - genesisID, - genesisHash, - null, - null, - null, - // payment fields - null, - null, - null, - // keyreg fields - null, - null, - null, - null, - // voteKeyDilution - null, - null, - false, - // asset creation and configuration - params, - null, - // asset transfer fields - null, - null, - null, - null, - null, - null, - null, - false, // default value which wont be included in the serialized object. - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null); - } - - /** - * Create an asset configuration transaction. Note can be null. manager, reserve, freeze, and clawback can be zeroed. - * - * @param sender source address - * @param fee transaction fee - * @param firstValid first valid round - * @param lastValid last valid round - * @param note optional note field (can be null) - * @param genesisID - * @param genesisHash - * @param index asset index - * @param manager account which can reconfigure the asset - * @param reserve account whose asset holdings count as non-minted - * @param freeze account which can freeze or unfreeze holder accounts - * @param clawback account which can issue clawbacks against holder accounts - */ - private Transaction(Address sender, BigInteger fee, BigInteger firstValid, BigInteger lastValid, byte[] note, - String genesisID, Digest genesisHash, BigInteger index, - Address manager, Address reserve, Address freeze, Address clawback) { - - this.type = Type.AssetConfig; - if (sender != null) this.sender = sender; - setFee(fee); - if (firstValid != null) this.firstValid = firstValid; - if (lastValid != null) this.lastValid = lastValid; - setNote(note); - if (genesisID != null) this.genesisID = genesisID; - if (genesisHash != null) this.genesisHash = genesisHash; - this.assetParams = new AssetParams(BigInteger.valueOf(0), 0, false, "", "", "", null, manager, reserve, freeze, clawback); - assetIndex = index; - } - - /** - * Create an asset configuration transaction. Note can be null. manager, reserve, freeze, and clawback can be zeroed. - * - * @param sender source address - * @param fee transaction fee - * @param firstValid first valid round - * @param lastValid last valid round - * @param note optional note field (can be null) - * @param genesisID - * @param genesisHash - * @param index asset index - * @param manager account which can reconfigure the asset - * @param reserve account whose asset holdings count as non-minted - * @param freeze account which can freeze or unfreeze holder accounts - * @param clawback account which can issue clawbacks against holder accounts - * @param strictEmptyAddressChecking if true, disallow empty admin accounts from being set (preventing accidental disable of admin features) - */ - @Deprecated - public static Transaction createAssetConfigureTransaction( - Address sender, - BigInteger fee, - BigInteger firstValid, - BigInteger lastValid, - byte[] note, - String genesisID, - Digest genesisHash, - BigInteger index, - Address manager, - Address reserve, - Address freeze, - Address clawback, - boolean strictEmptyAddressChecking) { - Address defaultAddr = new Address(); - if (strictEmptyAddressChecking && ( - (manager == null || manager.equals(defaultAddr)) || - (reserve == null || reserve.equals(defaultAddr)) || - (freeze == null || freeze.equals(defaultAddr)) || - (clawback == null || clawback.equals(defaultAddr)) - )) { - throw new RuntimeException("strict empty address checking requested but " - + "empty or default address supplied to one or more manager addresses"); - } - return new Transaction( - sender, - fee, - firstValid, - lastValid, - note, - genesisID, - genesisHash, - index, - manager, - reserve, - freeze, - clawback); - } - /** * Helper for Jackson conversion. */ @@ -734,123 +284,13 @@ private Transaction(@JsonProperty("type") Type type, convertToAddressList(accounts), foreignApps, foreignAssets, + boxReferences, globalStateSchema, applicationId, localStateSchema, clearStateProgram == null ? null : new TEALProgram(clearStateProgram), extraPages ); - // Set fields _not_ exposed by public constructor. Needed because: - // * Adding parameters to a public constructor is a breaking API change. - // * To ensure JSON/msgpack serialization (via Jackson's ObjectMapper) works, must add `@JsonProperty` to _a_ constructor. Using a private constructor here to maintain API backwards compatibility. - if (boxReferences != null) this.boxReferences = boxReferences; - } - - /** - * Constructor which takes all the fields of Transaction except for nonpart. - * For details about which fields to use with different transaction types, refer to the developer documentation: - * https://developer.algorand.org/docs/reference/transactions/#asset-transfer-transaction - */ - @Deprecated - public Transaction( - Type type, - //header fields - Address sender, - BigInteger fee, - BigInteger firstValid, - BigInteger lastValid, - byte[] note, - String genesisID, - Digest genesisHash, - byte[] lease, - Address rekeyTo, - Digest group, - // payment fields - BigInteger amount, - Address receiver, - Address closeRemainderTo, - // keyreg fields - ParticipationPublicKey votePK, - VRFPublicKey vrfPK, - BigInteger voteFirst, - BigInteger voteLast, - // voteKeyDilution - BigInteger voteKeyDilution, - // asset creation and configuration - AssetParams assetParams, - BigInteger assetIndex, - // asset transfer fields - BigInteger xferAsset, - BigInteger assetAmount, - Address assetSender, - Address assetReceiver, - Address assetCloseTo, - Address freezeTarget, - BigInteger assetFreezeID, - boolean freezeState, - // application fields - List applicationArgs, - OnCompletion onCompletion, - TEALProgram approvalProgram, - List

accounts, - List foreignApps, - List foreignAssets, - StateSchema globalStateSchema, - Long applicationId, - StateSchema localStateSchema, - TEALProgram clearStateProgram, - Long extraPages - ) { - this( - type, - //header fields - sender, - fee, - firstValid, - lastValid, - note, - genesisID, - genesisHash, - lease, - rekeyTo, - group, - // payment fields - amount, - receiver, - closeRemainderTo, - // keyreg fields - votePK, - vrfPK, - new MerkleVerifier(), - voteFirst, - voteLast, - voteKeyDilution, - false, - // asset creation and configuration - assetParams, - assetIndex, - // asset transfer fields - xferAsset, - assetAmount, - assetSender, - assetReceiver, - assetCloseTo, - freezeTarget, - assetFreezeID, - freezeState, - // application fields - applicationArgs, - onCompletion, - approvalProgram == null ? null : approvalProgram, - accounts, - foreignApps, - foreignAssets, - globalStateSchema, - applicationId, - localStateSchema, - clearStateProgram == null ? null : clearStateProgram, - extraPages - ); } /** @@ -858,7 +298,7 @@ public Transaction( * For details about which fields to use with different transaction types, refer to the developer documentation: * https://developer.algorand.org/docs/reference/transactions/#asset-transfer-transaction */ - public Transaction( + private Transaction( Type type, //header fields Address sender, @@ -903,6 +343,7 @@ public Transaction( List
accounts, List foreignApps, List foreignAssets, + List boxReferences, StateSchema globalStateSchema, Long applicationId, StateSchema localStateSchema, @@ -911,13 +352,13 @@ public Transaction( ) { if (type != null) this.type = type; if (sender != null) this.sender = sender; - setFee(fee); + this.fee = (fee == null ? Account.MIN_TX_FEE_UALGOS : fee); if (firstValid != null) this.firstValid = firstValid; if (lastValid != null) this.lastValid = lastValid; setNote(note); if (genesisID != null) this.genesisID = genesisID; if (genesisHash != null) this.genesisHash = genesisHash; - setLease(lease); + if (lease != null) setLease(new Lease(lease)); if (rekeyTo != null) this.rekeyTo = rekeyTo; if (group != null) this.group = group; if (amount != null) this.amount = amount; @@ -946,6 +387,7 @@ public Transaction( if (accounts != null) this.accounts = accounts; if (foreignApps != null) this.foreignApps = foreignApps; if (foreignAssets != null) this.foreignAssets = foreignAssets; + if (boxReferences != null) this.boxReferences = boxReferences; if (globalStateSchema != null) this.globalStateSchema = globalStateSchema; if (applicationId != null) this.applicationId = applicationId; if (localStateSchema != null) this.localStateSchema = localStateSchema; @@ -957,305 +399,12 @@ public Transaction( public Transaction() { } - /** - * Base constructor with flat fee for asset xfer/freeze/destroy transactions. - * - * @param flatFee is the transaction flat fee - * @param firstRound is the first round this txn is valid (txn semantics - * unrelated to asset management) - * @param lastRound is the last round this txn is valid - * @param note - * @param genesisHash corresponds to the base64-encoded hash of the genesis - * of the network - **/ - private Transaction( - Type type, - BigInteger flatFee, - BigInteger firstRound, - BigInteger lastRound, - byte[] note, - Digest genesisHash) { - - this.type = type; - setFee(flatFee); - if (firstRound != null) this.firstValid = firstRound; - if (lastRound != null) this.lastValid = lastRound; - setNote(note); - if (genesisHash != null) this.genesisHash = genesisHash; - } - - /** - * Creates a tx to mark the account as willing to accept the asset. - * - * @param acceptingAccount is a checksummed, human-readable address that - * will accept receiving the asset. - * @param flatFee is the transaction flat fee - * @param firstRound is the first round this txn is valid (txn semantics - * unrelated to asset management) - * @param lastRound is the last round this txn is valid - * @param note - * @param genesisID corresponds to the id of the network - * @param genesisHash corresponds to the base64-encoded hash of the genesis - * of the network - * @param assetIndex is the asset index - **/ - @Deprecated - public static Transaction createAssetAcceptTransaction( //AssetTransaction - Address acceptingAccount, - BigInteger flatFee, - BigInteger firstRound, - BigInteger lastRound, - byte[] note, - String genesisID, - Digest genesisHash, - BigInteger assetIndex) { - - Transaction tx = createAssetTransferTransaction( - acceptingAccount, - acceptingAccount, - new Address(), - BigInteger.valueOf(0), - flatFee, - firstRound, - lastRound, - note, - genesisID, - genesisHash, - assetIndex); - - return tx; - } - - /** - * Creates a tx to destroy the asset - * - * @param senderAccount is a checksummed, human-readable address of the sender - * @param flatFee is the transaction flat fee - * @param firstValid is the first round this txn is valid (txn semantics - * unrelated to asset management) - * @param lastValid is the last round this txn is valid - * @param note - * @param genesisHash corresponds to the base64-encoded hash of the genesis - * of the network - * @param assetIndex is the asset ID to destroy - **/ - @Deprecated - public static Transaction createAssetDestroyTransaction( - Address senderAccount, - BigInteger flatFee, - BigInteger firstValid, - BigInteger lastValid, - byte[] note, - Digest genesisHash, - BigInteger assetIndex) { - Transaction tx = new Transaction( - Type.AssetConfig, - flatFee, - firstValid, - lastValid, - note, - genesisHash); - - if (assetIndex != null) tx.assetIndex = assetIndex; - if (senderAccount != null) tx.sender = senderAccount; - return tx; - } - - /** - * Creates a tx to freeze/unfreeze assets - * - * @param senderAccount is a checksummed, human-readable address of the sender - * @param flatFee is the transaction flat fee - * @param firstValid is the first round this txn is valid (txn semantics - * unrelated to asset management) - * @param lastValid is the last round this txn is valid - * @param note - * @param genesisHash corresponds to the base64-encoded hash of the genesis - * of the network - * @param assetIndex is the asset ID to destroy - **/ - @Deprecated - public static Transaction createAssetFreezeTransaction( - Address senderAccount, - Address accountToFreeze, - boolean freezeState, - BigInteger flatFee, - BigInteger firstValid, - BigInteger lastValid, - byte[] note, - Digest genesisHash, - BigInteger assetIndex) { - Transaction tx = new Transaction( - Type.AssetFreeze, - flatFee, - firstValid, - lastValid, - note, - genesisHash); - - if (senderAccount != null) tx.sender = senderAccount; - if (accountToFreeze != null) tx.freezeTarget = accountToFreeze; - if (assetIndex != null) tx.assetFreezeID = assetIndex; - tx.freezeState = freezeState; - return tx; - } - - /** - * Creates a tx for revoking an asset from an account and sending it to another - * - * @param transactionSender is a checksummed, human-readable address that will - * send the transaction - * @param assetRevokedFrom is a checksummed, human-readable address that will - * have assets taken from - * @param assetReceiver is a checksummed, human-readable address what will - * receive the assets - * @param assetAmount is the number of assets to send - * @param flatFee is the transaction flat fee - * @param firstRound is the first round this txn is valid (txn semantics - * unrelated to asset management) - * @param lastRound is the last round this txn is valid - * @param note - * @param genesisID corresponds to the id of the network - * @param genesisHash corresponds to the base64-encoded hash of the genesis - * of the network - * @param assetIndex is the asset index - **/ - @Deprecated - public static Transaction createAssetRevokeTransaction(// AssetTransaction - Address transactionSender, - Address assetRevokedFrom, - Address assetReceiver, - BigInteger assetAmount, - BigInteger flatFee, - BigInteger firstRound, - BigInteger lastRound, - byte[] note, - String genesisID, - Digest genesisHash, - BigInteger assetIndex) { - - Transaction tx = new Transaction( - Type.AssetTransfer, - flatFee, // fee - firstRound, // fv - lastRound, // lv - note, //note - genesisHash); // gh - - tx.assetReceiver = assetReceiver; //arcv - tx.assetSender = assetRevokedFrom; //asnd - tx.assetAmount = assetAmount; // aamt - tx.sender = transactionSender; // snd - if (assetIndex != null) tx.xferAsset = assetIndex; - return tx; - } - - - /** - * Creates a tx for sending some asset from an asset holder to another user. - * The asset receiver must have marked itself as willing to accept the - * asset. - * - * @param assetSender is a checksummed, human-readable address that will - * send the transaction and assets - * @param assetReceiver is a checksummed, human-readable address what will - * receive the assets - * @param assetCloseTo is a checksummed, human-readable address that - * behaves as a close-to address for the asset transaction; the remaining - * assets not sent to assetReceiver will be sent to assetCloseTo. Leave - * blank for no close-to behavior. - * @param assetAmount is the number of assets to send - * @param flatFee is the transaction flat fee - * @param firstRound is the first round this txn is valid (txn semantics - * unrelated to asset management) - * @param lastRound is the last round this txn is valid - * @param note - * @param genesisID corresponds to the id of the network - * @param genesisHash corresponds to the base64-encoded hash of the genesis - * of the network - * @param assetIndex is the asset index - **/ - @Deprecated - public static Transaction createAssetTransferTransaction(// AssetTransaction - Address assetSender, - Address assetReceiver, - Address assetCloseTo, - BigInteger assetAmount, - BigInteger flatFee, - BigInteger firstRound, - BigInteger lastRound, - byte[] note, - String genesisID, - Digest genesisHash, - BigInteger assetIndex) { - - Transaction tx = new Transaction( - Type.AssetTransfer, - flatFee, // fee - firstRound, // fv - lastRound, // lv - note, //note - genesisHash); // gh - - if (assetReceiver != null) tx.assetReceiver = assetReceiver; //arcv - if (assetCloseTo != null) tx.assetCloseTo = assetCloseTo; // aclose - if (assetAmount != null) tx.assetAmount = assetAmount; // aamt - if (assetSender != null) tx.sender = assetSender; // snd - if (assetIndex != null) tx.xferAsset = assetIndex; - return tx; - } - private void setNote(byte[] note) { if (note != null && note.length != 0) { this.note = note; } } - /** - * Set a transaction fee taking the minimum transaction fee into consideration. - * - * @param fee - * @Deprecated a transaction builder is coming. - */ - @Deprecated - public void setFee(BigInteger fee) { - if (fee != null) { - this.fee = fee; - } else { - this.fee = Account.MIN_TX_FEE_UALGOS; - } - - /* - // Cannot set this here without risk to breaking existing programs. - // Because of this common pattern: - // Transaction tx = new Transaction(fee = 10, ...); - // Account.setFeeByFeePerByte(tx, tx.fee); - if (this.fee.compareTo(Account.MIN_TX_FEE_UALGOS) < 0) { - this.fee = Account.MIN_TX_FEE_UALGOS; - } - */ - } - - /** - * Lease enforces mutual exclusion of transactions. If this field - * is nonzero, then once the transaction is confirmed, it acquires - * the lease identified by the (Sender, Lease) pair of the - * transaction until the LastValid round passes. While this - * transaction possesses the lease, no other transaction - * specifying this lease can be confirmed. - * The Size is fixed at 32 bytes. - * - * @param lease 32 byte lease - * @Deprecated use setLease(Lease) - **/ - @Deprecated - @JsonIgnore - public void setLease(byte[] lease) { - if (lease != null && lease.length != 0) { - setLease(new Lease(lease)); - } - } - /** * Lease enforces mutual exclusion of transactions. If this field * is nonzero, then once the transaction is confirmed, it acquires diff --git a/src/main/java/com/algorand/algosdk/transaction/TxGroup.java b/src/main/java/com/algorand/algosdk/transaction/TxGroup.java index 95dcd73f1..e8fcddae7 100644 --- a/src/main/java/com/algorand/algosdk/transaction/TxGroup.java +++ b/src/main/java/com/algorand/algosdk/transaction/TxGroup.java @@ -58,7 +58,7 @@ public static Digest computeGroupID(Transaction ...txns) throws IOException, Ill * @return array of grouped transactions, optionally filtered with the address parameter. */ public static Transaction[] assignGroupID(Transaction ...txns) throws IOException { - return assignGroupID(txns, null); + return assignGroupID(null, txns); } /** @@ -68,23 +68,8 @@ public static Transaction[] assignGroupID(Transaction ...txns) throws IOExceptio * @return array of grouped transactions, optionally filtered with the address parameter. */ public static Transaction[] assignGroupID(Address address, Transaction ...txns) throws IOException { - return assignGroupID(txns, address); - } - - /** - * Assigns group id to a given array of unsigned transactions - * @param txns array of transactions - * @param address optional sender address specifying which transaction return - * @return array of grouped transactions, optionally filtered with the address parameter. - * - * @Deprecated use assignGroupID(address, Transaction ...txns) - */ - @Deprecated // Jan 8, 2020 - public static Transaction[] assignGroupID( - Transaction[] txns, Address address - ) throws IOException { Digest gid = TxGroup.computeGroupID(txns); - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); for (Transaction tx : txns) { if (address == null || address.toString() == "" || address == tx.sender) { tx.assignGroupID(gid); diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/CatchpointAbortResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/CatchpointAbortResponse.java deleted file mode 100644 index 8dd5aeade..000000000 --- a/src/main/java/com/algorand/algosdk/v2/client/model/CatchpointAbortResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -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; - -public class CatchpointAbortResponse extends PathResponse { - - /** - * Catchup abort response string - */ - @JsonProperty("catchup-message") - public String catchupMessage; - - @Override - public boolean equals(Object o) { - - if (this == o) return true; - if (o == null) return false; - - CatchpointAbortResponse other = (CatchpointAbortResponse) o; - if (!Objects.deepEquals(this.catchupMessage, other.catchupMessage)) return false; - - return true; - } -} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/CatchpointStartResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/CatchpointStartResponse.java deleted file mode 100644 index 6cbbf89ea..000000000 --- a/src/main/java/com/algorand/algosdk/v2/client/model/CatchpointStartResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -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; - -public class CatchpointStartResponse extends PathResponse { - - /** - * Catchup start response string - */ - @JsonProperty("catchup-message") - public String catchupMessage; - - @Override - public boolean equals(Object o) { - - if (this == o) return true; - if (o == null) return false; - - CatchpointStartResponse other = (CatchpointStartResponse) o; - if (!Objects.deepEquals(this.catchupMessage, other.catchupMessage)) return false; - - return true; - } -} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/DryrunTxnResult.java b/src/main/java/com/algorand/algosdk/v2/client/model/DryrunTxnResult.java index 2aeda9a07..a5f645518 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/DryrunTxnResult.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/DryrunTxnResult.java @@ -33,13 +33,6 @@ public class DryrunTxnResult extends PathResponse { @JsonProperty("budget-consumed") public Long budgetConsumed; - /** - * Net cost of app execution. Field is DEPRECATED and is subject for removal. - * Instead, use `budget-added` and `budget-consumed. - */ - @JsonProperty("cost") - public Long cost; - /** * Disassembled program line by line. */ @@ -96,7 +89,6 @@ public boolean equals(Object o) { if (!Objects.deepEquals(this.appCallTrace, other.appCallTrace)) return false; if (!Objects.deepEquals(this.budgetAdded, other.budgetAdded)) return false; if (!Objects.deepEquals(this.budgetConsumed, other.budgetConsumed)) return false; - if (!Objects.deepEquals(this.cost, other.cost)) return false; if (!Objects.deepEquals(this.disassembly, other.disassembly)) return false; if (!Objects.deepEquals(this.globalDelta, other.globalDelta)) return false; if (!Objects.deepEquals(this.localDeltas, other.localDeltas)) return false; diff --git a/src/main/resources/langspec.json b/src/main/resources/langspec.json deleted file mode 100644 index ee94b0d33..000000000 --- a/src/main/resources/langspec.json +++ /dev/null @@ -1 +0,0 @@ -{"EvalMaxVersion":6,"LogicSigVersion":6,"Ops":[{"Opcode":0,"Name":"err","Cost":1,"Size":1,"Doc":"Fail immediately.","Groups":["Flow Control"]},{"Opcode":1,"Name":"sha256","Args":"B","Returns":"B","Cost":35,"Size":1,"Doc":"SHA256 hash of value A, yields [32]byte","Groups":["Arithmetic"]},{"Opcode":2,"Name":"keccak256","Args":"B","Returns":"B","Cost":130,"Size":1,"Doc":"Keccak256 hash of value A, yields [32]byte","Groups":["Arithmetic"]},{"Opcode":3,"Name":"sha512_256","Args":"B","Returns":"B","Cost":45,"Size":1,"Doc":"SHA512_256 hash of value A, yields [32]byte","Groups":["Arithmetic"]},{"Opcode":4,"Name":"ed25519verify","Args":"BBB","Returns":"U","Cost":1900,"Size":1,"Doc":"for (data A, signature B, pubkey C) verify the signature of (\"ProgData\" || program_hash || data) against the pubkey =\u003e {0 or 1}","DocExtra":"The 32 byte public key is the last element on the stack, preceded by the 64 byte signature at the second-to-last element on the stack, preceded by the data which was signed at the third-to-last element on the stack.","Groups":["Arithmetic"]},{"Opcode":5,"Name":"ecdsa_verify","Args":"BBBBB","Returns":"U","Cost":1700,"Size":2,"Doc":"for (data A, signature B, C and pubkey D, E) verify the signature of the data against the pubkey =\u003e {0 or 1}","DocExtra":"The 32 byte Y-component of a public key is the last element on the stack, preceded by X-component of a pubkey, preceded by S and R components of a signature, preceded by the data that is fifth element on the stack. All values are big-endian encoded. The signed data must be 32 bytes long, and signatures in lower-S form are only accepted.","ImmediateNote":"{uint8 curve index}","Groups":["Arithmetic"]},{"Opcode":6,"Name":"ecdsa_pk_decompress","Args":"B","Returns":"BB","Cost":650,"Size":2,"Doc":"decompress pubkey A into components X, Y","DocExtra":"The 33 byte public key in a compressed form to be decompressed into X and Y (top) components. All values are big-endian encoded.","ImmediateNote":"{uint8 curve index}","Groups":["Arithmetic"]},{"Opcode":7,"Name":"ecdsa_pk_recover","Args":"BUBB","Returns":"BB","Cost":2000,"Size":2,"Doc":"for (data A, recovery id B, signature C, D) recover a public key","DocExtra":"S (top) and R elements of a signature, recovery id and data (bottom) are expected on the stack and used to deriver a public key. All values are big-endian encoded. The signed data must be 32 bytes long.","ImmediateNote":"{uint8 curve index}","Groups":["Arithmetic"]},{"Opcode":8,"Name":"+","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A plus B. Fail on overflow.","DocExtra":"Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `addw`.","Groups":["Arithmetic"]},{"Opcode":9,"Name":"-","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A minus B. Fail if B \u003e A.","Groups":["Arithmetic"]},{"Opcode":10,"Name":"/","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A divided by B (truncated division). Fail if B == 0.","DocExtra":"`divmodw` is available to divide the two-element values produced by `mulw` and `addw`.","Groups":["Arithmetic"]},{"Opcode":11,"Name":"*","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A times B. Fail on overflow.","DocExtra":"Overflow is an error condition which halts execution and fails the transaction. Full precision is available from `mulw`.","Groups":["Arithmetic"]},{"Opcode":12,"Name":"\u003c","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A less than B =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":13,"Name":"\u003e","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A greater than B =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":14,"Name":"\u003c=","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A less than or equal to B =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":15,"Name":"\u003e=","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A greater than or equal to B =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":16,"Name":"\u0026\u0026","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A is not zero and B is not zero =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":17,"Name":"||","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A is not zero or B is not zero =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":18,"Name":"==","Args":"..","Returns":"U","Cost":1,"Size":1,"Doc":"A is equal to B =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":19,"Name":"!=","Args":"..","Returns":"U","Cost":1,"Size":1,"Doc":"A is not equal to B =\u003e {0 or 1}","Groups":["Arithmetic"]},{"Opcode":20,"Name":"!","Args":"U","Returns":"U","Cost":1,"Size":1,"Doc":"A == 0 yields 1; else 0","Groups":["Arithmetic"]},{"Opcode":21,"Name":"len","Args":"B","Returns":"U","Cost":1,"Size":1,"Doc":"yields length of byte value A","Groups":["Arithmetic"]},{"Opcode":22,"Name":"itob","Args":"U","Returns":"B","Cost":1,"Size":1,"Doc":"converts uint64 A to big endian bytes","Groups":["Arithmetic"]},{"Opcode":23,"Name":"btoi","Args":"B","Returns":"U","Cost":1,"Size":1,"Doc":"converts bytes A as big endian to uint64","DocExtra":"`btoi` fails if the input is longer than 8 bytes.","Groups":["Arithmetic"]},{"Opcode":24,"Name":"%","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A modulo B. Fail if B == 0.","Groups":["Arithmetic"]},{"Opcode":25,"Name":"|","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A bitwise-or B","Groups":["Arithmetic"]},{"Opcode":26,"Name":"\u0026","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A bitwise-and B","Groups":["Arithmetic"]},{"Opcode":27,"Name":"^","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A bitwise-xor B","Groups":["Arithmetic"]},{"Opcode":28,"Name":"~","Args":"U","Returns":"U","Cost":1,"Size":1,"Doc":"bitwise invert value A","Groups":["Arithmetic"]},{"Opcode":29,"Name":"mulw","Args":"UU","Returns":"UU","Cost":1,"Size":1,"Doc":"A times B as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low","Groups":["Arithmetic"]},{"Opcode":30,"Name":"addw","Args":"UU","Returns":"UU","Cost":1,"Size":1,"Doc":"A plus B as a 128-bit result. X is the carry-bit, Y is the low-order 64 bits.","Groups":["Arithmetic"]},{"Opcode":31,"Name":"divmodw","Args":"UUUU","Returns":"UUUU","Cost":20,"Size":1,"Doc":"W,X = (A,B / C,D); Y,Z = (A,B modulo C,D)","DocExtra":"The notation J,K indicates that two uint64 values J and K are interpreted as a uint128 value, with J as the high uint64 and K the low.","Groups":["Arithmetic"]},{"Opcode":32,"Name":"intcblock","Cost":1,"Size":0,"Doc":"prepare block of uint64 constants for use by intc","DocExtra":"`intcblock` loads following program bytes into an array of integer constants in the evaluator. These integer constants can be referred to by `intc` and `intc_*` which will push the value onto the stack. Subsequent calls to `intcblock` reset and replace the integer constants available to the script.","ImmediateNote":"{varuint length} [{varuint value}, ...]","Groups":["Loading Values"]},{"Opcode":33,"Name":"intc","Returns":"U","Cost":1,"Size":2,"Doc":"Ith constant from intcblock","ImmediateNote":"{uint8 int constant index}","Groups":["Loading Values"]},{"Opcode":34,"Name":"intc_0","Returns":"U","Cost":1,"Size":1,"Doc":"constant 0 from intcblock","Groups":["Loading Values"]},{"Opcode":35,"Name":"intc_1","Returns":"U","Cost":1,"Size":1,"Doc":"constant 1 from intcblock","Groups":["Loading Values"]},{"Opcode":36,"Name":"intc_2","Returns":"U","Cost":1,"Size":1,"Doc":"constant 2 from intcblock","Groups":["Loading Values"]},{"Opcode":37,"Name":"intc_3","Returns":"U","Cost":1,"Size":1,"Doc":"constant 3 from intcblock","Groups":["Loading Values"]},{"Opcode":38,"Name":"bytecblock","Cost":1,"Size":0,"Doc":"prepare block of byte-array constants for use by bytec","DocExtra":"`bytecblock` loads the following program bytes into an array of byte-array constants in the evaluator. These constants can be referred to by `bytec` and `bytec_*` which will push the value onto the stack. Subsequent calls to `bytecblock` reset and replace the bytes constants available to the script.","ImmediateNote":"{varuint length} [({varuint value length} bytes), ...]","Groups":["Loading Values"]},{"Opcode":39,"Name":"bytec","Returns":"B","Cost":1,"Size":2,"Doc":"Ith constant from bytecblock","ImmediateNote":"{uint8 byte constant index}","Groups":["Loading Values"]},{"Opcode":40,"Name":"bytec_0","Returns":"B","Cost":1,"Size":1,"Doc":"constant 0 from bytecblock","Groups":["Loading Values"]},{"Opcode":41,"Name":"bytec_1","Returns":"B","Cost":1,"Size":1,"Doc":"constant 1 from bytecblock","Groups":["Loading Values"]},{"Opcode":42,"Name":"bytec_2","Returns":"B","Cost":1,"Size":1,"Doc":"constant 2 from bytecblock","Groups":["Loading Values"]},{"Opcode":43,"Name":"bytec_3","Returns":"B","Cost":1,"Size":1,"Doc":"constant 3 from bytecblock","Groups":["Loading Values"]},{"Opcode":44,"Name":"arg","Returns":"B","Cost":1,"Size":2,"Doc":"Nth LogicSig argument","ImmediateNote":"{uint8 arg index N}","Groups":["Loading Values"]},{"Opcode":45,"Name":"arg_0","Returns":"B","Cost":1,"Size":1,"Doc":"LogicSig argument 0","Groups":["Loading Values"]},{"Opcode":46,"Name":"arg_1","Returns":"B","Cost":1,"Size":1,"Doc":"LogicSig argument 1","Groups":["Loading Values"]},{"Opcode":47,"Name":"arg_2","Returns":"B","Cost":1,"Size":1,"Doc":"LogicSig argument 2","Groups":["Loading Values"]},{"Opcode":48,"Name":"arg_3","Returns":"B","Cost":1,"Size":1,"Doc":"LogicSig argument 3","Groups":["Loading Values"]},{"Opcode":49,"Name":"txn","Returns":".","Cost":1,"Size":2,"ArgEnum":["Sender","Fee","FirstValid","FirstValidTime","LastValid","Note","Lease","Receiver","Amount","CloseRemainderTo","VotePK","SelectionPK","VoteFirst","VoteLast","VoteKeyDilution","Type","TypeEnum","XferAsset","AssetAmount","AssetSender","AssetReceiver","AssetCloseTo","GroupIndex","TxID","ApplicationID","OnCompletion","ApplicationArgs","NumAppArgs","Accounts","NumAccounts","ApprovalProgram","ClearStateProgram","RekeyTo","ConfigAsset","ConfigAssetTotal","ConfigAssetDecimals","ConfigAssetDefaultFrozen","ConfigAssetUnitName","ConfigAssetName","ConfigAssetURL","ConfigAssetMetadataHash","ConfigAssetManager","ConfigAssetReserve","ConfigAssetFreeze","ConfigAssetClawback","FreezeAsset","FreezeAssetAccount","FreezeAssetFrozen","Assets","NumAssets","Applications","NumApplications","GlobalNumUint","GlobalNumByteSlice","LocalNumUint","LocalNumByteSlice","ExtraProgramPages","Nonparticipation","Logs","NumLogs","CreatedAssetID","CreatedApplicationID","LastLog","StateProofPK"],"ArgEnumTypes":"BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBB","Doc":"field F of current transaction","DocExtra":"FirstValidTime causes the program to fail. The field is reserved for future use.","ImmediateNote":"{uint8 transaction field index}","Groups":["Loading Values"]},{"Opcode":50,"Name":"global","Returns":".","Cost":1,"Size":2,"Doc":"global field F","ImmediateNote":"{uint8 global field index}","Groups":["Loading Values"]},{"Opcode":51,"Name":"gtxn","Returns":".","Cost":1,"Size":3,"ArgEnum":["Sender","Fee","FirstValid","FirstValidTime","LastValid","Note","Lease","Receiver","Amount","CloseRemainderTo","VotePK","SelectionPK","VoteFirst","VoteLast","VoteKeyDilution","Type","TypeEnum","XferAsset","AssetAmount","AssetSender","AssetReceiver","AssetCloseTo","GroupIndex","TxID","ApplicationID","OnCompletion","ApplicationArgs","NumAppArgs","Accounts","NumAccounts","ApprovalProgram","ClearStateProgram","RekeyTo","ConfigAsset","ConfigAssetTotal","ConfigAssetDecimals","ConfigAssetDefaultFrozen","ConfigAssetUnitName","ConfigAssetName","ConfigAssetURL","ConfigAssetMetadataHash","ConfigAssetManager","ConfigAssetReserve","ConfigAssetFreeze","ConfigAssetClawback","FreezeAsset","FreezeAssetAccount","FreezeAssetFrozen","Assets","NumAssets","Applications","NumApplications","GlobalNumUint","GlobalNumByteSlice","LocalNumUint","LocalNumByteSlice","ExtraProgramPages","Nonparticipation","Logs","NumLogs","CreatedAssetID","CreatedApplicationID","LastLog","StateProofPK"],"ArgEnumTypes":"BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBB","Doc":"field F of the Tth transaction in the current group","DocExtra":"for notes on transaction fields available, see `txn`. If this transaction is _i_ in the group, `gtxn i field` is equivalent to `txn field`.","ImmediateNote":"{uint8 transaction group index} {uint8 transaction field index}","Groups":["Loading Values"]},{"Opcode":52,"Name":"load","Returns":".","Cost":1,"Size":2,"Doc":"Ith scratch space value. All scratch spaces are 0 at program start.","ImmediateNote":"{uint8 position in scratch space to load from}","Groups":["Loading Values"]},{"Opcode":53,"Name":"store","Args":".","Cost":1,"Size":2,"Doc":"store A to the Ith scratch space","ImmediateNote":"{uint8 position in scratch space to store to}","Groups":["Loading Values"]},{"Opcode":54,"Name":"txna","Returns":".","Cost":1,"Size":3,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ith value of the array field F of the current transaction","ImmediateNote":"{uint8 transaction field index} {uint8 transaction field array index}","Groups":["Loading Values"]},{"Opcode":55,"Name":"gtxna","Returns":".","Cost":1,"Size":4,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ith value of the array field F from the Tth transaction in the current group","ImmediateNote":"{uint8 transaction group index} {uint8 transaction field index} {uint8 transaction field array index}","Groups":["Loading Values"]},{"Opcode":56,"Name":"gtxns","Args":"U","Returns":".","Cost":1,"Size":2,"ArgEnum":["Sender","Fee","FirstValid","FirstValidTime","LastValid","Note","Lease","Receiver","Amount","CloseRemainderTo","VotePK","SelectionPK","VoteFirst","VoteLast","VoteKeyDilution","Type","TypeEnum","XferAsset","AssetAmount","AssetSender","AssetReceiver","AssetCloseTo","GroupIndex","TxID","ApplicationID","OnCompletion","ApplicationArgs","NumAppArgs","Accounts","NumAccounts","ApprovalProgram","ClearStateProgram","RekeyTo","ConfigAsset","ConfigAssetTotal","ConfigAssetDecimals","ConfigAssetDefaultFrozen","ConfigAssetUnitName","ConfigAssetName","ConfigAssetURL","ConfigAssetMetadataHash","ConfigAssetManager","ConfigAssetReserve","ConfigAssetFreeze","ConfigAssetClawback","FreezeAsset","FreezeAssetAccount","FreezeAssetFrozen","Assets","NumAssets","Applications","NumApplications","GlobalNumUint","GlobalNumByteSlice","LocalNumUint","LocalNumByteSlice","ExtraProgramPages","Nonparticipation","Logs","NumLogs","CreatedAssetID","CreatedApplicationID","LastLog","StateProofPK"],"ArgEnumTypes":"BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBB","Doc":"field F of the Ath transaction in the current group","DocExtra":"for notes on transaction fields available, see `txn`. If top of stack is _i_, `gtxns field` is equivalent to `gtxn _i_ field`. gtxns exists so that _i_ can be calculated, often based on the index of the current transaction.","ImmediateNote":"{uint8 transaction field index}","Groups":["Loading Values"]},{"Opcode":57,"Name":"gtxnsa","Args":"U","Returns":".","Cost":1,"Size":3,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ith value of the array field F from the Ath transaction in the current group","ImmediateNote":"{uint8 transaction field index} {uint8 transaction field array index}","Groups":["Loading Values"]},{"Opcode":58,"Name":"gload","Returns":".","Cost":1,"Size":3,"Doc":"Ith scratch space value of the Tth transaction in the current group","DocExtra":"`gload` fails unless the requested transaction is an ApplicationCall and T \u003c GroupIndex.","ImmediateNote":"{uint8 transaction group index} {uint8 position in scratch space to load from}","Groups":["Loading Values"]},{"Opcode":59,"Name":"gloads","Args":"U","Returns":".","Cost":1,"Size":2,"Doc":"Ith scratch space value of the Ath transaction in the current group","DocExtra":"`gloads` fails unless the requested transaction is an ApplicationCall and A \u003c GroupIndex.","ImmediateNote":"{uint8 position in scratch space to load from}","Groups":["Loading Values"]},{"Opcode":60,"Name":"gaid","Returns":"U","Cost":1,"Size":2,"Doc":"ID of the asset or application created in the Tth transaction of the current group","DocExtra":"`gaid` fails unless the requested transaction created an asset or application and T \u003c GroupIndex.","ImmediateNote":"{uint8 transaction group index}","Groups":["Loading Values"]},{"Opcode":61,"Name":"gaids","Args":"U","Returns":"U","Cost":1,"Size":1,"Doc":"ID of the asset or application created in the Ath transaction of the current group","DocExtra":"`gaids` fails unless the requested transaction created an asset or application and A \u003c GroupIndex.","Groups":["Loading Values"]},{"Opcode":62,"Name":"loads","Args":"U","Returns":".","Cost":1,"Size":1,"Doc":"Ath scratch space value. All scratch spaces are 0 at program start.","Groups":["Loading Values"]},{"Opcode":63,"Name":"stores","Args":"U.","Cost":1,"Size":1,"Doc":"store B to the Ath scratch space","Groups":["Loading Values"]},{"Opcode":64,"Name":"bnz","Args":"U","Cost":1,"Size":3,"Doc":"branch to TARGET if value A is not zero","DocExtra":"The `bnz` instruction opcode 0x40 is followed by two immediate data bytes which are a high byte first and low byte second which together form a 16 bit offset which the instruction may branch to. For a bnz instruction at `pc`, if the last element of the stack is not zero then branch to instruction at `pc + 3 + N`, else proceed to next instruction at `pc + 3`. Branch targets must be aligned instructions. (e.g. Branching to the second byte of a 2 byte op will be rejected.) Starting at v4, the offset is treated as a signed 16 bit integer allowing for backward branches and looping. In prior version (v1 to v3), branch offsets are limited to forward branches only, 0-0x7fff.\n\nAt v2 it became allowed to branch to the end of the program exactly after the last instruction: bnz to byte N (with 0-indexing) was illegal for a TEAL program with N bytes before v2, and is legal after it. This change eliminates the need for a last instruction of no-op as a branch target at the end. (Branching beyond the end--in other words, to a byte larger than N--is still illegal and will cause the program to fail.)","ImmediateNote":"{int16 branch offset, big endian}","Groups":["Flow Control"]},{"Opcode":65,"Name":"bz","Args":"U","Cost":1,"Size":3,"Doc":"branch to TARGET if value A is zero","DocExtra":"See `bnz` for details on how branches work. `bz` inverts the behavior of `bnz`.","ImmediateNote":"{int16 branch offset, big endian}","Groups":["Flow Control"]},{"Opcode":66,"Name":"b","Cost":1,"Size":3,"Doc":"branch unconditionally to TARGET","DocExtra":"See `bnz` for details on how branches work. `b` always jumps to the offset.","ImmediateNote":"{int16 branch offset, big endian}","Groups":["Flow Control"]},{"Opcode":67,"Name":"return","Args":"U","Cost":1,"Size":1,"Doc":"use A as success value; end","Groups":["Flow Control"]},{"Opcode":68,"Name":"assert","Args":"U","Cost":1,"Size":1,"Doc":"immediately fail unless A is a non-zero number","Groups":["Flow Control"]},{"Opcode":72,"Name":"pop","Args":".","Cost":1,"Size":1,"Doc":"discard A","Groups":["Flow Control"]},{"Opcode":73,"Name":"dup","Args":".","Returns":"..","Cost":1,"Size":1,"Doc":"duplicate A","Groups":["Flow Control"]},{"Opcode":74,"Name":"dup2","Args":"..","Returns":"....","Cost":1,"Size":1,"Doc":"duplicate A and B","Groups":["Flow Control"]},{"Opcode":75,"Name":"dig","Args":".","Returns":"..","Cost":1,"Size":2,"Doc":"Nth value from the top of the stack. dig 0 is equivalent to dup","ImmediateNote":"{uint8 depth}","Groups":["Flow Control"]},{"Opcode":76,"Name":"swap","Args":"..","Returns":"..","Cost":1,"Size":1,"Doc":"swaps A and B on stack","Groups":["Flow Control"]},{"Opcode":77,"Name":"select","Args":"..U","Returns":".","Cost":1,"Size":1,"Doc":"selects one of two values based on top-of-stack: B if C != 0, else A","Groups":["Flow Control"]},{"Opcode":78,"Name":"cover","Args":".","Returns":".","Cost":1,"Size":2,"Doc":"remove top of stack, and place it deeper in the stack such that N elements are above it. Fails if stack depth \u003c= N.","ImmediateNote":"{uint8 depth}","Groups":["Flow Control"]},{"Opcode":79,"Name":"uncover","Args":".","Returns":".","Cost":1,"Size":2,"Doc":"remove the value at depth N in the stack and shift above items down so the Nth deep value is on top of the stack. Fails if stack depth \u003c= N.","ImmediateNote":"{uint8 depth}","Groups":["Flow Control"]},{"Opcode":80,"Name":"concat","Args":"BB","Returns":"B","Cost":1,"Size":1,"Doc":"join A and B","DocExtra":"`concat` fails if the result would be greater than 4096 bytes.","Groups":["Arithmetic"]},{"Opcode":81,"Name":"substring","Args":"B","Returns":"B","Cost":1,"Size":3,"Doc":"A range of bytes from A starting at S up to but not including E. If E \u003c S, or either is larger than the array length, the program fails","ImmediateNote":"{uint8 start position} {uint8 end position}","Groups":["Byte Array Manipulation"]},{"Opcode":82,"Name":"substring3","Args":"BUU","Returns":"B","Cost":1,"Size":1,"Doc":"A range of bytes from A starting at B up to but not including C. If C \u003c B, or either is larger than the array length, the program fails","Groups":["Byte Array Manipulation"]},{"Opcode":83,"Name":"getbit","Args":".U","Returns":"U","Cost":1,"Size":1,"Doc":"Bth bit of (byte-array or integer) A.","DocExtra":"see explanation of bit ordering in setbit","Groups":["Arithmetic"]},{"Opcode":84,"Name":"setbit","Args":".UU","Returns":".","Cost":1,"Size":1,"Doc":"Copy of (byte-array or integer) A, with the Bth bit set to (0 or 1) C","DocExtra":"When A is a uint64, index 0 is the least significant bit. Setting bit 3 to 1 on the integer 0 yields 8, or 2^3. When A is a byte array, index 0 is the leftmost bit of the leftmost byte. Setting bits 0 through 11 to 1 in a 4-byte-array of 0s yields the byte array 0xfff00000. Setting bit 3 to 1 on the 1-byte-array 0x00 yields the byte array 0x10.","Groups":["Arithmetic"]},{"Opcode":85,"Name":"getbyte","Args":"BU","Returns":"U","Cost":1,"Size":1,"Doc":"Bth byte of A, as an integer","Groups":["Arithmetic"]},{"Opcode":86,"Name":"setbyte","Args":"BUU","Returns":"B","Cost":1,"Size":1,"Doc":"Copy of A with the Bth byte set to small integer (between 0..255) C","Groups":["Arithmetic"]},{"Opcode":87,"Name":"extract","Args":"B","Returns":"B","Cost":1,"Size":3,"Doc":"A range of bytes from A starting at S up to but not including S+L. If L is 0, then extract to the end of the string. If S or S+L is larger than the array length, the program fails","ImmediateNote":"{uint8 start position} {uint8 length}","Groups":["Byte Array Manipulation"]},{"Opcode":88,"Name":"extract3","Args":"BUU","Returns":"B","Cost":1,"Size":1,"Doc":"A range of bytes from A starting at B up to but not including B+C. If B+C is larger than the array length, the program fails","Groups":["Byte Array Manipulation"]},{"Opcode":89,"Name":"extract_uint16","Args":"BU","Returns":"U","Cost":1,"Size":1,"Doc":"A uint16 formed from a range of big-endian bytes from A starting at B up to but not including B+2. If B+2 is larger than the array length, the program fails","Groups":["Byte Array Manipulation"]},{"Opcode":90,"Name":"extract_uint32","Args":"BU","Returns":"U","Cost":1,"Size":1,"Doc":"A uint32 formed from a range of big-endian bytes from A starting at B up to but not including B+4. If B+4 is larger than the array length, the program fails","Groups":["Byte Array Manipulation"]},{"Opcode":91,"Name":"extract_uint64","Args":"BU","Returns":"U","Cost":1,"Size":1,"Doc":"A uint64 formed from a range of big-endian bytes from A starting at B up to but not including B+8. If B+8 is larger than the array length, the program fails","Groups":["Byte Array Manipulation"]},{"Opcode":96,"Name":"balance","Args":".","Returns":"U","Cost":1,"Size":1,"Doc":"get balance for account A, in microalgos. The balance is observed after the effects of previous transactions in the group, and after the fee for the current transaction is deducted.","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.","Groups":["State Access"]},{"Opcode":97,"Name":"app_opted_in","Args":".U","Returns":"U","Cost":1,"Size":1,"Doc":"1 if account A is opted in to application B, else 0","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: 1 if opted in and 0 otherwise.","Groups":["State Access"]},{"Opcode":98,"Name":"app_local_get","Args":".B","Returns":".","Cost":1,"Size":1,"Doc":"local state of the key B in the current application in account A","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), state key. Return: value. The value is zero (of type uint64) if the key does not exist.","Groups":["State Access"]},{"Opcode":99,"Name":"app_local_get_ex","Args":".UB","Returns":".U","Cost":1,"Size":1,"Doc":"X is the local state of application B, key C in account A. Y is 1 if key existed, else 0","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.","Groups":["State Access"]},{"Opcode":100,"Name":"app_global_get","Args":"B","Returns":".","Cost":1,"Size":1,"Doc":"global state of the key A in the current application","DocExtra":"params: state key. Return: value. The value is zero (of type uint64) if the key does not exist.","Groups":["State Access"]},{"Opcode":101,"Name":"app_global_get_ex","Args":"UB","Returns":".U","Cost":1,"Size":1,"Doc":"X is the global state of application A, key B. Y is 1 if key existed, else 0","DocExtra":"params: Txn.ForeignApps offset (or, since v4, an _available_ application id), state key. Return: did_exist flag (top of the stack, 1 if the application and key existed and 0 otherwise), value. The value is zero (of type uint64) if the key does not exist.","Groups":["State Access"]},{"Opcode":102,"Name":"app_local_put","Args":".B.","Cost":1,"Size":1,"Doc":"write C to key B in account A's local state of the current application","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), state key, value.","Groups":["State Access"]},{"Opcode":103,"Name":"app_global_put","Args":"B.","Cost":1,"Size":1,"Doc":"write B to key A in the global state of the current application","Groups":["State Access"]},{"Opcode":104,"Name":"app_local_del","Args":".B","Cost":1,"Size":1,"Doc":"delete key B from account A's local state of the current application","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), state key.\n\nDeleting a key which is already absent has no effect on the application local state. (In particular, it does _not_ cause the program to fail.)","Groups":["State Access"]},{"Opcode":105,"Name":"app_global_del","Args":"B","Cost":1,"Size":1,"Doc":"delete key A from the global state of the current application","DocExtra":"params: state key.\n\nDeleting a key which is already absent has no effect on the application global state. (In particular, it does _not_ cause the program to fail.)","Groups":["State Access"]},{"Opcode":112,"Name":"asset_holding_get","Args":".U","Returns":".U","Cost":1,"Size":2,"ArgEnum":["AssetBalance","AssetFrozen"],"ArgEnumTypes":"UU","Doc":"X is field F from account A's holding of asset B. Y is 1 if A is opted into B, else 0","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ address), asset id (or, since v4, a Txn.ForeignAssets offset). Return: did_exist flag (1 if the asset existed and 0 otherwise), value.","ImmediateNote":"{uint8 asset holding field index}","Groups":["State Access"]},{"Opcode":113,"Name":"asset_params_get","Args":"U","Returns":".U","Cost":1,"Size":2,"ArgEnum":["AssetTotal","AssetDecimals","AssetDefaultFrozen","AssetUnitName","AssetName","AssetURL","AssetMetadataHash","AssetManager","AssetReserve","AssetFreeze","AssetClawback","AssetCreator"],"ArgEnumTypes":"UUUBBBBBBBBB","Doc":"X is field F from asset A. Y is 1 if A exists, else 0","DocExtra":"params: Txn.ForeignAssets offset (or, since v4, an _available_ asset id. Return: did_exist flag (1 if the asset existed and 0 otherwise), value.","ImmediateNote":"{uint8 asset params field index}","Groups":["State Access"]},{"Opcode":114,"Name":"app_params_get","Args":"U","Returns":".U","Cost":1,"Size":2,"ArgEnum":["AppApprovalProgram","AppClearStateProgram","AppGlobalNumUint","AppGlobalNumByteSlice","AppLocalNumUint","AppLocalNumByteSlice","AppExtraProgramPages","AppCreator","AppAddress"],"ArgEnumTypes":"BBUUUUUBB","Doc":"X is field F from app A. Y is 1 if A exists, else 0","DocExtra":"params: Txn.ForeignApps offset or an _available_ app id. Return: did_exist flag (1 if the application existed and 0 otherwise), value.","ImmediateNote":"{uint8 app params field index}","Groups":["State Access"]},{"Opcode":115,"Name":"acct_params_get","Args":".","Returns":".U","Cost":1,"Size":2,"Doc":"X is field F from account A. Y is 1 if A owns positive algos, else 0","ImmediateNote":"{uint8 account params field index}","Groups":["State Access"]},{"Opcode":120,"Name":"min_balance","Args":".","Returns":"U","Cost":1,"Size":1,"Doc":"get minimum required balance for account A, in microalgos. Required balance is affected by [ASA](https://developer.algorand.org/docs/features/asa/#assets-overview) and [App](https://developer.algorand.org/docs/features/asc1/stateful/#minimum-balance-requirement-for-a-smart-contract) usage. When creating or opting into an app, the minimum balance grows before the app code runs, therefore the increase is visible there. When deleting or closing out, the minimum balance decreases after the app executes.","DocExtra":"params: Txn.Accounts offset (or, since v4, an _available_ account address), _available_ application id (or, since v4, a Txn.ForeignApps offset). Return: value.","Groups":["State Access"]},{"Opcode":128,"Name":"pushbytes","Returns":"B","Cost":1,"Size":0,"Doc":"immediate BYTES","DocExtra":"pushbytes args are not added to the bytecblock during assembly processes","ImmediateNote":"{varuint length} {bytes}","Groups":["Loading Values"]},{"Opcode":129,"Name":"pushint","Returns":"U","Cost":1,"Size":0,"Doc":"immediate UINT","DocExtra":"pushint args are not added to the intcblock during assembly processes","ImmediateNote":"{varuint int}","Groups":["Loading Values"]},{"Opcode":136,"Name":"callsub","Cost":1,"Size":3,"Doc":"branch unconditionally to TARGET, saving the next instruction on the call stack","DocExtra":"The call stack is separate from the data stack. Only `callsub` and `retsub` manipulate it.","ImmediateNote":"{int16 branch offset, big endian}","Groups":["Flow Control"]},{"Opcode":137,"Name":"retsub","Cost":1,"Size":1,"Doc":"pop the top instruction from the call stack and branch to it","DocExtra":"The call stack is separate from the data stack. Only `callsub` and `retsub` manipulate it.","Groups":["Flow Control"]},{"Opcode":144,"Name":"shl","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A times 2^B, modulo 2^64","Groups":["Arithmetic"]},{"Opcode":145,"Name":"shr","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A divided by 2^B","Groups":["Arithmetic"]},{"Opcode":146,"Name":"sqrt","Args":"U","Returns":"U","Cost":4,"Size":1,"Doc":"The largest integer I such that I^2 \u003c= A","Groups":["Arithmetic"]},{"Opcode":147,"Name":"bitlen","Args":".","Returns":"U","Cost":1,"Size":1,"Doc":"The highest set bit in A. If A is a byte-array, it is interpreted as a big-endian unsigned integer. bitlen of 0 is 0, bitlen of 8 is 4","DocExtra":"bitlen interprets arrays as big-endian integers, unlike setbit/getbit","Groups":["Arithmetic"]},{"Opcode":148,"Name":"exp","Args":"UU","Returns":"U","Cost":1,"Size":1,"Doc":"A raised to the Bth power. Fail if A == B == 0 and on overflow","Groups":["Arithmetic"]},{"Opcode":149,"Name":"expw","Args":"UU","Returns":"UU","Cost":10,"Size":1,"Doc":"A raised to the Bth power as a 128-bit result in two uint64s. X is the high 64 bits, Y is the low. Fail if A == B == 0 or if the results exceeds 2^128-1","Groups":["Arithmetic"]},{"Opcode":150,"Name":"bsqrt","Args":"B","Returns":"B","Cost":40,"Size":1,"Doc":"The largest integer I such that I^2 \u003c= A. A and I are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":151,"Name":"divw","Args":"UUU","Returns":"U","Cost":1,"Size":1,"Doc":"A,B / C. Fail if C == 0 or if result overflows.","DocExtra":"The notation A,B indicates that A and B are interpreted as a uint128 value, with A as the high uint64 and B the low.","Groups":["Arithmetic"]},{"Opcode":160,"Name":"b+","Args":"BB","Returns":"B","Cost":10,"Size":1,"Doc":"A plus B. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":161,"Name":"b-","Args":"BB","Returns":"B","Cost":10,"Size":1,"Doc":"A minus B. A and B are interpreted as big-endian unsigned integers. Fail on underflow.","Groups":["Byte Array Arithmetic"]},{"Opcode":162,"Name":"b/","Args":"BB","Returns":"B","Cost":20,"Size":1,"Doc":"A divided by B (truncated division). A and B are interpreted as big-endian unsigned integers. Fail if B is zero.","Groups":["Byte Array Arithmetic"]},{"Opcode":163,"Name":"b*","Args":"BB","Returns":"B","Cost":20,"Size":1,"Doc":"A times B. A and B are interpreted as big-endian unsigned integers.","Groups":["Byte Array Arithmetic"]},{"Opcode":164,"Name":"b\u003c","Args":"BB","Returns":"U","Cost":1,"Size":1,"Doc":"1 if A is less than B, else 0. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":165,"Name":"b\u003e","Args":"BB","Returns":"U","Cost":1,"Size":1,"Doc":"1 if A is greater than B, else 0. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":166,"Name":"b\u003c=","Args":"BB","Returns":"U","Cost":1,"Size":1,"Doc":"1 if A is less than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":167,"Name":"b\u003e=","Args":"BB","Returns":"U","Cost":1,"Size":1,"Doc":"1 if A is greater than or equal to B, else 0. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":168,"Name":"b==","Args":"BB","Returns":"U","Cost":1,"Size":1,"Doc":"1 if A is equal to B, else 0. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":169,"Name":"b!=","Args":"BB","Returns":"U","Cost":1,"Size":1,"Doc":"0 if A is equal to B, else 1. A and B are interpreted as big-endian unsigned integers","Groups":["Byte Array Arithmetic"]},{"Opcode":170,"Name":"b%","Args":"BB","Returns":"B","Cost":20,"Size":1,"Doc":"A modulo B. A and B are interpreted as big-endian unsigned integers. Fail if B is zero.","Groups":["Byte Array Arithmetic"]},{"Opcode":171,"Name":"b|","Args":"BB","Returns":"B","Cost":6,"Size":1,"Doc":"A bitwise-or B. A and B are zero-left extended to the greater of their lengths","Groups":["Byte Array Logic"]},{"Opcode":172,"Name":"b\u0026","Args":"BB","Returns":"B","Cost":6,"Size":1,"Doc":"A bitwise-and B. A and B are zero-left extended to the greater of their lengths","Groups":["Byte Array Logic"]},{"Opcode":173,"Name":"b^","Args":"BB","Returns":"B","Cost":6,"Size":1,"Doc":"A bitwise-xor B. A and B are zero-left extended to the greater of their lengths","Groups":["Byte Array Logic"]},{"Opcode":174,"Name":"b~","Args":"B","Returns":"B","Cost":4,"Size":1,"Doc":"A with all bits inverted","Groups":["Byte Array Logic"]},{"Opcode":175,"Name":"bzero","Args":"U","Returns":"B","Cost":1,"Size":1,"Doc":"zero filled byte-array of length A","Groups":["Loading Values"]},{"Opcode":176,"Name":"log","Args":"B","Cost":1,"Size":1,"Doc":"write A to log state of the current application","DocExtra":"`log` fails if called more than MaxLogCalls times in a program, or if the sum of logged bytes exceeds 1024 bytes.","Groups":["State Access"]},{"Opcode":177,"Name":"itxn_begin","Cost":1,"Size":1,"Doc":"begin preparation of a new inner transaction in a new transaction group","DocExtra":"`itxn_begin` initializes Sender to the application address; Fee to the minimum allowable, taking into account MinTxnFee and credit from overpaying in earlier transactions; FirstValid/LastValid to the values in the invoking transaction, and all other fields to zero or empty values.","Groups":["Inner Transactions"]},{"Opcode":178,"Name":"itxn_field","Args":".","Cost":1,"Size":2,"ArgEnum":["Sender","Fee","FirstValid","FirstValidTime","LastValid","Note","Lease","Receiver","Amount","CloseRemainderTo","VotePK","SelectionPK","VoteFirst","VoteLast","VoteKeyDilution","Type","TypeEnum","XferAsset","AssetAmount","AssetSender","AssetReceiver","AssetCloseTo","GroupIndex","TxID","ApplicationID","OnCompletion","ApplicationArgs","NumAppArgs","Accounts","NumAccounts","ApprovalProgram","ClearStateProgram","RekeyTo","ConfigAsset","ConfigAssetTotal","ConfigAssetDecimals","ConfigAssetDefaultFrozen","ConfigAssetUnitName","ConfigAssetName","ConfigAssetURL","ConfigAssetMetadataHash","ConfigAssetManager","ConfigAssetReserve","ConfigAssetFreeze","ConfigAssetClawback","FreezeAsset","FreezeAssetAccount","FreezeAssetFrozen","Assets","NumAssets","Applications","NumApplications","GlobalNumUint","GlobalNumByteSlice","LocalNumUint","LocalNumByteSlice","ExtraProgramPages","Nonparticipation","Logs","NumLogs","CreatedAssetID","CreatedApplicationID","LastLog","StateProofPK"],"ArgEnumTypes":"BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBB","Doc":"set field F of the current inner transaction to A","DocExtra":"`itxn_field` fails if A is of the wrong type for F, including a byte array of the wrong size for use as an address when F is an address field. `itxn_field` also fails if A is an account, asset, or app that is not _available_, or an attempt is made extend an array field beyond the limit imposed by consensus parameters. (Addresses set into asset params of acfg transactions need not be _available_.)","ImmediateNote":"{uint8 transaction field index}","Groups":["Inner Transactions"]},{"Opcode":179,"Name":"itxn_submit","Cost":1,"Size":1,"Doc":"execute the current inner transaction group. Fail if executing this group would exceed the inner transaction limit, or if any transaction in the group fails.","DocExtra":"`itxn_submit` resets the current transaction so that it can not be resubmitted. A new `itxn_begin` is required to prepare another inner transaction.","Groups":["Inner Transactions"]},{"Opcode":180,"Name":"itxn","Returns":".","Cost":1,"Size":2,"ArgEnum":["Sender","Fee","FirstValid","FirstValidTime","LastValid","Note","Lease","Receiver","Amount","CloseRemainderTo","VotePK","SelectionPK","VoteFirst","VoteLast","VoteKeyDilution","Type","TypeEnum","XferAsset","AssetAmount","AssetSender","AssetReceiver","AssetCloseTo","GroupIndex","TxID","ApplicationID","OnCompletion","ApplicationArgs","NumAppArgs","Accounts","NumAccounts","ApprovalProgram","ClearStateProgram","RekeyTo","ConfigAsset","ConfigAssetTotal","ConfigAssetDecimals","ConfigAssetDefaultFrozen","ConfigAssetUnitName","ConfigAssetName","ConfigAssetURL","ConfigAssetMetadataHash","ConfigAssetManager","ConfigAssetReserve","ConfigAssetFreeze","ConfigAssetClawback","FreezeAsset","FreezeAssetAccount","FreezeAssetFrozen","Assets","NumAssets","Applications","NumApplications","GlobalNumUint","GlobalNumByteSlice","LocalNumUint","LocalNumByteSlice","ExtraProgramPages","Nonparticipation","Logs","NumLogs","CreatedAssetID","CreatedApplicationID","LastLog","StateProofPK"],"ArgEnumTypes":"BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBB","Doc":"field F of the last inner transaction","ImmediateNote":"{uint8 transaction field index}","Groups":["Inner Transactions"]},{"Opcode":181,"Name":"itxna","Returns":".","Cost":1,"Size":3,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ith value of the array field F of the last inner transaction","ImmediateNote":"{uint8 transaction field index} {uint8 transaction field array index}","Groups":["Inner Transactions"]},{"Opcode":182,"Name":"itxn_next","Cost":1,"Size":1,"Doc":"begin preparation of a new inner transaction in the same transaction group","DocExtra":"`itxn_next` initializes the transaction exactly as `itxn_begin` does","Groups":["Inner Transactions"]},{"Opcode":183,"Name":"gitxn","Returns":".","Cost":1,"Size":3,"ArgEnum":["Sender","Fee","FirstValid","FirstValidTime","LastValid","Note","Lease","Receiver","Amount","CloseRemainderTo","VotePK","SelectionPK","VoteFirst","VoteLast","VoteKeyDilution","Type","TypeEnum","XferAsset","AssetAmount","AssetSender","AssetReceiver","AssetCloseTo","GroupIndex","TxID","ApplicationID","OnCompletion","ApplicationArgs","NumAppArgs","Accounts","NumAccounts","ApprovalProgram","ClearStateProgram","RekeyTo","ConfigAsset","ConfigAssetTotal","ConfigAssetDecimals","ConfigAssetDefaultFrozen","ConfigAssetUnitName","ConfigAssetName","ConfigAssetURL","ConfigAssetMetadataHash","ConfigAssetManager","ConfigAssetReserve","ConfigAssetFreeze","ConfigAssetClawback","FreezeAsset","FreezeAssetAccount","FreezeAssetFrozen","Assets","NumAssets","Applications","NumApplications","GlobalNumUint","GlobalNumByteSlice","LocalNumUint","LocalNumByteSlice","ExtraProgramPages","Nonparticipation","Logs","NumLogs","CreatedAssetID","CreatedApplicationID","LastLog","StateProofPK"],"ArgEnumTypes":"BUUUUBBBUBBBUUUBUUUBBBUBUUBUBUBBBUUUUBBBBBBBBUBUUUUUUUUUUUBUUUBB","Doc":"field F of the Tth transaction in the last inner group submitted","ImmediateNote":"{uint8 transaction group index} {uint8 transaction field index}","Groups":["Inner Transactions"]},{"Opcode":184,"Name":"gitxna","Returns":".","Cost":1,"Size":4,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ith value of the array field F from the Tth transaction in the last inner group submitted","ImmediateNote":"{uint8 transaction group index} {uint8 transaction field index} {uint8 transaction field array index}","Groups":["Inner Transactions"]},{"Opcode":192,"Name":"txnas","Args":"U","Returns":".","Cost":1,"Size":2,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ath value of the array field F of the current transaction","ImmediateNote":"{uint8 transaction field index}","Groups":["Loading Values"]},{"Opcode":193,"Name":"gtxnas","Args":"U","Returns":".","Cost":1,"Size":3,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Ath value of the array field F from the Tth transaction in the current group","ImmediateNote":"{uint8 transaction group index} {uint8 transaction field index}","Groups":["Loading Values"]},{"Opcode":194,"Name":"gtxnsas","Args":"UU","Returns":".","Cost":1,"Size":2,"ArgEnum":["ApplicationArgs","Accounts","Assets","Applications","Logs"],"ArgEnumTypes":"BBUUB","Doc":"Bth value of the array field F from the Ath transaction in the current group","ImmediateNote":"{uint8 transaction field index}","Groups":["Loading Values"]},{"Opcode":195,"Name":"args","Args":"U","Returns":"B","Cost":1,"Size":1,"Doc":"Ath LogicSig argument","Groups":["Loading Values"]},{"Opcode":196,"Name":"gloadss","Args":"UU","Returns":".","Cost":1,"Size":1,"Doc":"Bth scratch space value of the Ath transaction in the current group","Groups":["Loading Values"]},{"Opcode":197,"Name":"itxnas","Args":"U","Returns":".","Cost":1,"Size":2,"Doc":"Ath value of the array field F of the last inner transaction","ImmediateNote":"{uint8 transaction field index}","Groups":["Inner Transactions"]},{"Opcode":198,"Name":"gitxnas","Args":"U","Returns":".","Cost":1,"Size":3,"Doc":"Ath value of the array field F from the Tth transaction in the last inner group submitted","ImmediateNote":"{uint8 transaction group index} {uint8 transaction field index}","Groups":["Inner Transactions"]}]} diff --git a/src/test/java/com/algorand/algosdk/crypto/TestLogicsigSignature.java b/src/test/java/com/algorand/algosdk/crypto/TestLogicsigSignature.java index 673fbe82e..67be7fd0d 100644 --- a/src/test/java/com/algorand/algosdk/crypto/TestLogicsigSignature.java +++ b/src/test/java/com/algorand/algosdk/crypto/TestLogicsigSignature.java @@ -13,7 +13,7 @@ public class TestLogicsigSignature { @Test - public void testLogicsigEmptyCreation() throws Exception { + public void testLogicsigEmptyCreation() { assertThatThrownBy(() -> new LogicsigSignature(null, null)) .isInstanceOf(NullPointerException.class); } @@ -23,7 +23,7 @@ public void testLogicsigCreation() throws Exception { byte[] program = { 0x01, 0x20, 0x01, 0x01, 0x22 // int 1 }; - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); String programHash = "6Z3C3LDVWGMX23BMSYMANACQOSINPFIRF77H7N3AWJZYV6OH6GWTJKVMXY"; Address sender = new Address(programHash); diff --git a/src/test/java/com/algorand/algosdk/logic/TestLogic.java b/src/test/java/com/algorand/algosdk/logic/TestLogic.java deleted file mode 100644 index 64abd28fc..000000000 --- a/src/test/java/com/algorand/algosdk/logic/TestLogic.java +++ /dev/null @@ -1,450 +0,0 @@ -package com.algorand.algosdk.logic; - -import com.google.common.collect.ImmutableList; -import org.junit.jupiter.api.Test; - -import java.util.*; - -import static com.algorand.algosdk.logic.Logic.*; -import static org.assertj.core.api.Assertions.*; - -public class TestLogic { - @Test - public void testParseUvarint1() throws Exception { - byte[] data = {0x01}; - VarintResult result = getUVarint(data, 0); - assertThat(result.length).isEqualTo(1); - assertThat(result.value).isEqualTo(1); - } - - @Test - public void testParseUvarint2() throws Exception { - byte[] data = {0x02}; - VarintResult result = getUVarint(data, 0); - assertThat(result.length).isEqualTo(1); - assertThat(result.value).isEqualTo(2); - } - - @Test - public void testParseUvarint3() throws Exception { - byte[] data = {0x7b}; - VarintResult result = getUVarint(data, 0); - assertThat(result.length).isEqualTo(1); - assertThat(result.value).isEqualTo(123); - } - - @Test - public void testParseUvarint4() throws Exception { - byte[] data = {(byte)0xc8, 0x03}; - VarintResult result = getUVarint(data, 0); - assertThat(result.length).isEqualTo(2); - assertThat(result.value).isEqualTo(456); - } - - @Test - public void testParseUvarint4AtOffset() throws Exception { - byte[] data = {0x0, 0x0, (byte)0xc8, 0x03}; - VarintResult result = getUVarint(data, 2); - assertThat(result.length).isEqualTo(2); - assertThat(result.value).isEqualTo(456); - } - - @Test - public void testParseIntcBlock() throws Exception { - byte[] data = { - 0x20, 0x05, 0x00, 0x01, (byte)0xc8, 0x03, 0x7b, 0x02 - }; - - IntConstBlock results = readIntConstBlock(data, 0); - assertThat(results.size).isEqualTo(data.length); - assertThat(results.results) - .containsExactlyElementsOf(ImmutableList.of(0, 1, 456, 123, 2)); - } - - @Test - public void testParseBytecBlock() throws Exception { - byte[] data = { - 0x026, 0x02, 0x0d, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x02, 0x01, 0x02 - }; - List values = ImmutableList.of( - new byte[]{ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x33 }, - new byte[]{ 0x1, 0x2 }); - - Logic.ByteConstBlock results = readByteConstBlock(data, 0); - assertThat(results.size).isEqualTo(data.length); - assertThat(results.results).containsExactlyElementsOf(values); - } - - @Test - public void testParsePushIntOp() throws Exception { - byte[] data = { - (byte)0x81, (byte)0x80, (byte)0x80, 0x04 - }; - - IntConstBlock results = readPushIntOp(data, 0); - assertThat(results.size).isEqualTo(data.length); - assertThat(results.results) - .containsExactlyElementsOf(ImmutableList.of(65536)); - } - - @Test - public void testParsePushBytesOp() throws Exception { - byte[] data = { - (byte)0x80, 0x0b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64 - }; - List values = ImmutableList.of( - new byte[]{ 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd' } - ); - - Logic.ByteConstBlock results = readPushByteOp(data, 0); - assertThat(results.size).isEqualTo(data.length); - assertThat(results.results).containsExactlyElementsOf(values); - } - - @Test - public void testCheckProgramValid() throws Exception { - byte[] program = { - 0x01, 0x20, 0x01, 0x01, 0x22 // int 1 - }; - - // Null argument - ProgramData programData = readProgram(program, null); - assertThat(programData.good).isTrue(); - assertThat(programData.intBlock) - .containsExactlyElementsOf(ImmutableList.of(1)); - assertThat(programData.byteBlock).isEmpty(); - - // No argument - ArrayList args = new ArrayList<>(); - programData = readProgram(program, args); - assertThat(programData.good).isTrue(); - assertThat(programData.intBlock) - .containsExactlyElementsOf(ImmutableList.of(1)); - assertThat(programData.byteBlock).isEmpty(); - - // Unused argument - byte[] arg = new byte[10]; - Arrays.fill(arg, (byte)0x31); - args.add(arg); - - programData = readProgram(program, args); - assertThat(programData.good).isTrue(); - assertThat(programData.intBlock) - .containsExactlyElementsOf(ImmutableList.of(1)); - assertThat(programData.byteBlock).isEmpty(); - - // Repeated int constants parsing - byte[] int1 = new byte[10]; - Arrays.fill(int1, (byte)0x22); - byte[] program2 = new byte[program.length + int1.length]; - System.arraycopy(program, 0, program2, 0, program.length); - System.arraycopy(int1, 0, program2, program.length, int1.length); - programData = readProgram(program2, args); - assertThat(programData.good).isTrue(); - assertThat(programData.intBlock) - .containsExactlyElementsOf(ImmutableList.of(1)); - assertThat(programData.byteBlock).isEmpty(); - } - - @Test - public void testCheckProgramLongArgs() throws Exception { - byte[] program = { - 0x01, 0x20, 0x01, 0x01, 0x22 // int 1 - }; - ArrayList args = new ArrayList(); - - byte[] arg = new byte[1000]; - Arrays.fill(arg, (byte)0x31); - args.add(arg); - - assertThatThrownBy(() -> readProgram(program, args)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("program too long"); - } - - @Test - public void testCheckProgramLong() throws Exception { - byte[] program = { - 0x01, 0x20, 0x01, 0x01, 0x22 // int 1 - }; - byte[] int1 = new byte[1000]; - byte[] program2 = new byte[program.length + int1.length]; - ArrayList args = new ArrayList(); - - System.arraycopy(program, 0, program2, 0, program.length); - System.arraycopy(int1, 0, program2, program.length, int1.length); - assertThatThrownBy(() -> checkProgram(program2, args)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("program too long"); - } - - @Test - public void testCheckProgramCostly() throws Exception { - - byte[] old_versions = { - 0x1, 0x2, 0x3 - }; - - byte[] versions = { - 0x4 - }; - - byte[] program = { - 0x01, 0x26, 0x01, 0x01, 0x01, 0x28, 0x02 // byte 0x01 + keccak256 - }; - ArrayList args = new ArrayList(); - - byte[] arg = "aaaaaaaaaa".getBytes(); - args.add(arg); - - ProgramData programData = readProgram(program, args); - assertThat(programData.good).isTrue(); - - byte[] keccakx800 = new byte[800]; - for (int i = 0; i < keccakx800.length; i++) { - keccakx800[i] = 0x02; - } - - byte[] program2 = new byte[program.length + keccakx800.length]; - System.arraycopy(program, 0, program2, 0, program.length); - System.arraycopy(keccakx800, 0, program2, program.length, keccakx800.length); - - for (byte v : old_versions) { - program2[0] = v; - assertThatThrownBy(() -> readProgram(program2, args)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("program too costly for version < 4. consider using v4."); - } - - for (byte v : versions) { - program2[0] = v; - programData = readProgram(program2, args); - assertThat(programData.good).isTrue(); - } -} - - @Test - public void testCheckProgramInvalidOpcode() throws Exception { - byte[] program = { - 0x01, 0x20, 0x01, 0x01, (byte)0xFF - }; - ArrayList args = new ArrayList<>(); - - assertThatThrownBy(() -> checkProgram(program, args)) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("invalid instruction: 255"); - } - - @Test - public void testCheckProgramV2() throws Exception { - assertThat(getEvalMaxVersion()).isGreaterThanOrEqualTo(2); - assertThat(getLogicSigVersion()).isGreaterThanOrEqualTo(2); - - { - // balance - byte[] program = { - 0x02, 0x20, 0x01, 0x00, 0x22, 0x60 // int 0; balance - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - // app_opted_in - { - byte[] program = { - 0x02, 0x20, 0x01, 0x00, 0x22, 0x22, 0x61 // int 0; int 0; app_opted_in - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // asset_holding_get - byte[] program = { - 0x02, 0x20, 0x01, 0x00, 0x22, 0x70, 0x00 // int 0; int 0; asset_holding_get Balance - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - } - - @Test - public void testCheckProgramV3() throws Exception { - assertThat(getEvalMaxVersion()).isGreaterThanOrEqualTo(3); - assertThat(getLogicSigVersion()).isGreaterThanOrEqualTo(3); - - { - // min_balance - byte[] program = { - 0x03, 0x20, 0x01, 0x00, 0x22, 0x78 // int 0; min_balance - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - // pushbytes - { - byte[] program = { - 0x03, 0x20, 0x01, 0x00, 0x22, (byte)0x80, 0x02, 0x68, 0x69, 0x48 // int 0; pushbytes "hi"; pop - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // pushint - byte[] program = { - 0x03, 0x20, 0x01, 0x00, 0x22, (byte)0x81, 0x01, 0x48 // int 0; pushint 1; pop - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // swap - byte[] program = { - 0x03, 0x20, 0x02, 0x00, 0x01, 0x22, 0x23, 0x4c, 0x48 // int 0; int 1; swap; pop - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - } - - @Test - public void testCheckProgramV4() throws Exception { - assertThat(getEvalMaxVersion()).isGreaterThanOrEqualTo(4); - - { - // divmodw - byte[] program = { - 0x04, 0x20, 0x03, 0x01, 0x00, 0x02, 0x22, (byte) 0x81, (byte) 0xd0, (byte) 0x0f, 0x23, 0x24, 0x1f // int 1; pushint 2000; int 0; int 2; divmodw - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - // gloads i - { - byte[] program = { - 0x04, 0x20, 0x01, 0x00, 0x22, 0x3b, 0x00 // int 0; gloads 0 - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // callsub - byte[] program = { - 0x04, 0x20, 0x02, 0x01, 0x02, 0x22, (byte) 0x88, 0x00, 0x02, 0x23, 0x12, 0x49 // int 1; callsub double; int 2; ==; double: dup; - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // b>= - byte[] program = { - 0x04, 0x26, 0x02, 0x01, 0x11, 0x01, 0x10, 0x28, 0x29, (byte) 0xa7 // byte 0x11; byte 0x10; b>= - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // b^ - byte[] program = { - 0x04, 0x26, 0x02, 0x01, 0x11, 0x01, 0x10, 0x28, 0x29, (byte) 0xa7 // byte 0x11; byte 0x10; b^; byte 0x01; == - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // callsub, retsub. - byte[] program = { - 0x04, 0x20, 0x02, 0x01, 0x02, 0x22, (byte) 0x88, 0x00, 0x03, 0x23, 0x12, 0x43, 0x49, 0x08, (byte) 0x89 // int 1; callsub double; int 2; ==; return; double: dup; +; retsub; - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // loop - byte[] program = { - 0x04, 0x20, 0x04, 0x01, 0x02, 0x0a, 0x10, 0x22, 0x23, 0x0b, 0x49, 0x24, 0x0c, 0x40, (byte) 0xff, (byte) 0xf8, 0x25, 0x12 // int 1; loop: int 2; *; dup; int 10; <; bnz loop; int 16; == - }; - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - } - - @Test - public void testCheckProgramV5() throws Exception { - assertThat(getEvalMaxVersion()).isGreaterThanOrEqualTo(5); - - { - // itxn ops - byte[] program = { - 0x05, 0x20, 0x01, (byte) 0xc0, (byte) 0x84, 0x3d, (byte) 0xb1, (byte) 0x81, 0x01, (byte) 0xb2, 0x10, 0x22, (byte) 0xb2, 0x08, 0x31, 0x00, (byte) 0xb2, 0x07, (byte) 0xb3, (byte) 0xb4, 0x08, 0x22, 0x12 - }; - // itxn_begin; int pay; itxn_field TypeEnum; int 1000000; itxn_field Amount; txn Sender; itxn_field Receiver; itxn_submit; itxn Amount; int 1000000; == - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // ECDSA ops - byte[] program = { - 0x05,(byte)0x80,0x08,0x74,0x65,0x73,0x74,0x64,0x61,0x74,0x61,0x03,(byte)0x80,0x20,0x79,(byte)0xbf,(byte)0xa8,0x24,0x5a,(byte)0xea,(byte)0xc0,(byte)0xe7,0x14,(byte)0xb7,(byte)0xbd,0x2b,0x32,0x52,(byte)0xd0,0x39,0x79,(byte)0xe5,(byte)0xe7,(byte)0xa4,0x3c,(byte)0xb0,0x39,0x71,0x5a,0x5f,(byte)0x81,0x09,(byte)0xa7,(byte)0xdd,(byte)0x9b,(byte)0xa1,(byte)0x80,0x20,0x07,0x53,(byte)0xd3,0x17,(byte)0xe5,0x43,0x50,(byte)0xd1,(byte)0xd1,0x02,0x28,(byte)0x9a,(byte)0xfb,(byte)0xde,0x30,0x02,(byte)0xad,(byte)0xd4,0x52,(byte)0x9f,0x10,(byte)0xb9,(byte)0xf7,(byte)0xd3,(byte)0xd2,0x23,(byte)0x84,0x39,(byte)0x85,(byte)0xde,0x62,(byte)0xe0,(byte)0x80,0x21,0x03,(byte)0xab,(byte)0xfb,0x5e,0x6e,0x33,0x1f,(byte)0xb8,0x71,(byte)0xe4,0x23,(byte)0xf3,0x54,(byte)0xe2,(byte)0xbd,0x78,(byte)0xa3,(byte)0x84,(byte)0xef,0x7c,(byte)0xb0,0x7a,(byte)0xc8,(byte)0xbb,(byte)0xf2,0x7d,0x2d,(byte)0xd1,(byte)0xec,(byte)0xa0,0x0e,0x73,(byte)0xc1,0x06,0x00,0x05,0x00 - }; - // byte "testdata"; sha512_256; byte 0x79bfa8245aeac0e714b7bd2b3252d03979e5e7a43cb039715a5f8109a7dd9ba1; byte 0x0753d317e54350d1d102289afbde3002add4529f10b9f7d3d223843985de62e0; byte 0x03abfb5e6e331fb871e423f354e2bd78a384ef7cb07ac8bbf27d2dd1eca00e73c1; ecdsa_pk_decompress Secp256k1; ecdsa_verify Secp256k1 - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // cover, uncover, log - byte[] program = { - 0x05, (byte) 0x80, 0x01, 0x61, (byte) 0x80, 0x01, 0x62, (byte) 0x80, 0x01, 0x63, 0x4e, 0x02, 0x4f, 0x02, 0x50, 0x50, (byte) 0xb0, (byte) 0x81, 0x01 - }; - // byte "a"; byte "b"; byte "c"; cover 2; uncover 2; concat; concat; log; int 1 - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - } - - @Test - public void testCheckProgramV6() throws Exception { - assertThat(getEvalMaxVersion()).isGreaterThanOrEqualTo(6); - - { - // bsqrt - byte[] program = { - 0x06, (byte) 0x80, 0x01, (byte) 0x90, (byte) 0x96, (byte) 0x80, 0x01, 0x0c, (byte) 0xa8 - }; - // byte 0x90; bsqrt; byte 0x0c; b== - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // divw - byte[] program = { - 0x06, (byte) 0x81, 0x09, (byte) 0x81, (byte) 0xec, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x01, (byte) 0x81, 0x0a, (byte) 0x97, (byte) 0x81, (byte) 0xfe, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x01, 0x12 - }; - // int 9; int 18446744073709551596; int 10; divw; int 18446744073709551614; == - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - - { - // txn fields - byte[] program = { - 0x06, 0x31, 0x3f, 0x15, (byte) 0x81, 0x40, 0x12, 0x33, 0x00, 0x3e, 0x15, (byte) 0x81, 0x0a, 0x12, 0x10 - }; - // txn StateProofPK; len; int 64; ==; gtxn 0 LastLog; len; int 10; ==; && - boolean valid = checkProgram(program, null); - assertThat(valid).isTrue(); - } - } -} From 4b2a5c4c5320314f60797aaaeb42c269f4629170 Mon Sep 17 00:00:00 2001 From: Lucky Baar Date: Tue, 3 Jan 2023 09:40:15 -0600 Subject: [PATCH 4/4] bump to 2.0.0 --- CHANGELOG.md | 3 +++ README.md | 2 +- pom.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e6455228..989dc52f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.0.0 ## What's Changed + ### Breaking changes * Remove `TxGroup.assignGroupID(Transaction[] txns, Address address)` in favor @@ -14,6 +15,8 @@ * Remove the deprecated `MethodCallParams` public constructor in favor of `com.algorand.algosdk.builder.transaction.MethodCallTransactionBuilder`. * Remove unused generated types: `CatchpointAbortResponse`, `CatchpointStartResponse`. +**Full Changelog**: https://github.com/algorand/java-algorand-sdk/compare/1.22.0...2.0.0 + # 1.22.0 ### Bugfixes diff --git a/README.md b/README.md index 88c1b1e88..b7e4909d2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Maven: com.algorand algosdk - 1.22.0 + 2.0.0 ``` diff --git a/pom.xml b/pom.xml index 48355f23a..1b9036764 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.algorand algosdk - 1.22.0 + 2.0.0 jar ${project.groupId}:${project.artifactId}