Skip to content

Commit a8508ab

Browse files
committed
Merge branch 'release/v1.16.0'
2 parents 671aeb6 + ed5f85d commit a8508ab

27 files changed

+4389
-4266
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- checkout
2626
- run: pip install -r requirements.txt
2727
- run: black --check .
28-
- run: python3 test_unit.py
28+
- run: pytest tests/unit_tests
2929
integration-test:
3030
parameters:
3131
python-version:

.github/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- Skip-Release-Notes
5+
categories:
6+
- title: Bugfixes
7+
labels:
8+
- Bug-Fix
9+
- title: New Features
10+
labels:
11+
- New Feature
12+
- title: Enhancements
13+
labels:
14+
- Enhancement
15+
- title: Not Yet Enabled
16+
labels:
17+
- Not-Yet-Enabled
18+
- title: Other
19+
labels:
20+
- "*"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Check PR category and type
2+
on:
3+
pull_request:
4+
branches:
5+
- develop
6+
types: [opened, synchronize, reopened, labeled, unlabeled, edited]
7+
jobs:
8+
check_label:
9+
runs-on: ubuntu-latest
10+
name: Check PR Category and Type
11+
steps:
12+
- name: Checking for correct number of required github pr labels
13+
uses: mheap/github-action-required-labels@v2
14+
with:
15+
mode: exactly
16+
count: 1
17+
labels: "New Feature, Enhancement, Bug-Fix, Not-Yet-Enabled, Skip-Release-Notes"
18+
19+
- name: "Checking for PR Category in PR title. Should be like '<category>: <pr title>'."
20+
run: |
21+
if [[ ! "${{ github.event.pull_request.title }}" =~ ^.{2,}\:.{2,} ]]; then
22+
echo "## PR Category is missing from PR title. Please add it like '<category>: <pr title>'." >> GITHUB_STEP_SUMMARY
23+
exit 1
24+
fi

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ venv.bak/
114114

115115
# Testing files
116116
*.feature
117-
test/features
117+
tests/features
118118
test-harness
119119

120120
# Build files

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Changelog
22

3+
# v1.16.0
4+
5+
## What's Changed
6+
7+
### New Features
8+
* Dev Tools: Source map decoder by @barnjamin in https://github.com/algorand/py-algorand-sdk/pull/353
9+
10+
### Enhancements
11+
* Github-Actions: Adding pr title and label checks by @algojack in https://github.com/algorand/py-algorand-sdk/pull/358
12+
13+
### Other
14+
* Implement new step asserting that AtomicTransactionComposer's attempt to add a method can fail with a particular error by @tzaffi in https://github.com/algorand/py-algorand-sdk/pull/347
15+
* Split up unit test files and rename tests directory to test by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/351
16+
* App page const by @barnjamin in https://github.com/algorand/py-algorand-sdk/pull/357
17+
18+
**Full Changelog**: https://github.com/algorand/py-algorand-sdk/compare/v1.15.0...v1.16.0
19+
20+
321
# v1.15.0
422

523
## What's Changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.ledger_refactoring or @unit.applications or @unit.atomic_transaction_composer or @unit.dryrun or @unit.dryrun.trace.application or @unit.feetest or @unit.indexer or @unit.indexer.ledger_refactoring or @unit.indexer.logs or @unit.offline or @unit.rekey or @unit.transactions.keyreg or @unit.responses or @unit.responses.231 or @unit.tealsign or @unit.transactions or @unit.transactions.payment or @unit.responses.unlimited_assets"
1+
UNITS = "@unit.abijson or @unit.abijson.byname or @unit.algod or @unit.algod.ledger_refactoring or @unit.applications or @unit.atc_method_args or @unit.atomic_transaction_composer or @unit.dryrun or @unit.dryrun.trace.application or @unit.feetest or @unit.indexer or @unit.indexer.ledger_refactoring or @unit.indexer.logs or @unit.offline or @unit.rekey or @unit.transactions.keyreg or @unit.responses or @unit.responses.231 or @unit.tealsign or @unit.transactions or @unit.transactions.payment or @unit.responses.unlimited_assets or @unit.sourcemap"
22
unit:
3-
behave --tags=$(UNITS) test -f progress2
3+
behave --tags=$(UNITS) tests -f progress2
44

5-
INTEGRATIONS = "@abi or @algod or @applications or @applications.verified or @assets or @auction or @c2c or @compile or @dryrun or @dryrun.testing or @indexer or @indexer.231 or @indexer.applications or @kmd or @rekey or @send.keyregtxn or @send"
5+
INTEGRATIONS = "@abi or @algod or @applications or @applications.verified or @assets or @auction or @c2c or @compile or @dryrun or @dryrun.testing or @indexer or @indexer.231 or @indexer.applications or @kmd or @rekey or @send.keyregtxn or @send or @compile.sourcemap"
66
integration:
7-
behave --tags=$(INTEGRATIONS) test -f progress2
7+
behave --tags=$(INTEGRATIONS) tests -f progress2
88

99
PYTHON_VERSION ?= 3.8
1010
docker-test:

algosdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
from . import v2client
1717
from . import wallet
1818
from . import wordlist
19+
from . import source_map
1920

2021
name = "algosdk"

algosdk/constants.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
LOGIC_SIG_MAX_SIZE = 1000
9090
"""int: max size of a teal program and its arguments in bytes"""
9191

92+
APP_PAGE_MAX_SIZE = 2048
93+
"""int: max size of a page for an application in bytes"""
94+
9295
ZERO_ADDRESS = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ"
9396
"""str: algorand encoded address of 32 zero bytes"""
9497

