steemit / steem-python

The official Python (3) library for the Steem Blockchain.
https://steem.io
MIT License
154 stars 99 forks source link

AttributeError: 'Steemd' object has no attribute 'commit' in steem-python #122

Closed amosbastian closed 2 years ago

amosbastian commented 6 years ago

When using the functions buy(), sell() and cancel() from dex.py / the Dex class it returns the following error

AttributeError: 'Steemd' object has no attribute 'commit'

Expected behavior

When executing the following example program dex_bug.py you expect it to place an order on the market

from steem.dex import Dex

if __name__ == '__main__':
    dex = Dex()
    dex.sell(
        amount=0.1,
        quote_symbol="SBD",
        rate=2.0,
        expiration=60,
        killfill=False,
        account="amosbastian"
    )

which would look like this

order_example.png

Actual behavior

When executing dex_bug.py you get the following output

$ python dex_bug.py 
Traceback (most recent call last):
  File "dex_bug.py", line 11, in <module>
    account="amosbastian"
  File "/home/amos/Documents/steem-python/steem/dex.py", line 232, in sell
    return self.steemd.commit.finalizeOp(op, account, "active")
AttributeError: 'Steemd' object has no attribute 'commit'

How to reproduce

An easy way to reproduce this error is to have Python3.6 installed and do the following

$ virtualenv env
$ source env/bin/activate
$ (env) pip install steem

then create a file called dex_bug.py (the example shown above) and execute it with

$ (env) python dex_bug.py

How to solve it?

I have submitted a pull request on the official steem-python GitHub, which can be found here. You can either use my branch to install steem-python with a working dex.py, or manually edit your local one by copying from here.

Changes made

The changes I made to dex.py to fix it can be seen below

changed_made_dex.png



Posted on Utopian.io - Rewarding Open Source Contributors