Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
changelog:
exclude:
labels:
- Skip-Release-Notes
categories:
- title: Bugfixes
labels:
- Bug-Fix
- title: New Features
labels:
- New Feature
- title: Enhancements
labels:
- Enhancement
- title: Not Yet Enabled
labels:
- Not-Yet-Enabled
- title: Other
labels:
- "*"
24 changes: 24 additions & 0 deletions .github/workflows/pr-type-category.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check PR category and type
on:
pull_request:
branches:
- develop
types: [opened, synchronize, reopened, labeled, unlabeled, edited]
jobs:
check_label:
runs-on: ubuntu-latest
name: Check PR Category and Type
steps:
- name: Checking for correct number of required github pr labels
uses: mheap/github-action-required-labels@v2
with:
mode: exactly
count: 1
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes"

- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'."
run: |
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY
exit 1
fi
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
unit:
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.applications.boxes or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application"
mvn test -Dcucumber.filter.tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.indexer.rekey or @unit.transactions or @unit.transactions.keyreg or @unit.responses or @unit.applications or @unit.applications.boxes or @unit.dryrun or @unit.tealsign or @unit.responses.messagepack or @unit.responses.231 or @unit.responses.messagepack.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.abijson.byname or @unit.atomic_transaction_composer or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.algod.ledger_refactoring or @unit.indexer.ledger_refactoring or @unit.dryrun.trace.application or @unit.sourcemap"

integration:
mvn test -Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey or @applications.verified or @applications or @applications.boxes or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c"
mvn test \
-Dtest=com.algorand.algosdk.integration.RunCucumberIntegrationTest \
-Dcucumber.filter.tags="@algod or @assets or @auction or @kmd or @send or @send.keyregtxn or @indexer or @rekey_v1 or @applications.verified or @applications or @applications.boxes or @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c or @compile.sourcemap"

docker-test:
./run_integration_tests.sh
6 changes: 3 additions & 3 deletions src/main/java/com/algorand/algosdk/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,14 @@ public static ProgramData readProgram(byte[] program, List<byte[]> args) throws
}
// costs calculated dynamically starting in v4
if (version < 4 && cost > MAX_COST) {
throw new IllegalArgumentException("program too costly for Teal version < 4. consider using v4.");
throw new IllegalArgumentException("program too costly for version < 4. consider using v4.");
}

return new ProgramData(true, ints, bytes);
}

/**
* Retrieves TEAL supported version
* Retrieves supported program version
* @return int
* @throws IOException
*/
Expand All @@ -269,7 +269,7 @@ public static int getLogicSigVersion() throws IOException {
}

/**
* Retrieves max supported version of TEAL evaluator
* Retrieves max supported program version of evaluator
* @return int
* @throws IOException
*/
Expand Down
121 changes: 121 additions & 0 deletions src/main/java/com/algorand/algosdk/logic/SourceMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.algorand.algosdk.logic;

import java.lang.Integer;
import java.util.ArrayList;
import java.util.HashMap;

