Skip to content

Commit

Permalink
Merge branch 'release/v1.20.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
algojack committed Dec 5, 2022
2 parents a411457 + 161e7b0 commit 9bf39f2
Show file tree
Hide file tree
Showing 17 changed files with 152 additions and 198 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# Changelog

# v1.20.2

## What's Changed
### Bugfixes
* Bug-Fix: encode ABI string with non-ASCII characters by @ahangsu in https://github.com/algorand/py-algorand-sdk/pull/402
### Enhancements
* Tests: Migrate v1 algod dependencies to v2 in cucumber tests by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/400
* Enhancement: allowing zero length static array by @ahangsu in https://github.com/algorand/py-algorand-sdk/pull/401
* README: Delete Travis CI Badge by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/404
* examples: Migrate v1 algod usage to v2 algod by @algochoi in https://github.com/algorand/py-algorand-sdk/pull/403

**Full Changelog**: https://github.com/algorand/py-algorand-sdk/compare/v1.20.1...v1.20.2

# v1.20.1

## What's Changed
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# py-algorand-sdk

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

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

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.
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`.

You're now ready to run example.py!

Expand Down
4 changes: 2 additions & 2 deletions algosdk/abi/array_static_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class ArrayStaticType(ABIType):
"""

def __init__(self, arg_type: ABIType, array_len: int) -> None:
if array_len < 1:
if array_len < 0:
raise error.ABITypeError(
"static array length must be a positive integer: {}".format(
"static array length {} must be a non-negative integer".format(
array_len
)
)
Expand Down
2 changes: 1 addition & 1 deletion algosdk/abi/base_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Globals
ABI_LENGTH_SIZE = 2 # We use 2 bytes to encode the length of a dynamic element
UFIXED_REGEX = r"^ufixed([1-9][\d]*)x([1-9][\d]*)$"
STATIC_ARRAY_REGEX = r"^([a-z\d\[\](),]+)\[([1-9][\d]*)]$"
STATIC_ARRAY_REGEX = r"^([a-z\d\[\](),]+)\[(0|[1-9][\d]*)]$"


class ABIType(ABC):
Expand Down
2 changes: 1 addition & 1 deletion algosdk/abi/string_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def encode(self, string_val: str) -> bytes:
Returns:
bytes: encoded bytes of the string
"""
length_to_encode = len(string_val).to_bytes(2, byteorder="big")
encoded = string_val.encode("utf-8")
length_to_encode = len(encoded).to_bytes(2, byteorder="big")
return length_to_encode + encoded

def decode(self, bytestring: Union[bytes, bytearray]) -> str:
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_header_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# key, instead of a string, as the token.

import tokens
from algosdk import algod
from algosdk.v2client import algod

headers = {
"X-API-Key": "#######",
Expand Down Expand Up @@ -37,7 +37,7 @@ def main():
)

# Retrieve latest block information
last_round = algod_client.status().get("lastRound")
last_round = algod_client.status().get("last-round")
print("####################")
block = algod_client.block_info(last_round)
print(block)
Expand Down
6 changes: 4 additions & 2 deletions examples/log_sig_example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Example: creating a LogicSig transaction signed by a program that never approves the transfer.

import tokens
from algosdk import algod, account
from algosdk import account
from algosdk.v2client import algod
from algosdk.future import transaction

program = b"\x01\x20\x01\x00\x22" # int 0
lsig = transaction.LogicSigAccount(program)
sender = lsig.address()
receiver = account.generate_account()
_, receiver = account.generate_account()

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

# send them over network
# Logicsig will reject the transaction
acl.send_transaction(lstx)
6 changes: 4 additions & 2 deletions examples/multisig_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Example: manipulating multisig transactions

import tokens
from algosdk import account, algod, encoding

from algosdk import account, encoding
from algosdk.future import transaction
from algosdk.v2client import algod

# generate three accounts
private_key_1, account_1 = account.generate_account()
Expand All @@ -16,7 +18,7 @@

# get suggested parameters
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)
suggested_params = acl.suggested_params_as_object()
suggested_params = acl.suggested_params()

# create a transaction
sender = msig.address()
Expand Down
9 changes: 6 additions & 3 deletions examples/notefield_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
# with an auction bid. Note that you can put any bytes you want in the "note"
# field; you don't have to use the NoteField object.

import base64

import tokens
from algosdk import algod, mnemonic, account, auction, constants, encoding

from algosdk import account, auction, constants, encoding
from algosdk.future import transaction
import base64
from algosdk.v2client import algod

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

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

# get suggested parameters
sp = acl.suggested_params_as_object()
sp = acl.suggested_params()

# Set other parameters
amount = 100000
Expand Down
8 changes: 5 additions & 3 deletions examples/rekey_example.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Example: rekeying

from algosdk import account, algod
from algosdk.future import transaction
import tokens

from algosdk import account
from algosdk.future import transaction
from algosdk.v2client import algod

# this should be the current account
sender_private_key, sender = account.generate_account()
rekey_private_key, rekey_address = account.generate_account()
Expand All @@ -12,7 +14,7 @@

# get suggested parameters
acl = algod.AlgodClient(tokens.algod_token, tokens.algod_address)
suggested_params = acl.suggested_params_as_object()
suggested_params = acl.suggested_params()

# To rekey an account to a new address, add the `rekey_to` argument to creation.
# After sending this rekeying transaction, every transaction needs to be signed by the private key of the new address
Expand Down
18 changes: 10 additions & 8 deletions examples/tokens.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# examples helper file
# Examples helper file

from os import listdir
from os.path import expanduser

home = expanduser("~")

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

kmd_token = ""
kmd_address = ""

algod_token = ""
algod_address = ""
algod_token = "a" * 64
algod_address = "http://localhost:60000"

# you can also get tokens and addresses automatically
get_automatically = True
get_automatically = False

# path to the data directory
data_dir_path = home + "/node/network/Node"
Expand Down
6 changes: 4 additions & 2 deletions examples/transaction_group_example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Example: working with transaction groups

import tokens
from algosdk import algod, kmd, account

from algosdk import account, kmd
from algosdk.future import transaction
from algosdk.v2client import algod

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

# get suggested parameters
sp = acl.suggested_params_as_object()
sp = acl.suggested_params()

# create a transaction
amount = 10000
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
description="Algorand SDK in Python",
author="Algorand",
author_email="[email protected]",
version="v1.20.1",
version="v1.20.2",
long_description=long_description,
long_description_content_type="text/markdown",
license="MIT",
Expand Down
24 changes: 5 additions & 19 deletions tests/steps/application_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@
import json
import re
import time

import pytest
from behave import given, step, then, when

from algosdk import (
abi,
atomic_transaction_composer,
encoding,
mnemonic,
)
from algosdk import abi, atomic_transaction_composer, encoding, mnemonic
from algosdk.abi.contract import NetworkInfo
from algosdk.error import (
ABITypeError,
AtomicTransactionComposerError,
)
from algosdk.error import ABITypeError, AtomicTransactionComposerError
from algosdk.future import transaction
from behave import given, step, then, when
from tests.steps.other_v2_steps import read_program


Expand Down Expand Up @@ -446,14 +439,7 @@ def remember_app_id(context):
@step("I wait for the transaction to be confirmed.")
def wait_for_app_txn_confirm(context):
wait_for_transaction_processing_to_complete_in_dev_mode()
if hasattr(context, "acl"):
# TODO: get rid of this branch of logic when v1 fully deprecated
assert "type" in context.acl.transaction_info(
context.transient_pk, context.app_txid
)
# assert "type" in context.acl.transaction_by_id(context.app_txid)
else:
transaction.wait_for_confirmation(context.app_acl, context.app_txid, 1)
transaction.wait_for_confirmation(context.app_acl, context.app_txid, 1)


@given("an application id {app_id}")
Expand Down
12 changes: 4 additions & 8 deletions tests/steps/other_v2_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
from urllib.request import Request, urlopen

import parse
from behave import register_type # pylint: disable=no-name-in-module
from behave import given, step, then, when
from glom import glom

from algosdk import dryrun_results, encoding, error, mnemonic, source_map
from algosdk.error import AlgodHTTPError
from algosdk.future import transaction
Expand All @@ -18,14 +22,6 @@
DryrunRequest,
DryrunSource,
)
from behave import (
given,
register_type, # pylint: disable=no-name-in-module
step,
then,
when,
)
from glom import glom
from tests.steps.steps import algod_port, indexer_port
from tests.steps.steps import token as daemon_token

Expand Down
Loading

0 comments on commit 9bf39f2

Please sign in to comment.