Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate updated client API code #318

Merged
merged 7 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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 base64 encoded 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) {
jasonpaulos marked this conversation as resolved.
Show resolved Hide resolved
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 base64 encoded 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
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ public class DryrunTxnResult extends PathResponse {
public List<DryrunState> appCallTrace = new ArrayList<DryrunState>();

/**
* Execution cost of app call transaction
* Budget consumed during execution of app call transaction.
*/
@JsonProperty("cost")
public Long cost;
@JsonProperty("budget-credit")
public Long budgetCredit;

/**
* Budget added during execution of app call transaction.
*/
@JsonProperty("budget-debit")
public Long budgetDebit;

/**
* Disassembled program line by line.
Expand Down Expand Up @@ -78,10 +84,11 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;

DryrunTxnResult other = (DryrunTxnResult) o;
DryrunTxnResult other = (DryrunTxnResult) o;
if (!Objects.deepEquals(this.appCallMessages, other.appCallMessages)) return false;
if (!Objects.deepEquals(this.appCallTrace, other.appCallTrace)) return false;
if (!Objects.deepEquals(this.cost, other.cost)) return false;
if (!Objects.deepEquals(this.budgetCredit, other.budgetCredit)) return false;
if (!Objects.deepEquals(this.budgetDebit, other.budgetDebit)) 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;
Expand Down
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