diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 28e2e330e..67d62e75a 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Generate and PR uses: algorand/generator/.github/actions/sdk-codegen/@master with: diff --git a/.github/workflows/create-release-pr.yml b/.github/workflows/create-release-pr.yml index f1e344c72..85abee554 100644 --- a/.github/workflows/create-release-pr.yml +++ b/.github/workflows/create-release-pr.yml @@ -43,7 +43,7 @@ jobs: fi - name: Checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v4 with: fetch-depth: 0 diff --git a/.github/workflows/pr-type-category.yml b/.github/workflows/pr-type-category.yml index e03505595..ed2983321 100644 --- a/.github/workflows/pr-type-category.yml +++ b/.github/workflows/pr-type-category.yml @@ -10,7 +10,7 @@ jobs: name: Check PR Category and Type steps: - name: Checking for correct number of required github pr labels - uses: mheap/github-action-required-labels@v3 + uses: mheap/github-action-required-labels@v5 with: mode: exactly count: 1 diff --git a/.gitignore b/.gitignore index 3938a2dbd..0a9b910c9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ src/test/resources/generated_responses/ *.feature src/test/resources/**/*.json src/test/resources/**/*.base64 +src/test/resources/**/*.tok.map src/test/resources/**/*.teal src/test/resources/**/*.tok src/test/resources/**/*.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d1343a17..96d4ff643 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# 2.5.0 + + + +## What's Changed +### Bugfixes +* Fix: Fix indexer sync issue in cucumber tests by @jasonpaulos in https://github.com/algorand/java-algorand-sdk/pull/686 +### Enhancements +* API Update: Regenerate code with the latest specification file (8f8a9ef2) by @github-actions in https://github.com/algorand/java-algorand-sdk/pull/661 +* Codegen: Regenerate code with the latest specification file (2335b019) by @github-actions in https://github.com/algorand/java-algorand-sdk/pull/715 +* Test: Add minbalance tests for Java SDK. by @gmalouf in https://github.com/algorand/java-algorand-sdk/pull/717 +* ci: upgrade checkout action to v4 by @michaeltchuang in https://github.com/algorand/java-algorand-sdk/pull/716 + + +**Full Changelog**: https://github.com/algorand/java-algorand-sdk/compare/2.4.0...2.5.0 + # 2.4.0 diff --git a/README.md b/README.md index 2964d18b8..4a70162a7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Maven: com.algorand algosdk - 2.4.0 + 2.5.0 ``` diff --git a/pom.xml b/pom.xml index e18984ea8..659d1b7c2 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.algorand algosdk - 2.4.0 + 2.5.0 jar ${project.groupId}:${project.artifactId} diff --git a/src/main/java/com/algorand/algosdk/v2/client/algod/GetBlockLogs.java b/src/main/java/com/algorand/algosdk/v2/client/algod/GetBlockLogs.java new file mode 100644 index 000000000..a7d96fa13 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/algod/GetBlockLogs.java @@ -0,0 +1,65 @@ +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.BlockLogsResponse; + + +/** + * Get all of the logs from outer and inner app calls in the given round + * /v2/blocks/{round}/logs + */ +public class GetBlockLogs extends Query { + + private Long round; + + /** + * @param round The round from which to fetch block log information. + */ + public GetBlockLogs(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(BlockLogsResponse.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(BlockLogsResponse.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("logs")); + + return qd; + } +} 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 80b618361..813479cf0 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 @@ -14,6 +14,7 @@ import com.algorand.algosdk.v2.client.algod.GetBlockTxids; import com.algorand.algosdk.v2.client.algod.GetBlockHash; import com.algorand.algosdk.v2.client.algod.GetTransactionProof; +import com.algorand.algosdk.v2.client.algod.GetBlockLogs; import com.algorand.algosdk.v2.client.algod.GetSupply; import com.algorand.algosdk.v2.client.algod.GetStatus; import com.algorand.algosdk.v2.client.algod.WaitForBlock; @@ -188,6 +189,14 @@ public GetTransactionProof GetTransactionProof(Long round, return new GetTransactionProof((Client) this, round, txid); } + /** + * Get all of the logs from outer and inner app calls in the given round + * /v2/blocks/{round}/logs + */ + public GetBlockLogs GetBlockLogs(Long round) { + return new GetBlockLogs((Client) this, round); + } + /** * Get the current supply reported by the ledger. * /v2/ledger/supply diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Account.java b/src/main/java/com/algorand/algosdk/v2/client/model/Account.java index 473d551e8..d9bac5d29 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Account.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Account.java @@ -35,7 +35,7 @@ public String address() throws NoSuchAlgorithmException { public Address address; /** - * (algo) total number of MicroAlgos in the account + * total number of MicroAlgos in the account */ @JsonProperty("amount") public Long amount; @@ -47,37 +47,36 @@ public String address() throws NoSuchAlgorithmException { public Long amountWithoutPendingRewards; /** - * (appl) applications local data stored in this account. + * application local data stored in this account. * Note the raw object uses `map[int] -> AppLocalState` for this type. */ @JsonProperty("apps-local-state") public List appsLocalState = new ArrayList(); /** - * (teap) the sum of all extra application program pages for this account. + * the sum of all extra application program pages for this account. */ @JsonProperty("apps-total-extra-pages") public Long appsTotalExtraPages; /** - * (tsch) stores the sum of all of the local schemas and global schemas in this - * account. + * the sum of all of the local schemas and global schemas in this account. * Note: the raw account uses `StateSchema` for this type. */ @JsonProperty("apps-total-schema") public ApplicationStateSchema appsTotalSchema; /** - * (asset) assets held by this account. + * assets held by this account. * Note the raw object uses `map[int] -> AssetHolding` for this type. */ @JsonProperty("assets") public List assets = new ArrayList(); /** - * (spend) the address against which signing should be checked. If empty, the - * address of the current account is used. This field can be updated in any - * transaction by setting the RekeyTo field. + * The address against which signing should be checked. If empty, the address of + * the current account is used. This field can be updated in any transaction by + * setting the RekeyTo field. */ @JsonProperty("auth-addr") public void authAddr(String authAddr) throws NoSuchAlgorithmException { @@ -100,15 +99,14 @@ public String authAddr() throws NoSuchAlgorithmException { public java.math.BigInteger closedAtRound; /** - * (appp) parameters of applications created by this account including app global - * data. + * parameters of applications created by this account including app global data. * Note: the raw account uses `map[int] -> AppParams` for this type. */ @JsonProperty("created-apps") public List createdApps = new ArrayList(); /** - * (apar) parameters of assets created by this account. + * parameters of assets created by this account. * Note: the raw account uses `map[int] -> Asset` for this type. */ @JsonProperty("created-assets") @@ -126,6 +124,33 @@ public String authAddr() throws NoSuchAlgorithmException { @JsonProperty("deleted") public Boolean deleted; + /** + * can the account receive block incentives if its balance is in range at proposal + * time. + */ + @JsonProperty("incentive-eligible") + public Boolean incentiveEligible; + + /** + * The round in which this account last went online, or explicitly renewed their + * online status. + */ + @JsonProperty("last-heartbeat") + public Long lastHeartbeat; + + /** + * The round in which this account last proposed the block. + */ + @JsonProperty("last-proposed") + public Long lastProposed; + + /** + * MicroAlgo balance required by the account. + * The requirement grows based on asset and application usage. + */ + @JsonProperty("min-balance") + public Long minBalance; + /** * AccountParticipation describes the parameters used by this account in consensus * protocol. @@ -140,15 +165,14 @@ public String authAddr() throws NoSuchAlgorithmException { public Long pendingRewards; /** - * (ebase) used as part of the rewards computation. Only applicable to accounts - * which are participating. + * used as part of the rewards computation. Only applicable to accounts which are + * participating. */ @JsonProperty("reward-base") public Long rewardBase; /** - * (ern) total rewards of MicroAlgos the account has received, including pending - * rewards. + * total rewards of MicroAlgos the account has received, including pending rewards. */ @JsonProperty("rewards") public Long rewards; @@ -160,7 +184,7 @@ public String authAddr() throws NoSuchAlgorithmException { public Long round; /** - * Indicates what type of signature is used by this account, must be one of: + * the type of signature used by this account, must be one of: * sig * msig * lsig @@ -170,7 +194,7 @@ public String authAddr() throws NoSuchAlgorithmException { public Enums.SigType sigType; /** - * (onl) delegation status of the account's MicroAlgos + * voting status of the account's MicroAlgos * Offline - indicates that the associated account is delegated. * Online - indicates that the associated account used as part of the delegation * pool. @@ -240,6 +264,10 @@ public boolean equals(Object o) { if (!Objects.deepEquals(this.createdAssets, other.createdAssets)) return false; if (!Objects.deepEquals(this.createdAtRound, other.createdAtRound)) return false; if (!Objects.deepEquals(this.deleted, other.deleted)) return false; + if (!Objects.deepEquals(this.incentiveEligible, other.incentiveEligible)) return false; + if (!Objects.deepEquals(this.lastHeartbeat, other.lastHeartbeat)) return false; + if (!Objects.deepEquals(this.lastProposed, other.lastProposed)) return false; + if (!Objects.deepEquals(this.minBalance, other.minBalance)) return false; if (!Objects.deepEquals(this.participation, other.participation)) return false; if (!Objects.deepEquals(this.pendingRewards, other.pendingRewards)) return false; if (!Objects.deepEquals(this.rewardBase, other.rewardBase)) return false; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetHolding.java b/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetHolding.java new file mode 100644 index 000000000..e10864540 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetHolding.java @@ -0,0 +1,40 @@ +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; + +/** + * AccountAssetHolding describes the account's asset holding and asset parameters + * (if either exist) for a specific asset ID. + */ +public class AccountAssetHolding extends PathResponse { + + /** + * (asset) Details about the asset held by this account. + * The raw account uses `AssetHolding` for this type. + */ + @JsonProperty("asset-holding") + public AssetHolding assetHolding; + + /** + * (apar) parameters of the asset held by this account. + * The raw account uses `AssetParams` for this type. + */ + @JsonProperty("asset-params") + public AssetParams assetParams; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + AccountAssetHolding other = (AccountAssetHolding) o; + if (!Objects.deepEquals(this.assetHolding, other.assetHolding)) return false; + if (!Objects.deepEquals(this.assetParams, other.assetParams)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetsInformationResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetsInformationResponse.java new file mode 100644 index 000000000..4729fb140 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AccountAssetsInformationResponse.java @@ -0,0 +1,44 @@ +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; + +/** + * AccountAssetsInformationResponse contains a list of assets held by an account. + */ +public class AccountAssetsInformationResponse extends PathResponse { + + @JsonProperty("asset-holdings") + public List assetHoldings = new ArrayList(); + + /** + * Used for pagination, when making another request provide this token with the + * next parameter. + */ + @JsonProperty("next-token") + public String nextToken; + + /** + * The round for which this information is relevant. + */ + @JsonProperty("round") + public Long round; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + AccountAssetsInformationResponse other = (AccountAssetsInformationResponse) o; + if (!Objects.deepEquals(this.assetHoldings, other.assetHoldings)) return false; + if (!Objects.deepEquals(this.nextToken, other.nextToken)) return false; + if (!Objects.deepEquals(this.round, other.round)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AccountParticipation.java b/src/main/java/com/algorand/algosdk/v2/client/model/AccountParticipation.java index aab24a9c2..ec8d3998e 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/AccountParticipation.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AccountParticipation.java @@ -13,7 +13,7 @@ public class AccountParticipation extends PathResponse { /** - * (sel) Selection public key (if any) currently registered for this round. + * Selection public key (if any) currently registered for this round. */ @JsonProperty("selection-participation-key") public void selectionParticipationKey(String base64Encoded) { @@ -25,7 +25,7 @@ public String selectionParticipationKey() { public byte[] selectionParticipationKey; /** - * (stprf) Root of the state proof key (if any) + * Root of the state proof key (if any) */ @JsonProperty("state-proof-key") public void stateProofKey(String base64Encoded) { @@ -37,26 +37,25 @@ public String stateProofKey() { public byte[] stateProofKey; /** - * (voteFst) First round for which this participation is valid. + * First round for which this participation is valid. */ @JsonProperty("vote-first-valid") public Long voteFirstValid; /** - * (voteKD) Number of subkeys in each batch of participation keys. + * Number of subkeys in each batch of participation keys. */ @JsonProperty("vote-key-dilution") public Long voteKeyDilution; /** - * (voteLst) Last round for which this participation is valid. + * Last round for which this participation is valid. */ @JsonProperty("vote-last-valid") public Long voteLastValid; /** - * (vote) root participation public key (if any) currently registered for this - * round. + * root participation public key (if any) currently registered for this round. */ @JsonProperty("vote-participation-key") public void voteParticipationKey(String base64Encoded) { diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AppCallLogs.java b/src/main/java/com/algorand/algosdk/v2/client/model/AppCallLogs.java new file mode 100644 index 000000000..45d41dcf4 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AppCallLogs.java @@ -0,0 +1,64 @@ +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; + +/** + * The logged messages from an app call along with the app ID and outer transaction + * ID. Logs appear in the same order that they were emitted. + */ +public class AppCallLogs extends PathResponse { + + /** + * The application from which the logs were generated + */ + @JsonProperty("application-index") + public Long applicationIndex; + + /** + * An array of logs + */ + @JsonProperty("logs") + public List logs = new ArrayList(); + @JsonIgnore + public void logs(List base64Encoded) { + this.logs = new ArrayList(); + for (String val : base64Encoded) { + this.logs.add(Encoder.decodeFromBase64(val)); + } + } + @JsonIgnore + public List logs() { + ArrayList ret = new ArrayList(); + for (byte[] val : this.logs) { + ret.add(Encoder.encodeToBase64(val)); + } + return ret; + } + + /** + * The transaction ID of the outer app call that lead to these logs + */ + @JsonProperty("txId") + public String txId; + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + AppCallLogs other = (AppCallLogs) o; + if (!Objects.deepEquals(this.applicationIndex, other.applicationIndex)) return false; + if (!Objects.deepEquals(this.logs, other.logs)) return false; + if (!Objects.deepEquals(this.txId, other.txId)) return false; + + return true; + } +} diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/Application.java b/src/main/java/com/algorand/algosdk/v2/client/model/Application.java index 5783b4e54..80c7543f6 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/Application.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/Application.java @@ -29,13 +29,13 @@ public class Application extends PathResponse { public java.math.BigInteger deletedAtRound; /** - * (appidx) application index. + * application index. */ @JsonProperty("id") public Long id; /** - * (appparams) application parameters. + * application parameters. */ @JsonProperty("params") public ApplicationParams params; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalState.java b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalState.java index ff4af4804..1ab5b1023 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalState.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLocalState.java @@ -32,7 +32,7 @@ public class ApplicationLocalState extends PathResponse { public Long id; /** - * (tkv) storage. + * storage. */ @JsonProperty("key-value") public List keyValue = new ArrayList(); @@ -44,7 +44,7 @@ public class ApplicationLocalState extends PathResponse { public java.math.BigInteger optedInAtRound; /** - * (hsch) schema. + * schema. */ @JsonProperty("schema") public ApplicationStateSchema schema; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLogData.java b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLogData.java index d920f5e82..40255c2ac 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLogData.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationLogData.java @@ -15,7 +15,7 @@ public class ApplicationLogData extends PathResponse { /** - * (lg) Logs for the application being executed by the transaction. + * Logs for the application being executed by the transaction. */ @JsonProperty("logs") public List logs = new ArrayList(); diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationParams.java b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationParams.java index f1ffad82c..41c78e4f7 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationParams.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationParams.java @@ -16,7 +16,7 @@ public class ApplicationParams extends PathResponse { /** - * (approv) approval program. + * approval program. */ @JsonProperty("approval-program") public void approvalProgram(String base64Encoded) { @@ -28,7 +28,7 @@ public String approvalProgram() { public byte[] approvalProgram; /** - * (clearp) approval program. + * clear state program. */ @JsonProperty("clear-state-program") public void clearStateProgram(String base64Encoded) { @@ -58,25 +58,25 @@ public String creator() throws NoSuchAlgorithmException { public Address creator; /** - * (epp) the amount of extra program pages available to this app. + * the number of extra program pages available to this app. */ @JsonProperty("extra-program-pages") public Long extraProgramPages; /** - * [\gs) global schema + * global state */ @JsonProperty("global-state") public List globalState = new ArrayList(); /** - * [\gsch) global schema + * global schema */ @JsonProperty("global-state-schema") public ApplicationStateSchema globalStateSchema; /** - * [\lsch) local schema + * local schema */ @JsonProperty("local-state-schema") public ApplicationStateSchema localStateSchema; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationStateSchema.java b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationStateSchema.java index b27ed52bf..7723f7b48 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationStateSchema.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/ApplicationStateSchema.java @@ -11,13 +11,13 @@ public class ApplicationStateSchema extends PathResponse { /** - * (nbs) num of byte slices. + * number of byte slices. */ @JsonProperty("num-byte-slice") public Long numByteSlice; /** - * (nui) num of uints. + * number of uints. */ @JsonProperty("num-uint") public Long numUint; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java b/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java index b312c0a54..81759e818 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AssetHolding.java @@ -13,7 +13,7 @@ public class AssetHolding extends PathResponse { /** - * (a) number of units held. + * number of units held. */ @JsonProperty("amount") public java.math.BigInteger amount; @@ -31,7 +31,7 @@ public class AssetHolding extends PathResponse { public Boolean deleted; /** - * (f) whether or not the holding is frozen. + * whether or not the holding is frozen. */ @JsonProperty("is-frozen") public Boolean isFrozen; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/AssetParams.java b/src/main/java/com/algorand/algosdk/v2/client/model/AssetParams.java index c2aed5072..d217b2194 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/AssetParams.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/AssetParams.java @@ -15,8 +15,8 @@ public class AssetParams extends PathResponse { /** - * (c) Address of account used to clawback holdings of this asset. If empty, - * clawback is not permitted. + * Address of account used to clawback holdings of this asset. If empty, clawback + * is not permitted. */ @JsonProperty("clawback") public String clawback; @@ -30,36 +30,36 @@ public class AssetParams extends PathResponse { public String creator; /** - * (dc) The number of digits to use after the decimal point when displaying this - * asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in - * tenths. If 2, the base unit of the asset is in hundredths, and so on. This value - * must be between 0 and 19 (inclusive). + * The number of digits to use after the decimal point when displaying this asset. + * If 0, the asset is not divisible. If 1, the base unit of the asset is in tenths. + * If 2, the base unit of the asset is in hundredths, and so on. This value must be + * between 0 and 19 (inclusive). */ @JsonProperty("decimals") public Long decimals; /** - * (df) Whether holdings of this asset are frozen by default. + * Whether holdings of this asset are frozen by default. */ @JsonProperty("default-frozen") public Boolean defaultFrozen; /** - * (f) Address of account used to freeze holdings of this asset. If empty, freezing - * is not permitted. + * Address of account used to freeze holdings of this asset. If empty, freezing is + * not permitted. */ @JsonProperty("freeze") public String freeze; /** - * (m) Address of account used to manage the keys of this asset and to destroy it. + * Address of account used to manage the keys of this asset and to destroy it. */ @JsonProperty("manager") public String manager; /** - * (am) A commitment to some unspecified asset metadata. The format of this - * metadata is up to the application. + * A commitment to some unspecified asset metadata. The format of this metadata is + * up to the application. */ @JsonProperty("metadata-hash") public void metadataHash(String base64Encoded) { @@ -71,8 +71,8 @@ public String metadataHash() { public byte[] metadataHash; /** - * (an) Name of this asset, as supplied by the creator. Included only when the - * asset name is composed of printable utf-8 characters. + * Name of this asset, as supplied by the creator. Included only when the asset + * name is composed of printable utf-8 characters. */ @JsonProperty("name") public String name; @@ -90,20 +90,20 @@ public String nameB64() { public byte[] nameB64; /** - * (r) Address of account holding reserve (non-minted) units of this asset. + * Address of account holding reserve (non-minted) units of this asset. */ @JsonProperty("reserve") public String reserve; /** - * (t) The total number of units of this asset. + * The total number of units of this asset. */ @JsonProperty("total") public java.math.BigInteger total; /** - * (un) Name of a unit of this asset, as supplied by the creator. Included only - * when the name of a unit of this asset is composed of printable utf-8 characters. + * Name of a unit of this asset, as supplied by the creator. Included only when the + * name of a unit of this asset is composed of printable utf-8 characters. */ @JsonProperty("unit-name") public String unitName; @@ -121,8 +121,8 @@ public String unitNameB64() { public byte[] unitNameB64; /** - * (au) URL where more information about the asset can be retrieved. Included only - * when the URL is composed of printable utf-8 characters. + * URL where more information about the asset can be retrieved. Included only when + * the URL is composed of printable utf-8 characters. */ @JsonProperty("url") public String url; 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 dc4feb686..5792da558 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 @@ -1,9 +1,11 @@ package com.algorand.algosdk.v2.client.model; +import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.Objects; +import com.algorand.algosdk.crypto.Address; import com.algorand.algosdk.util.Encoder; import com.algorand.algosdk.v2.client.common.PathResponse; import com.fasterxml.jackson.annotation.JsonProperty; @@ -15,6 +17,18 @@ */ public class Block extends PathResponse { + /** + * the potential bonus payout for this block. + */ + @JsonProperty("bonus") + public Long bonus; + + /** + * the sum of all fees paid by transactions in this block. + */ + @JsonProperty("fees-collected") + public Long feesCollected; + /** * (gh) hash to which this block belongs. */ @@ -51,6 +65,29 @@ public String previousBlockHash() { } public byte[] previousBlockHash; + /** + * the proposer of this block. + */ + @JsonProperty("proposer") + public void proposer(String proposer) throws NoSuchAlgorithmException { + this.proposer = new Address(proposer); + } + @JsonProperty("proposer") + public String proposer() throws NoSuchAlgorithmException { + if (this.proposer != null) { + return this.proposer.encodeAsString(); + } else { + return null; + } + } + public Address proposer; + + /** + * the actual amount transferred to the proposer from the fee sink. + */ + @JsonProperty("proposer-payout") + public Long proposerPayout; + /** * Fields relating to rewards, */ @@ -154,10 +191,14 @@ public boolean equals(Object o) { if (o == null) return false; Block other = (Block) o; + if (!Objects.deepEquals(this.bonus, other.bonus)) return false; + if (!Objects.deepEquals(this.feesCollected, other.feesCollected)) return false; if (!Objects.deepEquals(this.genesisHash, other.genesisHash)) return false; if (!Objects.deepEquals(this.genesisId, other.genesisId)) return false; if (!Objects.deepEquals(this.participationUpdates, other.participationUpdates)) return false; if (!Objects.deepEquals(this.previousBlockHash, other.previousBlockHash)) return false; + if (!Objects.deepEquals(this.proposer, other.proposer)) return false; + if (!Objects.deepEquals(this.proposerPayout, other.proposerPayout)) return false; 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; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/BlockLogsResponse.java b/src/main/java/com/algorand/algosdk/v2/client/model/BlockLogsResponse.java new file mode 100644 index 000000000..b342e2787 --- /dev/null +++ b/src/main/java/com/algorand/algosdk/v2/client/model/BlockLogsResponse.java @@ -0,0 +1,35 @@ +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; + +/** + * All logs emitted in the given round. Each app call, whether top-level or inner, + * that contains logs results in a separate AppCallLogs object. Therefore there may + * be multiple AppCallLogs with the same application ID and outer transaction ID in + * the event of multiple inner app calls to the same app. App calls with no logs + * are not included in the response. AppCallLogs are returned in the same order + * that their corresponding app call appeared in the block (pre-order traversal of + * inner app calls) + */ +public class BlockLogsResponse extends PathResponse { + + @JsonProperty("logs") + public List logs = new ArrayList(); + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null) return false; + + BlockLogsResponse other = (BlockLogsResponse) o; + if (!Objects.deepEquals(this.logs, other.logs)) return false; + + return true; + } +} 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 df6b7c775..eee96c87f 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 @@ -147,11 +147,10 @@ public static OnCompletion forValue(String value) { } /** - * Indicates what type of signature is used by this account, must be one of: - * sig - * msig - * lsig - * or null if unknown + * SigType filters just results using the specified type of signature: + * sig - Standard + * msig - MultiSig + * lsig - LogicSig */ public enum SigType { @JsonProperty("sig") SIG("sig"), diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/ParticipationUpdates.java b/src/main/java/com/algorand/algosdk/v2/client/model/ParticipationUpdates.java index 554274a9a..ea68d5d92 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/ParticipationUpdates.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/ParticipationUpdates.java @@ -12,6 +12,12 @@ */ public class ParticipationUpdates extends PathResponse { + /** + * (partupabs) a list of online accounts that need to be suspended. + */ + @JsonProperty("absent-participation-accounts") + public List absentParticipationAccounts = new ArrayList(); + /** * (partupdrmv) a list of online accounts that needs to be converted to offline * since their participation key expired. @@ -26,6 +32,7 @@ public boolean equals(Object o) { if (o == null) return false; ParticipationUpdates other = (ParticipationUpdates) o; + if (!Objects.deepEquals(this.absentParticipationAccounts, other.absentParticipationAccounts)) return false; if (!Objects.deepEquals(this.expiredParticipationAccounts, other.expiredParticipationAccounts)) return false; return true; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/SimulationTransactionExecTrace.java b/src/main/java/com/algorand/algosdk/v2/client/model/SimulationTransactionExecTrace.java index 80fb8633d..0287a927f 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/SimulationTransactionExecTrace.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/SimulationTransactionExecTrace.java @@ -50,6 +50,21 @@ public String clearStateProgramHash() { @JsonProperty("clear-state-program-trace") public List clearStateProgramTrace = new ArrayList(); + /** + * If true, indicates that the clear state program failed and any persistent state + * changes it produced should be reverted once the program exits. + */ + @JsonProperty("clear-state-rollback") + public Boolean clearStateRollback; + + /** + * The error message explaining why the clear state program failed. This field will + * only be populated if clear-state-rollback is true and the failure was due to an + * execution error. + */ + @JsonProperty("clear-state-rollback-error") + public String clearStateRollbackError; + /** * An array of SimulationTransactionExecTrace representing the execution trace of * any inner transactions executed. @@ -86,6 +101,8 @@ public boolean equals(Object o) { if (!Objects.deepEquals(this.approvalProgramTrace, other.approvalProgramTrace)) return false; if (!Objects.deepEquals(this.clearStateProgramHash, other.clearStateProgramHash)) return false; if (!Objects.deepEquals(this.clearStateProgramTrace, other.clearStateProgramTrace)) return false; + if (!Objects.deepEquals(this.clearStateRollback, other.clearStateRollback)) return false; + if (!Objects.deepEquals(this.clearStateRollbackError, other.clearStateRollbackError)) return false; if (!Objects.deepEquals(this.innerTrace, other.innerTrace)) return false; if (!Objects.deepEquals(this.logicSigHash, other.logicSigHash)) return false; if (!Objects.deepEquals(this.logicSigTrace, other.logicSigTrace)) return false; diff --git a/src/main/java/com/algorand/algosdk/v2/client/model/TealValue.java b/src/main/java/com/algorand/algosdk/v2/client/model/TealValue.java index e9c046ee5..c2a261aa4 100644 --- a/src/main/java/com/algorand/algosdk/v2/client/model/TealValue.java +++ b/src/main/java/com/algorand/algosdk/v2/client/model/TealValue.java @@ -11,19 +11,19 @@ public class TealValue extends PathResponse { /** - * (tb) bytes value. + * bytes value. */ @JsonProperty("bytes") public String bytes; /** - * (tt) value type. Value `1` refers to bytes , value `2` refers to uint + * type of the value. Value `1` refers to bytes , value `2` refers to uint */ @JsonProperty("type") public Long type; /** - * (ui) uint value. + * uint value. */ @JsonProperty("uint") public java.math.BigInteger uint; diff --git a/src/test/java/com/algorand/algosdk/integration/Applications.java b/src/test/java/com/algorand/algosdk/integration/Applications.java index 85d7758ee..1e58d5428 100644 --- a/src/test/java/com/algorand/algosdk/integration/Applications.java +++ b/src/test/java/com/algorand/algosdk/integration/Applications.java @@ -36,6 +36,7 @@ public class Applications { public Transaction transaction; public String txId = null; + public Long lastTxConfirmedRound = 0L; public Long appId = 0L; public List rememberedAppIds = new ArrayList<>(); @@ -141,7 +142,8 @@ public void sendTransactionWithTransientAccountAndCheckForError(String error) th @Given("I wait for the transaction to be confirmed.") public void waitForTransactionToBeConfirmed() throws Exception { - Utils.waitForConfirmation(base.aclv2, base.txid, 1); + PendingTransactionResponse response = Utils.waitForConfirmation(base.aclv2, base.txid, 1); + this.lastTxConfirmedRound = response.confirmedRound; } @Given("I remember the new application ID.") @@ -346,8 +348,30 @@ public void indexerCheckAppBoxesWithParams(Long limit, String next, String encod assertSetOfByteArraysEqual(expectedNames, actualNames); } - @Then("I sleep for {int} milliseconds for indexer to digest things down.") - public void sleepForNSecondsForIndexer(int milliseconds) throws Exception { - Thread.sleep(milliseconds); + @Then("I wait for indexer to catch up to the round where my most recent transaction was confirmed.") + public void sleepForNSecondsForIndexer() throws Exception { + final int maxAttempts = 30; + + final long roundToWaitFor = this.lastTxConfirmedRound; + long indexerRound = 0; + int attempts = 0; + + while(true) { + Response response = base.v2IndexerClient.makeHealthCheck().execute(); + Assert.assertTrue(response.isSuccessful()); + indexerRound = response.body().round; + if (indexerRound >= roundToWaitFor) { + // Success + break; + } + + // Sleep for 1 second and try again + Thread.sleep(1000); + attempts++; + + if (attempts > maxAttempts) { + throw new Exception("Timeout waiting for indexer to catch up to round " + roundToWaitFor + ". It is currently on " + indexerRound); + } + } } } diff --git a/src/test/unit.tags b/src/test/unit.tags index 429a1642e..8d8ea38d0 100644 --- a/src/test/unit.tags +++ b/src/test/unit.tags @@ -23,6 +23,7 @@ @unit.responses.blocksummary @unit.responses.messagepack @unit.responses.messagepack.231 +@unit.responses.minbalance @unit.responses.statedelta @unit.responses.timestamp @unit.responses.txid.json