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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ src/test/resources/**/*.json
src/test/resources/**/*.base64
src/test/resources/**/*.teal
src/test/resources/**/*.tok
src/test/resources/**/*.txt

# OS X
.DS_Store
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 1.17.0
### New Features
* DevTools: adding source map decoder by @barnjamin in https://github.com/algorand/java-algorand-sdk/pull/352
### Enhancements
* Github-Actions: Adding pr title and label checks by @algojack in https://github.com/algorand/java-algorand-sdk/pull/339
* Enhancement: Add UNKNOWN enum type to HTTP client enums. by @winder in https://github.com/algorand/java-algorand-sdk/pull/351
* AVM: Consolidate TEAL and AVM versions by @michaeldiamant in https://github.com/algorand/java-algorand-sdk/pull/348
* Testing: Modify cucumber steps to use dev mode network by @michaeldiamant in https://github.com/algorand/java-algorand-sdk/pull/350
### Other
* Ignore copied over txt test resource files by @michaeldiamant in https://github.com/algorand/java-algorand-sdk/pull/342

# 1.16.0

## What's Changed
Expand Down
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.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.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 @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 @compile or @dryrun or @indexer.applications or @indexer.231 or @abi or @c2c or @compile.sourcemap"

docker-test:
./run_integration_tests.sh
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Maven:
<dependency>
<groupId>com.algorand</groupId>
<artifactId>algosdk</artifactId>
<version>1.16.0</version>
<version>1.17.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.algorand</groupId>
<artifactId>algosdk</artifactId>
<version>1.16.0</version>
<version>1.17.0</version>
<packaging>jar</packaging>

<name>${project.groupId}:${project.artifactId}</name>
Expand Down
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;
}
}

}
Loading