@@ -130,3 +133,4 @@
130133
max_asset_decimals = MAX_ASSET_DECIMALS
131134
logic_sig_max_cost = LOGIC_SIG_MAX_COST
132135
logic_sig_max_size = LOGIC_SIG_MAX_SIZE
136+
app_page_max_size = APP_PAGE_MAX_SIZE

algosdk/error.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,11 @@ def __init__(self, msg):
222222
class AtomicTransactionComposerError(Exception):
223223
def __init__(self, msg):
224224
super().__init__(msg)
225+
226+
227+
class SourceMapVersionError(Exception):
228+
def __init__(self, version):
229+
Exception.__init__(
230+
self,
231+
"Only SourceMap version 3 is supported, got: {}".format(version),
232+
)

algosdk/source_map.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
from typing import Dict, Any, List, Tuple
2+
3+
from algosdk.error import SourceMapVersionError
4+
5+
6+
class SourceMap:
7+
"""
8+
Decodes a VLQ-encoded source mapping between PC values and TEAL source code lines.
9+
Spec available here: https://sourcemaps.info/spec.html
10+
11+
Args:
12+
source_map (dict(str, Any)): source map JSON from algod
13+
"""
14+
15+
def __init__(self, source_map: Dict[str, Any]):
16+
17+
self.version: int = source_map["version"]
18+
19+
if self.version != 3:
20+
raise SourceMapVersionError(self.version)
21+
22+
self.sources: List[str] = source_map["sources"]
23+
24+
self.mappings: str = source_map["mappings"]
25+
26+
pc_list = [
27+
_decode_int_value(raw_val) for raw_val in self.mappings.split(";")
28+
]
29+
30+
self.pc_to_line: Dict[int, int] = {}
31+
self.line_to_pc: Dict[int, List[int]] = {}
32+
33+
last_line = 0
34+
for index, line_delta in enumerate(pc_list):
35+
# line_delta is None if the line number has not changed
36+
# or if the line is empty
37+
if line_delta is not None:
38+
last_line = last_line + line_delta
39+
40+
if last_line not in self.line_to_pc:
41+
self.line_to_pc[last_line] = []
42+
43+
self.line_to_pc[last_line].append(index)
44+
self.pc_to_line[index] = last_line
45+
46+
def get_line_for_pc(self, pc: int) -> int:
47+
return self.pc_to_line.get(pc, None)
48+
49+
def get_pcs_for_line(self, line: int) -> List[int]:
50+
return self.line_to_pc.get(line, None)
51+
52+
53+
def _decode_int_value(value: str) -> int:
54+
# Mappings may have up to 5 segments:
55+
# Third segment represents the zero-based starting line in the original source represented.
56+
decoded_value = _base64vlq_decode(value)
57+
return decoded_value[2] if decoded_value else None
58+
59+
60+
"""
61+
Source taken from: https://gist.github.com/mjpieters/86b0d152bb51d5f5979346d11005588b
62+
"""
63+
64+
_b64chars = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
65+
_b64table = [None] * (max(_b64chars) + 1)
66+
for i, b in enumerate(_b64chars):
67+
_b64table[b] = i
68+
69+
shiftsize, flag, mask = 5, 1 << 5, (1 << 5) - 1
70+
71+
72+
def _base64vlq_decode(vlqval: str) -> Tuple[int]:
73+
"""Decode Base64 VLQ value"""
74+
results = []
75+
shift = value = 0
76+
# use byte values and a table to go from base64 characters to integers
77+
for v in map(_b64table.__getitem__, vlqval.encode("ascii")):
78+
value += (v & mask) << shift
79+
if v & flag:
80+
shift += shiftsize
81+
continue
82+
# determine sign and add to results
83+
results.append((value >> 1) * (-1 if value & 1 else 1))
84+
shift = value = 0
85+
return results

algosdk/v2client/algod.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def suggested_params(self, **kwargs):
347347
res["min-fee"],
348348
)
349349

350-
def compile(self, source, **kwargs):
350+
def compile(self, source, source_map=False, **kwargs):
351351
"""
352352
Compile TEAL source with remote algod.
353353
@@ -365,9 +365,9 @@ def compile(self, source, **kwargs):
365365
{"Content-Type": "application/x-binary"},
366366
)
367367
kwargs["headers"] = headers
368-
368+
params = {"sourcemap": source_map}
369369
return self.algod_request(
370-
"POST", req, data=source.encode("utf-8"), **kwargs
370+
"POST", req, params=params, data=source.encode("utf-8"), **kwargs
371371
)
372372

373373
def dryrun(self, drr, **kwargs):

run_integration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ rm -rf test-harness
1010
git clone --single-branch --branch master https://github.com/algorand/algorand-sdk-testing.git test-harness
1111

1212
## Copy feature files into the project resources
13-
mkdir -p test/features
14-
cp -r test-harness/features/* test/features
13+
mkdir -p tests/features
14+
cp -r test-harness/features/* tests/features
1515

1616
# Build SDK testing environment
1717
docker build -t py-sdk-testing --build-arg PYTHON_VERSION="${PYTHON_VERSION}" -f Dockerfile "$(pwd)"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
description="Algorand SDK in Python",
1010
author="Algorand",
1111
author_email="pypiservice@algorand.com",
12-
version="v1.15.0",
12+
version="v1.16.0",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",
1515
license="MIT",

0 commit comments

Comments
 (0)