tinymanorg / tinyman-py-sdk

Tinyman Python SDK
MIT License
117 stars 60 forks source link

AttributeError: module 'algosdk.v2client.algod' has no attribute 'asset_info' #47

Closed Bhaney44 closed 2 years ago

Bhaney44 commented 2 years ago

I'm using the code from #36 but I am getting an error that is preventing any functional return.

from tinyman.v1.client import TinymanMainnetClient
from algosdk.v2client import algod
client = TinymanMainnetClient(algod_client=algod)

asset1 = client.fetch_asset(31566704)
asset2 = client.fetch_asset(386192725)
amount = 100
asset_in = asset1

pool = client.fetch_pool(asset1, asset2)
quote = pool.fetch_fixed_input_swap_quote(asset_in(amount * 10 ** asset_in.decimals), slippage=0.05)

Error

Traceback (most recent call last):
  File "/Users/Desktop/Projects/quote.py", line 5, in <module>
    asset1 = client.fetch_asset(92772865)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/tinyman/v1/client.py", line 25, in fetch_asset
    asset.fetch(self.algod)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/tinyman/assets.py", line 19, in fetch
    params = algod.asset_info(self.id)['params']
AttributeError: module 'algosdk.v2client.algod' has no attribute 'asset_info'

I searched in client.py and assets.py but I have not found a way to change the params variable such that asset_info is recognized. I'm not sure how or why this error would occur because it is resulting in a de facto deprecation of the Python-SDK. Any advice or suggestions would be appreciated. Thanks!

Bhaney44 commented 2 years ago

Solution

algod = AlgodClient('', 'https://node.algoexplorerapi.io', headers={'User-Agent': 'algosdk'})
client = TinymanMainnetClient(algod_client=algod)