Skip to content

Commit

Permalink
Rerun code generation based on new models
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Warehime committed May 20, 2022
1 parent 6eae55f commit 7658af9
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 25 deletions.
11 changes: 11 additions & 0 deletions src/main/java/com/algorand/algosdk/v2/client/algod/GetProof.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;
import com.algorand.algosdk.v2.client.model.Enums;
import com.algorand.algosdk.v2.client.model.ProofResponse;


Expand All @@ -28,6 +29,16 @@ public GetProof(Client client, Long round, String txid) {
this.txid = txid;
}

/**
* The type of hash function used to create the proof, must be one of:
* sha512_256
* sha256
*/
public GetProof hashtype(Enums.Hashtype hashtype) {
addQuery("hashtype", String.valueOf(hashtype));
return this;
}

/**
* Execute the query.
* @return the query response object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public TealCompile source(byte[] source) {
return this;
}

/**
* When set to `true`, returns the source map of the program as a JSON. Defaults to
* `false`.
*/
public TealCompile sourcemap(Boolean sourcemap) {
addQuery("sourcemap", String.valueOf(sourcemap));
return this;
}

/**
* Execute the query.
* @return the query response object.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.algorand.algosdk.v2.client.algod;

import com.algorand.algosdk.v2.client.common.Client;
import com.algorand.algosdk.v2.client.common.HttpMethod;
import com.algorand.algosdk.v2.client.common.Query;
import com.algorand.algosdk.v2.client.common.QueryData;
import com.algorand.algosdk.v2.client.common.Response;
import com.algorand.algosdk.v2.client.model.DisassembleResponse;


/**
* Given the program bytes, return the TEAL source code in plain text. This
* endpoint is only enabled when a node's configuration file sets
* EnableDeveloperAPI to true.
* /v2/teal/disassemble
*/
public class TealDisassemble extends Query {

public TealDisassemble(Client client) {
super(client, new HttpMethod("post"));
}

/**
* TEAL program binary to be disassembled
*/
public TealDisassemble source(byte[] source) {
addToBody(source);
return this;
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<DisassembleResponse> execute() throws Exception {
Response<DisassembleResponse> resp = baseExecute();
resp.setValueType(DisassembleResponse.class);
return resp;
}

/**
* Execute the query with custom headers, there must be an equal number of keys and values
* or else an error will be generated.
* @param headers an array of header keys
* @param values an array of header values
* @return the query response object.
* @throws Exception
*/
@Override
public Response<DisassembleResponse> execute(String[] headers, String[] values) throws Exception {
Response<DisassembleResponse> resp = baseExecute(headers, values);
resp.setValueType(DisassembleResponse.class);
return resp;
}

protected QueryData getRequestString() {
if (qd.bodySegments.isEmpty()) {
throw new RuntimeException("source is not set. It is a required parameter.");
}
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("teal"));
addPathSegment(String.valueOf("disassemble"));

return qd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.algorand.algosdk.v2.client.algod.GetApplicationByID;
import com.algorand.algosdk.v2.client.algod.GetAssetByID;
import com.algorand.algosdk.v2.client.algod.TealCompile;
import com.algorand.algosdk.v2.client.algod.TealDisassemble;
import com.algorand.algosdk.v2.client.algod.TealDryrun;
import com.algorand.algosdk.crypto.Address;

Expand Down Expand Up @@ -240,6 +241,16 @@ public TealCompile TealCompile() {
return new TealCompile((Client) this);
}

/**
* Given the program bytes, return the TEAL source code in plain text. This
* endpoint is only enabled when a node's configuration file sets
* EnableDeveloperAPI to true.
* /v2/teal/disassemble
*/
public TealDisassemble TealDisassemble() {
return new TealDisassemble((Client) this);
}

/**
* Executes TEAL program(s) in context and returns debugging information about the
* execution. This endpoint is only enabled when a node's configuration file sets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public LookupAccountCreatedApplications lookupAccountCreatedApplications(Address
}

/**
* Lookup account transactions.
* Lookup account transactions. Transactions are returned newest to oldest.
* /v2/accounts/{account-id}/transactions
*/
public LookupAccountTransactions lookupAccountTransactions(Address accountId) {
Expand Down Expand Up @@ -166,7 +166,7 @@ public LookupAssetBalances lookupAssetBalances(Long assetId) {
}

/**
* Lookup transactions for an asset.
* Lookup transactions for an asset. Transactions are returned oldest to newest.
* /v2/assets/{asset-id}/transactions
*/
public LookupAssetTransactions lookupAssetTransactions(Long assetId) {
Expand All @@ -190,7 +190,8 @@ public LookupTransaction lookupTransaction(String txid) {
}

/**
* Search for transactions.
* Search for transactions. Transactions are returned oldest to newest unless the
* address parameter is used, in which case results are returned newest to oldest.
* /v2/transactions
*/
public SearchForTransactions searchForTransactions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


/**
* Lookup account transactions.
* Lookup account transactions. Transactions are returned newest to oldest.
* /v2/accounts/{account-id}/transactions
*/
public class LookupAccountTransactions extends Query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


/**
* Lookup transactions for an asset.
* Lookup transactions for an asset. Transactions are returned oldest to newest.
* /v2/assets/{asset-id}/transactions
*/
public class LookupAssetTransactions extends Query {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@


/**
* Search for transactions.
* Search for transactions. Transactions are returned oldest to newest unless the
* address parameter is used, in which case results are returned newest to oldest.
* /v2/transactions
*/
public class SearchForTransactions extends Query {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.algorand.algosdk.v2.client.model;

import java.util.HashMap;
import java.util.Objects;

import com.algorand.algosdk.v2.client.common.PathResponse;
Expand All @@ -22,6 +23,12 @@ public class CompileResponse extends PathResponse {
@JsonProperty("result")
public String result;

/**
* JSON of the source map
*/
@JsonProperty("sourcemap")
public HashMap<String,Object> sourcemap;

@Override
public boolean equals(Object o) {

Expand All @@ -31,6 +38,7 @@ public boolean equals(Object o) {
CompileResponse other = (CompileResponse) o;
if (!Objects.deepEquals(this.hash, other.hash)) return false;
if (!Objects.deepEquals(this.result, other.result)) return false;
if (!Objects.deepEquals(this.sourcemap, other.sourcemap)) return false;

return true;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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;

/**
* Teal disassembly Result
*/
public class DisassembleResponse extends PathResponse {

/**
* disassembled Teal code
*/
@JsonProperty("result")
public String result;

@Override
public boolean equals(Object o) {

if (this == o) return true;
if (o == null) return false;

DisassembleResponse other = (DisassembleResponse) o;
if (!Objects.deepEquals(this.result, other.result)) return false;

return true;
}
}
38 changes: 20 additions & 18 deletions src/main/java/com/algorand/algosdk/v2/client/model/Enums.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ public String toString() {
}
}

/**
* The type of hash function used to create the proof, must be one of:
* sha512_256
* sha256
*/
public enum Hashtype {
@JsonProperty("sha512_256") SHA512_256("sha512_256"),
@JsonProperty("sha256") SHA256("sha256");

final String serializedName;
Hashtype(String name) {
this.serializedName = name;
}

@Override
public String toString() {
return this.serializedName;
}
}

/**
* (apan) defines the what additional actions occur with the transaction.
* Valid types:
Expand Down Expand Up @@ -130,22 +150,4 @@ public String toString() {
}
}

/**
* Combine with the address parameter to define what type of address to search for.
*/
public enum Hashtype {
@JsonProperty("sumhash") SUMHASH("sumhash"),
@JsonProperty("sha512_256") SHA512_256("sha512_256");

final String serializedName;
Hashtype(String name) {
this.serializedName = name;
}

@Override
public String toString() {
return this.serializedName;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class ProofResponse extends PathResponse {

/**
* The type of hash function used to create the proof, must be one of:
* sumhash
* sha512_256
* sha256
*/
@JsonProperty("hashtype")
public Enums.Hashtype hashtype;
Expand Down

0 comments on commit 7658af9

Please sign in to comment.