Skip to content

Commit 9bf39f2

Browse files
committed
Merge branch 'release/v1.20.2'
2 parents a411457 + 161e7b0 commit 9bf39f2

17 files changed

+152
-198
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
# Changelog
2+
3+
# v1.20.2
4+
5+
## What's Changed
6+
### Bugfixes
7+
* Bug-Fix: encode ABI string with non-ASCII characters by @ahangsu in https://github.com/algorand/py-algorand-sdk/pull/402
8+
### Enhancements
9+
* Tests: Migrate v1 algod dependencies to v2 in cucumber tests by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/400
10+
* Enhancement: allowing zero length static array by @ahangsu in https://github.com/algorand/py-algorand-sdk/pull/401
11+
* README: Delete Travis CI Badge by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/404
12+
* examples: Migrate v1 algod usage to v2 algod by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/403
13+
14+
**Full Changelog**: https://github.com/algorand/py-algorand-sdk/compare/v1.20.1...v1.20.2
15+
216
# v1.20.1
317

418
## What's Changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# py-algorand-sdk
22

3-
[![Build Status](https://travis-ci.com/algorand/py-algorand-sdk.svg?branch=master)](https://travis-ci.com/algorand/py-algorand-sdk)
43
[![PyPI version](https://badge.fury.io/py/py-algorand-sdk.svg)](https://badge.fury.io/py/py-algorand-sdk)
54
[![Documentation Status](https://readthedocs.org/projects/py-algorand-sdk/badge/?version=latest&style=flat)](https://py-algorand-sdk.readthedocs.io/en/latest)
65
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
@@ -90,7 +89,7 @@ Next, create a wallet and an account:
9089

9190
Visit the [Algorand dispenser](https://bank.testnet.algorand.network/) and enter the account address to fund your account.
9291

93-
Next, in [tokens.py](https://github.com/algorand/py-algorand-sdk/blob/master/examples/tokens.py), either update the tokens and addresses, or provide a path to the data directory.
92+
Next, in [tokens.py](https://github.com/algorand/py-algorand-sdk/blob/master/examples/tokens.py), either update the tokens and addresses, or provide a path to the data directory. Alternatively, `tokens.py` also defaults to the sandbox harness configurations for algod and kmd, which can be brought up by running `make harness`.
9493

9594
You're now ready to run example.py!
9695

algosdk/abi/array_static_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class ArrayStaticType(ABIType):
2222
"""
2323

2424
def __init__(self, arg_type: ABIType, array_len: int) -> None:
25-
if array_len < 1:
25+
if array_len < 0:
2626
raise error.ABITypeError(
27-
"static array length must be a positive integer: {}".format(
27+
"static array length {} must be a non-negative integer".format(
2828
array_len
2929
)
3030
)

algosdk/abi/base_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# Globals
99
ABI_LENGTH_SIZE = 2 # We use 2 bytes to encode the length of a dynamic element
1010
UFIXED_REGEX = r"^ufixed([1-9][\d]*)x([1-9][\d]*)$"
11-
STATIC_ARRAY_REGEX = r"^([a-z\d\[\](),]+)\[([1-9][\d]*)]$"
11+
STATIC_ARRAY_REGEX = r"^([a-z\d\[\](),]+)\[(0|[1-9][\d]*)]$"
1212

1313

1414
class ABIType(ABC):

algosdk/abi/string_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def encode(self, string_val: str) -> bytes:
3838
Returns:
3939
bytes: encoded bytes of the string
4040
"""
41-
length_to_encode = len(string_val).to_bytes(2, byteorder="big")
4241
encoded = string_val.encode("utf-8")
42+
length_to_encode = len(encoded).to_bytes(2, byteorder="big")
4343
return length_to_encode + encoded
4444

4545
def decode(self, bytestring: Union[bytes, bytearray]) -> str:

examples/custom_header_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# key, instead of a string, as the token.
66

77
import tokens
8-
from algosdk import algod
8+
from algosdk.v2client import algod
99

1010
headers = {
1111
"X-API-Key": "#######",
@@ -37,7 +37,7 @@ def main():
3737
)
3838

3939
# Retrieve latest block information
40-
last_round = algod_client.status().get("lastRound")
40+
last_round = algod_client.status().get("last-round")
4141
print("####################")
4242
block = algod_client.block_info(last_round)
4343
print(block)

examples/log_sig_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Example: creating a LogicSig transaction signed by a program that never approves the transfer.
22

33
import tokens
4-
from algosdk import algod, account
4+
from algosdk import account
5+
from algosdk.v2client import algod
56
from algosdk.future import transaction
67

78
program = b"\x01\x20\x01\x00\x22" # int 0
89
lsig = transaction.LogicSigAccount(program)
910
sender = lsig.address()
10-
receiver = account.generate_account()
11+
_, receiver = account.generate_account()
1112

1213
# create an algod client
1314
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)
@@ -25,4 +26,5 @@
2526
assert lstx.verify()
2627

2728
# send them over network
29+
# Logicsig will reject the transaction
2830
acl.send_transaction(lstx)

examples/multisig_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Example: manipulating multisig transactions
22

33
import tokens
4-
from algosdk import account, algod, encoding
4+
5+
from algosdk import account, encoding
56
from algosdk.future import transaction
7+
from algosdk.v2client import algod
68

79
# generate three accounts
810
private_key_1, account_1 = account.generate_account()
@@ -16,7 +18,7 @@
1618

1719
# get suggested parameters
1820
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)
19-
suggested_params = acl.suggested_params_as_object()
21+
suggested_params = acl.suggested_params()
2022

2123
# create a transaction
2224
sender = msig.address()

examples/notefield_example.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
# with an auction bid. Note that you can put any bytes you want in the "note"
44
# field; you don't have to use the NoteField object.
55

6+
import base64
7+
68
import tokens
7-
from algosdk import algod, mnemonic, account, auction, constants, encoding
9+
10+
from algosdk import account, auction, constants, encoding
811
from algosdk.future import transaction
9-
import base64
12+
from algosdk.v2client import algod
1013

1114
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)
1215

1316
# generate an account
1417
private_key, public_key = account.generate_account()
1518

1619
# get suggested parameters
17-
sp = acl.suggested_params_as_object()
20+
sp = acl.suggested_params()
1821

1922
# Set other parameters
2023
amount = 100000

examples/rekey_example.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Example: rekeying
22

3-
from algosdk import account, algod
4-
from algosdk.future import transaction
53
import tokens
64

5+
from algosdk import account
6+
from algosdk.future import transaction
7+
from algosdk.v2client import algod
8+
79
# this should be the current account
810
sender_private_key, sender = account.generate_account()
911
rekey_private_key, rekey_address = account.generate_account()
@@ -12,7 +14,7 @@
1214

1315
# get suggested parameters
1416
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)
15-
suggested_params = acl.suggested_params_as_object()
17+
suggested_params = acl.suggested_params()
1618

1719
# To rekey an account to a new address, add the `rekey_to` argument to creation.
1820
# After sending this rekeying transaction, every transaction needs to be signed by the private key of the new address

examples/tokens.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
# examples helper file
1+
# Examples helper file
22

33
from os import listdir
44
from os.path import expanduser
55

66
home = expanduser("~")
77

8-
# change these after starting the node and kmd
8+
# These values are initialized for the SDK sandbox harness.
9+
# You can bring the harness up by running `make harness`.
10+
#
11+
# If you are using your own node installation, change these after starting the node and kmd.
912
# algod info is in the algod.net and algod.token files in the data directory
1013
# kmd info is in the kmd.net and kmd.token files in the kmd directory in data
14+
kmd_token = "a" * 64
15+
kmd_address = "http://localhost:59999"
1116

12-
kmd_token = ""
13-
kmd_address = ""
14-
15-
algod_token = ""
16-
algod_address = ""
17+
algod_token = "a" * 64
18+
algod_address = "http://localhost:60000"
1719

1820
# you can also get tokens and addresses automatically
19-
get_automatically = True
21+
get_automatically = False
2022

2123
# path to the data directory
2224
data_dir_path = home + "/node/network/Node"

examples/transaction_group_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Example: working with transaction groups
22

33
import tokens
4-
from algosdk import algod, kmd, account
4+
5+
from algosdk import account, kmd
56
from algosdk.future import transaction
7+
from algosdk.v2client import algod
68

79
# generate accounts
810
private_key_sender, sender = account.generate_account()
@@ -13,7 +15,7 @@
1315
kcl = kmd.KMDClient(tokens.kmd_token, tokens.kmd_address)
1416

1517
# get suggested parameters
16-
sp = acl.suggested_params_as_object()
18+
sp = acl.suggested_params()
1719

1820
# create a transaction
1921
amount = 10000

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.20.1",
12+
version="v1.20.2",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",
1515
license="MIT",

tests/steps/application_v2_steps.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,14 @@
22
import json
33
import re
44
import time
5+
56
import pytest
7+
from behave import given, step, then, when
68

7-
from algosdk import (
8-
abi,
9-
atomic_transaction_composer,
10-
encoding,
11-
mnemonic,
12-
)
9+
from algosdk import abi, atomic_transaction_composer, encoding, mnemonic
1310
from algosdk.abi.contract import NetworkInfo
14-
from algosdk.error import (
15-
ABITypeError,
16-
AtomicTransactionComposerError,
17-
)
11+
from algosdk.error import ABITypeError, AtomicTransactionComposerError
1812
from algosdk.future import transaction
19-
from behave import given, step, then, when
2013
from tests.steps.other_v2_steps import read_program
2114

2215

@@ -446,14 +439,7 @@ def remember_app_id(context):
446439
@step("I wait for the transaction to be confirmed.")
447440
def wait_for_app_txn_confirm(context):
448441
wait_for_transaction_processing_to_complete_in_dev_mode()
449-
if hasattr(context, "acl"):
450-
# TODO: get rid of this branch of logic when v1 fully deprecated
451-
assert "type" in context.acl.transaction_info(
452-
context.transient_pk, context.app_txid
453-
)
454-
# assert "type" in context.acl.transaction_by_id(context.app_txid)
455-
else:
456-
transaction.wait_for_confirmation(context.app_acl, context.app_txid, 1)
442+
transaction.wait_for_confirmation(context.app_acl, context.app_txid, 1)
457443

458444

459445
@given("an application id {app_id}")

tests/steps/other_v2_steps.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
from urllib.request import Request, urlopen
88

99
import parse
10+
from behave import register_type # pylint: disable=no-name-in-module
11+
from behave import given, step, then, when
12+
from glom import glom
13+
1014
from algosdk import dryrun_results, encoding, error, mnemonic, source_map
1115
from algosdk.error import AlgodHTTPError
1216
from algosdk.future import transaction
@@ -18,14 +22,6 @@
1822
DryrunRequest,
1923
DryrunSource,
2024
)
21-
from behave import (
22-
given,
23-
register_type, # pylint: disable=no-name-in-module
24-
step,
25-
then,
26-
when,
27-
)
28-
from glom import glom
2925
from tests.steps.steps import algod_port, indexer_port
3026
from tests.steps.steps import token as daemon_token
3127

0 commit comments

Comments
 (0)