[busy old post edit test] Steem Python library sbd_to_rshares bugfix

I've fixed the code to enable edit for posts older than 7 days. This 11 day old (as of Dec 23, 2018) post was picked for testing that feature before pull request.

(This original post wasn't accepted unfortunately because Steem official Python library isn't in the utopian whitelist. But I'm still happy to see my code was merged, which was my first open source contribution to Steem community.)

Hope this will be my second and much more impactful contribution to Steem. HF20 was a long time ago. Come on, posts should be editable now :)

ps. It worked like a charm :)

This is my Christmas gift to Steem community :) Hope that it'll be merged soon. Merry Christmas!

ps2. Since I gave you a present, please make Steem official Python library included in the Utopian whitelist (of course, in addition to generous voting :) So many people are using Busy. Enjoy editing!


Project Information

Expected behavior

sbd_to_rshares() should return rshares value for a given sbd.

Actual behavior

It raises TypeError exception as follows:

  File "/anaconda3/lib/python3.6/site-packages/steem/converter.py", line 101, in sbd_to_rshares
    steem_payout / total_reward_fund_steem) * total_reward_shares2
TypeError: unsupported operand type(s) for /: 'float' and 'Amount'

How to reproduce

  • Operating system: any OS that can use Steem Python library

It happens all the time.

get_dynamic_global_properties() no longer returns reward_fund info. Technically it still returns something but all zeros as follows.

'total_reward_fund_steem'={'amount': '0', 'precision': 3, 'nai': '@@000000021'}
'total_reward_shares2'= 0

How to fix

sbd_to_rshares() should use get_reward_fund() instead. I've made a pull request: https://github.com/steemit/steem-python/pull/274

Suggestion

While my pull request for the Python library has been merged already (as in PS below), I think Steem database API should also change for fields no longer supported. Just returning 0 may look like it might be due to temporary errors or even valid value (e.g., theoretically possible in this example). Please return special values for non-supported fields if those fields should still be kept for some reasons (e.g., compatibility).

GitHub Account

I made a pull request here: https://github.com/steemit/steem-python/pull/274

PS. Wow, @roadscape already merged it. Thanks a lot! I actually thought this library is no longer maintained, but I'm still using it since it's still official library. Go for Steemit again!

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
25 Comments