/**
* SourceMap class provides parser for source map from
* algod compile endpoint
*/
public class SourceMap {

public int version;
public String file;
public String[] sources;
public String[] names;
public String mappings;

public HashMap<Integer, Integer> pcToLine;
public HashMap<Integer, ArrayList<Integer>> lineToPc;

public SourceMap(HashMap<String,Object> sourceMap) {
int version = (int) sourceMap.get("version");
if(version != 3){
throw new IllegalArgumentException("Only source map version 3 is supported");
}
this.version = version;

this.file = (String) sourceMap.get("file");
this.mappings = (String) sourceMap.get("mappings");

this.lineToPc = new HashMap<>();
this.pcToLine = new HashMap<>();

Integer lastLine = 0;
String[] vlqs = this.mappings.split(";");
for(int i=0; i<vlqs.length; i++){
ArrayList<Integer> vals = VLQDecoder.decodeSourceMapLine(vlqs[i]);

// If the vals length >= 3 the lineDelta
if(vals.size() >= 3){
lastLine = lastLine + vals.get(2);
}

if(!this.lineToPc.containsKey(lastLine)){
this.lineToPc.put(lastLine, new ArrayList<Integer>());
}

ArrayList<Integer> currList = this.lineToPc.get(lastLine);
currList.add(i);
this.lineToPc.put(lastLine, currList);

this.pcToLine.put(i, lastLine);
}

}

/**
* Returns the Integer line number for the passed PC or null if not found
* @param pc the pc (program counter) of the assembled file
* @return the line number or null if not found
*/
public Integer getLineForPc(Integer pc) {
return this.pcToLine.get(pc);
}

/**
* Returns the List of PCs for the passed line number
* @param line the line number of the source file
* @return the list of PCs that line generated or empty array if not found
*/
public ArrayList<Integer> getPcsForLine(Integer line) {
if(!this.pcToLine.containsKey(line)){
return new ArrayList<Integer>();
}
return this.lineToPc.get(line);
}

private static class VLQDecoder {
// VLQDecoder for decoding the VLQ values returned for source map
// based on the decoder implementation here: https://github.com/algorand/go-algorand-sdk/blob/develop/logic/source_map.go

private static final String b64table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private static final int vlqShiftSize = 5;
private static final int vlqFlag = 1 << vlqShiftSize;
private static final int vlqMask = vlqFlag - 1;

public static ArrayList<Integer> decodeSourceMapLine(String vlq) {

ArrayList<Integer> results = new ArrayList<>();
int value = 0;
int shift = 0;

for(int i=0; i<vlq.length(); i++){
int digit = b64table.indexOf(vlq.charAt(i));

value |= (digit & vlqMask) << shift;

if((digit & vlqFlag) > 0) {
shift += vlqShiftSize;
continue;
}

if((value&1)>0){
value = (value >> 1) * -1;
}else{
value = value >> 1;
}

results.add(value);

// Reset
value = 0;
shift = 0;
}

return results;
}
}

}
85 changes: 79 additions & 6 deletions src/main/java/com/algorand/algosdk/v2/client/model/Enums.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.algorand.algosdk.v2.client.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class Enums {
Expand All @@ -10,7 +11,8 @@ public class Enums {
public enum AddressRole {
@JsonProperty("sender") SENDER("sender"),
@JsonProperty("receiver") RECEIVER("receiver"),
@JsonProperty("freeze-target") FREEZETARGET("freeze-target");
@JsonProperty("freeze-target") FREEZETARGET("freeze-target"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
AddressRole(String name) {
Expand All @@ -21,6 +23,17 @@ public enum AddressRole {
public String toString() {
return this.serializedName;
}

@JsonCreator
public static AddressRole forValue(String value) {
for (AddressRole t : values()) {
if (t.serializedName.equalsIgnoreCase(value)) {
return t;
}
}
return UNKNOWN;
}

}

/**
Expand All @@ -34,7 +47,8 @@ public enum Exclude {
@JsonProperty("created-assets") CREATEDASSETS("created-assets"),
@JsonProperty("apps-local-state") APPSLOCALSTATE("apps-local-state"),
@JsonProperty("created-apps") CREATEDAPPS("created-apps"),
@JsonProperty("none") NONE("none");
@JsonProperty("none") NONE("none"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
Exclude(String name) {
Expand All @@ -45,6 +59,17 @@ public enum Exclude {
public String toString() {
return this.serializedName;
}

@JsonCreator
public static Exclude forValue(String value) {
for (Exclude t : values()) {
if (t.serializedName.equalsIgnoreCase(value)) {
return t;
}
}
return UNKNOWN;
}

}

/**
Expand All @@ -54,7 +79,8 @@ public String toString() {
*/
public enum Hashtype {
@JsonProperty("sha512_256") SHA512_256("sha512_256"),
@JsonProperty("sha256") SHA256("sha256");
@JsonProperty("sha256") SHA256("sha256"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
Hashtype(String name) {
Expand All @@ -65,6 +91,17 @@ public enum Hashtype {
public String toString() {
return this.serializedName;
}

@JsonCreator
public static Hashtype forValue(String value) {
for (Hashtype t : values()) {
if (t.serializedName.equalsIgnoreCase(value)) {
return t;
}
}
return UNKNOWN;
}

}

/**
Expand All @@ -84,7 +121,8 @@ public enum OnCompletion {
@JsonProperty("closeout") CLOSEOUT("closeout"),
@JsonProperty("clear") CLEAR("clear"),
@JsonProperty("update") UPDATE("update"),
@JsonProperty("delete") DELETE("delete");
@JsonProperty("delete") DELETE("delete"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
OnCompletion(String name) {
Expand All @@ -95,6 +133,17 @@ public enum OnCompletion {
public String toString() {
return this.serializedName;
}

@JsonCreator
public static OnCompletion forValue(String value) {
for (OnCompletion t : values()) {
if (t.serializedName.equalsIgnoreCase(value)) {
return t;
}
}
return UNKNOWN;
}

}

/**
Expand All @@ -107,7 +156,8 @@ public String toString() {
public enum SigType {
@JsonProperty("sig") SIG("sig"),
@JsonProperty("msig") MSIG("msig"),
@JsonProperty("lsig") LSIG("lsig");
@JsonProperty("lsig") LSIG("lsig"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
SigType(String name) {
Expand All @@ -118,6 +168,17 @@ public enum SigType {
public String toString() {
return this.serializedName;
}

@JsonCreator
public static SigType forValue(String value) {
for (SigType t : values()) {
if (t.serializedName.equalsIgnoreCase(value)) {
return t;
}
}
return UNKNOWN;
}

}

/**
Expand All @@ -137,7 +198,8 @@ public enum TxType {
@JsonProperty("acfg") ACFG("acfg"),
@JsonProperty("axfer") AXFER("axfer"),
@JsonProperty("afrz") AFRZ("afrz"),
@JsonProperty("appl") APPL("appl");
@JsonProperty("appl") APPL("appl"),
@JsonProperty("") UNKNOWN("");

final String serializedName;
TxType(String name) {
Expand All @@ -148,6 +210,17 @@ public enum TxType {
public String toString() {
return this.serializedName;
}

@JsonCreator
public static TxType forValue(String value) {
for (TxType t : values()) {
if (t.serializedName.equalsIgnoreCase(value)) {
return t;
}
}
return UNKNOWN;
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void sendTransactionWithTransientAccountAndCheckForError(String error) th

@Given("I wait for the transaction to be confirmed.")
public void waitForTransactionToBeConfirmed() throws Exception {
Utils.waitForConfirmation(clients.v2Client, txId, 5);
Utils.waitForConfirmation(clients.v2Client, txId, 1);
}

// TODO: Use V2 Pending Transaction endpoint when it is available.
Expand Down Expand Up @@ -173,7 +173,7 @@ public void fundAppAccount(Integer amount) throws Exception {
SignedTransaction stx = base.signWithAddress(tx, sender);

Response<PostTransactionsResponse> rPost = clients.v2Client.RawTransaction().rawtxn(Encoder.encodeToMsgPack(stx)).execute();
Utils.waitForConfirmation(clients.v2Client, rPost.body().txId, 5);
Utils.waitForConfirmation(clients.v2Client, rPost.body().txId, 1);
}

@Then("I get the account address for the current application and see that it matches the app id's hash")
Expand Down
Loading