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

Support Algosdk 2.0.0 #58

Merged
merged 1 commit into from
Jan 19, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
python-version: ["3.11", "3.10", "3.9", "3.8"]
py-algorand-sdk-version: ["1.10.0", "1.11.0", "1.12.0", "1.13.0", "1.13.1", "1.14.0", "1.15.0", "1.16.0", "1.16.1",
"1.17.0", "1.18.0", "1.19.0", "1.20.0", "1.20.1", "1.20.2"]
"1.17.0", "1.18.0", "1.19.0", "1.20.0", "1.20.1", "1.20.2", "2.0.0"]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The SDK supports Tinyman V2 and V1.1.

## Requirements
- Python 3.8+
- py-algorand-sdk 1.10.0+, <2.0.0
- py-algorand-sdk 1.10.0+

## Installation
tinyman-py-sdk is not released on PYPI. It can be installed directly from this repository with pip:
Expand Down
2 changes: 1 addition & 1 deletion examples/v1/swapping1_less_convenience.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from tinyman.v1.pools import Pool
from tinyman.assets import Asset
from algosdk.future.transaction import wait_for_confirmation
from tinyman.compat import wait_for_confirmation
from algosdk.v2client.algod import AlgodClient
from tinyman.v1.client import TinymanClient

Expand Down
2 changes: 1 addition & 1 deletion examples/v2/tutorial/11_flash_loan_1_single_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from examples.v2.tutorial.common import get_account, get_assets
from examples.v2.utils import get_algod
from tinyman.v2.client import TinymanV2TestnetClient
from algosdk.future.transaction import AssetTransferTxn
from tinyman.compat import AssetTransferTxn

account = get_account()
algod = get_algod()
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/tutorial/12_flash_loan_2_multiple_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from examples.v2.tutorial.common import get_account, get_assets
from examples.v2.utils import get_algod
from tinyman.v2.client import TinymanV2TestnetClient
from algosdk.future.transaction import AssetTransferTxn, PaymentTxn
from tinyman.compat import AssetTransferTxn, PaymentTxn

account = get_account()
algod = get_algod()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pprint import pprint
from urllib.parse import quote_plus

from algosdk.future.transaction import AssetTransferTxn, PaymentTxn
from tinyman.compat import AssetTransferTxn, PaymentTxn

from examples.v2.tutorial.common import get_account, get_assets
from examples.v2.utils import get_algod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pprint import pprint
from urllib.parse import quote_plus

from algosdk.future.transaction import AssetTransferTxn, PaymentTxn
from tinyman.compat import AssetTransferTxn, PaymentTxn

from examples.v2.tutorial.common import get_account, get_assets
from examples.v2.utils import get_algod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pprint import pprint
from urllib.parse import quote_plus

from algosdk.future.transaction import AssetTransferTxn, PaymentTxn
from tinyman.compat import AssetTransferTxn, PaymentTxn

from examples.v2.tutorial.common import get_account, get_assets
from examples.v2.utils import get_algod
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/tutorial/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import random
from pprint import pprint

from algosdk.future.transaction import AssetCreateTxn, wait_for_confirmation
from tinyman.compat import AssetCreateTxn, wait_for_confirmation


def get_account_file_path(filename="account.json"):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
project_urls={
"Source": "https://github.com/tinyman/tinyman-py-sdk",
},
install_requires=["py-algorand-sdk >= 1.10.0, <2.0.0"],
install_requires=["py-algorand-sdk >= 1.10.0"],
packages=setuptools.find_packages(),
python_requires=">=3.8",
package_data={"tinyman.v1": ["asc.json"], "tinyman.v2": ["amm_approval.map.json"]},
Expand Down
2 changes: 1 addition & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from algosdk.future.transaction import SuggestedParams
from tinyman.compat import SuggestedParams


def get_suggested_params():
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_add_liquidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from algosdk.account import generate_account
from algosdk.constants import ASSETTRANSFER_TXN, APPCALL_TXN
from algosdk.encoding import decode_address
from algosdk.future.transaction import OnComplete
from tinyman.compat import OnComplete
from algosdk.logic import get_application_address

from tests.v2 import BaseTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from algosdk.account import generate_account
from algosdk.constants import APPCALL_TXN, PAYMENT_TXN
from algosdk.encoding import decode_address
from algosdk.future.transaction import OnComplete
from tinyman.compat import OnComplete
from algosdk.logic import get_application_address

from tests.v2 import BaseTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_flash_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from algosdk.account import generate_account
from algosdk.constants import APPCALL_TXN
from algosdk.encoding import decode_address
from algosdk.future.transaction import AssetTransferTxn, OnComplete
from tinyman.compat import AssetTransferTxn, OnComplete
from algosdk.logic import get_application_address

from tests.v2 import BaseTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_flash_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from algosdk.account import generate_account
from algosdk.constants import APPCALL_TXN
from algosdk.encoding import decode_address
from algosdk.future.transaction import OnComplete
from tinyman.compat import OnComplete
from algosdk.logic import get_application_address

from tests.v2 import BaseTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_remove_liquidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from algosdk.account import generate_account
from algosdk.constants import ASSETTRANSFER_TXN, APPCALL_TXN
from algosdk.encoding import decode_address
from algosdk.future.transaction import OnComplete
from tinyman.compat import OnComplete
from algosdk.logic import get_application_address

