Skip to content

Commit

Permalink
Regenerate code from specification file
Browse files Browse the repository at this point in the history
  • Loading branch information
algo-dev-service committed Jan 13, 2025
1 parent 672b9c3 commit 6193384
Show file tree
Hide file tree
Showing 11 changed files with 476 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


/**
* Given a specific account public key, this call returns the accounts status,
* Given a specific account public key, this call returns the account's status,
* balance and spendable amounts
* /v2/accounts/{address}
*/
Expand Down
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.BlockHeaderResponse;


/**
* Get the block header for the block on the given round.
* /v2/blocks/{round}/header
*/
public class GetBlockHeader extends Query {

private Long round;

/**
* @param round The round from which to fetch block header information.
*/
public GetBlockHeader(Client client, Long round) {
super(client, new HttpMethod("get"));
addQuery("format", "msgpack");
this.round = round;
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<BlockHeaderResponse> execute() throws Exception {
Response<BlockHeaderResponse> resp = baseExecute();
resp.setValueType(BlockHeaderResponse.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<BlockHeaderResponse> execute(String[] headers, String[] values) throws Exception {
Response<BlockHeaderResponse> resp = baseExecute(headers, values);
resp.setValueType(BlockHeaderResponse.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("header"));

return qd;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.algorand.algosdk.v2.client.algod.GetBlock;
import com.algorand.algosdk.v2.client.algod.GetBlockTxids;
import com.algorand.algosdk.v2.client.algod.GetBlockHash;
import com.algorand.algosdk.v2.client.algod.GetBlockHeader;
import com.algorand.algosdk.v2.client.algod.GetTransactionProof;
import com.algorand.algosdk.v2.client.algod.GetBlockLogs;
import com.algorand.algosdk.v2.client.algod.GetSupply;
Expand Down Expand Up @@ -115,7 +116,7 @@ public GetVersion GetVersion() {
}

/**
* Given a specific account public key, this call returns the accounts status,
* Given a specific account public key, this call returns the account's status,
* balance and spendable amounts
* /v2/accounts/{address}
*/
Expand Down Expand Up @@ -180,6 +181,14 @@ public GetBlockHash GetBlockHash(Long round) {
return new GetBlockHash((Client) this, round);
}

/**
* Get the block header for the block on the given round.
* /v2/blocks/{round}/header
*/
public GetBlockHeader GetBlockHeader(Long round) {
return new GetBlockHeader((Client) this, round);
}

/**
* Get a proof for a transaction in a block.
* /v2/blocks/{round}/transactions/{txid}/proof
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.algorand.algosdk.v2.client.indexer.LookupAssetByID;
import com.algorand.algosdk.v2.client.indexer.LookupAssetBalances;
import com.algorand.algosdk.v2.client.indexer.LookupAssetTransactions;
import com.algorand.algosdk.v2.client.indexer.SearchForBlockHeaders;
import com.algorand.algosdk.v2.client.indexer.LookupBlock;
import com.algorand.algosdk.v2.client.indexer.LookupTransaction;
import com.algorand.algosdk.v2.client.indexer.SearchForTransactions;
Expand Down Expand Up @@ -196,6 +197,15 @@ public LookupAssetTransactions lookupAssetTransactions(Long assetId) {
return new LookupAssetTransactions((Client) this, assetId);
}

/**
* Search for block headers. Block headers are returned in ascending round order.
* Transactions are not included in the output.
* /v2/block-headers
*/
public SearchForBlockHeaders searchForBlockHeaders() {
return new SearchForBlockHeaders((Client) this);
}

/**
* Lookup block.
* /v2/blocks/{round-number}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package com.algorand.algosdk.v2.client.indexer;

import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.algorand.algosdk.crypto.Address;
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.common.Utils;
import com.algorand.algosdk.v2.client.model.BlockHeadersResponse;


/**
* Search for block headers. Block headers are returned in ascending round order.
* Transactions are not included in the output.
* /v2/block-headers
*/
public class SearchForBlockHeaders extends Query {

public SearchForBlockHeaders(Client client) {
super(client, new HttpMethod("get"));
}

/**
* Accounts marked as absent in the block header's participation updates. This
* parameter accepts a comma separated list of addresses.
*/
public SearchForBlockHeaders absent(List<Address> absent) {
addQuery("absent", StringUtils.join(absent, ","));
return this;
}

/**
* Include results after the given time. Must be an RFC 3339 formatted string.
*/
public SearchForBlockHeaders afterTime(Date afterTime) {
addQuery("after-time", Utils.getDateString(afterTime));
return this;
}

/**
* Include results before the given time. Must be an RFC 3339 formatted string.
*/
public SearchForBlockHeaders beforeTime(Date beforeTime) {
addQuery("before-time", Utils.getDateString(beforeTime));
return this;
}

/**
* Accounts marked as expired in the block header's participation updates. This
* parameter accepts a comma separated list of addresses.
*/
public SearchForBlockHeaders expired(List<Address> expired) {
addQuery("expired", StringUtils.join(expired, ","));
return this;
}

/**
* Maximum number of results to return. There could be additional pages even if the
* limit is not reached.
*/
public SearchForBlockHeaders limit(Long limit) {
addQuery("limit", String.valueOf(limit));
return this;
}

/**
* Include results at or before the specified max-round.
*/
public SearchForBlockHeaders maxRound(Long maxRound) {
addQuery("max-round", String.valueOf(maxRound));
return this;
}

/**
* Include results at or after the specified min-round.
*/
public SearchForBlockHeaders minRound(Long minRound) {
addQuery("min-round", String.valueOf(minRound));
return this;
}

/**
* The next page of results. Use the next token provided by the previous results.
*/
public SearchForBlockHeaders next(String next) {
addQuery("next", String.valueOf(next));
return this;
}

/**
* Accounts marked as proposer in the block header's participation updates. This
* parameter accepts a comma separated list of addresses.
*/
public SearchForBlockHeaders proposers(List<Address> proposers) {
addQuery("proposers", StringUtils.join(proposers, ","));
return this;
}

/**
* Execute the query.
* @return the query response object.
* @throws Exception
*/
@Override
public Response<BlockHeadersResponse> execute() throws Exception {
Response<BlockHeadersResponse> resp = baseExecute();
resp.setValueType(BlockHeadersResponse.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<BlockHeadersResponse> execute(String[] headers, String[] values) throws Exception {
Response<BlockHeadersResponse> resp = baseExecute(headers, values);
resp.setValueType(BlockHeadersResponse.class);
return resp;
}

protected QueryData getRequestString() {
addPathSegment(String.valueOf("v2"));
addPathSegment(String.valueOf("block-headers"));

return qd;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.algorand.algosdk.v2.client.model;

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

import com.algorand.algosdk.v2.client.common.PathResponse;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Block header.
*/
public class BlockHeaderResponse extends PathResponse {

/**
* Block header data.
*/
@JsonProperty("blockHeader")
public HashMap<String,Object> blockHeader;

@Override
public boolean equals(Object o) {

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

BlockHeaderResponse other = (BlockHeaderResponse) o;
if (!Objects.deepEquals(this.blockHeader, other.blockHeader)) return false;

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.algorand.algosdk.v2.client.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.algorand.algosdk.v2.client.common.PathResponse;
import com.fasterxml.jackson.annotation.JsonProperty;

public class BlockHeadersResponse extends PathResponse {

@JsonProperty("blocks")
public List<Block> blocks = new ArrayList<Block>();

/**
* Round at which the results were computed.
*/
@JsonProperty("current-round")
public Long currentRound;

/**
* Used for pagination, when making another request provide this token with the
* next parameter.
*/
@JsonProperty("next-token")
public String nextToken;

@Override
public boolean equals(Object o) {

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

BlockHeadersResponse other = (BlockHeadersResponse) o;
if (!Objects.deepEquals(this.blocks, other.blocks)) return false;
if (!Objects.deepEquals(this.currentRound, other.currentRound)) return false;
if (!Objects.deepEquals(this.nextToken, other.nextToken)) return false;

return true;
}
}
2 changes: 2 additions & 0 deletions src/main/java/com/algorand/algosdk/v2/client/model/Enums.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public static SigType forValue(String value) {
* (afrz) asset-freeze-transaction
* (appl) application-transaction
* (stpf) state-proof-transaction
* (hb) heartbeat-transaction
*/
public enum TxType {
@JsonProperty("pay") PAY("pay"),
Expand All @@ -200,6 +201,7 @@ public enum TxType {
@JsonProperty("afrz") AFRZ("afrz"),
@JsonProperty("appl") APPL("appl"),
@JsonProperty("stpf") STPF("stpf"),
@JsonProperty("hb") HB("hb"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
Expand Down
Loading

0 comments on commit 6193384

Please sign in to comment.