-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StateProofs: Add State Proof support. (#360)
* Regenerate client. * Implement cucumber response tests. * Implement path tests, update Makefile, update README. * Revert * Add state proof fields to Transaction. * Update README.md * Update src/main/java/com/algorand/algosdk/transaction/Transaction.java * publish results. * Add transaction-root-256
- Loading branch information
Showing
31 changed files
with
983 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/com/algorand/algosdk/v2/client/algod/GetLightBlockHeaderProof.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<LightBlockHeaderProof> execute() throws Exception { | ||
Response<LightBlockHeaderProof> 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<LightBlockHeaderProof> execute(String[] headers, String[] values) throws Exception { | ||
Response<LightBlockHeaderProof> 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; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/algorand/algosdk/v2/client/algod/GetStateProof.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<StateProof> execute() throws Exception { | ||
Response<StateProof> 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<StateProof> execute(String[] headers, String[] values) throws Exception { | ||
Response<StateProof> 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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.