from tests.v2 import BaseTestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/test_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from algosdk.account import generate_account
from algosdk.constants import ASSETTRANSFER_TXN, APPCALL_TXN
from algosdk.encoding import decode_address
from algosdk.future.transaction import OnComplete
from tinyman.compat import OnComplete
from algosdk.logic import get_application_address

from tests.v2 import BaseTestCase
Expand Down
2 changes: 1 addition & 1 deletion tinyman/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import wait_for_confirmation
from tinyman.compat import wait_for_confirmation
from algosdk.v2client.algod import AlgodClient

from tinyman.assets import Asset
Expand Down
36 changes: 36 additions & 0 deletions tinyman/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# flake8: noqa

try:
from algosdk.transaction import (
ApplicationClearStateTxn,
ApplicationOptInTxn,
ApplicationNoOpTxn,
AssetTransferTxn,
AssetCreateTxn,
AssetOptInTxn,
assign_group_id,
LogicSigAccount,
LogicSigTransaction,
PaymentTxn,
SuggestedParams,
Transaction,
OnComplete,
wait_for_confirmation,
)
except ImportError:
from algosdk.future.transaction import (
ApplicationClearStateTxn,
ApplicationOptInTxn,
ApplicationNoOpTxn,
AssetTransferTxn,
AssetCreateTxn,
AssetOptInTxn,
assign_group_id,
LogicSigAccount,
LogicSigTransaction,
PaymentTxn,
SuggestedParams,
Transaction,
OnComplete,
wait_for_confirmation,
)
2 changes: 1 addition & 1 deletion tinyman/optin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationOptInTxn, AssetOptInTxn
from tinyman.compat import ApplicationOptInTxn, AssetOptInTxn

from tinyman.utils import TransactionGroup

Expand Down
2 changes: 1 addition & 1 deletion tinyman/staking/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from algosdk.constants import PAYMENT_TXN, ASSETTRANSFER_TXN
from algosdk.encoding import is_valid_address
from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationClearStateTxn,
ApplicationOptInTxn,
PaymentTxn,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Optional

from algosdk.error import AlgodHTTPError
from algosdk.future.transaction import (
from tinyman.compat import (
LogicSigTransaction,
assign_group_id,
wait_for_confirmation,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationOptInTxn,
PaymentTxn,
AssetCreateTxn,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/burn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn
from tinyman.compat import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn

from tinyman.utils import TransactionGroup
from .contracts import get_pool_logicsig
Expand Down
10 changes: 8 additions & 2 deletions tinyman/v1/contracts.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import sys
import json
import importlib.resources
from algosdk.future.transaction import LogicSigAccount
from tinyman.compat import LogicSigAccount
import tinyman.v1
from base64 import b64decode
from tinyman.utils import encode_value

_contracts = json.loads(importlib.resources.read_text(tinyman.v1, "asc.json"))
if sys.version_info >= (3, 9):
_contracts = json.loads(
importlib.resources.files(tinyman.v1).joinpath("asc.json").read_text()
)
else:
_contracts = json.loads(importlib.resources.read_text(tinyman.v1, "asc.json"))

pool_logicsig_def = _contracts["contracts"]["pool_logicsig"]["logic"]

Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/fees.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn
from tinyman.compat import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn

from tinyman.utils import TransactionGroup
from .contracts import get_pool_logicsig
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/mint.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn
from tinyman.compat import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn

from tinyman.utils import TransactionGroup
from .contracts import get_pool_logicsig
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/optout.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationClearStateTxn
from tinyman.compat import ApplicationClearStateTxn
from algosdk.v2client.algod import AlgodClient


Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/redeem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn
from tinyman.compat import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn

from tinyman.utils import TransactionGroup
from .contracts import get_pool_logicsig
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v1/swap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn
from tinyman.compat import ApplicationNoOpTxn, PaymentTxn, AssetTransferTxn

from tinyman.utils import TransactionGroup
from .contracts import get_pool_logicsig
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/add_liquidity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationNoOpTxn,
PaymentTxn,
AssetTransferTxn,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationOptInTxn,
PaymentTxn,
SuggestedParams,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/contracts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from base64 import b64decode

from algosdk.future.transaction import LogicSigAccount
from tinyman.compat import LogicSigAccount

from tinyman.v2.constants import POOL_LOGICSIG_TEMPLATE

Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/fees.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationNoOpTxn,
SuggestedParams,
)
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/flash_loan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
Transaction,
ApplicationNoOpTxn,
PaymentTxn,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/flash_swap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
Transaction,
ApplicationNoOpTxn,
SuggestedParams,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/management.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationNoOpTxn,
SuggestedParams,
)
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/pools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import LogicSigAccount, Transaction, SuggestedParams
from tinyman.compat import LogicSigAccount, Transaction, SuggestedParams
from algosdk.v2client.algod import AlgodClient

from tinyman.assets import Asset, AssetAmount
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/remove_liquidity.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationNoOpTxn,
AssetTransferTxn,
SuggestedParams,
Expand Down
2 changes: 1 addition & 1 deletion tinyman/v2/swap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Optional

from algosdk.future.transaction import (
from tinyman.compat import (
ApplicationNoOpTxn,
PaymentTxn,
AssetTransferTxn,
Expand Down
Loading