diff --git a/README.md b/README.md index 71df35d52..f44389c10 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,14 @@ mvn clean site -P github,default # for javadoc mvn clean deploy -P release,default ``` +# Testing + +Many cross-SDK tests are defined in [algorand-sdk-testing](https://github.com/algorand/algorand-sdk-testing/). Some are integration tests with additional dependencies. These dependencies are containerized in a docker file, which can be executed with `make docker-test`. + +It is occasionally useful to run locally, or against alternate integration branches. To do this: +1. Install feature files for your test branch "./run_integration_tests.sh -feature-only -test-branch " +2. Run locally with `make integration` and `make unit`, or from the IDE by running "RunCucumberUnitTest.java" + # Android Support Significant work has been taken to ensure Android compatibility (in particular for `minSdkVersion` 16). Note that the @@ -252,7 +260,7 @@ A testing framework can also be generated with: `com.algorand.sdkutils.RunQueryM ## Regenerate the Client Code -To actually regenerate the code, use `run_generator.sh` with paths to the `*.oas2.json` files mentioned above. +The actual generation is done using the `generate_java.sh` script in the [generator](https://github.com/algorand/generator/) repo. # Updating the `kmd` REST client The `kmd` REST client has not been upgraded to use the new code generation, it is still largely autogenerated by `swagger-codegen`. [https://github.com/swagger-api/swagger-codegen] diff --git a/src/main/java/com/algorand/algosdk/transaction/Transaction.java b/src/main/java/com/algorand/algosdk/transaction/Transaction.java index 98963413d..0f3531c07 100644 --- a/src/main/java/com/algorand/algosdk/transaction/Transaction.java +++ b/src/main/java/com/algorand/algosdk/transaction/Transaction.java @@ -162,6 +162,16 @@ public class Transaction implements Serializable { @JsonProperty("apep") public Long extraPages = 0L; + /* state proof fields */ + @JsonProperty("sptype") + public Integer stateProofType = null; + + @JsonProperty("sp") + public Map stateProof = null; + + @JsonProperty("spmsg") + public Map stateProofMessage = null; + /** * Create a payment transaction * @param fromAddr source address @@ -722,7 +732,7 @@ private Transaction(@JsonProperty("type") Type type, } /** - * Constructor which takes all the fields of Transaction except for nonpart and state proof. + * 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 */ @@ -1250,7 +1260,8 @@ public enum Type { AssetConfig("acfg"), AssetTransfer("axfer"), AssetFreeze("afrz"), - ApplicationCall("appl"); + ApplicationCall("appl"), + StateProof("stpf"); private static Map namesMap = new HashMap(6); diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/GetLightBlockHeaderProof.java b/src/main/java/com/algorand/algosdk/v2/client/algod/GetLightBlockHeaderProof.java new file mode 100644 index 000000000..ecf9cdf87 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/GetLightBlockHeaderProof.java @@ -0,0 +1,66 @@ +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.LightBlockHeaderProof; + + +/** + * Gets a proof for a given light block header inside a state proof commitment + * /v2/blocks/{round}/lightheader/proof + */ +public class GetLightBlockHeaderProof extends Query { + + private Long round; + + /** + * @param round The round to which the light block header belongs. + */ + public GetLightBlockHeaderProof(Client client, Long round) { + super(client, new HttpMethod("get")); + this.round = round; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(LightBlockHeaderProof.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(LightBlockHeaderProof.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.round == null) { + throw new RuntimeException("round is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("blocks")); + addPathSegment(String.valueOf(round)); + addPathSegment(String.valueOf("lightheader")); + addPathSegment(String.valueOf("proof")); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/GetStateProof.java b/src/main/java/com/algorand/algosdk/v2/client/algod/GetStateProof.java new file mode 100644 index 000000000..dc35ba3cd --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/GetStateProof.java @@ -0,0 +1,64 @@ +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.StateProof; + + +/** + * Get a state proof that covers a given round + * /v2/stateproofs/{round} + */ +public class GetStateProof extends Query { + + private Long round; + + /** + * @param round The round for which a state proof is desired. + */ + public GetStateProof(Client client, Long round) { + super(client, new HttpMethod("get")); + this.round = round; + } + + /** + * Execute the query. + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(StateProof.class); + return resp; + } + + /** + * Execute the query with custom headers, there must be an equal number of keys and values + * or else an error will be generated. + * @param headers an array of header keys + * @param values an array of header values + * @return the query response object. + * @throws Exception + */ + @Override + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(StateProof.class); + return resp; + } + + protected QueryData getRequestString() { + if (this.round == null) { + throw new RuntimeException("round is not set. It is a required parameter."); + } + addPathSegment(String.valueOf("v2")); + addPathSegment(String.valueOf("stateproofs")); + addPathSegment(String.valueOf(round)); + + return qd; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/GetProof.java b/src/main/java/com/algorand/algosdk/v2/client/algod/GetTransactionProof.java similarity index 73% rename from src/main/java/com/algorand/algosdk/v2/client/algod/GetProof.java rename to src/main/java/com/algorand/algosdk/v2/client/algod/GetTransactionProof.java index 6824d0f4c..edde98b7e 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/algod/GetProof.java +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/GetTransactionProof.java @@ -6,14 +6,14 @@ 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; +import com.algorand.algosdk.v2.client.model.TransactionProofResponse; /** - * Get a Merkle proof for a transaction in a block. + * Get a proof for a transaction in a block. * /v2/blocks/{round}/transactions/{txid}/proof */ -public class GetProof extends Query { +public class GetTransactionProof extends Query { private Long round; private String txid; @@ -22,7 +22,7 @@ public class GetProof extends Query { * @param round The round in which the transaction appears. * @param txid The transaction ID for which to generate a proof. */ - public GetProof(Client client, Long round, String txid) { + public GetTransactionProof(Client client, Long round, String txid) { super(client, new HttpMethod("get")); addQuery("format", "msgpack"); this.round = round; @@ -34,7 +34,7 @@ public GetProof(Client client, Long round, String txid) { * sha512_256 * sha256 */ - public GetProof hashtype(Enums.Hashtype hashtype) { + public GetTransactionProof hashtype(Enums.Hashtype hashtype) { addQuery("hashtype", String.valueOf(hashtype)); return this; } @@ -45,9 +45,9 @@ public GetProof hashtype(Enums.Hashtype hashtype) { * @throws Exception */ @Override - public Response execute() throws Exception { - Response resp = baseExecute(); - resp.setValueType(ProofResponse.class); + public Response execute() throws Exception { + Response resp = baseExecute(); + resp.setValueType(TransactionProofResponse.class); return resp; } @@ -60,9 +60,9 @@ public Response execute() throws Exception { * @throws Exception */ @Override - public Response execute(String[] headers, String[] values) throws Exception { - Response resp = baseExecute(headers, values); - resp.setValueType(ProofResponse.class); + public Response execute(String[] headers, String[] values) throws Exception { + Response resp = baseExecute(headers, values); + resp.setValueType(TransactionProofResponse.class); return resp; } diff --git a/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java b/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java index 4d2909782..920996c26 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java +++ b/src/main/java/com/algorand/algosdk/v2/client/common/AlgodClient.java @@ -10,7 +10,7 @@ import com.algorand.algosdk.v2.client.algod.AccountApplicationInformation; import com.algorand.algosdk.v2.client.algod.GetPendingTransactionsByAddress; import com.algorand.algosdk.v2.client.algod.GetBlock; -import com.algorand.algosdk.v2.client.algod.GetProof; +import com.algorand.algosdk.v2.client.algod.GetTransactionProof; import com.algorand.algosdk.v2.client.algod.GetSupply; import com.algorand.algosdk.v2.client.algod.GetStatus; import com.algorand.algosdk.v2.client.algod.WaitForBlock; @@ -18,6 +18,8 @@ import com.algorand.algosdk.v2.client.algod.TransactionParams; import com.algorand.algosdk.v2.client.algod.GetPendingTransactions; import com.algorand.algosdk.v2.client.algod.PendingTransactionInformation; +import com.algorand.algosdk.v2.client.algod.GetStateProof; +import com.algorand.algosdk.v2.client.algod.GetLightBlockHeaderProof; import com.algorand.algosdk.v2.client.algod.GetApplicationByID; import com.algorand.algosdk.v2.client.algod.GetAssetByID; import com.algorand.algosdk.v2.client.algod.TealCompile; @@ -140,12 +142,12 @@ public GetBlock GetBlock(Long round) { } /** - * Get a Merkle proof for a transaction in a block. + * Get a proof for a transaction in a block. * /v2/blocks/{round}/transactions/{txid}/proof */ - public GetProof GetProof(Long round, + public GetTransactionProof GetTransactionProof(Long round, String txid) { - return new GetProof((Client) this, round, txid); + return new GetTransactionProof((Client) this, round, txid); } /** @@ -213,6 +215,22 @@ public PendingTransactionInformation PendingTransactionInformation(String txid) return new PendingTransactionInformation((Client) this, txid); } + /** + * Get a state proof that covers a given round + * /v2/stateproofs/{round} + */ + public GetStateProof GetStateProof(Long round) { + return new GetStateProof((Client) this, round); + } + + /** + * Gets a proof for a given light block header inside a state proof commitment + * /v2/blocks/{round}/lightheader/proof + */ + public GetLightBlockHeaderProof GetLightBlockHeaderProof(Long round) { + return new GetLightBlockHeaderProof((Client) this, round); + } + /** * Given a application ID, it returns application information including creator, * approval and clear programs, global and local schemas, and global state. diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Block.java b/src/main/java/com/algorand/algosdk/v2/client/model/Block.java index 442ab604c..83078c5ee 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Block.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Block.java @@ -69,6 +69,12 @@ public String seed() { } public byte[] seed; + /** + * Tracks the status of state proofs. + */ + @JsonProperty("state-proof-tracking") + public List stateProofTracking = new ArrayList(); + /** * (ts) Block creation timestamp in seconds since eposh */ @@ -98,6 +104,21 @@ public String transactionsRoot() { } public byte[] transactionsRoot; + /** + * (txn256) TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a + * vector commitment instead of a merkle tree, and SHA256 hash function instead of + * the default SHA512_256. This commitment can be used on environments where only + * the SHA256 function exists. + */ + @JsonProperty("transactions-root-sha256") + public void transactionsRootSha256(String base64Encoded) { + this.transactionsRootSha256 = Encoder.decodeFromBase64(base64Encoded); + } + public String transactionsRootSha256() { + return Encoder.encodeToBase64(this.transactionsRootSha256); + } + public byte[] transactionsRootSha256; + /** * (tc) TxnCounter counts the number of transactions committed in the ledger, from * the time at which support for this feature was introduced. @@ -133,9 +154,11 @@ public boolean equals(Object o) { if (!Objects.deepEquals(this.rewards, other.rewards)) return false; if (!Objects.deepEquals(this.round, other.round)) return false; if (!Objects.deepEquals(this.seed, other.seed)) return false; + if (!Objects.deepEquals(this.stateProofTracking, other.stateProofTracking)) return false; if (!Objects.deepEquals(this.timestamp, other.timestamp)) return false; if (!Objects.deepEquals(this.transactions, other.transactions)) return false; if (!Objects.deepEquals(this.transactionsRoot, other.transactionsRoot)) return false; + if (!Objects.deepEquals(this.transactionsRootSha256, other.transactionsRootSha256)) return false; if (!Objects.deepEquals(this.txnCounter, other.txnCounter)) return false; if (!Objects.deepEquals(this.upgradeState, other.upgradeState)) return false; if (!Objects.deepEquals(this.upgradeVote, other.upgradeVote)) return false; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java b/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java index 8fc2fec9e..df6b7c775 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Enums.java @@ -191,6 +191,7 @@ public static SigType forValue(String value) { * (axfer) asset-transfer-transaction * (afrz) asset-freeze-transaction * (appl) application-transaction + * (stpf) state-proof-transaction */ public enum TxType { @JsonProperty("pay") PAY("pay"), @@ -199,6 +200,7 @@ public enum TxType { @JsonProperty("axfer") AXFER("axfer"), @JsonProperty("afrz") AFRZ("afrz"), @JsonProperty("appl") APPL("appl"), + @JsonProperty("stpf") STPF("stpf"), @JsonProperty("") UNKNOWN(""); final String serializedName; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/HashFactory.java b/src/main/java/com/algorand/algosdk/v2/client/model/HashFactory.java new file mode 100644 index 000000000..56e436772 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/HashFactory.java @@ -0,0 +1,27 @@ +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 HashFactory extends PathResponse { + + /** + * (t) + */ + @JsonProperty("hash-type") + public Long hashType; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + HashFactory other = (HashFactory) o; + if (!Objects.deepEquals(this.hashType, other.hashType)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/IndexerStateProofMessage.java b/src/main/java/com/algorand/algosdk/v2/client/model/IndexerStateProofMessage.java new file mode 100644 index 000000000..9358b4168 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/IndexerStateProofMessage.java @@ -0,0 +1,68 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class IndexerStateProofMessage extends PathResponse { + + /** + * (b) + */ + @JsonProperty("block-headers-commitment") + public void blockHeadersCommitment(String base64Encoded) { + this.blockHeadersCommitment = Encoder.decodeFromBase64(base64Encoded); + } + public String blockHeadersCommitment() { + return Encoder.encodeToBase64(this.blockHeadersCommitment); + } + public byte[] blockHeadersCommitment; + + /** + * (f) + */ + @JsonProperty("first-attested-round") + public java.math.BigInteger firstAttestedRound; + + /** + * (l) + */ + @JsonProperty("latest-attested-round") + public java.math.BigInteger latestAttestedRound; + + /** + * (P) + */ + @JsonProperty("ln-proven-weight") + public java.math.BigInteger lnProvenWeight; + + /** + * (v) + */ + @JsonProperty("voters-commitment") + public void votersCommitment(String base64Encoded) { + this.votersCommitment = Encoder.decodeFromBase64(base64Encoded); + } + public String votersCommitment() { + return Encoder.encodeToBase64(this.votersCommitment); + } + public byte[] votersCommitment; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + IndexerStateProofMessage other = (IndexerStateProofMessage) o; + if (!Objects.deepEquals(this.blockHeadersCommitment, other.blockHeadersCommitment)) return false; + if (!Objects.deepEquals(this.firstAttestedRound, other.firstAttestedRound)) return false; + if (!Objects.deepEquals(this.latestAttestedRound, other.latestAttestedRound)) return false; + if (!Objects.deepEquals(this.lnProvenWeight, other.lnProvenWeight)) return false; + if (!Objects.deepEquals(this.votersCommitment, other.votersCommitment)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/LightBlockHeaderProof.java b/src/main/java/com/algorand/algosdk/v2/client/model/LightBlockHeaderProof.java new file mode 100644 index 000000000..f99af414f --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/LightBlockHeaderProof.java @@ -0,0 +1,52 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Proof of membership and position of a light block header. + */ +public class LightBlockHeaderProof extends PathResponse { + + /** + * The index of the light block header in the vector commitment tree + */ + @JsonProperty("index") + public Long index; + + /** + * The encoded proof. + */ + @JsonProperty("proof") + public void proof(String base64Encoded) { + this.proof = Encoder.decodeFromBase64(base64Encoded); + } + public String proof() { + return Encoder.encodeToBase64(this.proof); + } + public byte[] proof; + + /** + * Represents the depth of the tree that is being proven, i.e. the number of edges + * from a leaf to the root. + */ + @JsonProperty("treedepth") + public Long treedepth; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + LightBlockHeaderProof other = (LightBlockHeaderProof) o; + if (!Objects.deepEquals(this.index, other.index)) return false; + if (!Objects.deepEquals(this.proof, other.proof)) return false; + if (!Objects.deepEquals(this.treedepth, other.treedepth)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/MerkleArrayProof.java b/src/main/java/com/algorand/algosdk/v2/client/model/MerkleArrayProof.java new file mode 100644 index 000000000..454d526d8 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/MerkleArrayProof.java @@ -0,0 +1,57 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class MerkleArrayProof extends PathResponse { + + @JsonProperty("hash-factory") + public HashFactory hashFactory; + + /** + * (pth) + */ + @JsonProperty("path") + public List path = new ArrayList(); + @JsonIgnore + public void path(List base64Encoded) { + this.path = new ArrayList(); + for (String val : base64Encoded) { + this.path.add(Encoder.decodeFromBase64(val)); + } + } + @JsonIgnore + public List path() { + ArrayList ret = new ArrayList(); + for (byte[] val : this.path) { + ret.add(Encoder.encodeToBase64(val)); + } + return ret; + } + + /** + * (td) + */ + @JsonProperty("tree-depth") + public Long treeDepth; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + MerkleArrayProof other = (MerkleArrayProof) o; + if (!Objects.deepEquals(this.hashFactory, other.hashFactory)) return false; + if (!Objects.deepEquals(this.path, other.path)) return false; + if (!Objects.deepEquals(this.treeDepth, other.treeDepth)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProof.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProof.java new file mode 100644 index 000000000..7fd5a2301 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProof.java @@ -0,0 +1,44 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents a state proof and its corresponding message + */ +public class StateProof extends PathResponse { + + /** + * Represents the message that the state proofs are attesting to. + */ + @JsonProperty("Message") + public StateProofMessage message; + + /** + * The encoded StateProof for the message. + */ + @JsonProperty("StateProof") + public void stateProof(String base64Encoded) { + this.stateProof = Encoder.decodeFromBase64(base64Encoded); + } + public String stateProof() { + return Encoder.encodeToBase64(this.stateProof); + } + public byte[] stateProof; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProof other = (StateProof) o; + if (!Objects.deepEquals(this.message, other.message)) return false; + if (!Objects.deepEquals(this.stateProof, other.stateProof)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofFields.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofFields.java new file mode 100644 index 000000000..049ea5a9b --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofFields.java @@ -0,0 +1,84 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * (sp) represents a state proof. + * Definition: + * crypto/stateproof/structs.go : StateProof + */ +public class StateProofFields extends PathResponse { + + /** + * (P) + */ + @JsonProperty("part-proofs") + public MerkleArrayProof partProofs; + + /** + * (pr) Sequence of reveal positions. + */ + @JsonProperty("positions-to-reveal") + public List positionsToReveal = new ArrayList(); + + /** + * (r) Note that this is actually stored as a map[uint64] - Reveal in the actual + * msgp + */ + @JsonProperty("reveals") + public List reveals = new ArrayList(); + + /** + * (v) Salt version of the merkle signature. + */ + @JsonProperty("salt-version") + public Long saltVersion; + + /** + * (c) + */ + @JsonProperty("sig-commit") + public void sigCommit(String base64Encoded) { + this.sigCommit = Encoder.decodeFromBase64(base64Encoded); + } + public String sigCommit() { + return Encoder.encodeToBase64(this.sigCommit); + } + public byte[] sigCommit; + + /** + * (S) + */ + @JsonProperty("sig-proofs") + public MerkleArrayProof sigProofs; + + /** + * (w) + */ + @JsonProperty("signed-weight") + public java.math.BigInteger signedWeight; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofFields other = (StateProofFields) o; + if (!Objects.deepEquals(this.partProofs, other.partProofs)) return false; + if (!Objects.deepEquals(this.positionsToReveal, other.positionsToReveal)) return false; + if (!Objects.deepEquals(this.reveals, other.reveals)) return false; + if (!Objects.deepEquals(this.saltVersion, other.saltVersion)) return false; + if (!Objects.deepEquals(this.sigCommit, other.sigCommit)) return false; + if (!Objects.deepEquals(this.sigProofs, other.sigProofs)) return false; + if (!Objects.deepEquals(this.signedWeight, other.signedWeight)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofMessage.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofMessage.java new file mode 100644 index 000000000..1ee30534a --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofMessage.java @@ -0,0 +1,73 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents the message that the state proofs are attesting to. + */ +public class StateProofMessage extends PathResponse { + + /** + * The vector commitment root on all light block headers within a state proof + * interval. + */ + @JsonProperty("BlockHeadersCommitment") + public void blockHeadersCommitment(String base64Encoded) { + this.blockHeadersCommitment = Encoder.decodeFromBase64(base64Encoded); + } + public String blockHeadersCommitment() { + return Encoder.encodeToBase64(this.blockHeadersCommitment); + } + public byte[] blockHeadersCommitment; + + /** + * The first round the message attests to. + */ + @JsonProperty("FirstAttestedRound") + public java.math.BigInteger firstAttestedRound; + + /** + * The last round the message attests to. + */ + @JsonProperty("LastAttestedRound") + public java.math.BigInteger lastAttestedRound; + + /** + * An integer value representing the natural log of the proven weight with 16 bits + * of precision. This value would be used to verify the next state proof. + */ + @JsonProperty("LnProvenWeight") + public java.math.BigInteger lnProvenWeight; + + /** + * The vector commitment root of the top N accounts to sign the next StateProof. + */ + @JsonProperty("VotersCommitment") + public void votersCommitment(String base64Encoded) { + this.votersCommitment = Encoder.decodeFromBase64(base64Encoded); + } + public String votersCommitment() { + return Encoder.encodeToBase64(this.votersCommitment); + } + public byte[] votersCommitment; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofMessage other = (StateProofMessage) o; + if (!Objects.deepEquals(this.blockHeadersCommitment, other.blockHeadersCommitment)) return false; + if (!Objects.deepEquals(this.firstAttestedRound, other.firstAttestedRound)) return false; + if (!Objects.deepEquals(this.lastAttestedRound, other.lastAttestedRound)) return false; + if (!Objects.deepEquals(this.lnProvenWeight, other.lnProvenWeight)) return false; + if (!Objects.deepEquals(this.votersCommitment, other.votersCommitment)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofParticipant.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofParticipant.java new file mode 100644 index 000000000..e48d99581 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofParticipant.java @@ -0,0 +1,34 @@ +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 StateProofParticipant extends PathResponse { + + /** + * (p) + */ + @JsonProperty("verifier") + public StateProofVerifier verifier; + + /** + * (w) + */ + @JsonProperty("weight") + public java.math.BigInteger weight; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofParticipant other = (StateProofParticipant) o; + if (!Objects.deepEquals(this.verifier, other.verifier)) return false; + if (!Objects.deepEquals(this.weight, other.weight)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofReveal.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofReveal.java new file mode 100644 index 000000000..4db51d66c --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofReveal.java @@ -0,0 +1,42 @@ +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 StateProofReveal extends PathResponse { + + /** + * (p) + */ + @JsonProperty("participant") + public StateProofParticipant participant; + + /** + * The position in the signature and participants arrays corresponding to this + * entry. + */ + @JsonProperty("position") + public java.math.BigInteger position; + + /** + * (s) + */ + @JsonProperty("sig-slot") + public StateProofSigSlot sigSlot; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofReveal other = (StateProofReveal) o; + if (!Objects.deepEquals(this.participant, other.participant)) return false; + if (!Objects.deepEquals(this.position, other.position)) return false; + if (!Objects.deepEquals(this.sigSlot, other.sigSlot)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofSigSlot.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofSigSlot.java new file mode 100644 index 000000000..7f9a7cd69 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofSigSlot.java @@ -0,0 +1,31 @@ +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 StateProofSigSlot extends PathResponse { + + /** + * (l) The total weight of signatures in the lower-numbered slots. + */ + @JsonProperty("lower-sig-weight") + public java.math.BigInteger lowerSigWeight; + + @JsonProperty("signature") + public StateProofSignature signature; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofSigSlot other = (StateProofSigSlot) o; + if (!Objects.deepEquals(this.lowerSigWeight, other.lowerSigWeight)) return false; + if (!Objects.deepEquals(this.signature, other.signature)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofSignature.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofSignature.java new file mode 100644 index 000000000..4491515f9 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofSignature.java @@ -0,0 +1,52 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class StateProofSignature extends PathResponse { + + @JsonProperty("falcon-signature") + public void falconSignature(String base64Encoded) { + this.falconSignature = Encoder.decodeFromBase64(base64Encoded); + } + public String falconSignature() { + return Encoder.encodeToBase64(this.falconSignature); + } + public byte[] falconSignature; + + @JsonProperty("merkle-array-index") + public Long merkleArrayIndex; + + @JsonProperty("proof") + public MerkleArrayProof proof; + + /** + * (vkey) + */ + @JsonProperty("verifying-key") + public void verifyingKey(String base64Encoded) { + this.verifyingKey = Encoder.decodeFromBase64(base64Encoded); + } + public String verifyingKey() { + return Encoder.encodeToBase64(this.verifyingKey); + } + public byte[] verifyingKey; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofSignature other = (StateProofSignature) o; + if (!Objects.deepEquals(this.falconSignature, other.falconSignature)) return false; + if (!Objects.deepEquals(this.merkleArrayIndex, other.merkleArrayIndex)) return false; + if (!Objects.deepEquals(this.proof, other.proof)) return false; + if (!Objects.deepEquals(this.verifyingKey, other.verifyingKey)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofTracking.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofTracking.java new file mode 100644 index 000000000..aac966d25 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofTracking.java @@ -0,0 +1,57 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class StateProofTracking extends PathResponse { + + /** + * (n) Next round for which we will accept a state proof transaction. + */ + @JsonProperty("next-round") + public Long nextRound; + + /** + * (t) The total number of microalgos held by the online accounts during the + * StateProof round. + */ + @JsonProperty("online-total-weight") + public Long onlineTotalWeight; + + /** + * State Proof Type. Note the raw object uses map with this as key. + */ + @JsonProperty("type") + public java.math.BigInteger type; + + /** + * (v) Root of a vector commitment containing online accounts that will help sign + * the proof. + */ + @JsonProperty("voters-commitment") + public void votersCommitment(String base64Encoded) { + this.votersCommitment = Encoder.decodeFromBase64(base64Encoded); + } + public String votersCommitment() { + return Encoder.encodeToBase64(this.votersCommitment); + } + public byte[] votersCommitment; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofTracking other = (StateProofTracking) o; + if (!Objects.deepEquals(this.nextRound, other.nextRound)) return false; + if (!Objects.deepEquals(this.onlineTotalWeight, other.onlineTotalWeight)) return false; + if (!Objects.deepEquals(this.type, other.type)) return false; + if (!Objects.deepEquals(this.votersCommitment, other.votersCommitment)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/StateProofVerifier.java b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofVerifier.java new file mode 100644 index 000000000..4806a63d6 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/StateProofVerifier.java @@ -0,0 +1,41 @@ +package com.algorand.algosdk.v2.client.model; + +import java.util.Objects; + +import com.algorand.algosdk.util.Encoder; +import com.algorand.algosdk.v2.client.common.PathResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class StateProofVerifier extends PathResponse { + + /** + * (cmt) Represents the root of the vector commitment tree. + */ + @JsonProperty("commitment") + public void commitment(String base64Encoded) { + this.commitment = Encoder.decodeFromBase64(base64Encoded); + } + public String commitment() { + return Encoder.encodeToBase64(this.commitment); + } + public byte[] commitment; + + /** + * (lf) Key lifetime. + */ + @JsonProperty("key-lifetime") + public java.math.BigInteger keyLifetime; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + StateProofVerifier other = (StateProofVerifier) o; + if (!Objects.deepEquals(this.commitment, other.commitment)) return false; + if (!Objects.deepEquals(this.keyLifetime, other.keyLifetime)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Transaction.java b/src/main/java/com/algorand/algosdk/v2/client/model/Transaction.java index 345e6b61f..1ac8a4423 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Transaction.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Transaction.java @@ -302,6 +302,14 @@ public String rekeyTo() throws NoSuchAlgorithmException { @JsonProperty("signature") public TransactionSignature signature; + /** + * Fields for a state proof transaction. + * Definition: + * data/transactions/stateproof.go : StateProofTxnFields + */ + @JsonProperty("state-proof-transaction") + public TransactionStateProof stateProofTransaction; + /** * (type) Indicates what type of transaction this is. Different types have * different fields. @@ -312,6 +320,7 @@ public String rekeyTo() throws NoSuchAlgorithmException { * (axfer) asset-transfer-transaction * (afrz) asset-freeze-transaction * (appl) application-transaction + * (stpf) state-proof-transaction */ @JsonProperty("tx-type") public Enums.TxType txType; @@ -355,6 +364,7 @@ public boolean equals(Object o) { if (!Objects.deepEquals(this.sender, other.sender)) return false; if (!Objects.deepEquals(this.senderRewards, other.senderRewards)) return false; if (!Objects.deepEquals(this.signature, other.signature)) return false; + if (!Objects.deepEquals(this.stateProofTransaction, other.stateProofTransaction)) return false; if (!Objects.deepEquals(this.txType, other.txType)) return false; return true; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ProofResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/TransactionProofResponse.java similarity index 91% rename from src/main/java/com/algorand/algosdk/v2/client/model/ProofResponse.java rename to src/main/java/com/algorand/algosdk/v2/client/model/TransactionProofResponse.java index 6318e77a3..e74827b8e 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/ProofResponse.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/TransactionProofResponse.java @@ -9,7 +9,7 @@ /** * Proof of transaction in a block. */ -public class ProofResponse extends PathResponse { +public class TransactionProofResponse extends PathResponse { /** * The type of hash function used to create the proof, must be one of: @@ -26,7 +26,7 @@ public class ProofResponse extends PathResponse { public Long idx; /** - * Merkle proof of transaction membership. + * Proof of transaction membership. */ @JsonProperty("proof") public void proof(String base64Encoded) { @@ -62,7 +62,7 @@ public boolean equals(Object o) { if (this == o) return true; if (o == null) return false; - ProofResponse other = (ProofResponse) o; + TransactionProofResponse other = (TransactionProofResponse) o; if (!Objects.deepEquals(this.hashtype, other.hashtype)) return false; if (!Objects.deepEquals(this.idx, other.idx)) return false; if (!Objects.deepEquals(this.proof, other.proof)) return false; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/TransactionStateProof.java b/src/main/java/com/algorand/algosdk/v2/client/model/TransactionStateProof.java new file mode 100644 index 000000000..7ffa0868d --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/TransactionStateProof.java @@ -0,0 +1,49 @@ +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; + +/** + * Fields for a state proof transaction. + * Definition: + * data/transactions/stateproof.go : StateProofTxnFields + */ +public class TransactionStateProof extends PathResponse { + + /** + * (spmsg) + */ + @JsonProperty("message") + public IndexerStateProofMessage message; + + /** + * (sp) represents a state proof. + * Definition: + * crypto/stateproof/structs.go : StateProof + */ + @JsonProperty("state-proof") + public StateProofFields stateProof; + + /** + * (sptype) Type of the state proof. Integer representing an entry defined in + * protocol/stateproof.go + */ + @JsonProperty("state-proof-type") + public java.math.BigInteger stateProofType; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + TransactionStateProof other = (TransactionStateProof) o; + if (!Objects.deepEquals(this.message, other.message)) return false; + if (!Objects.deepEquals(this.stateProof, other.stateProof)) return false; + if (!Objects.deepEquals(this.stateProofType, other.stateProofType)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/VersionBuild.java b/src/main/java/com/algorand/algosdk/v2/client/model/VersionBuild.java deleted file mode 100644 index 38dd12457..000000000 --- a/src/main/java/com/algorand/algosdk/v2/client/model/VersionBuild.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.algorand.algosdk.v2.client.model; - -import java.util.Objects; - -import com.algorand.algosdk.util.Encoder; -import com.algorand.algosdk.v2.client.common.PathResponse; -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * the current algod build version information. - */ -public class VersionBuild extends PathResponse { - - @JsonProperty("branch") - public String branch; - - @JsonProperty("build-number") - public Long buildNumber; - - @JsonProperty("channel") - public String channel; - - @JsonProperty("commit-hash") - public void commitHash(String base64Encoded) { - this.commitHash = Encoder.decodeFromBase64(base64Encoded); - } - @JsonProperty("commit-hash") - public String commitHash() { - return Encoder.encodeToBase64(this.commitHash); - } - public byte[] commitHash; - - @JsonProperty("major") - public Long major; - - @JsonProperty("minor") - public Long minor; - - @Override - public boolean equals(Object o) { - - if (this == o) return true; - if (o == null) return false; - - VersionBuild other = (VersionBuild) o; - if (!Objects.deepEquals(this.branch, other.branch)) return false; - if (!Objects.deepEquals(this.buildNumber, other.buildNumber)) return false; - if (!Objects.deepEquals(this.channel, other.channel)) return false; - if (!Objects.deepEquals(this.commitHash, other.commitHash)) return false; - if (!Objects.deepEquals(this.major, other.major)) return false; - if (!Objects.deepEquals(this.minor, other.minor)) return false; - - return true; - } -} diff --git a/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java b/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java index 611f622a1..59bae3fd3 100644 --- a/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java +++ b/src/test/java/com/algorand/algosdk/unit/AlgodPaths.java @@ -1,10 +1,10 @@ package com.algorand.algosdk.unit; import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.unit.utils.QueryMapper; import com.algorand.algosdk.unit.utils.TestingUtils; import com.algorand.algosdk.v2.client.algod.*; import com.algorand.algosdk.v2.client.common.AlgodClient; +import com.algorand.algosdk.v2.client.model.Enums; import io.cucumber.java.en.When; import java.security.NoSuchAlgorithmException; @@ -78,7 +78,24 @@ public void accountAssetInformation(String string, Integer int1) throws NoSuchAl @When("we make an Account Information call against account {string} with exclude {string}") public void accountInformation(String string, String string2) throws NoSuchAlgorithmException { AccountInformation aiq = algodClient.AccountInformation(new Address(string)); - if (TestingUtils.notEmpty(string2)) aiq.exclude(QueryMapper.getExclude(string2)); + if (TestingUtils.notEmpty(string2)) aiq.exclude(Enums.Exclude.forValue(string2)); ps.q = aiq; } + + @When("we make a GetTransactionProof call for round {long} txid {string} and hashtype {string}") + public void getTransactionProof(Long round, String txid, String hashType) { + GetTransactionProof gtp = algodClient.GetTransactionProof(round, txid); + if (TestingUtils.notEmpty(hashType)) gtp.hashtype(Enums.Hashtype.forValue(hashType)); + ps.q = gtp; + } + + @When("we make a GetLightBlockHeaderProof call for round {long}") + public void getLightBlockHeaderProof(Long round) { + ps.q = algodClient.GetLightBlockHeaderProof(round); + } + + @When("we make a GetStateProof call for round {long}") + public void getStateProof(Long round) { + ps.q = algodClient.GetStateProof(round); + } } diff --git a/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java b/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java index bdcec1fd9..8c9cb43e8 100644 --- a/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java +++ b/src/test/java/com/algorand/algosdk/unit/IndexerPaths.java @@ -1,7 +1,6 @@ package com.algorand.algosdk.unit; import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.unit.utils.QueryMapper; import com.algorand.algosdk.unit.utils.TestingUtils; import com.algorand.algosdk.util.Encoder; import com.algorand.algosdk.v2.client.common.IndexerClient; @@ -155,8 +154,8 @@ public void lookupAssetTransactions(Long assetId, String notePrefix, String txTy LookupAssetTransactions q = this.indexerClient.lookupAssetTransactions(assetId); if (TestingUtils.notEmpty(address)) q.address(new Address(address)); if (TestingUtils.notEmpty(notePrefix)) q.notePrefix(Encoder.decodeFromBase64(notePrefix)); - if (TestingUtils.notEmpty(txType)) q.txType(QueryMapper.getTxType(txType)); - if (TestingUtils.notEmpty(sigType)) q.sigType(QueryMapper.getSigType(sigType)); + if (TestingUtils.notEmpty(txType)) q.txType(Enums.TxType.forValue(txType)); + if (TestingUtils.notEmpty(sigType)) q.sigType(Enums.SigType.forValue(sigType)); if (TestingUtils.notEmpty(txid)) q.txid(txid); if (TestingUtils.notEmpty(round)) q.round(round); if (TestingUtils.notEmpty(minRound)) q.minRound(minRound); @@ -166,7 +165,7 @@ public void lookupAssetTransactions(Long assetId, String notePrefix, String txTy if (TestingUtils.notEmpty(afterTime)) q.afterTime(Utils.parseDate(afterTime)); if (TestingUtils.notEmpty(currencyGT)) q.currencyGreaterThan(currencyGT); if (TestingUtils.notEmpty(currencyLT)) q.currencyLessThan(currencyLT); - if (TestingUtils.notEmpty(addressRole)) q.addressRole(QueryMapper.getAddressRole(addressRole)); + if (TestingUtils.notEmpty(addressRole)) q.addressRole(Enums.AddressRole.forValue(addressRole)); if (TestingUtils.notEmpty(excludeCloseTo)) q.excludeCloseTo(excludeCloseTo.equals("true")); if (TestingUtils.notEmpty(rekeyTo)) q.rekeyTo(rekeyTo.equals("true")); ps.q = q; @@ -176,8 +175,8 @@ public void lookupAssetTransactions(Long assetId, String notePrefix, String txTy public void lookupAccountTransactions(String account, String notePrefix, String txType, String sigType, String txid, Long round, Long minRound, Long maxRound, Long limit, String beforeTime, String afterTime, Long currencyGT, Long currencyLT, Long assetId, String rekeyTo) throws NoSuchAlgorithmException, ParseException { LookupAccountTransactions q = this.indexerClient.lookupAccountTransactions(new Address(account)); if (TestingUtils.notEmpty(notePrefix)) q.notePrefix(Encoder.decodeFromBase64(notePrefix)); - if (TestingUtils.notEmpty(txType)) q.txType(QueryMapper.getTxType(txType)); - if (TestingUtils.notEmpty(sigType)) q.sigType(QueryMapper.getSigType(sigType)); + if (TestingUtils.notEmpty(txType)) q.txType(Enums.TxType.forValue(txType)); + if (TestingUtils.notEmpty(sigType)) q.sigType(Enums.SigType.forValue(sigType)); if (TestingUtils.notEmpty(txid)) q.txid(txid); if (TestingUtils.notEmpty(round)) q.round(round); if (TestingUtils.notEmpty(minRound)) q.minRound(minRound); @@ -213,8 +212,8 @@ public void searchForTransactions(String address, String notePrefix, String txTy SearchForTransactions q = this.indexerClient.searchForTransactions(); if (TestingUtils.notEmpty(address)) q.address(new Address(address)); if (TestingUtils.notEmpty(notePrefix)) q.notePrefix(Encoder.decodeFromBase64(notePrefix)); - if (TestingUtils.notEmpty(txType)) q.txType(QueryMapper.getTxType(txType)); - if (TestingUtils.notEmpty(sigType)) q.sigType(QueryMapper.getSigType(sigType)); + if (TestingUtils.notEmpty(txType)) q.txType(Enums.TxType.forValue(txType)); + if (TestingUtils.notEmpty(sigType)) q.sigType(Enums.SigType.forValue(sigType)); if (TestingUtils.notEmpty(txid)) q.txid(txid); if (TestingUtils.notEmpty(round)) q.round(round); if (TestingUtils.notEmpty(minRound)) q.minRound(minRound); @@ -225,7 +224,7 @@ public void searchForTransactions(String address, String notePrefix, String txTy if (TestingUtils.notEmpty(currencyGT)) q.currencyGreaterThan(currencyGT); if (TestingUtils.notEmpty(currencyLT)) q.currencyLessThan(currencyLT); if (TestingUtils.notEmpty(assetID)) q.assetId(assetID); - if (TestingUtils.notEmpty(addressRole)) q.addressRole(QueryMapper.getAddressRole(addressRole)); + if (TestingUtils.notEmpty(addressRole)) q.addressRole(Enums.AddressRole.forValue(addressRole)); if (TestingUtils.notEmpty(excludeCloseTo)) q.excludeCloseTo(excludeCloseTo.equals("true")); if (TestingUtils.notEmpty(rekeyTo)) q.rekeyTo(rekeyTo.equals("true")); ps.q = q; @@ -285,7 +284,7 @@ public void lookupAccountByID(String string, String string2) throws NoSuchAlgori if (TestingUtils.notEmpty(string2)) { ArrayList excludes = new ArrayList(); for (String excld : string2.split(",")) { - excludes.add(QueryMapper.getExclude(excld)); + excludes.add(Enums.Exclude.forValue(excld)); } q.exclude(excludes); } @@ -320,7 +319,7 @@ public void searchForAccounts(String string) { if (TestingUtils.notEmpty(string)) { ArrayList excludes = new ArrayList(); for (String excld : string.split(",")) { - excludes.add(QueryMapper.getExclude(excld)); + excludes.add(Enums.Exclude.forValue(excld)); } q.exclude(excludes); } diff --git a/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java b/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java index 65889dfe4..ae4f37c96 100644 --- a/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java +++ b/src/test/java/com/algorand/algosdk/unit/ResponsesShared.java @@ -10,6 +10,7 @@ import com.algorand.algosdk.v2.client.common.Response; import com.algorand.algosdk.v2.client.model.DryrunResponse; import com.algorand.algosdk.v2.client.model.DryrunTxnResult; +import com.algorand.algosdk.v2.client.model.StateProof; import com.google.common.io.Files; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; @@ -71,6 +72,9 @@ public void we_make_any_call_to(String client, String endpoint) throws Exception switch(client) { case "indexer": { switch(endpoint) { + case "lookupBlock": + response = indexer.lookupBlock(1234L).execute(); + break; case "lookupAccountByID": response = indexer.lookupAccountByID(new Address()).execute(); break; @@ -165,7 +169,8 @@ public void we_make_any_call_to(String client, String endpoint) throws Exception response = algod.TealDryrun().execute(); break; case "Proof": - response = algod.GetProof(0L, "").execute(); + case "GetTransactionProof": + response = algod.GetTransactionProof(0L, "").execute(); break; case "AccountInformation": response = algod.AccountInformation(new Address()).execute(); @@ -176,6 +181,16 @@ public void we_make_any_call_to(String client, String endpoint) throws Exception case "AccountAssetInformation": response = algod.AccountAssetInformation(new Address(), 0L).execute(); break; + case "GetBlock": + response = algod.GetBlock(1234L).execute(); + break; + case "GetLightBlockHeaderProof": + response = algod.GetLightBlockHeaderProof(1234L).execute(); + break; + case "GetStateProof": + Response r = algod.GetStateProof(1234L).execute(); + response = r; + break; default: Assertions.fail("Unsupported algod endpoint: " + endpoint); } diff --git a/src/test/java/com/algorand/algosdk/unit/RunCucumberUnitTest.java b/src/test/java/com/algorand/algosdk/unit/RunCucumberUnitTest.java index cd92dad4d..e287616ec 100644 --- a/src/test/java/com/algorand/algosdk/unit/RunCucumberUnitTest.java +++ b/src/test/java/com/algorand/algosdk/unit/RunCucumberUnitTest.java @@ -5,6 +5,6 @@ import org.junit.runner.RunWith; @RunWith(Cucumber.class) -@CucumberOptions(publish = false, plugin = {"progress"}, tags = "@disabled.by.default", extraGlue = "com.algorand.algosdk.cucumber.shared") +@CucumberOptions(publish = true, plugin = {"progress"}, tags = "@disabled.by.default", extraGlue = "com.algorand.algosdk.cucumber.shared") public class RunCucumberUnitTest { } diff --git a/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java b/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java deleted file mode 100644 index 15f18b1a1..000000000 --- a/src/test/java/com/algorand/algosdk/unit/utils/QueryMapper.java +++ /dev/null @@ -1,689 +0,0 @@ -/* - * THIS FILE IS GENERATED BY QueryMapperGenerator!!!!!!!!!!!!!!!! - */ -package com.algorand.algosdk.unit.utils; - -import java.security.NoSuchAlgorithmException; -import com.fasterxml.jackson.core.JsonProcessingException; -import java.text.ParseException; -import java.util.ArrayList; - -import com.algorand.algosdk.v2.client.common.Utils; - -import com.algorand.algosdk.crypto.Address; -import com.algorand.algosdk.util.Encoder; -import com.algorand.algosdk.v2.client.algod.*; -import com.algorand.algosdk.v2.client.indexer.*; -import com.algorand.algosdk.v2.client.model.Enums; -import com.algorand.algosdk.v2.client.common.*; - -public class QueryMapper { - - public static Query getClass(String name, IndexerClient client, String args[]) throws NoSuchAlgorithmException { - switch (name) { - case "makeHealthCheck": - return client.makeHealthCheck(); - case "searchForAccounts": - return client.searchForAccounts(); - case "lookupAccountByID": - return client.lookupAccountByID(new Address(args[0])); - case "lookupAccountAssets": - return client.lookupAccountAssets(new Address(args[0])); - case "lookupAccountCreatedAssets": - return client.lookupAccountCreatedAssets(new Address(args[0])); - case "lookupAccountAppLocalStates": - return client.lookupAccountAppLocalStates(new Address(args[0])); - case "lookupAccountCreatedApplications": - return client.lookupAccountCreatedApplications(new Address(args[0])); - case "lookupAccountTransactions": - return client.lookupAccountTransactions(new Address(args[0])); - case "searchForApplications": - return client.searchForApplications(); - case "lookupApplicationByID": - return client.lookupApplicationByID(Long.valueOf(args[0])); - case "lookupApplicationLogsByID": - return client.lookupApplicationLogsByID(Long.valueOf(args[0])); - case "searchForAssets": - return client.searchForAssets(); - case "lookupAssetByID": - return client.lookupAssetByID(Long.valueOf(args[0])); - case "lookupAssetBalances": - return client.lookupAssetBalances(Long.valueOf(args[0])); - case "lookupAssetTransactions": - return client.lookupAssetTransactions(Long.valueOf(args[0])); - case "lookupBlock": - return client.lookupBlock(Long.valueOf(args[0])); - case "lookupTransaction": - return client.lookupTransaction(args[0]); - case "searchForTransactions": - return client.searchForTransactions(); - } - return null; - } - - public static Query getClass(String name, AlgodClient client, String args[]) throws NoSuchAlgorithmException { - switch (name) { - case "HealthCheck": - return client.HealthCheck(); - case "Metrics": - return client.Metrics(); - case "GetGenesis": - return client.GetGenesis(); - case "SwaggerJSON": - return client.SwaggerJSON(); - case "GetVersion": - return client.GetVersion(); - case "AccountInformation": - return client.AccountInformation(new Address(args[0])); - case "AccountAssetInformation": - return client.AccountAssetInformation(new Address(args[0]), Long.valueOf(args[1])); - case "AccountApplicationInformation": - return client.AccountApplicationInformation(new Address(args[0]), Long.valueOf(args[1])); - case "GetPendingTransactionsByAddress": - return client.GetPendingTransactionsByAddress(new Address(args[0])); - case "GetBlock": - return client.GetBlock(Long.valueOf(args[0])); - case "GetProof": - return client.GetProof(Long.valueOf(args[0]), args[1]); - case "GetSupply": - return client.GetSupply(); - case "GetStatus": - return client.GetStatus(); - case "WaitForBlock": - return client.WaitForBlock(Long.valueOf(args[0])); - case "RawTransaction": - return client.RawTransaction(); - case "TransactionParams": - return client.TransactionParams(); - case "GetPendingTransactions": - return client.GetPendingTransactions(); - case "PendingTransactionInformation": - return client.PendingTransactionInformation(args[0]); - case "GetApplicationByID": - return client.GetApplicationByID(Long.valueOf(args[0])); - case "GetAssetByID": - return client.GetAssetByID(Long.valueOf(args[0])); - case "TealCompile": - return client.TealCompile(); - case "TealDryrun": - return client.TealDryrun(); - } - return null; - } - - public static void setValue(Query q, String className, String property, String value) throws ParseException, NoSuchAlgorithmException, JsonProcessingException { - switch (className) { - case "makeHealthCheck": - switch (property) { - } - break; - case "searchForAccounts": - switch (property) { - case "application-id": - ((SearchForAccounts)q).applicationId(Long.valueOf(value)); - break; - case "asset-id": - ((SearchForAccounts)q).assetId(Long.valueOf(value)); - break; - case "auth-addr": - ((SearchForAccounts)q).authAddr(new Address(value)); - break; - case "currency-greater-than": - ((SearchForAccounts)q).currencyGreaterThan(Long.valueOf(value)); - break; - case "currency-less-than": - ((SearchForAccounts)q).currencyLessThan(Long.valueOf(value)); - break; - case "exclude": - ArrayList vals = new ArrayList(); - for (String t : value.split(",")) { - vals.add(getExclude(t)); - } - ((SearchForAccounts)q).exclude(vals); - break; - case "include-all": - ((SearchForAccounts)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((SearchForAccounts)q).limit(Long.valueOf(value)); - break; - case "next": - ((SearchForAccounts)q).next(value); - break; - case "round": - ((SearchForAccounts)q).round(Long.valueOf(value)); - break; - } - break; - case "lookupAccountByID": - switch (property) { - case "exclude": - ArrayList vals = new ArrayList(); - for (String t : value.split(",")) { - vals.add(getExclude(t)); - } - ((SearchForAccounts)q).exclude(vals); - break; - case "include-all": - ((LookupAccountByID)q).includeAll(Boolean.valueOf(value)); - break; - case "round": - ((LookupAccountByID)q).round(Long.valueOf(value)); - break; - } - break; - case "lookupAccountAssets": - switch (property) { - case "asset-id": - ((LookupAccountAssets)q).assetId(Long.valueOf(value)); - break; - case "include-all": - ((LookupAccountAssets)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((LookupAccountAssets)q).limit(Long.valueOf(value)); - break; - case "next": - ((LookupAccountAssets)q).next(value); - break; - } - break; - case "lookupAccountCreatedAssets": - switch (property) { - case "asset-id": - ((LookupAccountCreatedAssets)q).assetId(Long.valueOf(value)); - break; - case "include-all": - ((LookupAccountCreatedAssets)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((LookupAccountCreatedAssets)q).limit(Long.valueOf(value)); - break; - case "next": - ((LookupAccountCreatedAssets)q).next(value); - break; - } - break; - case "lookupAccountAppLocalStates": - switch (property) { - case "application-id": - ((LookupAccountAppLocalStates)q).applicationId(Long.valueOf(value)); - break; - case "include-all": - ((LookupAccountAppLocalStates)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((LookupAccountAppLocalStates)q).limit(Long.valueOf(value)); - break; - case "next": - ((LookupAccountAppLocalStates)q).next(value); - break; - } - break; - case "lookupAccountCreatedApplications": - switch (property) { - case "application-id": - ((LookupAccountCreatedApplications)q).applicationId(Long.valueOf(value)); - break; - case "include-all": - ((LookupAccountCreatedApplications)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((LookupAccountCreatedApplications)q).limit(Long.valueOf(value)); - break; - case "next": - ((LookupAccountCreatedApplications)q).next(value); - break; - } - break; - case "lookupAccountTransactions": - switch (property) { - case "after-time": - ((LookupAccountTransactions)q).afterTime(Utils.parseDate(value)); - break; - case "asset-id": - ((LookupAccountTransactions)q).assetId(Long.valueOf(value)); - break; - case "before-time": - ((LookupAccountTransactions)q).beforeTime(Utils.parseDate(value)); - break; - case "currency-greater-than": - ((LookupAccountTransactions)q).currencyGreaterThan(Long.valueOf(value)); - break; - case "currency-less-than": - ((LookupAccountTransactions)q).currencyLessThan(Long.valueOf(value)); - break; - case "limit": - ((LookupAccountTransactions)q).limit(Long.valueOf(value)); - break; - case "max-round": - ((LookupAccountTransactions)q).maxRound(Long.valueOf(value)); - break; - case "min-round": - ((LookupAccountTransactions)q).minRound(Long.valueOf(value)); - break; - case "next": - ((LookupAccountTransactions)q).next(value); - break; - case "note-prefix": - ((LookupAccountTransactions)q).notePrefix(Encoder.decodeFromBase64(value)); - break; - case "rekey-to": - ((LookupAccountTransactions)q).rekeyTo(Boolean.valueOf(value)); - break; - case "round": - ((LookupAccountTransactions)q).round(Long.valueOf(value)); - break; - case "sig-type": - ((LookupAccountTransactions)q).sigType(getSigType(value)); - break; - case "tx-type": - ((LookupAccountTransactions)q).txType(getTxType(value)); - break; - case "txid": - ((LookupAccountTransactions)q).txid(value); - break; - } - break; - case "searchForApplications": - switch (property) { - case "application-id": - ((SearchForApplications)q).applicationId(Long.valueOf(value)); - break; - case "creator": - ((SearchForApplications)q).creator(value); - break; - case "include-all": - ((SearchForApplications)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((SearchForApplications)q).limit(Long.valueOf(value)); - break; - case "next": - ((SearchForApplications)q).next(value); - break; - } - break; - case "lookupApplicationByID": - switch (property) { - case "include-all": - ((LookupApplicationByID)q).includeAll(Boolean.valueOf(value)); - break; - } - break; - case "lookupApplicationLogsByID": - switch (property) { - case "limit": - ((LookupApplicationLogsByID)q).limit(Long.valueOf(value)); - break; - case "max-round": - ((LookupApplicationLogsByID)q).maxRound(Long.valueOf(value)); - break; - case "min-round": - ((LookupApplicationLogsByID)q).minRound(Long.valueOf(value)); - break; - case "next": - ((LookupApplicationLogsByID)q).next(value); - break; - case "sender-address": - ((LookupApplicationLogsByID)q).senderAddress(new Address(value)); - break; - case "txid": - ((LookupApplicationLogsByID)q).txid(value); - break; - } - break; - case "searchForAssets": - switch (property) { - case "asset-id": - ((SearchForAssets)q).assetId(Long.valueOf(value)); - break; - case "creator": - ((SearchForAssets)q).creator(value); - break; - case "include-all": - ((SearchForAssets)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((SearchForAssets)q).limit(Long.valueOf(value)); - break; - case "name": - ((SearchForAssets)q).name(value); - break; - case "next": - ((SearchForAssets)q).next(value); - break; - case "unit": - ((SearchForAssets)q).unit(value); - break; - } - break; - case "lookupAssetByID": - switch (property) { - case "include-all": - ((LookupAssetByID)q).includeAll(Boolean.valueOf(value)); - break; - } - break; - case "lookupAssetBalances": - switch (property) { - case "currency-greater-than": - ((LookupAssetBalances)q).currencyGreaterThan(Long.valueOf(value)); - break; - case "currency-less-than": - ((LookupAssetBalances)q).currencyLessThan(Long.valueOf(value)); - break; - case "include-all": - ((LookupAssetBalances)q).includeAll(Boolean.valueOf(value)); - break; - case "limit": - ((LookupAssetBalances)q).limit(Long.valueOf(value)); - break; - case "next": - ((LookupAssetBalances)q).next(value); - break; - } - break; - case "lookupAssetTransactions": - switch (property) { - case "address": - ((LookupAssetTransactions)q).address(new Address(value)); - break; - case "address-role": - ((LookupAssetTransactions)q).addressRole(getAddressRole(value)); - break; - case "after-time": - ((LookupAssetTransactions)q).afterTime(Utils.parseDate(value)); - break; - case "before-time": - ((LookupAssetTransactions)q).beforeTime(Utils.parseDate(value)); - break; - case "currency-greater-than": - ((LookupAssetTransactions)q).currencyGreaterThan(Long.valueOf(value)); - break; - case "currency-less-than": - ((LookupAssetTransactions)q).currencyLessThan(Long.valueOf(value)); - break; - case "exclude-close-to": - ((LookupAssetTransactions)q).excludeCloseTo(Boolean.valueOf(value)); - break; - case "limit": - ((LookupAssetTransactions)q).limit(Long.valueOf(value)); - break; - case "max-round": - ((LookupAssetTransactions)q).maxRound(Long.valueOf(value)); - break; - case "min-round": - ((LookupAssetTransactions)q).minRound(Long.valueOf(value)); - break; - case "next": - ((LookupAssetTransactions)q).next(value); - break; - case "note-prefix": - ((LookupAssetTransactions)q).notePrefix(Encoder.decodeFromBase64(value)); - break; - case "rekey-to": - ((LookupAssetTransactions)q).rekeyTo(Boolean.valueOf(value)); - break; - case "round": - ((LookupAssetTransactions)q).round(Long.valueOf(value)); - break; - case "sig-type": - ((LookupAssetTransactions)q).sigType(getSigType(value)); - break; - case "tx-type": - ((LookupAssetTransactions)q).txType(getTxType(value)); - break; - case "txid": - ((LookupAssetTransactions)q).txid(value); - break; - } - break; - case "lookupBlock": - switch (property) { - } - break; - case "lookupTransaction": - switch (property) { - } - break; - case "searchForTransactions": - switch (property) { - case "address": - ((SearchForTransactions)q).address(new Address(value)); - break; - case "address-role": - ((SearchForTransactions)q).addressRole(getAddressRole(value)); - break; - case "after-time": - ((SearchForTransactions)q).afterTime(Utils.parseDate(value)); - break; - case "application-id": - ((SearchForTransactions)q).applicationId(Long.valueOf(value)); - break; - case "asset-id": - ((SearchForTransactions)q).assetId(Long.valueOf(value)); - break; - case "before-time": - ((SearchForTransactions)q).beforeTime(Utils.parseDate(value)); - break; - case "currency-greater-than": - ((SearchForTransactions)q).currencyGreaterThan(Long.valueOf(value)); - break; - case "currency-less-than": - ((SearchForTransactions)q).currencyLessThan(Long.valueOf(value)); - break; - case "exclude-close-to": - ((SearchForTransactions)q).excludeCloseTo(Boolean.valueOf(value)); - break; - case "limit": - ((SearchForTransactions)q).limit(Long.valueOf(value)); - break; - case "max-round": - ((SearchForTransactions)q).maxRound(Long.valueOf(value)); - break; - case "min-round": - ((SearchForTransactions)q).minRound(Long.valueOf(value)); - break; - case "next": - ((SearchForTransactions)q).next(value); - break; - case "note-prefix": - ((SearchForTransactions)q).notePrefix(Encoder.decodeFromBase64(value)); - break; - case "rekey-to": - ((SearchForTransactions)q).rekeyTo(Boolean.valueOf(value)); - break; - case "round": - ((SearchForTransactions)q).round(Long.valueOf(value)); - break; - case "sig-type": - ((SearchForTransactions)q).sigType(getSigType(value)); - break; - case "tx-type": - ((SearchForTransactions)q).txType(getTxType(value)); - break; - case "txid": - ((SearchForTransactions)q).txid(value); - break; - } - break; - case "HealthCheck": - switch (property) { - } - break; - case "Metrics": - switch (property) { - } - break; - case "GetGenesis": - switch (property) { - } - break; - case "SwaggerJSON": - switch (property) { - } - break; - case "GetVersion": - switch (property) { - } - break; - case "AccountInformation": - switch (property) { - case "exclude": - ((AccountInformation)q).exclude(getExclude(value)); - break; - } - break; - case "AccountAssetInformation": - switch (property) { - } - break; - case "AccountApplicationInformation": - switch (property) { - } - break; - case "GetPendingTransactionsByAddress": - switch (property) { - case "max": - ((GetPendingTransactionsByAddress)q).max(Long.valueOf(value)); - break; - } - break; - case "GetBlock": - switch (property) { - } - break; - case "GetProof": - switch (property) { - } - break; - case "GetSupply": - switch (property) { - } - break; - case "GetStatus": - switch (property) { - } - break; - case "WaitForBlock": - switch (property) { - } - break; - case "RawTransaction": - switch (property) { - case "rawtxn": - ((RawTransaction)q).rawtxn(Encoder.decodeFromBase64(value)); - break; - } - break; - case "TransactionParams": - switch (property) { - } - break; - case "GetPendingTransactions": - switch (property) { - case "max": - ((GetPendingTransactions)q).max(Long.valueOf(value)); - break; - } - break; - case "PendingTransactionInformation": - switch (property) { - } - break; - case "GetApplicationByID": - switch (property) { - } - break; - case "GetAssetByID": - switch (property) { - } - break; - case "TealCompile": - switch (property) { - case "source": - ((TealCompile)q).source(Encoder.decodeFromBase64(value)); - break; - } - break; - case "TealDryrun": - switch (property) { - case "request": - ((TealDryrun)q).request(null); - break; - } - break; - - } - } - - public static String lookup(Query q, String className) throws Exception { - Response resp = q.execute(); - if (resp.body() == null) { - throw new RuntimeException(resp.message()); - } - return resp.body().toString(); - } - - public static Enums.AddressRole getAddressRole(String val) { - switch(val.toUpperCase()) { - case "SENDER": - return Enums.AddressRole.SENDER; - case "RECEIVER": - return Enums.AddressRole.RECEIVER; - case "FREEZETARGET": - return Enums.AddressRole.FREEZETARGET; - default: - throw new RuntimeException("Enum value not recognized: " + val +"!"); - } - } - public static Enums.SigType getSigType(String val) { - switch(val.toUpperCase()) { - case "SIG": - return Enums.SigType.SIG; - case "MSIG": - return Enums.SigType.MSIG; - case "LSIG": - return Enums.SigType.LSIG; - default: - throw new RuntimeException("Enum value not recognized: " + val +"!"); - } - } - public static Enums.TxType getTxType(String val) { - switch(val.toUpperCase()) { - case "PAY": - return Enums.TxType.PAY; - case "KEYREG": - return Enums.TxType.KEYREG; - case "ACFG": - return Enums.TxType.ACFG; - case "AXFER": - return Enums.TxType.AXFER; - case "AFRZ": - return Enums.TxType.AFRZ; - case "APPL": - return Enums.TxType.APPL; - default: - throw new RuntimeException("Enum value not recognized: " + val +"!"); - } - } - public static Enums.Exclude getExclude(String val) { - switch(val.toUpperCase().replaceAll("-", "")) { - case "ALL": - return Enums.Exclude.ALL; - case "ASSETS": - return Enums.Exclude.ASSETS; - case "CREATEDASSETS": - return Enums.Exclude.CREATEDASSETS; - case "APPSLOCALSTATE": - return Enums.Exclude.APPSLOCALSTATE; - case "CREATEDAPPS": - return Enums.Exclude.CREATEDAPPS; - case "NONE": - return Enums.Exclude.NONE; - default: - throw new RuntimeException("Enum value not recognized: " + val +"!"); - } - } -} \ No newline at end of file diff --git a/src/test/unit.tags b/src/test/unit.tags index f51517453..a3f91cec3 100644 --- a/src/test/unit.tags +++ b/src/test/unit.tags @@ -20,6 +20,9 @@ @unit.responses.messagepack.231 @unit.responses.unlimited_assets @unit.sourcemap +@unit.stateproof.paths +@unit.stateproof.responses +@unit.stateproof.responses.msgp @unit.tealsign @unit.transactions @unit.transactions.keyreg