Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOR REVIEW ONLY - py-algorand-sdk v1.10.0b1 #294

Merged
merged 28 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03ccaf1
Merge branch 'release/v1.9.0' into develop
algobarb Jan 14, 2022
42be795
Add App creator to account balances (#277)
barnjamin Jan 19, 2022
ddbbe7e
Change __init__.py to include v2client import (#243)
StylishTriangles Jan 19, 2022
16f037f
Add build and pycharm files to gitignore
bricerisingalgorand Jan 20, 2022
7ba92ef
Update circle job to use docker instead of vm
bricerisingalgorand Jan 20, 2022
3d9f4ff
Define workflow for test pipeline
bricerisingalgorand Jan 20, 2022
e30384c
Add version field to workflows
bricerisingalgorand Jan 20, 2022
52c8f8a
Add run to shell commands
bricerisingalgorand Jan 20, 2022
7d83af5
Fix name and add debug for unit test job
bricerisingalgorand Jan 20, 2022
159b5fe
Add checkout steps
bricerisingalgorand Jan 20, 2022
0237e6a
Make unit tests exit with 1 when tests fail
bricerisingalgorand Jan 20, 2022
1c13405
Fix verify for signatures with not enough chars
bricerisingalgorand Jan 20, 2022
32deda3
Switch to using vm for integration tests
bricerisingalgorand Jan 25, 2022
8e9cb9a
rearranged to keep logical order
algojack Jan 26, 2022
2ef7d33
Merge pull request #279 from bricerisingalgorand/feature/circleciPipe…
bricerisingalgorand Jan 26, 2022
f398850
Add CircleCI build step to generate docsets
aldur Feb 8, 2022
eb1e32e
Upload a `tar.gz` artifact so it can be downloaded with one click
aldur Feb 8, 2022
d50d997
Merge pull request #285 from algorand/docset
aldur Feb 9, 2022
4ee2d3d
C2C Feature and Testing (#268)
tzaffi Feb 9, 2022
216a1d4
revert to point testing harness to sdk testing's master branch
Feb 9, 2022
f0509ba
revert the revert dohhhh
Feb 9, 2022
0bdd947
revert to point testing harness to sdk testing's master branch (#288)
tzaffi Feb 9, 2022
af81385
`decode_error` is an optional Exception.
aldur Feb 14, 2022
7a50379
Merge pull request #290 from algorand/aldur/fix_atc_types
aldur Feb 14, 2022
5e8b3a2
New keyreg txn field (#244)
shiqizng Feb 14, 2022
d71b8c5
Update `langspec.json` for Teal6 (#292)
tzaffi Feb 15, 2022
fbd9e76
Add ABI and ATC to Sphinx (#289)
aldur Feb 15, 2022
ee6fa0d
Bumped version to v1.10.0b1
algobarb Feb 15, 2022
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
47 changes: 39 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
version: 2.1

workflows:
version: 2
test:
jobs:
- unit-test
- integration-test
- docset

jobs:
build:
machine:
image: "ubuntu-2004:202104-01"
unit-test:
docker:
- image: python:3.7.9
steps:
- checkout
- run: pip install -r requirements.txt
- run: black --check .
- run: python3 test_unit.py
integration-test:
machine:
image: "ubuntu-2004:202104-01"
steps:
- checkout
- run: make docker-test
docset:
docker:
# NOTE: We might eventually need Docker authentication here.
- image: cimg/python:3.9
steps:
- checkout
- run:
# NOTE: We might add caching at `pip` level here.
command: |
pip3 install -r requirements.txt
black --check .
set -e
python3 test_unit.py
make docker-test
pip install -r requirements.txt
cd docs
pip install -r requirements.txt
pip install sphinx sphinx_rtd_theme doc2dash
make html
doc2dash --name py-algo-sdk --index-page index.html --online-redirect-url https://py-algorand-sdk.readthedocs.io/en/latest/ _build/html
tar -czvf py-algo-sdk.docset.tar.gz py-algo-sdk.docset
mv py-algo-sdk.docset.tar.gz /tmp
- store_artifacts:
path: /tmp/py-algo-sdk.docset.tar.gz
destination: py-algo-sdk.docset.tar.gz
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,19 @@ venv.bak/
# vscode
.vscode/

# pycharm
.idea

# DS_Store
.DS_Store

# Testing files
*.feature
test/features
test-harness

# Build files
py-algorand-sdk-*

# Pycharm
.idea
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

# 1.10.0b1

## Added:

- New keyreg txn field (#244)
- C2C Feature and Testing (#268)
- Add App creator to account balances (#277)
- Add ABI and ATC to Sphinx (#289)

## Changed:

- Change __init__.py to include v2client import (#243)
- Updates to pipeline (#279)
- Add CircleCI build step to generate docsets (#285)
- revert to point testing harness to sdk testing's master branch (#288)
- Partially fix types for atomic transaction composer (#290)
- Update `langspec.json` for Teal6 (#292)

## 1.9.0
### Added

Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
UNITS = "@unit.abijson or @unit.algod or @unit.applications or @unit.atomic_transaction_composer or @unit.dryrun or @unit.feetest or @unit.indexer 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"
unit:
behave --tags="@unit.offline or @unit.algod or @unit.indexer or @unit.rekey or @unit.tealsign or @unit.dryrun or @unit.applications or @unit.responses or @unit.transactions or @unit.transactions.payment or @unit.responses.231 or @unit.feetest or @unit.indexer.logs or @unit.abijson or @unit.atomic_transaction_composer" test -f progress2
behave --tags=$(UNITS) test -f progress2

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"
integration:
behave --tags="@algod or @assets or @auction or @kmd or @send or @template or @indexer or @indexer.applications or @rekey or @compile or @dryrun or @dryrun.testing or @applications or @applications.verified or @indexer.231 or @abi" test -f progress2
behave --tags=$(INTEGRATIONS) test -f progress2

docker-test:
./run_integration.sh
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# 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)

[![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)

A python library for interacting with the Algorand network.

## Installation

Run ```$ pip3 install py-algorand-sdk``` to install the package.
Run `$ pip3 install py-algorand-sdk` to install the package.

Alternatively, choose a [distribution file](https://pypi.org/project/py-algorand-sdk/#files), and run ```$ pip3 install [file name]```.
Alternatively, choose a [distribution file](https://pypi.org/project/py-algorand-sdk/#files), and run `$ pip3 install [file name]`.

## SDK Development

Install dependencies
* `pip install -r requirements.txt`

- `pip install -r requirements.txt`

Run tests
* `make docker-test`

- `make docker-test`

Format code:
* `black .`

- `black .`

## Quick start

Expand Down Expand Up @@ -50,18 +54,18 @@ Follow the instructions in Algorand's [developer resources](https://developer.al

Before running [example.py](https://github.com/algorand/py-algorand-sdk/blob/master/examples/example.py), start kmd on a private network or testnet node:

```
$ ./goal kmd start -d [data directory]
```bash
./goal kmd start -d [data directory]
```

Next, create a wallet and an account:

```
$ ./goal wallet new [wallet name] -d [data directory]
```bash
./goal wallet new [wallet name] -d [data directory]
```

```
$ ./goal account new -d [data directory] -w [wallet name]
```bash
./goal account new -d [data directory] -w [wallet name]
```

Visit the [Algorand dispenser](https://bank.testnet.algorand.network/) and enter the account address to fund your account.
Expand All @@ -71,7 +75,9 @@ Next, in [tokens.py](https://github.com/algorand/py-algorand-sdk/blob/master/exa
You're now ready to run example.py!

## Documentation

Documentation for the Python SDK is available at [py-algorand-sdk.readthedocs.io](https://py-algorand-sdk.readthedocs.io/en/latest/).

## License
py-algorand-sdk is licensed under a MIT license. See the [LICENSE](https://github.com/algorand/py-algorand-sdk/blob/master/LICENSE) file for details.

py-algorand-sdk is licensed under an MIT license. See the [LICENSE](https://github.com/algorand/py-algorand-sdk/blob/master/LICENSE) file for details.
1 change: 1 addition & 0 deletions algosdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from . import template
from . import transaction
from . import util
from . import v2client
from . import wallet
from . import wordlist

Expand Down
38 changes: 21 additions & 17 deletions algosdk/atomic_transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import base64
import copy
from enum import IntEnum
from typing import Any, List, TypeVar, Union
from typing import Any, List, Optional, TypeVar, Union

from algosdk import abi, error
from algosdk.abi.address_type import AddressType
Expand Down Expand Up @@ -495,26 +495,27 @@ def execute(
raw_value = None
return_value = None
decode_error = None
tx_info = None

if i not in self.method_dict:
continue
# Return is void
if self.method_dict[i].returns.type == abi.Returns.VOID:
method_results.append(
ABIResult(
tx_id=tx_id,
raw_value=raw_value,
return_value=return_value,
decode_error=decode_error,
)
)
continue

# Parse log for ABI method return value
try:
resp = client.pending_transaction_info(tx_id)
confirmed_round = resp["confirmed-round"]
logs = resp["logs"] if "logs" in resp else []
tx_info = client.pending_transaction_info(tx_id)
if self.method_dict[i].returns.type == abi.Returns.VOID:
method_results.append(
ABIResult(
tx_id=tx_id,
raw_value=raw_value,
return_value=return_value,
decode_error=decode_error,
tx_info=tx_info,
)
)
continue

logs = tx_info["logs"] if "logs" in tx_info else []

# Look for the last returned value in the log
if not logs:
Expand Down Expand Up @@ -543,6 +544,7 @@ def execute(
raw_value=raw_value,
return_value=return_value,
decode_error=decode_error,
tx_info=tx_info,
)
method_results.append(abi_result)

Expand Down Expand Up @@ -688,17 +690,19 @@ def __init__(
tx_id: int,
raw_value: bytes,
return_value: Any,
decode_error: error,
decode_error: Optional[Exception],
tx_info: dict,
) -> None:
self.tx_id = tx_id
self.raw_value = raw_value
self.return_value = return_value
self.decode_error = decode_error
self.tx_info = tx_info


class AtomicTransactionResponse:
def __init__(
self, confirmed_round: int, tx_ids: List[str], results: ABIResult
self, confirmed_round: int, tx_ids: List[str], results: List[ABIResult]
) -> None:
self.confirmed_round = confirmed_round
self.tx_ids = tx_ids
Expand Down
2 changes: 1 addition & 1 deletion algosdk/data/langspec.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions algosdk/future/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@


class Template:
"""
NOTE: This class is deprecated
"""

def get_address(self):
"""
Return the address of the contract.
Expand All @@ -19,6 +23,8 @@ def get_program(self):

class Split(Template):
"""
NOTE: This class is deprecated.

Split allows locking algos in an account which allows transfering to two
predefined addresses in a specified ratio such that for the given ratn and
ratd parameters we have:
Expand Down Expand Up @@ -156,6 +162,8 @@ def get_split_funds_transaction(contract, amount: int, sp):

class HTLC(Template):
"""
NOTE: This class is deprecated.

Hash Time Locked Contract allows a user to recieve the Algo prior to a
deadline (in terms of a round) by proving knowledge of a special value
or to forfeit the ability to claim, returning it to the payer.
Expand Down Expand Up @@ -291,6 +299,8 @@ def get_transaction(contract, preimage, sp):

class DynamicFee(Template):
"""
NOTE: This class is deprecated.

DynamicFee contract allows you to create a transaction without
specifying the fee. The fee will be determined at the moment of
transfer.
Expand Down Expand Up @@ -416,6 +426,8 @@ def sign_dynamic_fee(self, private_key):

class PeriodicPayment(Template):
"""
NOTE: This class is deprecated.

PeriodicPayment contract enables creating an account which allows the
withdrawal of a fixed amount of assets every fixed number of rounds to a
specific Algrorand Address. In addition, the contract allows to add
Expand Down Expand Up @@ -528,6 +540,8 @@ def get_withdrawal_transaction(contract, sp):

class LimitOrder(Template):
"""
NOTE: This class is deprecated.

Limit Order allows to trade Algos for other assets given a specific ratio;
for N Algos, swap for Rate * N Assets.
...
Expand Down
Loading